s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s512267845
p03816
u731368968
1575221708
Python
Python (3.4.3)
py
Runtime Error
17
2940
594
#1,1,1 -> (1,1) 1 #1,2,3 -> (1,3) 2 #1,1,3 -> (1,3) 1 <=> 1,1,3,3 -> (1,3) 1,3 #1,2,1,3,7 == [1:2, 2:1, 3:1, 7:1] #[1:4, 2:3, 3:2, 5:1, 6:2, 8:2, 11:1] #それぞれ1または2と等しい #[1:2, 2:1, 3:2, 5:1, 6:2, 8:2, 11:1] #[1,1,3,3,6,6,8,8] #[1,1,3,6,6,8,8] #[1,3,6,8] N = int(input()) A = list(map(int, input().split())) B = [-1 for i in range(100005)] for i in range(N): if B[A[i]] == -1: B[A[i]] = 1 elif B[A[i]] == 1: B[A[i]] = 2: elif B[A[i]] == 2: B[A[i]] = 1 n = N - B.count(-1) if B.count(2) % 2 == 0: print(n) else: print(n-1)
s809788055
p03816
u109617108
1574221824
Python
PyPy3 (2.4.0)
py
Runtime Error
216
58796
97
N=int(input()) A=list(map(int,input().split())) m=set(A) if m%2==0: print(m-1) else: print(m)
s063213447
p03816
u256464928
1574132008
Python
Python (3.4.3)
py
Runtime Error
71
18656
450
from collections import Counter import math N = int(input()) A = list(map(int,input().split())) R = [] T = [] C = Counter(A) cnt = 0 for c in C.items(): if c[1] > 1: cnt += c[1] - 1 T.append(c[0]) else: R.append(c[0]) Max_R = max(T) Min_R = min(T) flg = False for r in R: if Min_R <= r <= Max_R: flg = True break if cnt % 2 != 0: ans = N - cnt - 1 else: if flg: ans = N - cnt else: ans = N - cnt - 2 print(ans)
s301690111
p03816
u614875193
1573060947
Python
Python (3.4.3)
py
Runtime Error
2104
14004
376
N=int(input()) A=list(map(int,input().split())) A.sort() S=[] D=[] for i in A: if i in S: D.append(i) else: S.append(i) #print(D) M=N-len(D) if len(D)%2==1: print(M-1) else: MaxD,MinD=max(D),min(D) Med=-1 for i in S: if MinD<=i<=MaxD: Med=i print(M) break if Med==-1: print(M-2)
s175509118
p03816
u023229441
1570264651
Python
Python (3.4.3)
py
Runtime Error
2057
141044
204
n=int(input()) def cut(list): return [list[1]] A=sorted(list(map(int,input().split()))) i=0 while i<=len(A)-3: if A[i]==A[i+1]: del A[i] del A[i+2] else: i+=1 print(A) print(len(A))
s451047277
p03816
u654470292
1570072734
Python
PyPy3 (2.4.0)
py
Runtime Error
329
65256
520
import sys import collections import heapq def input(): return sys.stdin.readline()[:-1] n=int(input()) a=list(map(int,input().split())) tmp=collections.Counter(a) b=list(tmp.values()) b=list(map(lambda x:x*-1, b)) heapq.heapify(b) ans=0 while 1: cnt1=heapq.heappop(b) if cnt1==-1: break cnt2=heapq.heappop(b) if cnt2==-1: ans+=cnt1*-2-2 break ans+=max(cnt1,cnt2)*-2-2 heapq.heappush(b,cnt1-max(cnt1,cnt2)-1) heapq.heappush(b,cnt2-max(cnt1,cnt2)-1) print(n-ans)
s170047998
p03816
u994988729
1568841133
Python
Python (3.4.3)
py
Runtime Error
110
21460
611
import bisect from collections import Counter n=int(input()) a=list(map(int, input().split())) c=list(Counter(a).items()) c=[i[1]-1 for i in sorted(c)] u=0 l=len(c)-1 ans=0 while True: if c[u]>c[l]: ans += c[l] c[u] -= c[l] c[l] = 0 l -= 1 elif c[u]<c[l]: ans += c[u] c[l] -= c[u] c[u] = 0 u += 1 else: ans += c[u] c[l] = 0 c[u] = 0 l -= 1 u += 1 if l - u == 1: ans += max(c[u], c[l]) break elif l == u: ans += c[l]//2 + c[l]%2 break print(n-2*ans)
s229433244
p03816
u695429668
1567897045
Python
Python (3.4.3)
py
Runtime Error
127
18656
372
from collections import defaultdict N = int(input()) A = list(map(int, input().split())) d = defaultdict(int) for i in range(N): d[A[i]] += 1 ans = 0 se = 0 dd = [0 for i in range(3)] for k, v in d.items(): value = v // 3 + (v % 3) dd[value] += 1 if value % 3 == 0 or value % 3 == 1: ans += 1 else: se += 1 print(ans + ((se//2)*2))
s678971402
p03816
u614314290
1566409002
Python
Python (3.4.3)
py
Runtime Error
18
3060
1345
import sys sys.setrecursionlimit(1_000_000) from math import factorial, ceil, floor from bisect import bisect_right as bsr from operator import itemgetter as ig from collections import defaultdict as dd from collections import deque # お約束 args = None INF = float("inf") MOD = int(1e9 + 7) def input(*ps): if type(ps[0]) is list: return [input(*ps[0][:-1]) for _ in range(ps[0][-1])] elif len(ps) == 1: return ps[0](next(args)) else: return [p(next(args)) for p in ps] def nlist(n, v): if not n: return [] if type(v) is list else v return [nlist(n[1:], v) for _ in range(n[0])] # データ構造:ヒープ import heapq class heapque: def __init__(self, *args): self.que = [] for arg in args: self.push(arg) def push(self, v): heapq.heappush(self.que, v) def pop(self): return heapq.heappop(self.que) from collections import Counter # エントリーポイント def main(): N = input(int) A = input([int, N]) cnt = Counter(A).values() # 3以上の奇数を相殺させ1へ cnt = [1 if c % 2 else c for c in cnt] # 偶数を相殺させ2へ cnt = [2 if c % 2 == 0 else c for c in cnt] print(len(cnt) - cnt.count(2) % 2) if __name__ == '__main__': args = iter(sys.stdin.read().split()) main()
s411292409
p03816
u903215911
1563732610
Python
Python (3.4.3)
py
Runtime Error
140
18272
511
N = int(input()) A = list(map(int, input().split())) # print(A) cnt = {} for a in A: if a not in cnt: cnt[a] = 1 else: cnt[a] += 1 s, e = 1, 100000 while True: while (s not in cnt or cnt[s] <= 1) and s < e: s += 1 while (e not in cnt or cnt[e] <= 1) and s < e: e -= 1 if e < s: break if s == e and cnt[s] <= 1: break if s in cnt: cnt[s] -= 1 if e in cnt: cnt[e] -= 1 ans = 0 for i in range(1, 100001): if i in cnt and cnt[i] > 0: ans += 1 print(ans)
s603498172
p03816
u903215911
1563732467
Python
Python (3.4.3)
py
Runtime Error
128
17396
478
N = int(input()) A = list(map(int, input().split())) # print(A) cnt = {} for a in A: if a not in cnt: cnt[a] = 1 else: cnt[a] += 1 s, e = 1, 100000 while True: while (s not in cnt or cnt[s] <= 1) and s < e: s += 1 while (e not in cnt or cnt[e] <= 1) and s < e: e -= 1 if e < s: break if s == e and cnt[s] <= 1: break cnt[s] -= 1 cnt[e] -= 1 ans = 0 for i in range(1, 100001): if i in cnt and cnt[i] > 0: ans += 1 print(ans)
s765025799
p03816
u074402558
1559348373
Python
Python (3.4.3)
py
Runtime Error
84
18272
489
N = int(input()) A = list(map(int, input().split())) dict1 = {} for i in range(N): if A[i] not in dict1.keys(): dict1[A[i]] = 0 else: dict1[A[i]] += 1 value1 = [] for value in dict1.values(): value1.append(value) value2 = sorted(value1, reverse = True) if value2[0] - value2[1] >= sum(value2[1:]): print(N - (value2[0] * 2)) else: if(sum(value2[0:]) % 2 == 0): print(len(value2)) else: if len(value2) != 1: print(len(value2) - 1) else: print(1)
s010953362
p03816
u074402558
1559348263
Python
Python (3.4.3)
py
Runtime Error
83
18272
489
N = int(input()) A = list(map(int, input().split())) dict1 = {} for i in range(N): if A[i] not in dict1.keys(): dict1[A[i]] = 0 else: dict1[A[i]] += 1 value1 = [] for value in dict1.values(): value1.append(value) value2 = sorted(value1, reverse = True) if value2[0] - value2[1] >= sum(value2[1:]): print(N - (value2[0] * 2)) else: if(sum(value2[0:]) % 2 == 0): print(len(value2)) else: if len(value2) != 0: print(len(value2) - 1) else: print(1)
s961210032
p03816
u074402558
1559348097
Python
Python (3.4.3)
py
Runtime Error
85
17400
436
N = int(input()) A = list(map(int, input().split())) dict1 = {} for i in range(N): if A[i] not in dict1.keys(): dict1[A[i]] = 0 else: dict1[A[i]] += 1 value1 = [] for value in dict1.values(): value1.append(value) value2 = sorted(value1, reverse = True) if value2[0] - value2[1] >= sum(value2[1:]): print(N - (value2[0] * 2)) else: if(sum(value2[0:]) % 2 == 0): print(len(value2)) else: print(len(value2) - 1)
s521395661
p03816
u074402558
1559347766
Python
Python (3.4.3)
py
Runtime Error
84
17396
441
N = int(input()) A = list(map(int, input().split())) dict1 = {} for i in range(N): if A[i] not in dict1.keys(): dict1[A[i]] = 0 else: dict1[A[i]] += 1 value1 = [] for value in dict1.values(): value1.append(value) value2 = sorted(value1, reverse = True) if value2[0] - value2[1] >= sum(value2[1:]): print(N - (value2[0] * 2)) else: if(sum(value2[0:]) % 2 == 0): print(len(value2)) else: print(len(value2 - 1))
s161780576
p03816
u902468164
1556211619
Python
Python (3.4.3)
py
Runtime Error
107
16668
231
_ = input() an = sorted([int(i) for i in input().split(" ")]) dic = {} for a in an: if a not in dic: dic[a] = 0 dic[a] += 1 tim = 0 for a in dic: if dic[1] % 2 == 0: tim += 1 print(len(dic)-(tim+1)%2)
s887440258
p03816
u585482323
1551686283
Python
PyPy3 (2.4.0)
py
Runtime Error
1076
63120
1235
#!usr/bin/env python3 from collections import defaultdict from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, sys.stdin.readline().split())) def S(): return list(sys.stdin.readline())[:-1] def IR(n): l = [None for i in range(n)] for i in range(n):l[i] = I() return l def LIR(n): l = [None for i in range(n)] for i in range(n):l[i] = LI() return l def SR(n): l = [None for i in range(n)] for i in range(n):l[i] = S() return l def LSR(n): l = [None for i in range(n)] for i in range(n):l[i] = SR() return l mod = 1000000007 #A #B #C """ x = I() ans = 2*(x//11)+1 x %= 11 if x == 0: ans -= 1 if x > 6: ans += 1 print(ans) """ #D n = I() a = LI() d = defaultdict(int) for i in a: d[i] += 1 l = list(d.keys()) i = 0 while i < len(l): if d[l[i]] < 2: l.pop(i) i -= 2 i += 1 if len(l) == 0:break l.sort() k = 0 for i in l: k ^= ~(d[i]%2) d[i] = 1 ans = sum(list(d.values())) ans -= 1 if k%2 else 0 print(ans) #E #F #G #H #I #J #K #L #M #N #O #P #Q #R #S #T
s874899541
p03816
u585482323
1551686083
Python
PyPy3 (2.4.0)
py
Runtime Error
1076
63120
1223
#!usr/bin/env python3 from collections import defaultdict from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, sys.stdin.readline().split())) def S(): return list(sys.stdin.readline())[:-1] def IR(n): l = [None for i in range(n)] for i in range(n):l[i] = I() return l def LIR(n): l = [None for i in range(n)] for i in range(n):l[i] = LI() return l def SR(n): l = [None for i in range(n)] for i in range(n):l[i] = S() return l def LSR(n): l = [None for i in range(n)] for i in range(n):l[i] = SR() return l mod = 1000000007 #A #B #C """ x = I() ans = 2*(x//11)+1 x %= 11 if x == 0: ans -= 1 if x > 6: ans += 1 print(ans) """ #D n = I() a = LI() d = defaultdict(int) l = [] for i in a: d[i] += 1 l = list(d.keys()) i = 0 while i < len(l): if d[l[i]] < 2: l.pop(i) i -= 2 i += 1 l.sort() k = 0 for i in l: if not d[i]%2:k += 1 d[i] = 1 ans = sum(list(d.values())) ans -= 1 if k%2 else 0 print(ans) #E #F #G #H #I #J #K #L #M #N #O #P #Q #R #S #T
s174314454
p03816
u653642801
1531105191
Python
Python (3.4.3)
py
Runtime Error
48
14396
402
import sys def main(): n = input() a = input().split() n = int(n) a = list(map(int, a)) lst = [0]* 20 dup = 0 ans =0 for i in a: lst[i]+=1 for i in lst: if i >0: ans+= 1 if i > 1: dup = dup + i - 1 if dup % 2 == 0: print(ans) else: print(ans-1) if __name__ == "__main__": main()
s314565103
p03816
u391331433
1502741748
Python
Python (2.7.6)
py
Runtime Error
2109
63056
1356
import sys import numpy as np from collections import deque import copy from math import * def get_read_func(fileobject): if fileobject == None : return raw_input else: return fileobject.readline class card: def __init__(self, value, count): self.value = value self.count = count def __lt__(self, other): return self.count < other.count def main(): if len(sys.argv) > 1: f = open(sys.argv[1]) else: f = None read_func = get_read_func(f); input_raw = read_func().strip().split() [N] = [int(input_raw[0])] input_raw = list(read_func().strip().split()) num_dict = {} for i in range(N): if int(input_raw[i]) not in num_dict: num_dict[int(input_raw[i])] = 1 else: num_dict[int(input_raw[i])] += 1 card_cnt_list = [] for num in num_dict: card_cnt_list.append(card(num, num_dict[num])) card_cnt_list.sort(reverse = True) while card_cnt_list[0].count > 1: card_cnt_list[0].count -= 1 if card_cnt_list[1].count >= 1: card_cnt_list[1].count -= 1 else: card_cnt_list[0].count -= 1 card_cnt_list.sort(reverse = True) cnt = 0 for c in card_cnt_list: cnt += c.count print cnt if __name__ == '__main__': main()
s938558984
p03816
u098968285
1498519812
Python
PyPy3 (2.4.0)
py
Runtime Error
228
54468
390
N = int(input()) A = list(map(int, input().split())) num = int(1e5) dp = [0]*(num+1) for e in A: dp[e] += 1 cnt = 0 maxm = 0 for i in range(1, num+1): if dp[i] > 1: cnt += dp[i] - 1 maxm = max(maxm, dp[i] - 1) if maxm * 2 > N // 2: print(ans) if maxm > cnt // 2: ans = N - (maxm-(cnt-maxm)) * 2 if ans <= 0: ans = 1 else: ans = N - (cnt + (cnt%2)*2) print(ans)
s986367017
p03816
u098968285
1498519727
Python
PyPy3 (2.4.0)
py
Runtime Error
225
53060
409
N = int(input()) A = list(map(int, input().split())) num = int(1e5) dp = [0]*(num+1) for e in A: dp[e] += 1 cnt = 0 maxm = 0 for i in range(1, num+1): if dp[i] > 1: cnt += dp[i] - 1 maxm = max(maxm, dp[i] - 1) if maxm * 2 > N // 2: print(ans) if maxm > cnt // 2: ans = N - (maxm-(cnt-maxm)) * 2 print(cnt, maxm) if ans <= 0: ans = 1 else: ans = N - (cnt + (cnt%2)*2) print(ans)
s904685709
p03816
u638057737
1488899797
Python
Python (3.4.3)
py
Runtime Error
21
4724
242
N = int(input()) uniques = {} count = 0 for i in range(N): a = int(input()) if a not in uniques.keys(): uniques[a] = True else: count += 1 if count % 2 == 0: print (N - count) else: print (N - count - 1)
s783170377
p03816
u683479402
1486926503
Python
Python (3.4.3)
py
Runtime Error
131
14452
364
from itertools import groupby N = input() A = map(int, input().split()) B = [len(list(group)) for key, group in groupby(sorted(A))] C = [] for i, val in enumerate(B): if val % 2 == 0: C.append(2) else: C.append(1) D = [len(list(group)) for key, group in groupby(sorted(C))] if D[1] % 2 == 0: answer = D[0] +D[1] else: answer = D[0] +D[1] - 1 print(answer)
s175490435
p03816
u791838908
1486923731
Python
Python (3.4.3)
py
Runtime Error
22
2940
257
N = int(input()) A = input() list_A = A.split() set_A = set(list_A) i = 0 for a in list_A: if a in set_A: i += 1 i = i - len(set_A) if i % 2 == 0: print(N - i) else: print(N - (i +1))
s109650609
p03816
u791838908
1486923701
Python
Python (3.4.3)
py
Runtime Error
24
3064
204
N = int(input()) A = input() list_A = A.split() set_A = set(list_A) i = 0 for a in list_A: if a in set_A: i += 1 i = i - len(set_A) if i % 2 == 0: print(N - i) else: print(N - (i +1))
s130329281
p03816
u615817983
1486816489
Python
Python (2.7.6)
py
Runtime Error
26
7936
62
int(raw_input()) print len(set(map(int, raw_input().strip())))
s009231205
p03816
u781758937
1485660262
Python
Python (3.4.3)
py
Runtime Error
279
23544
332
import numpy as np N = int(input()) A = np.array(list(map(int, input().split())), dtype=np.int64) U = list(np.unique(A, return_counts = True)) U[1] = np.subtract(U[1],1) max(U[1]) len(U[1]) sum(U[1]) if max(U[1]) > (sum(U[1]) - max(U[1])): res = max(U[1]) * 2 - sum(U[1]) else: res = sum(U[1]) % 2 print(len(U[1]) - res)
s625229681
p03816
u390382871
1485659700
Python
Python (3.4.3)
py
Runtime Error
22
3064
859
#include <iostream> #include <boost/algorithm/string.hpp> #include <vector> #include <map> using namespace std; int main(){ int n; cin >> n; vector<int> v; for(int i = 0; i < n; i++){ int t; cin >> t; v.push_back(t); } sort(v.begin(),v.end()); map<int, int> counter; for(int i = 0; i < n; i++){ if(counter.count(v[i]) != 0){ counter[v[i]]++; }else{ counter[v[i]] = 1; } } while(true){ int l = -1; int r = -1; for(int i = 0; i < n; i++){ if(counter[v[i]] > 1){ if(l == -1){ l = v[i]; } r = v[i]; } } if(r == -1){ break; } counter[l]--; counter[r]--; } int result = 0; for(auto itr = counter.begin(); itr != counter.end(); ++itr){ if(itr->second > 0){ result++; } } cout << result << endl; }
s629683028
p03817
u536034761
1599574508
Python
Python (3.8.2)
py
Runtime Error
25
8972
120
x = input() y = x % 11 if y > 0: cnt = 1 if y > 6: cnt += 1 else: cnt = 0 print(x // 11 + cnt)
s674708820
p03817
u802234211
1598405781
Python
Python (3.8.2)
py
Runtime Error
28
9096
207
import math x = int(input()) xi = math.floor(x/5.5) print(xi) for i in range(xi,100000000000000): # print(6*i - math.floor(i/2)) if(x < 6*i-math.floor(i/2)): xa = i break print(xa)
s951048561
p03817
u802234211
1598405745
Python
Python (3.8.2)
py
Runtime Error
29
9080
205
import math x = int(input()) xi = math.floor(x/5.5) print(xi) for i in range(xi,100000000000000): print(6*i - math.floor(i/2)) if(x < 6*i-math.floor(i/2)): xa = i break print(xa)
s366013524
p03817
u597455618
1596646914
Python
Python (3.8.2)
py
Runtime Error
30
9196
307
def main(): x = int(input()) s = 0 f = 0 while ans < x: s += 1 tmp = 6*s + 5*f if tmp >= x: print(s+f) exit() f += 1 tmp += 5 if tmp >= x: print(s+f) exit() if __name__ == "__main__": main()
s131950431
p03817
u083960235
1588210757
Python
Python (3.4.3)
py
Runtime Error
30
4012
884
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from heapq import heapify, heappop, heappush def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def S_MAP(): return map(str, input().split()) def LIST(): return list(map(int, input().split())) def S_LIST(): return list(map(str, input().split())) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 x = INT() if x % 11 == 0: print(2 * x // 11) else: if 6 < x % 11: tmp = 2 + 2 * (x // 11) else: tmp = 1 + 2 * (x // 11) print(tmp)
s108582748
p03817
u471539833
1586993003
Python
Python (3.4.3)
py
Runtime Error
17
3064
228
N=int(input()) A=list(map(int,input().split())) kind=0 c=[] d=[0]*(10**5) count=0 for i in range(N): if(d[A[i]-1]==0): kind+=1 d[A[i]-1]+=1 for i in range(N): if(d[i]>0 and d[i]%2==0): count+=1 print(kind-count%2)
s527144152
p03817
u293198424
1586347560
Python
PyPy3 (2.4.0)
py
Runtime Error
173
38384
113
x = int(input()) if x%11 > 6: ans = x//11 *2 +2 elif x %11==0: 1+1 else: ans = x//11 *2 +1 print(ans)
s259632140
p03817
u293198424
1586347496
Python
PyPy3 (2.4.0)
py
Runtime Error
179
38384
114
x = int(input()) if x%11 > 6: ans = x//11 *2 +2 elif x %11==0: pass else: ans = x//11 *2 +1 print(ans)
s232589342
p03817
u806999568
1583300820
Python
Python (3.4.3)
py
Runtime Error
17
2940
60
x = input() print((x // 11) * 2 + (2 if x % 11 > 6 else 1))
s988071853
p03817
u737451238
1579113858
Python
Python (3.4.3)
py
Runtime Error
17
2940
105
if x / 11 < 1: ans = 1 if x / 5 >= 1: ans = 2 else: ans = x // 11 * 2 + 1 print(ans)
s861704875
p03817
u637824361
1565236762
Python
Python (3.4.3)
py
Runtime Error
17
2940
111
N = int(input()) if N % 11 > 6: print(N+10//11*2) elif n % 11 == 0: print(N//11*2) else: print(N//11*2+1)
s284601581
p03817
u623819879
1557335425
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38384
93
n=int(input()) ans=(n//11)*2 ans+=2 if n-n//11>6 else 1 ans-=1 if n-n//11=0 else 0 print(ans)
s391862147
p03817
u667024514
1553392180
Python
Python (3.4.3)
py
Runtime Error
16
2940
130
n = int(input()) lis = list(map(int,input().split())) ans = set() for num in lis:ans.add(num) print(len(ans)-((len(ans) % 2)+1)%2)
s966808566
p03817
u243961437
1551986872
Python
Python (3.4.3)
py
Runtime Error
17
2940
141
x = int(input()) count = 0 q, mod = divmod(x, 11) count += q*2 if mod > 0: if(mod <= 6): count += 1 else: count += 2 print(count)
s232864176
p03817
u983918956
1547507616
Python
Python (3.4.3)
py
Runtime Error
18
2940
119
x = int(input()) t = x // 11 x -= 11 * t ans = t * 2 if x <= 5: ans += 1 elif 5 < x < 11: ans += 2 print(ans)za
s557253905
p03817
u620868411
1534903928
Python
Python (3.4.3)
py
Runtime Error
17
3060
213
# -*- coding: utf-8 -*- x = int(input()) if x<=6: print(1) exit() if x<=11: print(2) exit() r = x%11 ret = x//11 if r<=6: print(2*ret+1) elif t<=11: print(2*ret+2) else: print(2*ret)
s591890364
p03817
u785205215
1515031867
Python
PyPy3 (2.4.0)
py
Runtime Error
204
40432
1502
import math import itertools import heapq from sys import stdin, stdout, setrecursionlimit from bisect import bisect, bisect_left, bisect_right from collections import defaultdict, deque # d = defaultdict(lambda: 0) # setrecursionlimit(10**7) # inf = float("inf") ##### stdin #### def LM(t, r): return list(map(t, r)) def R(): return stdin.readline() def RS(): return R().split() def I(): return int(R()) def F(): return float(R()) def LI(): return LM(int,RS()) def LF(): return LM(float,RS()) def ONE_SL(): return list(input()) def ONE_IL(): return LM(int, ONE_SL()) def ALL_I(): return map(int, stdin) def ALL_IL(): return LM(int,stdin) ##### tools ##### def ap(f): return f.append def pll(li): print('\n'.join(LM(str,li))) def pljoin(li, s): print(s.join(li)) ##### main ##### class BIT(object): def __init__(self,l): self.size = l self.bit = [0]* (self.size+1) def sum(self, i): s = 0 while i > 0: s += self.bit[i] i -= i & -i return s def add(self, i, x): while i < self.size: self.bit[i] += x i += i & -i def __str__(self): return str(self.bit) def main(): N,M = LI() bit = BIT(M+2) L = [] R = [] b = [[] for i in range(M+1)] for i in range(N): l,r = LI() L.append(l); R.append(r) b[r-l +1].append(i) b = [] gone = 0 for d in range(1, M+1): for i in b[d]: gone+=1 bit.add(L[i], 1) bit.add(R[i]+1, -1) ans = N-gone for m in range(d, M+1, d): ans += bit.sum(m) print(ans) if __name__ == '__main__': main()
s737607011
p03817
u765237551
1493583051
Python
Python (3.4.3)
py
Runtime Error
20
3316
206
from collections import Counter _ = input() xs = Counter(map(int, input().split())) even = sum(1 for (k, c) in xs.items() if c%2==0) odd = sum(1 for (k, c) in xs.items() if c%2==1) print(odd + (even//2)*2)
s752508245
p03817
u848877025
1488673609
Python
Python (2.7.6)
py
Runtime Error
11
2696
1414
def main(): N = int(raw_input()) x = map(int, raw_input().split()) #-1:remove , 0:singe , 1~:label check= [0] * N flag = False label = 1 c = 0 x.sort() #labeling for i in range(N): for j in range(N): if(i != j): if(x[i] == x[j]): flag = True if flag: if i > 0: if(x[i] != x[i-1]): label += 1 check[i] = label else: check[i] = label else: check[i] = label flag = False #removing for i in range(N-1): if(check[i] > 0 and check[i+1] == check[i]): for j in range(N): if(check[i] != check[j] and check[j] > 0 and flag == False): check[i] = -1 check[j] = -1 if j < N-2: check[j+1] != check[j+2] check[j+1] = 0 else: check[j+1] = 0 flag = True if flag == False: check[check.index(0)] = -1 check[i] = -1 else: flag = False elif check[i] != -1: check[i] = 0 for i in range(N): if check[i] == 0: c += 1 return c print main()
s767190766
p03817
u886545507
1486830844
Python
Python (2.7.6)
py
Runtime Error
17
2568
114
#ARC068C n=int(raw_input()) if x<=6: print 1 else: res=n/11*2 if n%11>=6: res+=2 else: res+=1 print res
s178438337
p03817
u093843560
1486240808
Python
Python (2.7.6)
py
Runtime Error
15
2568
118
mport numpy as np x = raw_input() x = int(x) y = (x//11)*2 w = x%11 if w<7: y = y+1 else: y = y+2 print y
s120662345
p03817
u208486018
1485841913
Python
Python (2.7.6)
py
Runtime Error
18
2568
251
N = int(raw_input()) A = map(int, raw_input().split()) D = dict() for a in A: if not a in D: D[a] = 0 D[a] += 1 total = 0 for num, count in D.iteritems(): if count > 1: total += count - 1 if total % 2 != 0: total += 1 print (N - total)
s613026753
p03817
u208486018
1485841771
Python
Python (2.7.6)
py
Runtime Error
16
2568
249
N = int(raw_input()) A = map(int, raw_input().split()) D = dict() for a in A: if a not in D: D[a] = 0 D[a] += 1 total = 0 for num, count in D.iteritems(): if count > 1: total += count - 1 if total % 2 != 0: total += 1 print N - total
s924494117
p03817
u546700081
1485719481
Python
Python (2.7.6)
py
Runtime Error
16
2568
304
N,M=map(int,raw_input().split(" ")) items=[] for _ in xrange(0,N): items.append(map(int,raw_input().split(" "))) for d in xrange(1,M+1): isget=[False]*N for k in range(0,M+1,d): for i,item in enumerate(items): isget[i]=item[0]<=k<=item[1] or isget[i] print sum(isget)
s241378063
p03817
u966695411
1485658950
Python
Python (3.4.3)
py
Runtime Error
22
3192
265
N = int(input()) A = list(map(int, input().split())) D = {} for i in A: if i in D: D[i] += 1 else: D[i] = 1 cnt = 0 for k in D.keys(): if D[k] % 2: D[k] = 1 else: D[k] = 2 cnt += 1 print(len({*A}) - (cnt % 2))
s706271657
p03817
u541568482
1485658143
Python
Python (3.4.3)
py
Runtime Error
23
3064
179
import sys cin = sys.stdin cin = open("in.txt", "r") x = int(cin.readline()) c = x//11 cnt = c*2 r = x%11 # print(r) if r>0: cnt +=1 if r>6: cnt +=1 print(cnt)
s171375054
p03817
u755962107
1485657546
Python
Python (3.4.3)
py
Runtime Error
21
3064
139
n = int(input().strip()) q = n // 11 r = n % 11 res = 2 * q if r > 5: res += 2 elif r > 0: res += 1 print(res)
s721461054
p03818
u411203878
1600530129
Python
PyPy3 (7.3.0)
py
Runtime Error
185
102100
577
N = int(input()) A = list(map(int,input().split())) memo = {} for a in A: if a in memo: memo[a] += 1 else: memo[a] = 1 memo_sorted = sorted(memo.items(), key=lambda x:-x[1]) memo = [] for a,b in memo_sorted: memo.append([a,b]) for key,val in enumerate(memo): val_1, val_2 = val if val_2 <= 1: continue else: if val_2%2 == 1: memo[key][1] = 1 elif val_2%2 == 0: if key < N-1: memo[key+1][1] -= 1 memo[key][1] = 1 ans = 0 for a,b in memo: ans += b print(ans)
s797138502
p03818
u397496203
1600482932
Python
PyPy3 (7.3.0)
py
Runtime Error
138
103672
892
import sys # sys.setrecursionlimit(100000) def input(): return sys.stdin.readline().strip() def input_int(): return int(input()) def input_int_list(): return [int(i) for i in input().split()] def main(): from collections import Counter n = input_int() A = input_int_list() A_cnt = Counter(A).most_common() A_cnt = [list(a) for a in A_cnt] cnt = 0 for i in range(len(A_cnt)): if A_cnt[i][1] > 2: if A_cnt[i][1] % 2 == 1: cnt += A_cnt[i][1] // 2 A_cnt[i][1] = 1 elif A_cnt[i][1] % 2 == 0: cnt += (A_cnt[i][1] // 2) - 1 A_cnt[i][1] = 2 if A_cnt[i][1] == 2: if i + 1 < n: A_cnt[i + 1][1] -= 1 A_cnt[i][1] = 1 cnt += 1 print(n - cnt * 2) return if __name__ == "__main__": main()
s323174030
p03818
u397496203
1600482837
Python
PyPy3 (7.3.0)
py
Runtime Error
141
96904
862
import sys # sys.setrecursionlimit(100000) def input(): return sys.stdin.readline().strip() def input_int(): return int(input()) def input_int_list(): return [int(i) for i in input().split()] def main(): from collections import Counter n = input_int() A = input_int_list() A_cnt = Counter(A).most_common() A_cnt = [list(a) for a in A_cnt] cnt = 0 for i in range(len(A_cnt)): if A_cnt[i][1] > 2: if A_cnt[i][1] % 2 == 1: cnt += A_cnt[i][1] // 2 A_cnt[i][1] = 1 elif A_cnt[i][1] % 2 == 0: cnt += (A_cnt[i][1] // 2) - 1 A_cnt[i][1] = 2 if A_cnt[i][1] == 2: A_cnt[i + 1][1] -= 1 A_cnt[i][1] = 1 cnt += 1 print(n - cnt * 2) return if __name__ == "__main__": main()
s307232491
p03818
u119148115
1600482087
Python
PyPy3 (7.3.0)
py
Runtime Error
97
74776
157
N = I() A = LI() B = [0]*(10**5+1) for a in A: B[a] += 1 print(sum(B[i] != 0 for i in range(10**5+1))-(sum(max(0,B[i]-1) for i in range(10**5+1)) % 2))
s235042083
p03818
u535803878
1595136739
Python
PyPy3 (7.3.0)
py
Runtime Error
111
100584
530
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n = int(input()) a = list(map(int, input().split())) from collections import Counter c = Counter(a) ones = sum(v==1 for v in c.values()) ns = [v-1 for v in c.values() if v>1] ans = ones + len(ns) ns.sort() if ns[-1]>sum(ns[:-1]): after = ns[-1] - sum(ns[:-1]) if after%2==1: ans -= 1 else: after = 1 if sum(ns)%2==1 else 0 if after==1: ans -= 1 print(ans)
s794830106
p03818
u989306199
1594968412
Python
Python (3.8.2)
py
Runtime Error
55
21916
149
import collections as col N = int(input()) A = list(map(int, input().split())) m = col.Counter(A) ans = len(m) if m%2==1 else len(m)-1 print(ans)
s643067037
p03818
u946969297
1594860266
Python
Python (3.8.2)
py
Runtime Error
24
8944
730
import times, strutils, sequtils, math, algorithm, tables, sets, lists, intsets import critbits, future, strformat, deques template `max=`(x,y) = x = max(x,y) template `min=`(x,y) = x = min(x,y) let read* = iterator: string {.closure.} = while true: (for s in stdin.readLine.split: yield s) proc scan(): int = read().parseInt proc toInt(c:char): int = return int(c) - int('0') proc solve():int= var n = scan() a = newseqwith(n,scan()) vcount = newseqwith(1E5.int+1,0) for av in a: vcount[av]+=1 var odds = 0 evens = 0 for vc in vcount: if vc > 0: if vc mod 2 == 0: evens+=1 else: odds += 1 result = odds + (evens div 2) * 2 echo solve()
s823770192
p03818
u404290207
1592452766
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38256
1593
import sys sys.setrecursionlimit(10**6) from math import floor,ceil,sqrt,factorial,log,gcd from heapq import heappop, heappush, heappushpop from collections import Counter,defaultdict,deque from itertools import accumulate,permutations,combinations,product,combinations_with_replacement from bisect import bisect_left,bisect_right from copy import deepcopy from operator import itemgetter from fractions import gcd mod = 10 ** 9 + 7 inf = float('inf') ninf = -float('inf') ''' #Pythonを用いる場合 #numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4 import numpy as np from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson from scipy.sparse import csr_matrix ''' #整数input def ii(): return int(sys.stdin.readline().rstrip()) #int(input()) def mii(): return map(int,sys.stdin.readline().rstrip().split()) def limii(): return list(mii()) #list(map(int,input().split())) def lin(n:int): return [ii() for _ in range(n)] def llint(n: int): return [limii() for _ in range(n)] #文字列input def ss(): return sys.stdin.readline().rstrip() #input() def mss(): return sys.stdin.readline().rstrip().split() def limss(): return list(mss()) #list(input().split()) def lst(n:int): return [ss() for _ in range(n)] def llstr(n: int): return [limss() for _ in range(n)] #本当に貪欲法か? DP法では?? #本当に貪欲法か? DP法では?? #本当に貪欲法か? DP法では?? n=ii() arr=limii() res=Counter(arr) if len(list(res))%2==0: print(len(list(res))-1) else: print(len(list(res)))
s399439227
p03818
u333139319
1591270213
Python
PyPy3 (2.4.0)
py
Runtime Error
236
61676
756
import sys def input(): return sys.stdin.readline()[:-1] import collections n = int(input()) a = [int(i) for i in input().split()] dic = collections.defaultdict(int) for i in range(n): dic[a[i]] += 1 ls = collections.deque() for i in dic.keys(): if dic[i] > 1: ls.append(i) ans = n #n/2回ループ for i in range(n//2): if len(ls) == 1 and dic[ls[0]] == 2: ans -= 2 dic[ls[0]] -= 1 break else: if len(ls) == 1: dic[ls[0]] -= 2 else: dic[ls[0]] -= 1 dic[ls[-1]] -= 1 ans -= 2 if len(ls) > 1: if dic[ls[-1]] <= 1: ls.pop() if dic[ls[0]] <= 1: ls.popleft() if len(ls) == 0: break print(ans)
s224870110
p03818
u333139319
1591268952
Python
PyPy3 (2.4.0)
py
Runtime Error
2107
61804
586
import collections n = int(input()) a = [int(i) for i in input().split()] dic = collections.defaultdict(int) for i in range(n): dic[a[i]] += 1 ls = collections.deque() for i in dic.keys(): if dic[i] > 1: ls.append(i) ans = n for i in range(n//2): if max(dic.values()) == 1: break if len(ls) == 1 and dic[ls[0]] == 2: ans -= 2 dic[ls[0]] -= 1 break else: dic[ls[0]] -= 1 dic[ls[-1]] -= 1 ans -= 2 if dic[ls[0]] <= 1: ls.popleft() if dic[ls[-1]] <= 1: ls.pop() print(ans)
s121832268
p03818
u333139319
1591268758
Python
PyPy3 (2.4.0)
py
Runtime Error
2107
61804
598
import collections n = int(input()) a = [int(i) for i in input().split()] dic = collections.defaultdict(int) for i in range(n): dic[a[i]] += 1 ls = collections.deque() for i in dic.keys(): if dic[i] > 1: ls.append(i) ans = n while max(dic.values()) > 1: #print(dic) if len(ls) == 1 and dic[ls[0]] == 2: ans -= 2 dic[ls[0]] -= 1 break else: dic[ls[0]] -= 1 dic[ls[-1]] -= 1 ans -= 2 if len(ls) >= 1: if dic[ls[0]] <= 1: ls.popleft() if dic[ls[-1]] <= 1: ls.pop() print(ans)
s407034566
p03818
u306950978
1590015966
Python
Python (3.4.3)
py
Runtime Error
84
18656
558
import collections n = int(input()) a = list(map(int,input().split())) c = collections.Counter(a) p = [] ans = 0 for k,v in c.items(): ans += 1 if v != 1: p.append([k,v]) p.sort() lef = 0 rig = len(p)-1 while True: if lef == rig: if p[lef][1] % 2 == 1: print(ans) exit() elif p[lef][1] % 2 == 0: print(ans-1) exit() elif lef > rig: print(ans) p[lef][1] -= 1 p[rig][1] -= 1 if p[lef][1] == 1: lef += 1 if p[rig][1] == 1: rig -= 1
s777807667
p03818
u306950978
1590015809
Python
Python (3.4.3)
py
Runtime Error
85
18656
519
import collections n = int(input()) a = list(map(int,input().split())) c = collections.Counter(a) p = [] ans = 0 for k,v in c.items(): ans += 1 if v != 1: p.append([k,v]) p.sort() lef = 0 rig = len(p)-1 while True: p[lef][1] -= 1 p[rig][1] -= 1 if p[lef][1] == 1: lef += 1 if p[rig][1] == 1: rig -= 1 if lef == rig: if p[lef][1] % 2 == 1: print(ans) exit() elif p[lef][1] % 2 == 0: print(ans-1) exit()
s249330585
p03818
u992910889
1589508621
Python
PyPy3 (2.4.0)
py
Runtime Error
223
52780
396
import sys sys.setrecursionlimit(10 ** 5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): N = int(input()) A = list(map(int, input().split())) AA = Counter(A) ans = 0 val = 0 for k, v in AA.items(): if v % 2 == 0: ans += 1 else: val += 1 if ans % 2 !=0: ans -= 1 print(val+ans) resolve()
s164405124
p03818
u246217175
1587778558
Python
PyPy3 (2.4.0)
py
Runtime Error
220
53572
471
n = int(input()) a = list(map(int,input().split())) a = a + [0] a.sort(reverse = True) b = 1 ichi = 0 r = [] for i in range(n): if a[i] != a[i+1]: if b != 1: r.append(b) else: ichi += 1 b = 1 else: b += 1 for i in range(len(r)-1): if r[i] % 2 == 0: r[i] = 1 r[i+1] -= 1 else: r[i] = 1 if r[-1] % 2 == 0: print(ichi + len(r) - 1) else: print(ichi + len(r))
s484117149
p03818
u575431498
1574403425
Python
Python (3.4.3)
py
Runtime Error
82
15156
363
N = int(input()) fq = [0] * (N + 10) A = list(map(int, input().split())) for a in A: fq[a] += 1 fq = [f if f % 1 == 0 else 1 for f in fq] cnt_even = 0 cnt_odd = 0 for f in fq: if f & 1 == 0 and f != 0: cnt_even += 1 if f & 1 == 1: cnt_odd += 1 if cnt_even & 1 == 0: print(cnt_even + cnt_odd) else: print(cnt_even - 1 + cnt_odd)
s639057887
p03818
u688375653
1570378594
Python
PyPy3 (2.4.0)
py
Runtime Error
261
87592
298
N=int(input()) A=list(map(int, input().split())) #重複した値だけを集めて消す sets={} for i in A: if i in sets: sets[i]+=1 else: sets[i]=1 sets duplicate=0 for k,v in sets.items(): if v>1: duplicate+=(v-1) duplicate %=2 print(set(A))-duplicate
s237694217
p03818
u118642796
1568857157
Python
PyPy3 (2.4.0)
py
Runtime Error
168
38384
256
import sys N = int(input()) A = [int(a) for a in sys.stdin.readline().split()] dic = {} for a in A: dic[a] = dic.get(a,0) + 1 evenodd = [0,0] for k in dic: evenodd[dic[k]%2] += 1 if evenodd[0]%2==0: return len(dic) else: return len(dic)-1
s873341617
p03818
u223646582
1567924653
Python
PyPy3 (2.4.0)
py
Runtime Error
229
80684
129
n = int(input()) A = set([int(i) for i in input().split()]) print(A) if A % 2 == 1: print(len(A)) else: print(len(A)-1)
s868591243
p03818
u091051505
1567137454
Python
Python (3.4.3)
py
Runtime Error
61
18656
291
from collections import Counter n = int(input()) a = [int(i) for i in input().split()] k = Counter(a) b = list(k.values()) over_2 = [bb for bb in b if bb >= 2] if sum(over_2) % 2 == 1: print(len(b)) else: if len(over_2 == 0): print(len(b)) else: print(len(b) - 1)
s424238743
p03818
u667024514
1553392146
Python
Python (3.4.3)
py
Runtime Error
53
14564
130
n = int(input()) lis = list(map(int,input().split())) ans = set() for num in lis:ans.add(num) print(len(num)-((len(num) % 2)+1)%2)
s983270822
p03818
u388927326
1548593513
Python
Python (3.4.3)
py
Runtime Error
121
14104
785
#!/usr/bin/env python3 import heapq def main(): n = int(input()) h = list(map(int, input().split())) heapq.heapify(h) accepted = [heapq.heappop(h)] while len(h) > 0: assert len(h) >= 2 first = heapq.heappop(h) second = heapq.heappop(h) if accepted[-1] == first: del first del second elif first == second: if len(h) > 0: third = heapq.heappop(h) del first del third accepted.append(second) else: accepted.pop() accepted.append(first) del second else: accepted.append(first) accepted.append(second) print(len(accepted)) main()
s016171383
p03818
u827202523
1539509964
Python
Python (2.7.6)
py
Runtime Error
16
4724
429
from collections import defaultdict def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) N = getN() nums = getList() dup = defaultdict(int) for n in nums: dup[n] += 1 poss = len(dup.keys()) dupdup = 0 for val in dup.values(): if val % 2 == 0: dupdup += 1 if dupdup % 2 == 0: print(poss) else: print(poss-1)
s268083825
p03818
u391331433
1532745512
Python
Python (2.7.6)
py
Runtime Error
12
2928
828
from collections import deque import copy from math import * def get_read_func(fileobject): if fileobject == None : return raw_input else: return fileobject.readline def main(): if len(sys.argv) > 1: f = open(sys.argv[1]) else: f = None read_func = get_read_func(f); input_raw = read_func().strip().split() [N] = [long(input_raw[0])] input_raw = read_func().strip().split() cards = {} for i in range(N): c = int(input_raw[i]) if c not in cards: cards[c] = 1 else: cards[c] += 1 even_num = 0 for c in cards: if cards[c] % 2 == 0: even_num += 1 if even_num % 2 == 0: print len(cards) else: print len(cards) - 1 if __name__ == '__main__': main()
s430897276
p03818
u765237551
1493582963
Python
Python (3.4.3)
py
Runtime Error
18
2940
786
use std::io::stdin; fn main(){ let x = geti64s()[0]; let (d, m) = (x/11, x%11); println!("{}", match m { 0 => d*2, x if x<=6 => d*2 + 1, _ => d*2 + 2 }); } #[allow(dead_code)] fn getline() -> String { let mut s = String::new(); match stdin().read_line(&mut s){ Ok(_) => {s.trim().to_string()} Err(_) => String::new() } } #[allow(dead_code)] fn getvec() -> Vec<usize>{ let line = getline(); line.split_whitespace().map(|x| x.parse().unwrap()).collect() } #[allow(dead_code)] fn geti64s() -> Vec<i64>{ let line = getline(); line.split_whitespace().map(|x| x.parse().unwrap()).collect() } #[allow(dead_code)] fn getpair() -> (usize, usize){ let nm = getvec(); (nm[0], nm[1]) }
s982503604
p03818
u669382434
1493059043
Python
Python (3.4.3)
py
Runtime Error
70
14388
183
n=int(input()) a=list(map(int,input().split())) sn=[0]*n mi2=0 mi=0 for i in range(0,n): if sn[a[i]]==1: mi2=1-mi2 else: sn[a[i]]=1 mi+=1 print(mi-mi2)
s116680270
p03818
u619631862
1490814345
Python
Python (3.4.3)
py
Runtime Error
138
14388
185
n=int(input()) a=[int(i) for i in input().split()] a.sort() b=[a[0]] def f(i): if i>n-1: print(len(b)) return 0 if a[i]!=b[-1]: b.append(a[i]) f(i+1) else: f(i+2) f(1)
s013604938
p03818
u619631862
1490814076
Python
Python (3.4.3)
py
Runtime Error
140
13964
184
n=int(input()) a=[int(i) for i in input().split()] a.sort() b=[a[0]] def f(i): if i==n: print(len(b)) return 0 if a[i]!=b[-1]: b.append(a[i]) f(i+1) else: f(i+2) f(1)
s916153912
p03818
u848877025
1488673616
Python
Python (2.7.6)
py
Runtime Error
2104
14936
1414
def main(): N = int(raw_input()) x = map(int, raw_input().split()) #-1:remove , 0:singe , 1~:label check= [0] * N flag = False label = 1 c = 0 x.sort() #labeling for i in range(N): for j in range(N): if(i != j): if(x[i] == x[j]): flag = True if flag: if i > 0: if(x[i] != x[i-1]): label += 1 check[i] = label else: check[i] = label else: check[i] = label flag = False #removing for i in range(N-1): if(check[i] > 0 and check[i+1] == check[i]): for j in range(N): if(check[i] != check[j] and check[j] > 0 and flag == False): check[i] = -1 check[j] = -1 if j < N-2: check[j+1] != check[j+2] check[j+1] = 0 else: check[j+1] = 0 flag = True if flag == False: check[check.index(0)] = -1 check[i] = -1 else: flag = False elif check[i] != -1: check[i] = 0 for i in range(N): if check[i] == 0: c += 1 return c print main()
s388445088
p03818
u984351908
1485658172
Python
Python (3.4.3)
py
Runtime Error
128
14396
257
n = int(input()) a = list(map(int, input().split())) a.sort() c = 0 e = 0 i = 0 while i < len(a): c += 1 cai = 1 while a[i] == a[i + 1]: cai += 1 i += 1 if cai % 2 == 0: e += 1 i += 1 ans = c - (e % 2) print(ans)
s941749799
p03819
u222668979
1597889263
Python
PyPy3 (7.3.0)
py
Runtime Error
148
74500
77
x = int(input()) ans = x // 11 * 2 print(ans + (x % 11 > 0) + (x % 11 > 6))
s398367343
p03819
u864197622
1575264184
Python
PyPy3 (2.4.0)
py
Runtime Error
764
87644
725
import sys input = sys.stdin.readline N, M = map(int, input().split()) NN = (M + 10).bit_length() - 1 BIT=[0]*(2**NN+1) def addrange(l0, r0, x=1): l, r = l0, r0 while l <= 2**NN: BIT[l] += x l += l & (-l) while r <= 2**NN: BIT[r] -= x r += r & (-r) def getvalue(r): a = 0 while r != 0: a += BIT[r] r -= r&(-r) return a X = [] for _ in range(N): l, r = map(int, input().split()) X.append((l, r+1)) X = sorted(X, key = lambda x: -(x[1]-x[0])) for d in range(1, M+1): while X and X[-1][1] - X[-1][0] < d: l, r = X.pop() addrange(l, r) ans = len(X) for i in range(d, M+1, d): ans += getvalue(i) print(ans)
s100273460
p03819
u102461423
1568742004
Python
Python (3.4.3)
py
Runtime Error
22
3316
831
import sys input = sys.stdin.readline from collections import defaultdict N,M = map(int,input().split()) d_to_LR = defaultdict(list) for _ in range(N): L,R = map(int,input().split()) d_to_L[R-L+1].append(L) tree = [0] * (M+1) # BIT で管理。左にあるLの個数 - (R+1)の個数 → いくつの[L,R]に入っているか long = N # 長すぎて自動回収できる answer = [0] * (M+1) for m in range(1,M+1): for L in d_to_L[m]: R = L+m-1 x = L while x <= M: tree[x] += 1 x += x & (-x) x = R+1 while x <= M: tree[x] -= 1 x += x & (-x) long -= 1 s = long for x in range(m,M+1,m): while x: s += tree[x] x -= x & (-x) answer[m] = s print('\n'.join(map(str, answer[1:])))
s962711689
p03819
u777923818
1557803178
Python
PyPy3 (2.4.0)
py
Runtime Error
170
38384
1333
from bisect import bisect from operator import itemgetter inpl = lambda: list(map(int, input().split())) class BIT: from math import log2 def __init__(self, N): self.size = 2 ** (-int(-log2(N)//1)) self.tree = [0]*(self.size + 1) def sum(self, i): res = 0 while i: res += self.tree[i] i -= (i & -(i)) return res def add(self, i, x): while 1 <= i <= self.size: self.tree[i] += x i += (i & -(i)) class RABIT(): # range add BIT def __init__(self, N): self.bit0 = BIT(N) self.bit1 = BIT(N) def sum(self, i): return i*self.bit1.sum(i) + self.bit0.sum(i) def add_range(self, l, r, x): self.bit0.add(l, -x*(l-1)) self.bit1.add(l, x) self.bit0.add(r+1, x*r) self.bit1.add(r+1, -x) def get_range(self, l, r): return self.sum(r) - self.sum(l-1) N, M = inpl() R, L, S = [], [], [] Q = [] for _ in range(N): l, r = inpl() Q.append((l, r, (r-l+1))) Q = sorted(Q, key=itemgetter(2), reverse=True) rabit = RABIT(M+1) for i in range(1, M+1): while Q and Q[-1][2] < i: l, r, _ = Q.pop() rabit.add_range(l, r, 1) ans = len(Q) for j in range(i, M+1, i): ans += rabit.get_range(j, j) print(ans)
s950257821
p03819
u155024797
1556513013
Python
PyPy3 (2.4.0)
py
Runtime Error
170
38384
466
def is_prime(N): if N < 2: return False i = 2 while i*i <= N: if N % i == 0: return False i += 1 return True def main(): N = int(input()) if not is_prime(N): dsum = 0 for c in str(N): dsum += int(c) if N == 1 or N % 10 in [2, 4, 5, 6, 8, 0] or dsum % 3 == 0: print("Not Prime") return print("Prime") if __name__ == "__main__": main()
s276435730
p03819
u236127431
1546100921
Python
PyPy3 (2.4.0)
py
Runtime Error
1685
85664
516
N,M=map(int,input().split()) section=[[] for i in range(M+1)] for i in range(N): l,r=map(int,input().split()) section[r-l+1].append((l,r)) def add(B,a,s): x=a while x<=len(B): B[x]+=s x+=x&(-x) def sums(B,a): x=a S=0 while x!=0: S+=B[x] x-=x&(-x) return S Line=[0]*(M+2) K=N for d in range(1,M+1): for l,r in section[d]: add(Line,l,1) add(Line,r+1,-1) K-=1 ans=K for s in range(M//d+1): ans+=sums(Line,s*d) print(ans)
s682126310
p03819
u226155577
1518410213
Python
Python (3.4.3)
py
Runtime Error
18
3064
557
from math import sqrt N, M = map(int, input().split()) D = [0]*(M+2); R = [0]*(M) for i in range(N): l, r = map(int, input().split()) D[1] += 1 D[r+1] -= 1 if l <= r-l+1: continue D[r-l+2] -= 1 D[l] += 1 left = r-l+2; right = l for k in range(2, int(sqrt(r))+1): l0 = max((l+k-1) // k, left); r0 = min((r // k + 1, right)) if l0 < r0: D[l0] += 1 D[r0] -= 1 right = l0 print(*R, *D) tmp = 0 for i in range(1, M+1): tmp += D[i] R[i-1] += tmp print(*R, sep='\n')
s623306715
p03819
u637175065
1509316469
Python
PyPy3 (2.4.0)
py
Runtime Error
968
127320
1521
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**15 mod = 10**9+7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) def S(): return input() def pf(s): return print(s, flush=True) class BIT(): def __init__(self, n): i = 1 while 2**i <= n: i += 1 self.H = i self.N = 2**i self.A = [0] * self.N def find(self, i): r = 0 while i: r += self.A[i] i -= i & (i-1) ^ i return r def update(self, i, x): while i < self.N: self.A[i] += x i += i & (i-1) ^ i def query(self, a, b): return self.find(b-1) - self.find(a-1) def main(): n,m = LI() d = collections.defaultdict(list) for _ in range(n): l,r = LI() d[r-l+1].append((l,r)) r = [n] bit = BIT(n+3) c = n for i in range(2,m+1): for a,b in d[i-1]: c -= 1 bit.update(a,1) bit.update(b+1,-1) t = c for j in range(i,m+1,i): t += bit.find(j) r.append(t) return '\n'.join(map(str,r)) print(main())
s787263475
p03819
u772909448
1509237853
Python
Python (3.4.3)
py
Runtime Error
19
3316
921
import sys print("弁当の種類を指定してください:") bentoType = int(sys.stdin.readline()) print("駅の合計数を指定してください:") stationCnt = int(sys.stdin.readline()) startSta = 0 endSta = 0 array = [] for i in range(1, bentoType + 1) : bentoMap = {} print("弁当" + str(i) + "の開始駅を指定してください:") startSta = int(sys.stdin.readline()) print("弁当" + str(i) + "の終了駅を指定してください:") endSta = int(sys.stdin.readline()) for start in range(startSta, endSta + 1, 1) : bentoMap.update({str(start): 1}) array.append(bentoMap) bentoCnt = 0 for n in range(1, stationCnt + 1, 1) : bentoCnt = 0 for outMap in array : for m in range(0, stationCnt + 1, n) : if str(m) in outMap : bentoCnt += 1 break print("弁当" + str(n) + ":") print(bentoCnt)
s094396813
p03820
u723736091
1485659813
Python
Python (2.7.6)
py
Runtime Error
16
2568
804
#include <bits/stdc++.h> using namespace std; #define fo(i,a,b) for(int i=(a);i<(b);i++) #define MOD 1000000007 #define MP make_pair #define PB push_back typedef long long ll; int N, K; ll ans = 1; ll inv (ll a) { ll e = MOD-2, r = 1ll; while (e) { if (e&1) r = r * a % MOD; e /= 2, a = a * a % MOD; } return r; } int main () { scanf("%d %d", &N, &K); ll x = (ll) N-K+1; ans = x % MOD; for (ll i = (ll) K; i < (ll) K + (K-2); i++) { ans = ans * (x+i) % MOD; } for (ll i = 1ll; i < (ll) K; i++) ans = ans * inv(i) % MOD; if (x > 2) { for (ll i = 0; i < x-2; i++) ans = ans * 2 % MOD; } printf("%lld\n", ans); return 0; }
s120558419
p03821
u623814058
1597860540
Python
Python (3.8.2)
py
Runtime Error
300
52504
150
N=int(input()) A=[map(int,input().split()) for _ in range(N)] r=0 for i in range(N-1,-1,-1): a,b=A[i] a+=r r+=-(-a//b)*A[i][1]-a print(r)
s523128577
p03821
u760771686
1595958682
Python
Python (3.8.2)
py
Runtime Error
26
9032
184
N = int(input()) Array = [] for i in range(N): Array.append(tuple(map(int,input().split()))) res = 0 for i in reversed(range(N)): a,b = Array[i] a+=res res+ = b-a%b print(res)
s036874371
p03821
u917013605
1594931246
Python
PyPy3 (7.3.0)
py
Runtime Error
91
74880
337
import math def lcm(x, y): return (x * y) // math.gcd(x, y) N, M = map(int, input().split()) S = input() T = input() L = lcm(N , M) x = [""] * L for i in range(N): idx = i * (L // N) # x[idx] = S[i] for i in range(M): idx = i * (L // M) if x[idx] != "" and x[idx] != T[i]: print(-1) exit() print(L)
s715423148
p03821
u212328220
1593575491
Python
Python (3.8.2)
py
Runtime Error
283
16880
573
N = int(input()) al = [] bl = [] for i in range(N): a,b = map(int,input().split()) al.append(a) bl.append(b) al.reverse() bl.reverse() plus = 0 for i in range(N): if al[i]+plus > bl[i]: amari = (al[i]+plus) % bl[i] syo = (al[i]+plus) // bl[i] if amari != 0: syo += 1 plus += bl[i] * syo - (al[i]+plus) elif al[i]+plus < bl[i]: amari = bl[i] % (al[i]+plus) syo = bl[i] // (al[i]+plus) if amari != 0: syo += 1 plus += syo else: continue print(plus)