Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
# a,bの最大公約数


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


gcdl = [[0]*k*2 for _ in range(k*2)]
for a in range(1, k+1):
    for b in range(1, k+1):
        gcdl[a][b] = gcd(a, b)

ansl = [[[-1]*k*2 for _ in range(k*2)] for _ in range(k*2)]
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            if ansl[a][b][c] == -1:
                t = gcd(c, gcdl[a][b])
                ansl[a][b][c] = t
                ansl[a][c][b] = t
                ansl[b][a][c] = t
                ansl[b][c][a] = t
                ansl[c][b][a] = t
                ansl[c][a][b] = t
            else:
                t = ansl[a][b][c]
            ans += t
print(ans)


Fixed submission:
k = int(input())
# a,bの最大公約数


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


gcdl = [[0]*k*2 for _ in range(k*2)]
for a in range(1, k+1):
    for b in range(1, k+1):
        gcdl[a][b] = gcd(a, b)

ansl = [[[-1]*k*2 for _ in range(k*2)] for _ in range(k*2)]
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            if ansl[a][b][c] == -1:
                t = gcd(c, gcdl[a][b])
                ansl[a][b][c] = t
                ansl[a][c][b] = t
                ansl[b][a][c] = t
                ansl[b][c][a] = t
                ansl[c][b][a] = t
                ansl[c][a][b] = t
            else:
                t = ansl[a][b][c]
            ans += t
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop
from collections import deque
n, x, y = list(map(int, input().split()))
G = [[]*n for _ in range(n)]

for i in range(n-1):
    G[i].append((i+1, 1))
    G[i+1].append((i, 1))
G[x-1].append((y-1, 1))
G[y-1].append((x-1, 1))
# print(G)
INF = 10**30
N = n


# s: 開始頂点
# N: 頂点数
# G: グラフ
# G[v][i] = (w, d): 辺v-wのコストは d (0 or 1)
dd = []
for i in range(n):
    s = i
    dist = [10**9] * N
    S = deque([s])
    T = deque()
    dist[s] = 0

    d = 0
    while S:
        while S:
            v = S.popleft()
            for w, c in G[v]:
                if d+c < dist[w]:
                    dist[w] = d+c
                    if c:
                        T.append(w)
                    else:
                        S.append(w)
        S, T = T, S
        d += 1
    dd.append(dist)
for i in range(1, n):
    ans = 0
    for d in dd:
        ans += d.count(i)
    print(ans//2)


Fixed submission:
from collections import defaultdict
from heapq import heappush, heappop
from collections import deque
n, x, y = list(map(int, input().split()))
G = [[]*n for _ in range(n)]

for i in range(n-1):
    G[i].append((i+1, 1))
    G[i+1].append((i, 1))
G[x-1].append((y-1, 1))
G[y-1].append((x-1, 1))
# print(G)
INF = 10**30
N = n


# s: 開始頂点
# N: 頂点数
# G: グラフ
# G[v][i] = (w, d): 辺v-wのコストは d (0 or 1)
dd = []
for i in range(n):
    s = i
    dist = [10**9] * N
    S = deque([s])
    T = deque()
    dist[s] = 0

    d = 0
    while S:
        while S:
            v = S.popleft()
            for w, c in G[v]:
                if d+c < dist[w]:
                    dist[w] = d+c
                    if c:
                        T.append(w)
                    else:
                        S.append(w)
        S, T = T, S
        d += 1
    dd.append(dist)

ans = defaultdict(lambda: 0)
for dist in dd:
    for t in dist:
        ans[t] += 1
for i in range(n-1):
    print(ans[i+1]//2)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
import math


def combinations_count(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = int(input())
al = list(map(str, input().split()))
d = defaultdict(lambda: 0)
dd = defaultdict(lambda: 0)
for a in al:
    d[a] += 1

sam = 0
for key, value in d.items():
    dd[key] = combinations_count(value, 2)
    sam += dd[key]
# print(d)
# print(dd)
# print(sam)
for a in al:
    value = d[a]
    print(sam - dd[a] + combinations_count(value-1, 2))


Fixed submission:
from collections import defaultdict
import math


def combinations_count(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = int(input())
al = list(map(str, input().split()))
d = defaultdict(lambda: 0)
dd = defaultdict(lambda: 0)
dd_1 = defaultdict(lambda: 0)
for a in al:
    d[a] += 1

sam = 0
for key, value in d.items():
    dd[key] = combinations_count(value, 2)
    dd_1[key] = combinations_count(value-1, 2)
    sam += dd[key]
# print(d)
# print(dd)
# print(sam)
for a in al:
    value = d[a]
    print(sam - dd[a] + dd_1[a])
Buggy python submission (verdict: Runtime Error):
from itertools import product
import numpy as np

h, w, k = list(map(int, input().split()))
s = [list(map(int, list(input()))) for i in range(h)]
INF = float("inf")
ans = INF
for bits in product([0, 1], repeat=h-1):
    cnt = sum(bits)
    cuts = [0]+[i + 1 for i, x in enumerate(bits) if x == 1]+[h]
    data = [[0]*w for _ in range(len(cuts)-1)]
    for i in range(len(cuts)-1):
        target = s[cuts[i]:cuts[i+1]]
        for tt in target:
            for j, t in enumerate(tt):
                data[i][j] += t
    check = [[0]*(w+1) for _ in range(len(data))]
    flag = False
    for j in range(w):
        if flag:
            continue
        change = False
        for i in range(len(data)):
            if check[i][j] + data[i][j] > k:
                change = True
                break
        if change:
            for i in range(len(data)):
                if data[i][j] <= k:
                    check[i][j+1] = data[i][j]
                else:
                    flag = True
                    break
            cnt += 1
        else:
            for i in range(len(data)):
                check[i][j+1] = check[i][j] + data[i][j]
    if flag:
        continue
    ans = min(ans, cnt)
print(ans)


Fixed submission:
from itertools import product

h, w, k = list(map(int, input().split()))
s = [list(map(int, list(input()))) for i in range(h)]
INF = float("inf")
ans = INF
for bits in product([0, 1], repeat=h-1):
    cnt = sum(bits)
    cuts = [0]+[i + 1 for i, x in enumerate(bits) if x == 1]+[h]
    data = [[0]*w for _ in range(len(cuts)-1)]
    for i in range(len(cuts)-1):
        target = s[cuts[i]:cuts[i+1]]
        for tt in target:
            for j, t in enumerate(tt):
                data[i][j] += t
    check = [[0]*(w+1) for _ in range(len(data))]
    flag = False
    for j in range(w):
        if flag:
            continue
        change = False
        for i in range(len(data)):
            if check[i][j] + data[i][j] > k:
                change = True
                break
        if change:
            for i in range(len(data)):
                if data[i][j] <= k:
                    check[i][j+1] = data[i][j]
                else:
                    flag = True
                    break
            cnt += 1
        else:
            for i in range(len(data)):
                check[i][j+1] = check[i][j] + data[i][j]
    if flag:
        continue
    ans = min(ans, cnt)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
flag = True
for i in range(q):
    inp = input()
    if inp == '1':
        flag = not flag

    else:
        _, f, c = map(str, inp.split())
        if f == '1':
            if flag:
                s = c+s
            else:
                s += c
        else:
            if flag:
                s += c
            else:
                s = c+s
if flag:
    print(s)
else:
    print(s[::-1])


Fixed submission:
from collections import deque
s = input()
q = int(input())
flag = True
atama = deque()
osiri = deque()
for i in range(q):
    inp = input()
    if inp == '1':
        flag = not flag

    else:
        _, f, c = map(str, inp.split())
        if f == '1':
            if flag:
                atama.appendleft(c)
            else:
                osiri.append(c)
        else:
            if flag:
                osiri.append(c)
            else:
                atama.appendleft(c)

if flag:
    while(atama):
        tmp = atama.popleft()
        print(tmp, end='')
    print(s, end='')
    while(osiri):
        tmp = osiri.popleft()
        print(tmp, end='')
else:
    while(osiri):
        tmp = osiri.pop()
        print(tmp, end='')
    print(s[::-1], end='')
    while(atama):
        tmp = atama.pop()
        print(tmp, end='')
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
ki = [0]*1001
for i in range(1, 1001):
    ki[i] = ki[i-1]+i

pp = []
for pa in p:
    pp.append(ki[pa]/pa)

ans = 0
for i in range(n-k+1):
    ans = max(ans, sum(pp[i:i+k]))

print("{0:.12f}".format(ans))


Fixed submission:
import itertools
n, k = map(int, input().split())
p = list(map(int, input().split()))
ki = [0]*1001
for i in range(1, 1001):
    ki[i] = ki[i-1]+i

pp = []
for pa in p:
    pp.append(ki[pa]/pa)

# print(pp)
ppp = [0] + list(itertools.accumulate(pp))
# print(ppp)
ans = 0
for i in range(n-k+1):
    # print(ppp[i+k]-ppp[i])
    ans = max(ans, ppp[i+k]-ppp[i])

print("{0:.12f}".format(ans))
Buggy python submission (verdict: Runtime Error):
import numpy as np
import scipy as sp

a = int(input())
b = int(input())
print(6-a-b)


Fixed submission:
import numpy as np
import scipy as sp

a = int(input())
b = int(input())
print(6-a-b)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

int main()
{

    ll n, tmp, pau, ans = 0;
    cin >> n;

    for (ll i = 1; i < 30; i++)
    {
        pau = 1;
        rep(j, i)
        {
            pau *= 5;
        }
        pau = 2 * pau;
        if (n >= pau)
        {
            tmp = i;
            ans += n / pau;
        }
    }
    cout << ans << endl;
    // ll n, tmp, ans = 0;
    // n = 12;
    // tmp = n;
    // while (tmp >= 2)
    // {
    //     ans *= tmp;
    //     tmp -= 2;
    // }
    // cout << ans << endl;
    return 0;
}

Fixed submission:
n = int(input())
ans = 0
if(n%2 != 1):
  for i in range(1,30):
    ans = ans + n//(2*5**i)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# import numpy as np
# import scipy as sp

n = int(input())
info = []
for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        info.append([i, x-1, y])

ans = 0
for i in range(2 ** n):
    bit = [0] * n
    for j in range(n):
        if ((i >> j) & 1):
            bit[j] = 1

    flag = True
    # print(bit)
    for idx, j in enumerate(bit):
        if j == 1:
            for k in [x for x in info if x[0] == idx]:
                # print(' ', k)
                if bit[k[1]] != k[2]:
                    flag = False
    if flag:
        ans = max(ans, sum(bit))
    # print(ans)
print(ans)


Fixed submission:
# import numpy as np
# import scipy as sp

n = int(input())
info = []
for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        info.append([i, x-1, y])

ans = 0
for i in range(2 ** n):
    bit = [0] * n
    for j in range(n):
        if ((i >> j) & 1):
            bit[j] = 1

    flag = True
    # print(bit)
    for idx, j in enumerate(bit):
        if j == 1:
            for k in [x for x in info if x[0] == idx]:
                # print(' ', k)
                if bit[k[1]] != k[2]:
                    flag = False
    if flag:
        ans = max(ans, sum(bit))
    # print(ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# import numpy as np
# import scipy as sp
# import sys
# input = sys.stdin.readline
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=list(map(int, input().split()))  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# a=[int(input()) for _ in range (n)]  #リスト入力  改行でa1 ... anのとき
# s=[list(map(str,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# a = b[:], a = [x[:] for x in b] # deepcopy
# chr(ord('a') + 1) # chrのインクリメント
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）

n, w = list(map(int, input().split()))
wl = [0] * n
vl = [0] * n
for i in range(n):
    wl[i], vl[i] = map(int, input().split())


dp = [[0]*(w+1)for _ in range(n+1)]  # h:item w:weight v:value
for i in range(n):
    for j in range(w+1):
        if j+wl[i] <= w:
            dp[i+1][j+wl[i]] = max(dp[i+1][j+wl[i]], dp[i][j]+vl[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[-1][-1])


Fixed submission:
n, w = map(int, input().split())
s = [list(map(int, input().split())) for i in range(n)]
ws = [x[0] for x in s]
v = [x[1] for x in s]

dp = [[0]*(w+1) for _ in range(n+1)]

for sum_w in range(w+1):
    for i in range(1, n+1):
        if ws[i-1] <= sum_w:
            dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w-ws[i-1]]+v[i-1])
        else:
            dp[i][sum_w] = dp[i-1][sum_w]

print(dp[-1][-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, w = map(int, input().split())
s = [list(map(int, input().split())) for i in range(n)]
ws = [x[0] for x in s]
v = [x[1] for x in s]

dp = [[0]*(w+1) for _ in range(n+1)]
for i in range(n):
    for sum_w in range(w+1):
        if sum_w + ws[i] <= w:
            dp[i+1][sum_w + ws[i]] = max(dp[i+1][sum_w + ws[i]],
                                         dp[i][sum_w]+v[i])
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[-1][-1])


Fixed submission:
n, w = map(int, input().split())
s = [list(map(int, input().split())) for i in range(n)]
ws = [x[0] for x in s]
v = [x[1] for x in s]

dp = [[0]*(w+1) for _ in range(n+1)]

for sum_w in range(w+1):
    for i in range(1, n+1):
        if ws[i-1] <= sum_w:
            dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][sum_w-ws[i-1]]+v[i-1])
        else:
            dp[i][sum_w] = dp[i-1][sum_w]

print(dp[-1][-1])
Buggy python submission (verdict: Runtime Error):
h, w = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(h)]

ansl = []
n = 0
for i in range(h):
    for j in range(w-1):
        if a[i][j] % 2 == 0:
            pass
        else:
            n += 1
            ansl.append([i+1, j+1, i+2, j+1])
            a[i][j] -= 1
            a[i][j+1] += 1

for i in range(h-1):
    if a[i][-1] % 2 == 0:
        pass
    else:
        n += 1
        ansl.append([i+1, j+1, i+1, j+2])
        a[i][-1] -= 1
        a[i+1][-1] += 1

print(n)
[print(*x) for x in ansl]


Fixed submission:
h, w = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(h)]

ansl = []
n = 0
for i in range(h):
    for j in range(w-1):
        if a[i][j] % 2 == 0:
            pass
        else:
            n += 1
            ansl.append([i+1, j+1, i+1, j+2])
            a[i][j] -= 1
            a[i][j+1] += 1

for i in range(h-1):
    if a[i][w-1] % 2 == 0:
        pass
    else:
        n += 1
        ansl.append([i+1, w, i+2, w])
        a[i][w-1] -= 1
        a[i+1][w-1] += 1

print(n)
[print(*x) for x in ansl]
Buggy python submission (verdict: Runtime Error):
n=int(input())
a = list(map(int,split(input())))
a.sort()
print(abs(a[0]-a[-1]))

Fixed submission:
n=int(input())
a = list(map(int,input().split()))
a.sort()
print(abs(a[0]-a[-1]))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
s = input()
k = int(input())
anss = []
for bit in product(list(range(len(s)+1)), repeat=2):
    if bit[0] < bit[1] and s[bit[0]:bit[1]] not in anss:
        anss.append(s[bit[0]:bit[1]])

anss.sort()
print(anss[k-1])


Fixed submission:
from itertools import product
s = input()
k = int(input())
anss = []
for bit in product(list(range(len(s)+1)), repeat=2):
    if k >= bit[1] - bit[0] > 0:
        if bit[0] < bit[1] and s[bit[0]:bit[1]] not in anss:
            anss.append(s[bit[0]:bit[1]])

anss.sort()
print(anss[k-1])
Buggy python submission (verdict: Runtime Error):
import statistics
n = int(input())
a = list(map(int, input().split()))
median_low = statistics.median_low(a)
median_high = statistics.median_high(a)
for i in range(n):
    if median_high > a[i]:
        print(median_high)
    elif median_low < a[i]:
        print(median_low)
    elif median_high == a[i]:
        print(a[i])
    else:
        print(a[i-1])


Fixed submission:
import statistics
n = int(input())
a = list(map(int, input().split()))
median_low = statistics.median_low(a)
median_high = statistics.median_high(a)
for i in range(n):
    if median_high > a[i]:
        print(median_high)
    elif median_low < a[i]:
        print(median_low)
    elif median_high == a[i]:
        print(a[i])
    else:
        print(a[i-1])
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al.sort()
bl.sort()
cl.sort()
ans = 0
for i in range(n):
    # リストAに値xを入れ、xが複数になるとき、一番右の値xのインデックスを返す
    j = bisect.bisect_right(bl, al[i])
    for k in range(j, n):
        l = bisect.bisect_right(cl, bl[k])
        ans += (n-l)
print(ans)


Fixed submission:
import bisect
n = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al.sort()
bl.sort()
cl.sort()
ans = 0
tmp1 = [n]*n
tmp2 = [n]*n
for i in range(n):
    j = bisect.bisect_left(al, bl[i])
    tmp1[i] = j
for i in range(n):
    j = bisect.bisect_right(cl, bl[i])
    tmp2[i] = n-j
for i in range(n):
    ans += tmp1[i]*tmp2[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
for n in range(1, 3501):
    for w in range(n, 3501):
        t = (N*n*w) % (4*n*w - N*w - N*w)
        if t == 0:
            print(t,n,w)
            exit()


Fixed submission:
N = int(input())
for n in range(1, 3501):
    for w in range(n, 3501):

        try:
            t = (N*n*w) % (4*n*w - N*w - N*n)
        except:
            continue

        if t == 0 and 4*n*w - N*w - N*n>=0:
            print((N*n*w) // (4*n*w - N*w - N*n), n, w)
            exit()

Buggy python submission (verdict: Runtime Error):
N = int(input())
for n in range(1, 3501):
    for w in range(i, 3501):
        t = (N*n*w) % (4*n*w - N*w - N*w)
        if t == 0:
            print(t,n,w)
            exit()


Fixed submission:
N = int(input())
for n in range(1, 3501):
    for w in range(n, 3501):

        try:
            t = (N*n*w) % (4*n*w - N*w - N*n)
        except:
            continue

        if t == 0 and 4*n*w - N*w - N*n>=0:
            print((N*n*w) // (4*n*w - N*w - N*n), n, w)
            exit()

Buggy python submission (verdict: Runtime Error):
N = int(input())
for n in range(1, 3501):
    for w in range(i, 3501):
        t = N*n*w % (4*n*w - N*w - N*w)
        if t == 0:
            print(t, i, j)
            exit()


Fixed submission:
N = int(input())
for n in range(1, 3501):
    for w in range(n, 3501):

        try:
            t = (N*n*w) % (4*n*w - N*w - N*n)
        except:
            continue

        if t == 0 and 4*n*w - N*w - N*n>=0:
            print((N*n*w) // (4*n*w - N*w - N*n), n, w)
            exit()

Buggy python submission (verdict: Runtime Error):
N = int(input())
for i in range(1,3501):
  for j in range(i,3501):
    t = N*i*j % (4*i*j - N*i - j*N)
    if t==0:
      print(t,i,j)
      exit()


Fixed submission:
N = int(input())
for n in range(1, 3501):
    for w in range(n, 3501):

        try:
            t = (N*n*w) % (4*n*w - N*w - N*n)
        except:
            continue

        if t == 0 and 4*n*w - N*w - N*n>=0:
            print((N*n*w) // (4*n*w - N*w - N*n), n, w)
            exit()

Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(1,3501):
  for j in range(i,3501):
    t = N*i*j % (4*n*w - N*w - n*N)
    if t==0:
      print(t,i,j)
      exit()


Fixed submission:
N = int(input())
for n in range(1, 3501):
    for w in range(n, 3501):

        try:
            t = (N*n*w) % (4*n*w - N*w - N*n)
        except:
            continue

        if t == 0 and 4*n*w - N*w - N*n>=0:
            print((N*n*w) // (4*n*w - N*w - N*n), n, w)
            exit()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
for i in range(1,3501):
  for j in range(1,3501):
    if 3*i*j == n * (i+j):
      print(n,i,j)
      exit()

Fixed submission:
N = int(input())
for n in range(1, 3501):
    for w in range(n, 3501):

        try:
            t = (N*n*w) % (4*n*w - N*w - N*n)
        except:
            continue

        if t == 0 and 4*n*w - N*w - N*n>=0:
            print((N*n*w) // (4*n*w - N*w - N*n), n, w)
            exit()
Buggy python submission (verdict: Runtime Error):

def examD():
    def make_divisors(n):
        divisors = [1]
        for i in range(2, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)
        # divisors.sort()
        return divisors
    N = I()
    A = LI()
    C = set()
    D = set()
    ans = 0
    for a in A:
        if a in D:
            C.discard(a)
            continue
        D.add(a)
        C.add(a)

    for a in C:
        flag = 2
        cur = make_divisors(a)
        for c in cur:
            if c in D:
                flag -= 1
            if flag==0:
                break
        if flag>0:
            ans += 1
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examD()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""


Fixed submission:
def examA():
    X = LI()
    for i in range(len(X)):
        if X[i]==0:
            ans = i+1
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""