akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T)        vector<vector<T>>
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x)         {cout << #x << " = " << (x) << endl;}


struct Node { LL index, d; };


void solve(long long N, long long M, std::vector<long long> u, std::vector<long long> v, long long S, long long T){
    VVI G(N + 1);
    REP(i, SZ(u)) {
        G[u[i]].PB(v[i]);
    }
    VVI D(N + 1, VI(3, -1));

    queue<Node> q;
    q.push(Node{S, 0});   // 開始点が複数ある場合は全て追加
    LL count = 0;
    while (!q.empty() && count < 5 * M) {
        auto v = q.front(); q.pop();
        //$(v.index);
        //$(v.d);
        if (D[v.index][v.d % 3] < 0) {
            D[v.index][v.d % 3] = v.d;
            if (v.index == T && v.d % 3 == 0) {
                cout << v.d / 3 << endl;
                return;
            }
            EACH(w, G[v.index]) {
                q.push(Node{w, v.d + 1});
            }
        }
        count++;
    }
    cout << "-1" << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> u(M);
    std::vector<long long> v(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&u[i]);
        scanf("%lld",&v[i]);
    }
    long long S;
    scanf("%lld",&S);
    long long T;
    scanf("%lld",&T);
    solve(N, M, std::move(u), std::move(v), S, T);
    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
using namespace std;

int a, b;

int main()
{
  cin >> a >> b;

  int ans = -1;

  for (int i = 1; i < 10000; i++)
  {
    int tax1 = i * 0.08;
    int tax2 = i * 0.1;
    if (tax1 == a && tax2 == b)
    {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  vector<int> v(5);
  vector<int> remainder;
  for (int i = 0; i < 5; i++) {
    int value;
    cin >> value;
    int r = value % 10;
    int s = value / 10;
    if (r == 0) {
      v[i] = s * 10;
    } else {
      remainder.push_back(r);
      v[i] = (s + 1) * 10;
    }
  }
  int ans = 0;
  if (remainder.empty()) {
    for (int i = 0; i < 5; i++) {
      ans += v[i];
    }

    cout << ans << endl;
  } else {
    sort(remainder.begin(), remainder.end());
    for (int i = 0; i < 5; i++) {
      ans += v[i];
    }
    ans -= 10;
    ans += remainder[0];
    cout << ans << endl;
  }
};


Measured memory_bytes: 256
i1 = input()
i2 = int(i1.split(" ")[0])
i3 = int(i1.split(" ")[1])
i4 = 0
i5 = 0
i6 = 0
li = []
for i in range(i2):
  i4 = input().split(" ")
  i5 = (float(i4[1]) ** 2 + float(i4[0]) ** 2) ** 0.5
  if i3 >= abs(i5):
    i6 += 1
print(i6)

Measured memory_bytes: 9620
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
def run():
    H,W,K = map(int, sysread().split())
    S = []
    for i in range(H):
        S.append(list(accumulate(list(map(int, list(input()))), lambda x,y:x+y)))
    for h in range(1, H):
        for w in range(W):
            S[h][w] += S[h-1][w]

    ret = float('inf')

    for idxes_ in product((0,1), repeat=H-1):
        l = 0
        r = 1
        idxes = [0]
        for i, val in enumerate(idxes_, 1):
            if val == 1:
                idxes.append(i)
        idxes.append(H)
        min_cut = len(idxes) - 2
        while r <= W:
            for i in range(len(idxes)-1):
                if idxes[i] == 0 and l == 0:
                    cri = S[idxes[i+1]-1][r-1]
                elif l == 0:
                    cri = S[idxes[i+1]-1][r-1] - S[idxes[i]-1][r-1]
                elif idxes[i] == 0:
                    cri = S[idxes[i+1]-1][r-1] - S[idxes[i+1]-1][l-1]
                else:
                    cri = S[idxes[i+1]-1][r-1] - S[idxes[i]-1][r-1] - S[idxes[i+1]-1][l-1] + S[idxes[i]-1][l-1]

                if cri > K:
                    r -= 1
                    if l == r:
                        min_cut = float('inf')
                        r = W+1
                        break
                    l = r
                    min_cut += 1
                    break
            r += 1
        ret = min(ret, min_cut)

    print(ret)




if __name__ == "__main__":
    run()


Measured memory_bytes: 3444
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main() {
  int a,b;
  cin >> a >>b;
  if(a+b<10){
    cout << a+b << endl;
  }
  else{
    cout <<"error" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;

int main(int argc, char **argv)
{
	int MAX = 15;
	int n; cin >> n;
	vector<int> testi_num_vec(MAX);
	vector<vector<pint>> testi_vec;

	for (int i = 0; i < n; ++i)
	{
		cin >> testi_num_vec[i];
		vector<pint> v;
		int x, y;
		for (int k = 0; k < testi_num_vec[i]; ++k)
		{
			cin >> x >> y;
			v.push_back(pint(x, y));
		}
		testi_vec.push_back(v);
	}

	// bit full search
	int ans{INT_MIN};
	for (int bit = 0; bit < (1 << n); ++bit) // bit show honest
	{
		// std::cout << "bit : "<< bitset<10>(bit) << std::endl;
		
		int sum_honest{0};
		bool flag{true}; // contradiction

		for (int i = 0; i < n; ++i)
		{
			if (bit & (1 << i)) // honest
			{
				vector<pint> said = testi_vec[i];
				
				for (auto &e : said)
				{
					int human = e.first;
					int is_honest = e.second;

					if ((bit & (1 << (human-1))) && is_honest == 0)
					{
						flag = false;
						goto exit_bit;
					}
					if (!(bit & (1 << (human-1))) && is_honest == 1)
					{
						flag = false;
						goto exit_bit;
					}
				}
				++sum_honest;
			}
		}

	exit_bit:
		if (flag)
		{
			ans = max(ans, sum_honest);
		}
	}

	std::cout << ans << std::endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n = int(input())
S = list(input())
#print(len(S))
count = 0
count_total = 0
for moji in S:
    if moji == 'A':
        count = 'A'
    elif count == 'A' and moji == 'B':
        count = 'B'
    elif count == 'B' and moji == 'C':
        count = 0
        count_total += 1
    else:
        count = 0
    #print(moji, count, count_total)
print(count_total)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n;
    while(cin >> n && n){
        int mini = 1 << 29;
        int maxi = -1;
        int sum = 0;
        int tmp;
        for(int i=0;i<n;i++){
            cin >> tmp;
            mini = min(mini, tmp);
            maxi = max(maxi, tmp);
            sum += tmp;
        }
        cout << (sum - mini - maxi) / (n - 2) << endl;
    }
}

Measured memory_bytes: 0
def gcd1(a, b):
    def calc(a, b, first, second):
        if a < b:
            a, b = b, a
        r = a % b
        q = -(a - r)//b
        if r == 0:
            return b, second
        # first += q * second
        first = [x + q * y for (x, y) in zip(first, second)]
        return calc(r, b, second, first)
    first = [1, 0]
    second = [0, 1]
    return calc(a, b, first, second)

def mod_inv(n, mod):
    table = gcd1(n, mod)
    inv = table[1][1]
    if inv < 0:
        inv += mod
    return inv

def cmb(n, r, mod):
    ans = 1
    for i in range(r):
        ans = (ans * n) % mod
        n -= 1
    ans1 = 1
    for i in range(1, r + 1):
        ans1 = (ans1 * i) % mod
    return ans * mod_inv(ans1, mod)

def main():
    m = 10**9 + 7
    X, Y = map(int, input().split())
    XY = X + Y
    min_xy = XY // 3
    max_xy = XY - min_xy
    if XY % 3 != 0:
        print(0)
        return
    if X < min_xy or X > max_xy or Y < min_xy or Y > max_xy:
        print(0)
        return
    index_x = X - min_xy
    index_y = Y - min_xy
    # print(index_x, index_y)
    ans = cmb(min_xy, index_x, m)
    print(ans % m)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3188
n = int(input())

if n % 2 == 0:
    g = [[i + 1, n - i] for i in range(n // 2)]
else:
    g = [[i + 1, n - 1 - i] for i in range(n // 2)]
    g.append([n])

out = []
l = len(g)
for i in range(l):
    for j in range(i+1, l):
        out.extend((gi, gj) for gi in g[i] for gj in g[j])
print(len(out))
for o in out:
    print(o[0], o[1])


Measured memory_bytes: 3956
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
vector<ll> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        a.push_back(temp);
    }
    multiset<ll> st;
    for(int i=0;i<n;i++){
        //cout << st.size() << "\n";
        if(st.empty()){
            st.insert(a[i]);
        }
        else{
        auto itr=st.lower_bound(a[i]);
        if(itr!=st.begin()){
            itr--;
            st.erase(itr);
        }
        st.insert(a[i]);
        }
    }
    cout << st.size() << "\n";
}

Measured memory_bytes: 5748
n = int(input())
l = [int(x) for x in input().split()]
l.append(100000)
#print(n, l, len(l))
z = []
z.append(l[0])
for i in range(len(l)-1):
    #print(i)
    z.append(min(l[i],l[i+1]))
print(sum(z))



Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    string s;
    cin>>s;
    int found = 0;
    rep(i,0,s.length())
    {
        if ( i%2 == 0 )
        {
            if ( s[i] == 'L' )
            {
                found = 1;
                break;
            }
        }
        else
        {
            if ( s[i] == 'R' )
            {
                found = 1;
                break;
            }
        }
    }   

    if ( found == 1 )
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    } 
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
N = int(input())
C = []

flg = False
for _ in range(N):
    a = int(input())
    comment = [[int(_) for _ in input().split()] for i in range(a)]
    if a:
        flg=True
    C.append(comment)
if not flg :
    print(N)
    exit()


def bit_tbl2(length):
    _format = "{:0" + str(length) + "b}"
    for i in range(int('1' * length, 2) + 1):
        yield _format.format(i)


ans = 0
for b in bit_tbl2(N):
    # print(b)
    syo = [-1] * (N + 1)
    flg = False

    for i in range(N):
        if b[i] == '1':
            syo[i+1] = 1

    for i in range(N):
        if b[i] != '1': continue

        for x, y in C[i]:
            if y == 1 and syo[x] != 1:
                flg = True
                break
            if syo[x] != -1 and y != syo[x]:
                flg = True
                break
            syo[x] = y

        if flg: break

    if not flg:

        v = 0
        for x in syo:
            if x == 1: v += 1
        # print(v)

        ans = max(ans, v)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

int main()
{
    int a[3];
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
    }
    sort(a, a + 3);
    cout << a[0] + a[1] << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
answer = 1
for i in range(N):
    if A[i] % 2 == 0:
        if A[i]%3 == 0 or A[i]%5 == 0:
            answer = 1
        else:
            answer = -1
            break
if answer == 1:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int n,m;

bool check(const vector<string>&a, const vector<string>&b, int i, int j){
    if(i+m-1 > n || j+m-1 > n){
	return false;
    }else{
	bool flag = true;
	for(int b_i = 0; b_i < m && flag; b_i++){
	    for(int b_j = 0; b_j < m&& flag; b_j++){
		if(a[i+b_i][j+b_j] == b[b_i][b_j])  flag = true;
		else				    flag = false;
	    }
	}
	return flag;
    }
}

int main(){
    cin >> n >> m;
    vector<string>a(n);
    vector<string>b(m);
    rep(i, n)	cin >> a[i];
    rep(i, m)	cin >> b[i];
    //solve
    bool flag = false;
    for(int i = 0; i < n && !flag; i++){
	for(int j = 0; j < n && !flag; j++){
	    flag = check(a, b, i, j);
	}
    }
    if(flag){
	cout << "Yes" << endl;
    }else{
	cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
int second;
int time;
int minute;

//printf("?§?=");
scanf("%d",&second);

time=second/3600;
minute=(second-time*3600)/60;
second=second % 60	;

printf("%d:%d:%d\n",time,minute,second);

return 0;
}

Measured memory_bytes: 592
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n,x,t = m()



print(-(-n//x) * t)

Measured memory_bytes: 65148
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

struct node_t {
	int32_t idx;
	int32_t x, y;
};

struct load_t {
	int32_t n1, n2;
	int32_t cost;
};

int cmp_x(const void* x, const void* y) {
	struct node_t a = *(struct node_t*)x, b = *(struct node_t*)y;
	return a.x < b.x ? -1 : a.x > b.x;
}

int cmp_y(const void* x, const void* y) {
	struct node_t a = *(struct node_t*)x, b = *(struct node_t*)y;
	return a.y < b.y ? -1 : a.y > b.y;
}

int cmp_cost(const void* x, const void* y) {
	struct load_t a = *(struct load_t*)x, b = *(struct load_t*)y;
	return a.cost < b.cost ? -1 : a.cost > b.cost;
}

int32_t N;
struct node_t xy[114514];

struct load_t candidates[271828];

int32_t uf_parent[114514];

void uf_init(void) {
	int32_t i;
	for (i = 0; i < N; i++) uf_parent[i] = i;
}

int32_t uf_root(int32_t node) {
	if (uf_parent[node] == node) return node;
	return uf_parent[node] = uf_root(uf_parent[node]);
}

int uf_issame(int32_t a, int32_t b) {
	return uf_root(a) == uf_root(b);
}

void uf_merge(int32_t a, int32_t b) {
	int32_t a_root = uf_root(a), b_root = uf_root(b);
	if (a_root != b_root) uf_parent[a_root] = b_root;
}

int main(void) {
	int32_t i;
	int64_t answer = 0;
	if (scanf("%" SCNd32, &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNd32 "%" SCNd32, &xy[i].x, &xy[i].y) != 2) return 1;
		xy[i].idx = i;
	}
	qsort(xy, N, sizeof(*xy), cmp_x);
	for (i = 0; i < N - 1; i++) {
		candidates[i].n1 = xy[i].idx;
		candidates[i].n2 = xy[i + 1].idx;
		candidates[i].cost = xy[i + 1].x - xy[i].x;
	}
	qsort(xy, N, sizeof(*xy), cmp_y);
	for (i = 0; i < N - 1; i++) {
		candidates[i + (N - 1)].n1 = xy[i].idx;
		candidates[i + (N - 1)].n2 = xy[i + 1].idx;
		candidates[i + (N - 1)].cost = xy[i + 1].y - xy[i].y;
	}
	qsort(candidates, (N - 1) * 2, sizeof(*candidates),cmp_cost);
	uf_init();
	for (i = 0; i < (N - 1) * 2; i++) {
		if (!uf_issame(candidates[i].n1, candidates[i].n2)) {
			uf_merge(candidates[i].n1, candidates[i].n2);
			answer += candidates[i].cost;
		}
	}
	printf("%" PRId64 "\n", answer);
	return 0;
}

/*
x, yそれぞれについて、隣り合わないところに道を作るくらいなら隣り合うところを繋げた方が良い
minの判定をしなくても、どうせ安い(高くない)ほうが使われるはず
*/


Measured memory_bytes: 8424
/*
	B - Traveling AtCoDeer Problem
*/
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;

double EPS = 1e-10;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define int(x) int x; cin >> x;
#define lint(x) long long x; cin >> x;
#define vint(v,n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vlint(v,n) vector<lint> v(n); REP(i,n) cin >> v[i];
#define double(x) double x; cin >> x[i];
#define vdouble(v,n) vector<double> v(n); REP(i,n) cin >> v[i];
#define string(x) string x; cin >> x;

int main()
{
	int(N);
	vector<int> a(N);
	REP(i, N)
	{
		cin >> a[i];
	}

	sort(a.begin(), a.end());

	cout << a[N - 1] - a[0] << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {

            String str = scanner.nextLine();
            int res = 0;
            int count = 0;
            for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) == 'R') {
                    count++;
                } else {
                    count = 0;
                }
                res = Math.max(res, count);
            }
            System.out.println(res);
        }
    }

}


Measured memory_bytes: 26952
#include <cstdio>
#include <iostream>

using namespace std;

int arr[100005];

int main()
{
	int N, K, Q;
	cin >> N >> K >> Q;
	int x;
	for (int i = 0; i < Q; i++) {
		cin >> x;
		arr[x] += 1;
	}
	for (int i = 1; i <= N; i++) {
		if (K - (Q - arr[i]) > 0)cout << "Yes"<<'\n';
		else
			cout << "No" << '\n';
	}
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

ll lcm(ll a,ll b){
	return a * b / gcd(a,b);
}





signed main(){
	ll n,memo1 = 0,memo2 = 0;

	cin >> n;
	ll a[n];

	rep(i,0,n) cin >> a[i];

	memo1 = a[0];
	memo2 = a[0];

	rep(i,1,n){
		if(memo1 <= a[i]){
			memo1 = a[i];
			memo2 = a[i];
		}
		else memo2 = a[i];

		if(memo1 - memo2 >= 2){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
if n>2:
    for i in range(2,n):
        dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])
print(dp[n-1])

Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  ll n,ans=0;
  cin>>n;
  vector<ll>a(n);
  vector<ll>in(n);
  map<ll,ll>rep;
  for(int i=0;i<n;i++){
    cin>>in[i];
    a[i]=i+in[i];
  }
  for(int i=0;i<n;i++){
    ans+=rep[i-in[i]];
    rep[a[i]]++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 28968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	vector<pair<ll, ll>> point(N);

	int md;
	for(int i(0);i<N;++i){
		cin >> point[i].first >> point[i].second;
		if(i == 0) md = (abs(point[i].first) + abs(point[i].second)) % 2;
		if(md != (abs(point[i].first) + abs(point[i].second)) % 2){
			cout << -1 << endl;
			return 0;
		}
	}
	vector<ll> d;
	for(int i(32);i>=0;--i) d.push_back(pow(2,i));
	if(md == 0) d.push_back(1);
	
	cout << d.size() << endl;
	for(int i(0);i<(d.size()-1);++i){
		cout << d[i] << ' ';
	}
	cout << d[d.size()-1] << endl;

	for(int i(0);i<N;++i){
		ll x_sum(0), y_sum(0);
		for(int j(0);j<d.size();++j){
			ll u = point[i].first + point[i].second;
			ll v = point[i].first - point[i].second;
			if(x_sum <= u && y_sum <= v){
				x_sum += d[j]; y_sum += d[j]; cout << 'R'; 
			}else if(x_sum <= u && y_sum > v){
				x_sum += d[j]; y_sum -= d[j]; cout << 'U'; 
			}else if(x_sum > u && y_sum <= v){
				x_sum -= d[j]; y_sum += d[j]; cout << 'D'; 
			}else{
				x_sum -= d[j]; y_sum -= d[j]; cout << 'L'; 
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main(void){
  string s, t;
  cin >> s >> t;

  for(int i = 0; i < int(s.length()); i ++){
    if(s == t){
      cout << "Yes" << endl;
      return 0;
    }
    else{
      char temp = s.at(s.length() - 1);
      s.pop_back();
      s = temp + s;
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(0, 0); }
	V<V<pin>> qab(2);
	int sz = ab.size();
	qab[0].reserve(sz);
	qab[1].reserve(sz);
	for (pin& x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	int c = 0;
	for (pin& x : qab[0]) {
		int qc = (2 * x.first + x.second) % 3;
		c ^= (qc + 1);
	}
	if (!c) {
		pin ans = solve(qab[1], ex - 1);
		ans.first *= 2; ans.second *= 2; ans.second++;
		return ans;
	}
	pin ans = solve(qab[0], ex - 1);
	c = 0;
	int d = 0;
	for (pin& x : qab[1]) {
		int w = ans.second - x.second - 1;
		if ((w & x.first) == w) { c ^= 1; }
      	w++;
      	if ((w & x.first) == w) { d ^= 1; }
	}
  	ans.first *= 2; ans.second *= 2;
	if (!c&&!d) {
		return ans;
	}
	ans.first++; ans.second -= c;
	return ans;
}
signed main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long inf = 1e17;
	int n; cin >> n;
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 59);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}

Measured memory_bytes: 7552
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    tmp1 = input[1].split(" ")
    tmp2 = input[2].split(" ")
    N = Number(tmp0[0])
    A = []
    B = []

    for(var i=0; i<=N; i++)
    {
      A.push(Number(tmp1[i]))
      if(i !== N){
        B.push(Number(tmp2[i]))
      }
    }

    var ans=0
    for(var i=0; i < N; i++)
    {
      // B[i]->A[i]
      var knock_down=Math.min(A[i], B[i])
      A[i] -= knock_down
      B[i] -= knock_down
      ans+= knock_down

      // B[i]->A[i+1]
      var knock_down2 = Math.min(A[i+1], B[i])
      A[i+1] -= knock_down2
      B[i] -= knock_down2
      ans += knock_down2
    }
    console.log(ans)

}
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("2\n3 5 2\n4 5\n");

Measured memory_bytes: 32484
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
from math import ceil
a = ceil(N/A)
F = [A,B,C,D,E]
for i in range(1,5):
    if F[i-1] <= F[i]:
        a += 1
    else:
        b = ceil(N/F[i])
        a = max(a+1,b+i)
print(a)

Measured memory_bytes: 9196
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	d = Dict{String,Int}()
	ct = 0
	for i in 1:n
		s,t = readline() |> chomp |> split
		ct += parseInt(t)
		d[s]=ct
	end
	x = readline() |> chomp
	println(ct-d[x])
end

main()

Measured memory_bytes: 111756
#include <iostream>
#include <cstring>
//#include <fstream>

using namespace std;

int total[10];

int main()
{
//	cut here before submit 
//	freopen ("testcase.iceshop", "r", stdin );
	string str = "";
	int n;

	while (cin >> n && n ){
		memset (total, 0, sizeof (total ) );

		int i,j;
		for (i = 0; i < n; ++i ){
			int ice;
			cin >> ice;
			++total[ice];
		} // end for

		for (i = 0; i < 10; ++i ){
			if (total[i] == 0 ){		
				cout << '-' << endl;
			}else{
				for (j = 0; j < total[i]; ++j ){
					cout << '*';
				} // end for
				cout << endl;
			} // end if
		} // end for
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const int sz=1e3+100;
 
int main()
{
    Khela
    llu a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n)
    {
        llu p=((n+1ll)*n)/2;
        p-=n;
        cout<<p<<endl;
    }
 
 
 
 
 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
#include <set>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

ll llmin(ll x, ll y){
	if (x > y) return y;
	return x;
}


int main(){
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (a + b >= k){
		cout << llmin(a, k) << endl;
	}else{
		cout << a - (k - a - b) << endl;
	}
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N , X , i ;
  cin >> N ;
  i = 0 ;
    while (i < N * 1.08){
      i++ ;
      X= i * 1.08 ;
      if (X == N ){
       cout << i << endl;
        break ;
      }
    }
  if (!(X == N))
      cout << ":(" << endl;
  }

Measured memory_bytes: 256
from math import sqrt, ceil, floor

def factorize(x):
    result = []
    for p in range(2, floor(sqrt(x))):
        exp = 0
        while x % p == 0:
            exp += 1
            x = x // p
        if exp > 0:
            result.append((p, exp))
    if x > 1:
        result.append((x, 1))
    return result

N = int(input())
factors = factorize(N)
ans = sum([floor((sqrt(exp * 8 + 1) - 1) / 2) for p, exp in factors])
print(ans)


Measured memory_bytes: 9208
package main

import (
	"fmt"
	"math"
)

type X struct {
	values []int
}

func main() {
	var n, d int
	fmt.Scan(&n)
	fmt.Scan(&d)

	aryX := make([]X, n)
	for i := 0; i < n; i++ {
		for j := 0; j < d; j++ {
			var tmp int
			fmt.Scan(&tmp)
			aryX[i].values = append(aryX[i].values, tmp)
		}
	}

	count := 0
	for k := 0; k < n; k++ {
		for l := k + 1; l < n; l++ {
			calc := 0
			for o := 0; o < d; o++ {
				calc += (aryX[k].values[o] - aryX[l].values[o]) * (aryX[k].values[o] - aryX[l].values[o])
			}
			//fmt.Println(math.Sqrt(float64(calc)))
			//fmt.Println(math.Trunc(math.Sqrt(float64(calc))))
			if math.Trunc(math.Sqrt(float64(calc))) == math.Sqrt(float64(calc)) {
				count++
			}

		}
	}
	fmt.Println(count)

}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <cstdlib>  // abs() for integer
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;

int main (){
    long int N,K,Q;
    cin >>N >> K >> Q;
    //cout<<K-Q<<endl;
    vector<long int> A(Q);
    vector<long int> P(N);
    for(int i=0;i<Q;i++){
        cin >> A[i];
    }
    
    for (int i=0;i<Q;i++){
        P[A[i]-1]++;}
    
    for (int i=0;i<N;i++){
        if (P[i]-Q+K>0) cout<<"Yes"<<endl;
        else cout<< "No"<<endl;
    }
    
    
}

Measured memory_bytes: 2176
# _*_ coding:utf-8 _*_
#  Atcoder_Beginner_Contest074-C
#  TODO https://atcoder.jp/contests/abc074/tasks/arc083_a

def solveProblem(WaterOne100,WaterTwo100,SugarOne,SugarTwo,meltMax,maxSugarWater):
	maxBreakDown = meltMax / (meltMax + 100)
	WaterOneCup = WaterOne100 * 100
	WaterTwoCup = WaterTwo100 * 100
	WaterPossibleList=[]
	for oneCup in range(0,maxSugarWater+1,+WaterOneCup):
		for twoCup in range(0,maxSugarWater-oneCup+1,+WaterTwoCup):
				WaterPossibleList.append(oneCup+twoCup)

	SugarPossibleList = []
	for oneSugarCup in range(0,maxSugarWater+1,+SugarOne):
		for twoSugarCup in range(0,maxSugarWater+1-oneSugarCup,+SugarTwo):
				SugarPossibleList.append(oneSugarCup+twoSugarCup)

	returnSugarWater = -1
	returnSugar = -1
	limitedMaxDensity = -1
	for water in WaterPossibleList:
		for sugar in SugarPossibleList:
			if (0 < water+sugar) and (water+sugar<=maxSugarWater) and ((sugar/(sugar+water)) <= maxBreakDown):
				if limitedMaxDensity <= sugar/(sugar+water):
					limitedMaxDensity = sugar/(sugar+water)
					returnSugarWater = water+sugar
					returnSugar = sugar

	answer = returnSugarWater,returnSugar
	return answer

if __name__ == '__main__':
	A,B,C,D,E,F = map(int,input().strip().split(' '))
	solWater,solSuger = solveProblem(A,B,C,D,E,F)
	print("{} {}".format(solWater,solSuger))


Measured memory_bytes: 12440
n=int(input())
a=list(map(int,input().split()))
ans=1
temp=0
for i in range(1,n):
  if a[i-1]<a[i] and temp==0:
    temp=1
  elif a[i-1]>a[i] and temp==0:
    temp=2
  elif a[i-1]>a[i] and temp==1:
    temp=0
    ans=ans+1
  elif a[i-1]<a[i] and temp==2:
    temp=0
    ans=ans+1
print(ans)

Measured memory_bytes: 14228
#include<stdio.h>

int main()
{
				int in[1000];
				int num;
				int i=0;

				scanf("%d",&num);
				while(i++<num){
								scanf("%d",&in[i]);
				}

				for(;num>1;num--){
								printf("%d ",in[num]);
				}

				printf("%d",in[num]);
				printf("\n");


				return 0;

}


Measured memory_bytes: 2100
h,w = map(int, input().split())
sl = []
for _ in range(h):
    row = list(input())
    sl.append(row)


dp = [ [10000]*w for _ in range(h) ]
dp[0][0] = 0

for h_i in range(h):
    for w_i in range(w):
        if h_i+1 < h:
            if sl[h_i][w_i] == '.' and sl[h_i+1][w_i] == '#':
                dp[h_i+1][w_i] = min( dp[h_i+1][w_i], dp[h_i][w_i]+1 )
            else:
                dp[h_i+1][w_i] = min( dp[h_i+1][w_i], dp[h_i][w_i] )

        if w_i+1 < w:
            if sl[h_i][w_i] == '.' and sl[h_i][w_i+1] == '#':
                dp[h_i][w_i+1] = min( dp[h_i][w_i+1], dp[h_i][w_i]+1 )
            else:
                dp[h_i][w_i+1] = min( dp[h_i][w_i+1], dp[h_i][w_i] )


ans = dp[h-1][w-1]
if sl[0][0] == '#': ans += 1
print(ans)


Measured memory_bytes: 74604
from itertools import accumulate


def binary(N,T):  # 二分探索 # N:探索要素数
    l, r = -1, N+1
    while r - l > 1:
        if T < b[(l + r) // 2]:  # 条件式を代入
            r = (l + r) // 2
        else:
            l = (l + r) // 2
    return r-1


n, m, k = map(int, input().split())
a = [0]+list(accumulate(map(int, input().split())))
b = [0]+list(accumulate(map(int, input().split())))

ans = 0
for i, ai in enumerate(a):
    t = k - ai
    if t >= 0:
        j = binary(m, t)
        ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 45836
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H,W;
  cin >> H >> W;
  vector<string> A(100);
  for(int i=0;i<W+2;i++) cout << '#';
  cout << endl;
  for(int i=0;i<H;i++){
    cin >> A[i];
    cout << '#' << A[i] << '#' << endl;
  }
  for(int i=0;i<W+2;i++) cout << '#';
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ull i=a;i<b;i++)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define trace(s,a) cout<<s<<a,nl

int main(){
	

    ll n;
    cin>>n;

    pair<ll, ll> a[n];
    ll u, v;
    for(ll i=0; i<n; i++){
    	cin>>u>>v;
    	a[i] = mkp(v, u);
    }

    sort(a, a+n);

    ll flag = 1;
    ll sum = 0;
    for(ll i=0; i<n; i++){
    	sum += a[i].second;
    	if(sum > a[i].first){
    		flag = 0;
    		break;
    	}
    }

    if(flag == 0)
    	cout<<"No"<<endl;
    else
    	cout<<"Yes"<<endl;

}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch XYZTriplets | diff XYZTriplets.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address XYZTriplets.cpp && ./a.out

/*

 7/11/2020

 5:04-5:13

 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N;

void solve() {
  VI res(N+1);
  for(int x=1; x*x<=N; ++x) {
    for(int y=1; y*y+x*x+x*y<=N; ++y) {
      for(int z=1; x*x+y*y+z*z+x*y+y*z+z*x<=N; ++z) {
        res[x*x+y*y+z*z+x*y+y*z+z*x]+=1;
      }
    }
  }
  FORE(i,1,N) cout<<res[i]<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N;
  REP(i,N) cin>>A[i];
  solve();

  return 0;
}


Measured memory_bytes: 3640
// ░░░░░░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░░░░░
// ░░░░░░█░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░█░░░░░
// ░░░░░░█░█░▀░░░░░▀░░▀░░░░█░█░░░░░
// ░░░░░░█░█░░░░░░░░▄▀▀▄░▀░█░█▄▀▀▄░
// █▀▀█▄░█░█░░▀░░░░░█░░░▀▄▄█▄▀░░░█░
// ▀▄▄░▀██░█▄░▀░░░▄▄▀░░░░░░░░░░░░▀▄
// ░░▀█▄▄█░█░░░░▄░░█░░░▄█░░░▄░▄█░░█
// ░░░░░▀█░▀▄▀░░░░░█░██░▄░░▄░░▄░███
// ░░░░░▄█▄░░▀▀▀▀▀▀▀▀▄░░▀▀▀▀▀▀▀░▄▀░
// ░░░░█░░▄█▀█▀▀█▀▀▀▀▀▀█▀▀█▀█▀▀█░░░
// ░░░░▀▀▀▀░░▀▀▀░░░░░░░░▀▀▀░░▀▀░░░░
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main(int argc, char const *argv[])
{
	ll n;cin >> n;
	ll b[n-1],a[n];
	for (int i = 0; i < n-1; ++i)
	{
		cin >> b[i];
	}
	a[0]=a[1]=b[0];
	for (int i = 1; i < n-1; ++i)
	{
		if(a[i]>b[i])a[i]=b[i];
		a[i+1]=b[i];
	}
	ll ans =0;
	for (int i = 0; i < n; ++i)
	{
		ans+=a[i];
	}cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		for (int i = 0; i < K; i++) {
			if (A + i <= B) {
				System.out.println(A + i);
			}
		}
		for (int j = K - 1; j >= 0; j--) {
			if (B - j > A + K - 1) {
				System.out.println(B - j);
			}
		}
	}
}

Measured memory_bytes: 23764
import sys
A, B, C, X, Y = map(int, sys.stdin.readline().split(" "))
ans = float("inf")
 
for i in range(max(X, Y) * 2 + 1):
    j = X - i // 2
    if j < 0:
        j = 0
    k = Y - i // 2
    if k < 0:
        k = 0
    ans = min(ans, C * i + A * j + B * k)
print(ans)

Measured memory_bytes: 3064
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        q = input()
        for i in range(q):
            n = input()
            tmp = n
            ans = 0
            while tmp >= 10:
                max_val = -1
                s = str(tmp)
                for j in range(len(s)-1):
                    left = int(s[:j+1])
                    right = int(s[j+1:])
                    max_val = max(max_val, left * right)
                tmp = max_val
                ans += 1
            print ans
                    
        
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 4676
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
A = [inp() for i in range(n)]
rem = 0
res = 0
for i,a in enumerate(A):
    res += (a+rem)//2
    if a != 0:
        rem = (a+rem)%2
    else:
        rem = 0
print(res)

Measured memory_bytes: 9428
#include <bits/stdc++.h>

using namespace std;

               
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef LOCAL
	assert(freopen("input.txt", "r", stdin));
	#endif

	int n;
	cin >> n;
	vector<pair<int, int>> pairs;
	vector<int> a;
	for (int i = 1; i <= n; i++) {
		a.push_back(i);
	}
	if (n & 1) {
		a.insert(a.begin(), 0);
	}
	while (!a.empty()) {
		pairs.push_back({a[0], a[(int)a.size() - 1]});
		a.erase(a.begin());
		a.pop_back();
	}
	vector<pair<int, int>> ans;
	for (int i = 0; i < (int)pairs.size(); i++) {
		for (int j = i + 1; j < (int)pairs.size(); j++) {
			ans.push_back({pairs[i].first, pairs[j].first});
			ans.push_back({pairs[i].second, pairs[j].second});
			ans.push_back({pairs[i].first, pairs[j].second});
			ans.push_back({pairs[i].second, pairs[j].first});
		}
	}
	for (auto &t : ans) {
		if (t.first > t.second) {
			swap(t.first, t.second);
		}
	}
	sort(ans.begin(), ans.end());
	vector<pair<int, int>> rans;
	for (auto t : ans) {
		if (t.first != 0 && t.second != 0) {
			rans.push_back(t);
		}
	}
	cout << rans.size() << endl;
	for (auto t : rans) {
		cout << t.first << ' ' << t.second << endl;
	}
}



Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=2e5+10;
typedef long long ll;
int main(){
	ll k,n,mx=0,a[maxn];
	cin>>k>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) mx = max(mx,(i+1>=n ? a[0]+k : a[i+1])-a[i]);
	cout<<k-mx<<endl;
}

Measured memory_bytes: 1792
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
GC027 C
"""

n,m = map(int,input().split())
s = bytearray(input(),'utf-8')
ali = [0 for i in range(n)]
bli = [0 for i in range(n)]
from collections import defaultdict
graphAB = defaultdict(list)

for i in range(m):
    u,v=map(int,input().split())
    graphAB[u].append(v)
    graphAB[v].append(u)



def incrementAB(node,adj):
    if s[adj-1] == 65:
        ali[node-1]+=1
    if s[adj-1] == 66:
        bli[node-1]+=1

def decrementAB(node,adj):
    if s[adj-1] == 65:
        ali[node-1]-=1
    if s[adj-1] == 66:
        bli[node-1]-=1


def adjAB(node):
    if ali[node-1] and bli[node-1]:
        return(True)
    else:
        return(False)

graphvers = set(graphAB.keys())
visitset = set()
for i in range(1,n+1):
    if not i in graphvers:
        s[i-1] = 67
    else:
        for j in graphAB[i]:
            incrementAB(i,j)
        if not adjAB(i):
            visitset.add(i)

while bool(visitset):
    #print(graphAB)
    #print(graphABopp)
    #print(abli)
    i = visitset.pop()
    for j in filter(lambda x: s[x-1]!=67,graphAB[i]):
        decrementAB(j,i)
        if not adjAB(j):
            visitset.add(j)
    s[i-1] = 67

#print(graphAB)
#print(graphABopp)

sset= set(s)
sset.add(67)
sset.remove(67)
if bool(sset):
    print('Yes')
else:
    print('No')





Measured memory_bytes: 56860
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{
    public static void main(String[] args) throws IOException
    {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s;
		
		while((s = br.readLine())!=null && !s.isEmpty())
		{
			int m = Integer.parseInt(s.split(" ")[0]);
			int d = Integer.parseInt(s.split(" ")[1]);
			
			if(m==0&&d==0) break;
			else 			System.out.println(calc_days(m, d));
		}
	}
		
	private static String calc_days(int month, int day)
	{
		String[] days = {"Thursday", "Friday" ,"Saturday", "Sunday","Monday", "Tuesday", "Wednesday"};
		// days of a month
		int[] days_m = {31,29,31,30,31,30,31,31,30,31,30,31};
		
		//calculate days from Jan 1st, Thursday.
		int m = 0, count=0;
		while((m+1)!=month)
		{
			count += days_m[m];
			m++;
		}
		count += (day - 1);
		return days[count%7];
	}	
}
	

Measured memory_bytes: 9352
#include <iostream>
#include <vector>
#include <cstring>

#define MAX_V 10404
#define INF (int)1e9
#define NMAX 102

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

int V;
std::vector<P> v;

struct edge{int to,cap,rev;};
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
	G[from].push_back((edge){to,cap,(int)G[to].size()});
	G[to].push_back((edge){from,0,(int)G[from].size()-1});
}

int dfs(int v, int t,int f){
	if(v == t) return f;
	used[v] = true;
	for (int i = 0; i < G[v].size(); ++i)
	{
		edge &e = G[v][i];
		if(!used[e.to] && e.cap > 0){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t){
	int flow = 0;
	for(;;){
		memset(used,0,sizeof(used));
		int f = dfs(s,t,INF);
		if(f == 0) return flow;
		flow += f;
	}
}
int main(){
	cin >> V;
	for (int i = 0; i < V; ++i)
	{
		int a,b;
		cin >> a >> b;
		v.push_back(P(a,b));
		add_edge(0,i+1,1);
	}
	for (int i = 0; i < V; ++i)
	{
		int a,b;
		cin >> a >> b;
		for (int j = 0; j < V; ++j)
		{
			if(v[j].first < a && v[j].second < b){
				add_edge(j+1,V+i+1,1);
				// cout << j+1 << "," << V+i+1 << endl;
			}
		}
		add_edge(V+i+1,V*2+1,1);
	}
	int ans = max_flow(0,V*2+1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n,k = readInt()
    ans = n % k
    ans = min(ans,abs(ans-k))
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9032