prompt
string
response
string
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
i=input().split() n,k=int(i[0]),int(i[1]) found=0 for i in range(1,k+1): for j in range(1,n+1): if j<=k: k -= j else: found=1 break if found==1: break print(k)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; bool flage = false; while (!flage) { for (int i = 1; i <= n; i++) { if (k >= i) k -= i; else { flage = true; break; } } } cout << k << endl; }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import sys def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def rinput(): return map(int, sys.stdin.readline().strip().split()) def get_list(): return list(map(int, sys.stdin.readline().strip().split())) n,m=rinput() i=1 while(m>=i): if(i==n): m-=i i=1 ...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,m=[int(x) for x in input().split(" ")] l=[i for i in range(1,n+1)] a=0 while m-l[a]>=0: m-=l[a] if a==n-1: a=0 else: a+=1 print(m)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n, m = map(int, input().split()) walrus = n * (n + 1) / 2 remainders = int(m - (m // walrus) * walrus) for i in range(n + 1): if remainders - i >= 0: remainders = remainders - i else: print(remainders) break
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * * @author Hanif * */ public class Indris { public static void main(String[] args)throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(Syst...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n , k = map(int, input().split()) i = 1 while k>=i: k -= i i += 1 if i == n+1: i = 1 print(k)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n, m = [int(i) for i in input().split()] x=1 while m>=x: m-=x x=(x+1)%(n+1) print(m)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,k=list(map(int,input().split())) i=0 while k>=i+1: k-=i+1 i=(i+1)%n print(k)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[m]; for (int i = 0; i < m; i++) { if ((i + 1) % n == 0) a[i] = n; else a[i] = (i + 1) % n; } int t = m; for (int i = 0; i < m; i++) { if (t >= a[i]) { t = t - a[i]; } else { co...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
def answer(): a = [int(x) for x in input().split()] n = a[0] k = a[1] i=1 while k-i>=0: #print(k,i) k-=i i+=1 if i==n+1: i=1 print(k) answer()
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
def main(): n,m = map(int,input().split()) m = m%((n*(n+1))//2) for i in range(1,n+1): if m < i: print(m) break else: m -= i if __name__ == "__main__": main()
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.util.*; public class Chips { private static Scanner sc; public static void main(String[] args) { // TODO Auto-generated method stub sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); long sum = (long) ((n / 2.0) * (n + 1)); long remainder = m % sum, dil = 0; for(int i =...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#FIN = open("input.txt", "r") #FOUT = open("output.txt", "w") InputData = raw_input().split() n = int(InputData[0]) m = int(InputData[1]) m = m % (n*(n + 1) // 2) x = 0 while m >= x * (x + 1) // 2: x = x + 1 print m - (x * (x - 1)) // 2 #FIN.close() #FOUT.close()
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int start = 1; while (1) { if (m >= start) m -= start; else break; start++; if (start == (n + 1)) start = 1; if (m == 0) break; } cout << m; return 0; }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.io.*; import java.util.*; import java.util.TreeSet; import java.lang.*; import java.util.regex.Matcher; import java.util.regex.Pattern; public class abc{ public static void main(String args[]){ Scanner in=new Scanner(System.in); int n=in.nextInt(),m=in.nextInt(); int sum=(n*(n+1))/2,i=1; while(true...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.util.Scanner; public class Chips { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int m = s.nextInt(); s.close(); loop: while (true) { for (int i = 1; i <= n; i++) { if (m < i) break loop; m -= i; } } System.out.printl...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n, m = map(int, input().split()) i = 1 while m: if m < i: break m -= i i += 1 if i > n: i = 1 print(m)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,m=map(int,input().split()) k=1 while m: if k<=m: m-=k k%=n k+=1 else: break print(m)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
temp = raw_input().split(' ') n = int(temp[0]) m = int(temp[1]) full = n * ( n + 1 ) / 2 m = m % full for i in range(n): if( i+1 <= m ): m -= (i+1) else: break print m
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
s = raw_input().split() n = int(s[0]) m = int(s[1]) flag = True while flag: for i in range(1, n + 1): if m >= i: m -= i else: flag = False break print m
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,m = map(int,input().split()) i = 1 c = 0 while m > sum(range(1,n+1)): m -= sum(range(1,n+1)) for i in range(1,n+1): if m >= i: m-=i else: break print(m)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> const int MOD = 1e9 + 7; using namespace std; vector<pair<int, int>> sur = {{1, 0}, {0, -1}, {0, 1}, {-1, 0}, {-1, -1}, {1, 1}, {1, -1}, {-1, 1}}; bool bounds(int i, int j, int n, int m) { return i >= 0 && i <= n && j >= 0 && j <= m; } long long t, n, m, k; s...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
from sys import stdin walrus, chips = [int(x) for x in stdin.readline().split()] i = 1 while chips >= i: chips -= i i = i % walrus + 1 print chips
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> int main() { int n, m, ct = 0; scanf("%d %d", &n, &m); while (true) { ct++; if (ct > n) ct = 1; if (m < ct) break; m -= ct; } printf("%d\n", m); return 0; }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n, m = map(int, input().split()) i = 1 while m >= i: m -= i i += 1 if i == n+1: i = 1 print(m)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n, k = map(int, input().split()) t = 0 while k > 0 and t != 1: for i in range(n): if k >= i + 1: k -= (i + 1) else: t = 1 break print(k)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n, m = map(int, raw_input().split(" ")) while True: for x in range(1, n+1): if m < x: print m exit() m -= x
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
r, s = map(int, input().split()) k = 1 truth = True while truth == True: k=1 while k <= r: if s-k < 0: truth = False break else: s-=k k+=1 print(s)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,m = map(int,input().split()) sum_n = n*(n+1)/2 m%=sum_n for j in range(1,n+1): if m-j<0: print(int(m)) break m-=j
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,m=map(int,input().split()) if n>m: print("0") elif n*(n+1)//2>m: j=1 num=m while(num-j>0): num=num-j j=j+1 print(num) else: k=m%(n*(n+1)//2) increment=1 while(k- increment>=0): k= k- increment increment=increment+1 print(k)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n, m = map(int, raw_input().split()) k = 0 while m - ((k % n) + 1) >= 0: m -= (k % n) + 1; k += 1 print m
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
from sys import stdin list = stdin.readline().split(" ") n = int(list[0]) m = int(list[1]) i = 0 while m >= i: m -= i i = (i + 1) % (n + 1) print m
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int n, m, i; int main() { cin >> n >> m; i = 1; while (m - i >= 0) { m -= i; i++; if (i > n) i = 1; } cout << m; return 0; }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,m=map(int,raw_input().split()) m%=n*(n+1)/2 for i in range(n): if m<i: break m-=i print m
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,m=map(int,raw_input().split());m%=(n*(n+1))/2 d=min([n,int((((8*m+1)**0.5)-1)/2)]) print max([0,m-max([0,(d*(d+1))/2])])
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; for (int i = 1;; i++) { if (i == n + 1) i = 1; if (m >= i) m -= i; else break; } cout << m << endl; return 0; }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n = map(int, raw_input().split()) ; m=1 while True: if m> n[0]: m = 1; if n[1] < m: print n[1] ; quit() n[1]-=m ; m+=1
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.util.*; import java.io.*; public class Chips { public static void main(String [] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(in.readLine()); int n = Integer.parseInt(st.nextToken()); int m = Integer....
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
''' Author : knight_byte File : A_Chips.py Created on : 2021-04-16 11:55:37 ''' def main(): n, m = map(int, input().split()) i = 1 while i <= m: m -= i i = (i) % n + 1 print(m) if __name__ == '__main__': main()
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import math n,m = list(map(int,input().split())) #50,1e4 cc = (n*(n+1))//2 m = m%cc x = int((math.sqrt((m<<3)+1)-1)/2) print(m-(x*(x+1))//2)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
a=input().split() man=int(a[0]) total=int(a[1]) s=0 while True: for i in range(man): total=total-(i+1) if total<0: total=total+(i+1) s=1 if s==1: print(total) break
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
a,b=map(int,input().split()) c=1 while b>0: if b-c>=0: b-=c else: break c+=1 if c==a+1: c=1 print(b)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
l=lambda:map(int,raw_input().split()) n,m=l() sn=(1+n)*n/2 r=m%sn i=1 c=0 while c+i<=r: c+=i i+=1 print r-c
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import string; ii = []; ss = string.split(raw_input()); for s in ss: ii.append(int(s)); n = ii[0]; m = ii[1]; k = n * (n+1) / 2; #print n,m,k; m = m % k; #print m; for i in xrange(n): if (m < i + 1): print m; break; m -= (i+1); # print m;
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
# import sys # sys.stdin=open("input.in",'r') # sys.stdout=open("outp.out",'w') n,m=map(int,input().split()) i=1 while m>=i: m-=i if i<n: i+=1 else: i=1 print(m)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int d = (n * (n + 1)) / 2; m %= d; for (int i = 0; i < n; i++) { int x = ((i + 1) * (i + 2)) / 2; if (m < x) { m -= (i * (i + 1)) / 2; break; } } cout << m; }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,m=map(int,input().split()) w=m%(n*(n+1)//2) l=int(((8*w+1)**.5-1)//2) print(w-l*(l+1)//2)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java .util.*; public class Contest { static long []dp =new long [50]; public static void main(String [] yahia_mostafa) throws IOExcepti...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n, m = map(int, input().split()) m = m % (n * (n + 1) // 2) for i in range(1, n + 1): if m >= i: m -= i else: print(m) break
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i = 1; cin >> n >> m; while (i) { if (m < i) { cout << m; break; } if (m >= i) m -= i; i++; if (i > n) i = 1; } }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.util.Scanner; public class Chips { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); int i=0; while(m>0) { i++; m=m-i; if((i==n)&&m>0) ...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.lang.reflect.Array; import java.util.*; import java.lang.*; import java.io.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main(String[] args) throws Exception { // your code goes here Scanner sc = ne...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
def solve(): n, m = map(int, input().split()) stop_yn = True while stop_yn: for i in range(1, n + 1): if m - i >= 0: m -= i else: stop_yn = False print(m) if __name__ == "__main__": solve()
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); ...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
a,b=input().split() a,b=int(a),int(b) i=1 while b>=i: b-=i if i==a: i=1 else: i+=1 print(b)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const char nl = '\n'; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, chip; cin >> n >> chip; int k = n * (n + 1) / 2; while (chip > k) { chip -= k; } if (chip <= k) { int i = 1; while (i <= n) { ...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
from sys import stdin, stdout from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log from collections import defaultdict as dd, deque from heapq import merge, heapify, heappop, heappush, nsmallest from bisect import bisect_left as bl, bisect_right as br, bisect mod = pow(10, 9) + 7 mod2 = 998244353 def inp(...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int n, m, sum; int main() { cin >> n >> m; sum = n * (n + 1) / 2; m = m % sum; for (int i = 1; i <= n; i++) { if (m - i >= 0) m -= i; else break; } printf("%d\n", m); return 0; }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.util.Scanner; public class Main { public static void main (String...args){ Scanner input = new Scanner(System.in); int morsas = Integer.parseInt(input.next()); int fichas = Integer.parseInt(input.next()); morsas++; for(int i=morsas; fichas>=(i%morsas); i++){ if(i%...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.util.Scanner; public class Project { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); sc.close(); while(true){ for (int i = 1; i <= n; i++) { m -= i; if (m < 0){ System.out.println(m+i); retu...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.io.*; import java.util.*; public class main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int i = 1; while(m >= i) { m -= i; if(++i == n+1) { i = 1; } } System.out.println(m); } }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n, m = map(int, raw_input().split()) m %= sum(range(n + 1)) for i in range(1, n + 1): if m < sum(range(i + 1)): print m - sum(range(i)) break
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.util.*; public class Problem18 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int i = 1, c = 0; while(k != 0) { k -= i; if(k<0) { c = k + i; break; } i = i++; i = (i % n)+1; } System.out.print...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
//cODEFORces Rck :) import java.io.*; import java.util.*; public class A { public static void main(String args[])throws IOException { new A().run(); } void run()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(in.readLine());...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
a = 1 n, m =map(int, raw_input().split()) while a == 1: for i in range(1,n+1): if m < i: a = 0 break else: m = m - i print m
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,m=map(int,input().split()) i=1 while i<=n: if m<i: break else: m=m-i i=i+1 if i==n+1 and m>=1: i=1 print(m)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n, m = [int(i) for i in input().split()] distribute_further = True while m >= 1 and distribute_further: for i in range(1, n+1): if m >= i: m -= i else: distribute_further = False break print(m)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,m=[int(x) for x in input().split()] l=(n*(n+1))//2 d=m%l if d==0: print(0) else: i=1 while d>0: if i>d: break else: d-=i i+=1 print(d)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); int perRound = n * (n + 1) / 2; int numRound = m / perRound; int remainder = m % perRound; ...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#A. Chips n,m = map(int,input().split()) if m == n*(n+1)//2: print(0) else: i = 1 while m>=i: m -= i i += 1 i%=(n+1) print(m)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,m = map(int,raw_input().split()); for i in range(10000): tcaps = (i % n)+1; if m-tcaps>=0: m-=tcaps; else: break; print m;
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
def equ(c): x1=((-1+(1*1-4*c)**(0.5))/2) x2=((-1+(1*1-4*c)**(0.5))/2) if x1>0: return x1 elif x2>0: return x2 n,m=map(int,input().split()) k=n*(n+1)/2 m=m%k if m==0: print("0") else: q=-(m*2) p=(int(equ(q))) m=m-(p*(p+1))/2 print(int(m))
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#!/usr/bin/env python # -*- coding: UTF-8 -*- __author__ = 'firago' from sys import stdin, stdout n, m = map(int, stdin.read().split()) cicl = n * (n +1) / 2 m %= cicl i = 1 while m >= i: m -= i i += 1 stdout.write(str(m))
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; m = m % ((n * (n + 1)) / 2); for (int i = 1; i <= n; i++) { if (m >= i) m -= i; else break; } cout << m << endl; return 0; }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i = 1; cin >> n >> m; while (m >= i) { m -= i; i++; if (i == n + 1) i = 1; } cout << m << endl; return 0; }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int mod = N * (N + 1) / 2; M %= mod; int sum = 0; for (int i = 1; i + sum <= M; sum += i++) ; cout << M - sum; return 0; }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; long long ans, ans1, ans2, ans3, ans4, ans5, ans6; int main() { long long n, k; cin >> n >> k; for (int j = 1; j <= 100000; j++) { for (int i = 1; i <= n; i++) { if (k < i) { cout << k; return 0; } else { k -= i; } } ...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import string z=string.split(raw_input()) n=int(z[0]) m=int(z[1]) x=1 a=m while a>=x: a=a-x x=x+1 if x>n: x=1 print a
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#!/usr/bin/env python if __name__ == "__main__": N , K =map(int , raw_input().split()) K = K % ((N * (N + 1)) / 2) L = int((2 * K) ** (0.5)) - 1 while (L + 2) * (L + 1) <= 2 * K : L = L + 1 print K - (L * (L + 1)) / 2
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,m = map(int,input().split()) k = (n*(n+1))/2 flag = 0 if m%k != m: m = m %k i = 0 while True: if m-i >=0: m = m-i else: print(int(m)) break i += 1 else: for i in range(n,0,-1): k = (i*(i+1))/2 if m%k != m and flag != 1:...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, sum = 0; cin >> n >> m; for (i = 1; i <= (m - sum); i++) { sum += i; if (i == n) { i = 0; } } cout << m - sum << endl; return 0; }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
a,b=map(int,input().split()) c=1 while b>=c: b-=c c+=1 if c==a+1: c=1 print(b)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf("%d%d", &n, &m); m %= (n * n + n) / 2; for (int i = 1; i <= n; i++) if (m >= i) m -= i; else break; printf("%d", m); return 0; }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
s,c=input().split() s=int(s) c=int(c) i=0 while(1): k=0 for i in range(1,s+1): if(c>=i): c=c-i else: k=1 if(k==1): break print(c)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
x,y=map(int,input().split()) z=y%((x*(x+1))//2) for i in range(1,x+1): if i>z or z==0: print(z) break else: z=z-i #author:SK__Shanto__㋛ #code__define__your__smartness
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; void solve(int test_number); void pre() { cout.setf(ios::fixed); cout.precision(20); cerr.setf(ios::fixed); cerr.precision(3); } void post() { printf("\n"); fprintf(stderr, "Execution time: %Lf", (long double)clock()); } const int MAXN = 100100; inline void solv...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; while (m >= (n * (n + 1)) / 2) m -= (n * (n + 1)) / 2; int i = 1, flag = 0; while (flag == 0) { if (m >= i) m -= i; else flag = 1; i++; } cout << m << endl; return 0; }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; m %= ((n * (n + 1)) / 2); int i = 1; while (i <= m) m -= i++; cout << m << endl; return 0; }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,m = map(int,input().split()) i=1 while(m>=0): z=m m -= i i+=1 if i>n: i=1 print(z)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n, m = map(int, input().split()) #m = m % sum(i for i in range(1, n + 1)) alist=[i for i in range(1,n+1)] m=m%sum(alist) i = 1 while True: m -= i if m == 0: print(0) exit() elif m < 0: print(m + i) exit() i += 1
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n,m=map(int,raw_input().split()) add=0 a=0 while True: for i in range(1,n+1): m-=i if m<0: m+=i a=i break if m-a<0: break print m
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
#!/usr/bin/env python # -*- coding: utf-8 -*- n, m = map(int, raw_input().split()) while True: for i in xrange(1, n+1): if m >= i: m -= i else: print m exit()
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
w, c = [int(x) for x in input().split(' ')] cnt = 1 while c - cnt >= 0: c -= cnt cnt += 1 if cnt > w: cnt = 1 print(c)
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import sys n, m = map(int, sys.stdin.readline().split()) N = (n*(n+1))//2 m = m%N for i in range(1,n+1): if m >= i: m -= i else: print(m) break
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import sys n,m = map(int, sys.stdin.readline().strip().split(' ')) i = 1 while i <= m: m -= i i += 1 if n < i: i = 1 print m
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
n, chips = map(int, list(raw_input().split())) def nchips(k): return (k**2 + k)>>1 def findChips(chips, n): if nchips(n) <= chips: return n return findChips(chips, n-1) def chipDescent(chips, n): if nchips(n) > chips: return chips - nchips(findChips(chips, n)) elif nchips(n) == chips: return ...
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
import java.util.*; public class A{ public static void main(String[]args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); int i=1; while(m>0){ if(m>=i) m-=i; else break; i=(i+1)%(n+1); if(i==0) i++; } System.out.println(m); } }
Problem: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The ...
def readarray(f): return map(f, raw_input().split()) def readint(): return int(raw_input()) def printlist(l): print ' '.join(map(str, l)) n, m = readarray(int) tour = (n*(n+1))/2 m = m%tour for i in range(1, n+1): if m >= i: m -= i else: print m exit()