akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

vector<string> str(3);

// str[i].substr(k) と str[j] の matching (i != j)
vector<vector<vector<bool>>> vmatch(3, vector<vector<bool>>(3, vector<bool>(4010, true)));

bool match(char c, char d)
{
    if (c == '?' || d == '?')
    {
        return true;
    }
    return c == d;
}

int main()
{
    rep(i, 3)
    {
        cin >> str[i];
    }

    // vmatch つくる
    rep(i, 3)
    {
        rep(j, 3)
        {
            if (i == j)
            {
                continue;
            }
            int ilen = str.at(i).length();
            int jlen = str.at(j).length();
            rep(k, ilen)
            {
                bool res = true;
                rep(l, min(ilen - k, jlen))
                {
                    res = res && match(str.at(i).at(k + l), str.at(j).at(l));
                }
                vmatch[i][j][k] = res;
            }
        }
    }

    int res = 100000;
    rep(a, 3)
    {
        rep(b, 3)
        {
            rep(c, 3)
            {
                if (a == b || a == c || b == c)
                {
                    continue;
                }
                int alen = str.at(a).length();
                int blen = str.at(b).length();
                int clen = str.at(c).length();
                rep(k, alen + 1)
                {
                    if (!vmatch.at(a).at(b).at(k))
                    {
                        continue;
                    }
                    
                    rep(l, max(blen, alen - k) + 1)
                    {
                        if (!(vmatch.at(b).at(c).at(l) && vmatch.at(a).at(c).at(k + l)))
                        {
                            continue;
                        }
                        int newres = max({alen, k + blen, k + l + clen});
                        res = min(res, newres);
                    }
                }
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3180
N = int(input())
Junban_L = list(map(int, input().split()))
point_L = list(map(int, input().split()))
katen_point_L = list(map(int, input().split()))

ans=0
prenum = None
for num in Junban_L:
    ans = ans + point_L[num-1]
    if prenum == num-1:
        ans = ans + katen_point_L[prenum-1]
    prenum = num

print(ans)

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

int main() {
  long long n, k;
  cin >> n >> k;
  long long res;
  if (n > k) {
    res = n % k;
  } else {
    res = n;
  }
  res = res > k - res ? k - res : res;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
inline int lowbit(int x){return(x&(-x));}
int main()
{
	scanf("%d",&n);
	if (n<=2)
	{
		printf("No\n");
		return 0;
	}
	int x=(n>>2);
	if ((x==0 || x-lowbit(x)==0) && n%4==0)
	{
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	printf("1 2\n2 3\n3 %d\n%d %d\n%d %d\n",n+1,n+1,n+2,n+2,n+3);
	for (int i=1;i<(n+1)/4;i++)
	{
		int a,b,c,d;
		a=i*4,b=a+1,c=a+2,d=a+3;
		printf("%d %d\n",2,b);
		printf("%d %d\n",a,d);
		printf("%d %d\n",d,3);
		printf("%d %d\n",3,a+n);
		printf("%d %d\n",a+n,d+n);
		printf("%d %d\n",c+n,a+n);
		printf("%d %d\n",b+n,a+n);
		printf("%d %d\n",c,n+1);
	}
	if (n%4==0)
	{
		int a,b;
		a=((x-lowbit(x))<<2);
		b=(lowbit(x)<<2);
		b|=1;
		printf("%d %d\n",a+n,n);
		printf("%d %d\n",n+n,b);
	}
	if (n%4==1)
	{
		int a=n-1,b=n;
		printf("%d %d\n",a+n,b);
		printf("%d %d\n",b,1);
		printf("%d %d\n",1,a);
		printf("%d %d\n",a,b+n);
	}
	if (n%4==2)
	{
		int a=n-2,b=n-1,c=n;
		printf("%d %d\n",1,b+n);
		printf("%d %d\n",c+n,a+n);
		printf("%d %d\n",a+n,2);
		printf("%d %d\n",2,c);
		printf("%d %d\n",c,a);
		printf("%d %d\n",c,b);
	}
}

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

int main() {
    int N;
    cin >> N;
    deque<int> A;
    for(int i=1; i<=N; ++i) {
        int a; cin >> a;
        if(i % 2 == N % 2) A.push_front(a);
        else A.push_back(a);
    }
    for(int i=0; i<N; ++i) cout << A[i] << (i==N-1 ? '\n' : ' ');
}

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

int main()
{
  int N;
  cin >> N;
  
  for(int i = 0; i < N; i++)
  {
    string S;
    cin >> S;
    
    if(S == "Y")
    {
      cout << "Four" << endl;
      break;
    }
    else
    {
      if(i == N - 1)
      {
        cout << "Three" << endl;
      }
      else
        continue;
    }
  }
}

Measured memory_bytes: 256
let () =
  let nq = read_line () |> Str.split (Str.regexp " ")
         |> List.map int_of_string |> Array.of_list in
  let (n,q) = (nq.(0), nq.(1)) and
      queue = Queue.create () in
  let rec read = function
      0 -> ()
    | i ->
       let line = read_line () |> Str.split (Str.regexp " ")
                  |> Array.of_list in
       Queue.push (line.(0),int_of_string line.(1)) queue;
       read (i-1)
  in
  read n;
  let rec f time_total =
    if Queue.is_empty queue then ()
    else
      let (name, time) = Queue.pop queue in
      if time <= q then
        begin
          Printf.printf "%s %d\n" name (time+time_total);
          f (time+time_total)
        end
      else
        begin
          Queue.push (name, (time-q)) queue;
          f (q+time_total)
        end
  in
  f 0;;

Measured memory_bytes: 11696
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    B = [(i,a) for i,a in enumerate(A,start = 1)][::-1]

    #sigma(1/i) = O(log N)
    balls = set()
    for i,a in B:
        cnt = 0
        for j in range(N+1):
            k = i*j
            if k > N:
                break
            elif k in balls:
                cnt += 1
        if cnt%2 != a:
            balls.add(i)
    print(len(balls))
    print(*balls,sep="\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 77388
#include <cstdio>

int main(){
    int N, X;
    scanf("%d %d", &N, &X);
    int L[N];
    for(int i = 0; i < N; i++){
        scanf("%d", &L[i]);
    }
    
    int D[N+1];
    D[0] = 0;
    for(int i = 1; i < N+1; i++){
        D[i] = D[i-1] + L[i-1];
    }

    int count = 0;
    for(int i = 0; i < N+1; i++){
        if(D[i] <= X){
            count++;
        }
    }

    printf("%d\n", count);

    return 0;
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a,b,c;
    int x,y;
    cin >> a >> b >> c >> x >> y;

int min = INF;
int mx;
(x > y) ? mx = x : mx = y;
    for (int i = 0; i <= mx*2;i++)
    {
        int j;
        (x-i/2 > 0) ? j = x-i/2 : j = 0;
        int k;
        (y-i/2 > 0) ? k = y-i/2 : k = 0;
        int tmp = j*a + k*b + i*c;
        if (tmp < min)
        min = tmp;
    }

cout << min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    int n;
    cin >> n;
    bool f[4][13] = {false};
    rep(i, 0, n) {
        char mark;
        int num;
        cin >> mark >> num;
        if (mark == 'S') f[0][num - 1] = true;
        else if (mark == 'H') f[1][num - 1] = true;
        else if (mark == 'C') f[2][num - 1] = true;
        else f[3][num - 1] = true;
    }
    rep(i, 0, 4) {
        rep(j, 0, 13) {
            if (!f[i][j]) {
                if (i == 0) cout << 'S' << " " << j + 1 << endl;
                else if (i == 1) cout << 'H' << " " << j + 1 << endl;
                else if (i == 2) cout << 'C' << " " << j + 1 << endl;
                else cout << 'D' << " " << j + 1 << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
    string s;
    int q;

    cin >> s >> q;

    long long x;
    while (q--)
    {
        int t;
        cin >> t;

        if (t == 1)
        {
            x++;
        }
        else
        {            
            int f;
            string c;
            cin >> f >> c;

            if ((f == 1 && !(x % 2)) || (f == 2 && x % 2))
            {
                s = c + s;
            }
            else
            {
                s += c;
            }
            
        }
        
    }

    if (x % 2) reverse(s.begin(), s.end());

    cout << s << endl;
}

Measured memory_bytes: 4744
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

int main()
{
    int cnt1 = 0;
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        int j = i;
        int cnt2 = 0;
        while(j  != 0)
        {
            j /= 10;
            cnt2++;
        }
        if(cnt2 % 2 == 1)
        {
            cnt1++;
        }
    }
    cout << cnt1;

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

mod = pow(10, 9) + 7

n, k = map(int, input().split())

graph = defaultdict(list)

for _ in range(n-1):
	a, b = map(int, input().split())
	a -= 1
	b -= 1
	graph[a].append(b)
	graph[b].append(a)

def dfs(v):
	global graph, k
	ans = k	# k choices of color for root
	stack = [v]
	vis_set = {v, }

	while stack:
		v = stack.pop()
		if v==0: 
			avail_count = k-1
		else: 
			avail_count = k-2
		for nxt in graph[v]:
			if nxt not in vis_set:
				if avail_count <= 0:
					return 0
				ans = (ans*avail_count)%mod
				avail_count -= 1
				stack.append(nxt)
				vis_set.add(nxt)
	return ans

ans = dfs(0)
print(ans)

Measured memory_bytes: 35432
#include <iostream>

using namespace std;

int main() {
    long A, B;
    cin >> A >> B;

    long gcd, lcm;

    long m, n, r;
    m = A;
    n = B;
    r = A;

    while (r != 0) {
        r = m % n;
        m = n;
        n = r;
    }

    gcd = m;
    lcm = A * B / gcd;

    cout << lcm << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
struct UnionFind {
    vector<int> data;
    vector<ll> rootd;//rootd[i] : dist from node[i] to node[root(i)]
    UnionFind(int N) : data(N, -1), rootd(N, 0) {}
    void unite(int x_, int y_, ll weight) {
        int x = root(x_), y = root(y_);
        if(x != y){
            data[x] += data[y];
            data[y] = x;
            rootd[y] = weight - rootd[y_] + rootd[x_];
        }
    }
    int root(int x_) {
        int x = x_;
        vector<int> memo;
        while(data[x] >= 0) {
            memo.push_back(x);
            x = data[x];
        }
        int res = x;
        for(int i = memo.size() - 1; i >= 0; --i) {
            int k = memo[i];
            rootd[k] += rootd[data[k]];
            data[k] = res;
        }
        return res;
    }
    ll dist(int a, int b) { return rootd[b] - rootd[a];}
    bool same(int a, int b) { return root(a) == root(b);}
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    while(cin >> N >> M && N) {
        UnionFind uf(N);
        char q; int a, b; ll w;
        rep(i, M) {
            cin >> q >> a >> b;
            --a; --b;
            if(q == '?') {
                if(uf.same(a, b)) cout << uf.dist(a, b) << '\n';
                else cout << "UNKNOWN" << '\n';;
            }else {
                cin >> w;
                uf.unite(a, b, w);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
void init_ios() {ios_base::sync_with_stdio(false); cin.tie(nullptr);}

int N, L;
int a[100000];

int main() {
	scanf("%d%d", &N, &L);
	for (int i = 0; i < N; ++i) scanf("%d", a+i);

	int i;
	for (i = 1; i < N; ++i) {
		if (L <= a[i-1]+a[i]) break;
	}

	if (i == N) {
		puts("Impossible");
		return 0;
	}

	puts("Possible");
	for (int j = 1; j < i; ++j) {
		printf("%d\n", j);
	}
	for (int j = N-1; i < j; --j) {
		printf("%d\n", j);
	}
	printf("%d\n", i);

	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,x;
    while(~scanf("%d%d%d",&a,&b,&x))
    {
        if(a<x)
        {
            if((x-a)<b)
                printf("YES\n");
            else
                printf("NO\n");
        }
        else if(a>x)
            printf("NO\n");
        else if(a=x)
            printf("YES\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int N,M;
    double sum = 0;
    cin>>N>>M;
    vector<int> A(N);

    for(int i = 0;i < N;i++) {
        cin>>A[i];
        sum += A[i];
    }

    int ans = 0;
    for(auto u:A) {
        if(u >= sum/(4.0*M)) {
            ans++;
        }
    }

    if(ans >= M) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main(){
	int n;
  	cin >> n;
  	vector<int> x(n), y(n);
  	rep(i, n) cin >> x[i] >> y[i];
  
  	auto dist = [&](int i, int j){
    	double dx = x[i] - x[j];
      	double dy = y[i] - y[j];
      	return sqrt(dx * dx + dy * dy);
    };
  
	double len = 0;
  	rep(i, n)rep(j, i){
    	len += dist(i, j);
    }
  	double ans = len * 2 / n;
  	printf("%.10f\n", ans);
}

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

int n, h;
vector<lint> a, b;

int main() {
    cin >> n >> h;
    a.resize(n), b.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    lint repeater = *max_element(a.begin(), a.end());
    sort(b.begin(), b.end(), greater<lint>());
    lint ans = 0;
    for (int i = 0; i < n; i++) {
        if (b[i] <= repeater) {
            break;
        }
        h -= b[i];
        ans++;
        if (h <= 0) {
            cout << ans << endl;
            return 0;
        }
    }
    cout << ans + (h + repeater - 1) / repeater << endl;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import math
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

PPP = 1000000007

# 整数の入力
n = int(input())
#s = input()

# スペース区切りの入力
#n, x = input().split()

# スペース区切りの整数の入力
#a, b = map(int, input().split())
#n, x = map(int, input().split())
#print("sp", n, k, file=sys.stderr)
a = [int(x) for x in input().split()]
#b = [int(x) for x in input().split()]
#print("a", a, file=sys.stderr)
#p, q, r = map(int, input().split())
#s = [int(x) for x in input().split()]
#t = [int(x) for x in input().split()]

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))
#  a.append([int(x) for x in input().split()])
#b = []
#for x in range(m):
#  b.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]
#a.sort()
#print(l, file=sys.stderr)

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()

import re
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def ton(n, k, x):
  s = ""
  while n > 0:
    s = str(n%k) + s
    n //= k
  return s


#print("a", a, file=sys.stderr)
#print("b", b, file=sys.stderr)

def getEnergy():
  for y in b:
    yield y

  #print(res, file=sys.stderr)
  return res

def doit():
  ret = 0.0
  for x in a:
    ret += 1.0 / x
  return 1.0 / ret

def yn():
  if doit():
    return "YES"
  else:
    return "NO"

#print(doit([0] * 4))
#doit(a)
#print(doit())
try:
  #doit()
  print(doit())
  #print(yn())
except Exception as e:
  print("e", e, file=sys.stderr)


Measured memory_bytes: 5400
N = int(input())
A = list(map(int,input().split()))
i = 0
count = 0
flag = False
while (True):
  for i in range(N):
    if A[i] % 2 != 0:
      flag = True
    if flag == True:
      break
      
  if flag == True:
    break
    
  for i in range(N):
    A[i] = A[i] // 2
  
  count += 1

print(count)

Measured memory_bytes: 3060
N = int(input())
A = [1]
for k in range(1,7):
    A.append(6**k)
for k in range(1,6):
    A.append(9**k)
dp = [[0 for _ in range(len(A))] for _ in range(N+1)]
for i in range(N+1):
    dp[i][0] = i
for j in range(len(A)):
    dp[1][j] = 1
for i in range(2,N+1):
    for j in range(1,len(A)):
        if i>=A[j]:
            dp[i][j] = min(dp[i][j-1],dp[i-A[j]][j]+1)
        else:
            dp[i][j] = dp[i][j-1]
print(dp[N][len(A)-1])

Measured memory_bytes: 34824
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

a, p = map(int, input().split())

ans = (a*3+p)//2
print(ans)


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

int main(){
	int n,i,j,k;
	int a[4][3][10]={0};
	cin>>n;
	int b[n],f[n],r[n],v[n];
	for(i=0; i<n; i++){
		cin>>b[i]>>f[i]>>r[i]>>v[i];
	}
	for(i=0; i<n; i++){
		a[b[i]-1][f[i]-1][r[i]-1]+=v[i];
	}	
	for(i=0; i<4; i++){
		for(j=0; j<3; j++){
			for(k=0; k<10; k++){
			cout<<" "<<a[i][j][k];
		}
			cout<<"\n";
		}
		if(i!=3) cout<<"####################\n";
	}
	return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>

int main(void)
{
	int n,m;
	int a[1000];
	while(1){
		scanf("%d %d",&n,&m);
		if(n==0&&m==0) return 0;
		for(int i=0;i<n;i++) a[i]=0;
		int p=-1;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;){
				p=(p+1)%n;
				if(a[p]==0)j++;
			}
			a[p]=1;
		}
		printf("%d\n",p+1);
	}
	return 0;
}

Measured memory_bytes: 1012
import java.util.*;

import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();

	static class P{
		int x;
		int y;
		public P(int x,int y){
			this.x=x;this.y=y;
		}

		@Override
		public boolean equals(Object obj) {
			if(!(obj instanceof P))return false;
			P p=(P)obj;
			return p.x==x && p.y==y;
		}
		@Override
		public String toString() {
			return "("+x+","+y+")";
		}
	}

	public void run() {
		Test:while(true){
			int W=sc.nextInt(),H=sc.nextInt();
			if(W==0 && H==0)return;
			int[][] map=new int[H][W];
			for(int h=0;h<H;h++)for(int w=0;w<W;w++){
				map[h][w]=sc.nextInt();
			}

			int res=0;
			int[][] d=new int[][]{{0,1},{1,0},{0,-1},{-1,0},
					{1,1},{1,-1},{-1,-1},{-1,1}};

			while(true){
				//1を探す。

				Queue<P> pq=new LinkedList<P>();
				S1:for(int h=0;h<H;h++)for(int w=0;w<W;w++){
					if(map[h][w]==1){
						res++;
						pq.add(new P(w,h));
						map[h][w]=0;
						break S1;
					}
				}
				if(pq.isEmpty()){
					ln(res);
					continue Test;
				}

				while(!pq.isEmpty()){
					P p=pq.poll();
					for(int i=0;i<8;i++){
						int x=p.x+d[i][0];
						int y=p.y+d[i][1];
						if(0<=x && x<W && 0<=y && y<H){
							if(map[y][x]==1){
								map[y][x]=0;
								pq.add(new P(x,y));
							}
						}
					}
				}
			}
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

Measured memory_bytes: 51408
import std.stdio;
import std.array;
import std.conv;

void main(){
	string[] input = readln.split;
	int A = input[0].to!int;
	int B = input[1].to!int;
	int C = input[2].to!int;
	int cnt;
	while(C > 0){
		C--;
		cnt++;
		if(B > 0){
			B--;
			cnt++;
		}
		else if(A > 0){
			A--;
		}
		else{
			break;
		}
	}
	if(B > 0) cnt += B;
	write(cnt);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n+1, 0);
    for(int i = 1; i <= n; i++)  cin >> a[i];
    for(int i = 1; i <= n; i++)  a[i] += a[i-1];
    
    ll l = 0, r = a[n];
    // 1e5*log(1e5)*2*log2(1e15) ~~ 1.6e8
    while(r-l > 1){
        ll mid = (l+r)/2;
        bool ok = false;
        for(int i = 0; i < n; i++){
            int j = lower_bound(a.begin(), a.end(), a[i]+mid)-a.begin();
            if(j >= n)    continue;
            int k = lower_bound(a.begin(), a.end(), a[j]+mid)-a.begin();
            if(k == n+1)    continue;
            ll last = a[n]-a[k]+a[i];
            if(last >= mid){
                ok = true;
                break;
            }
        }
        if(!ok)  r = mid;
        else     l = mid;
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

vector<int> p, c;
int a;

void green(int cnt, int pt, int id)
{
    if(id < 0){
        if(pt <= 0) a = min(a, cnt);
        return;
    }

    if(pt <= 0){
        a = min(a, cnt);
        return;
    }

    int b = pt/((id+1)*100);
    if(b >= p[id]){
        green(cnt+p[id], pt-(id+1)*100*p[id]-c[id], id-1);
    }else{
        if(pt % (id*100+100) == 0) green(cnt+b, pt-(id+1)*100*b, id-1);
        else green(cnt+(b+1), pt-(id+1)*100*(b+1), id-1);
    }
    green(cnt, pt, id-1);
}

int main()
{
    int d;
    ll g;
    cin >> d >> g;
    p.resize(d);
    c.resize(d);
    rep(i, d){
        cin >> p[i] >> c[i];
    }
    a = INF;
    green(0, g, d-1);

    cout << a;

}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,k[15]={},p[15]={},s[15][15]={},cnt1,cnt2,ans=0;
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    cin >> k[i];
    for(int j=0; j<k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for(int i=0; i<m; i++) {
    cin >> p[i];
  }
  for(int i=0; i<(1<<n); i++) {
    cnt2=0;
    for(int j=0; j<m; j++) {
      cnt1=0;
      for(int l=0; l<k[j]; l++) {
        if(i&(1<<s[j][l]-1)) {
          cnt1++;
        }
      }
      if(cnt1%2==p[j]) {
        cnt2++;
      }
    }
    if(cnt2==m) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int fanc(int num){
    if(num%10 != 0){
        return 10 - num%10;
    }else{
        return 0;
    }
}

int main(){
    vector <int> a(5), b(5);
    int lastFoodNum=0, lastFood=0;

    for(int i=0;i<5;i++){
        cin>>a[i];
        b[i] = fanc(a[i]);
        if(lastFood < b[i]){
            lastFood = b[i];
            lastFoodNum = i;
        }
    }
    int sum=0;
    for(int i=0;i<5;i++){
        if(i == lastFoodNum){
            sum += a[i];
        }else{
            sum += a[i] + b[i];
        }
    }

    cout << sum << endl;
}

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

using namespace std;

int nr, N, mod = 1e9 + 7, a[20], maxS, needed[3];
int trie[70000][8], *arr[70000], sz[70000], sum[70000], dp[70000], old[70000], automaton[70000][11];

void back (int L, int curr_node, int curr_s)
{
    arr[curr_node] = new int[L + 2], sz[curr_node] = L, sum[curr_node] = curr_s;
    for (int i=1; i<=L; i++)
        arr[curr_node][i] = a[i];
    for (int i=1; i<=7; i++)
        if (curr_s + i < maxS)
            a[L + 1] = i, trie[curr_node][i] = ++nr, back (L + 1, trie[curr_node][i], curr_s + i);
}

void BuildAutomaton ()
{
    for (int state = 0; state <= nr; state ++)
        for (int new_val = 1; new_val <= 10; new_val ++)
        {
            if (new_val > 7)
            {
                automaton[state][new_val] = 0;
                continue;
            }
            arr[state][sz[state] + 1] = new_val;
            int currS = sum[state] + new_val, i = 1;
            while (currS > maxS && i <= sz[state]) currS -= arr[state][i ++];
            if (currS == maxS)
            {
                int auxS = 0, completed_pos = 0;
                for (int j=i; j<=sz[state] + 1; j++)
                {
                    auxS += arr[state][j];
                    if (auxS == needed[completed_pos]) auxS = 0, completed_pos ++;
                }
                if (completed_pos == 3)
                {
                    automaton[state][new_val] = -1;
                    continue;
                }
                i ++;
            }
            int q = 0;
            for (int j=i; j<=sz[state] + 1; j++)
                q = trie[q][arr[state][j]];
            automaton[state][new_val] = q;
        }
}

void DoDp ()
{
    dp[0] = 1;
    for (int i=1; i<=N; i++)
    {
        memcpy (old, dp, sizeof (dp)), memset (dp, 0, sizeof (dp));
        for (int state = 0; state <= nr; state ++)
            if (old[state] != 0)
                for (int cif = 1; cif <= 10; cif ++)
                    if (automaton[state][cif] != -1)
                    {
                        int new_state = automaton[state][cif];
                        dp[new_state] += old[state];
                        if (dp[new_state] >= mod) dp[new_state] -= mod;
                    }
    }
    int ans = 1;
    for (int i=1; i<=N; i++)
        ans = (1LL * ans * 10) % mod;
    for (int i=0; i<=nr; i++)
    {
        ans -= dp[i];
        if (ans < 0) ans += mod;
    }
    printf ("%d\n", ans);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %d %d", &N, &needed[0], &needed[1], &needed[2]), maxS = needed[0] + needed[1] + needed[2];
back (0, 0, 0);
BuildAutomaton ();
DoDp ();

return 0;
}


Measured memory_bytes: 9856
require 'pp'

L = readline.to_i
A = []
L.times do |i|
  A << readline.to_i
end


dp = Array.new(5) { Array.new(L+1, 0) }

# pp A,dp

L.times do |i|
  dp[0][i+1] = dp[0][i] + A[i]
  dp[1][i+1] = [dp[0][i],dp[1][i]].min + (A[i]==0?2:(A[i]%2))
  dp[2][i+1] = [dp[0][i],dp[1][i],dp[2][i]].min + ((A[i]+1)%2)
  dp[3][i+1] = [dp[0][i],dp[1][i],dp[2][i],dp[3][i]].min + (A[i]==0?2:(A[i]%2))
  dp[4][i+1] = [dp[0][i],dp[1][i],dp[2][i],dp[3][i],dp[4][i]].min + A[i]
end

puts [dp[0][L],dp[1][L],dp[2][L],dp[3][L],dp[4][L]].min



Measured memory_bytes: 11956
#include <iostream>
#include <algorithm>
#include <array>
#include <atomic>
#include <bitset>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;

#define rep(i, a, n) for(int i = a; i <= n; i++)

template<class T, class U> inline bool chmax(T& a, U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a, U b) { if (a > b) { a = b; return 1; } return 0; }

// 第一引数 == 第二引数 ? true : false
template<class T, class U>
bool check(T first, U second) {
    return (first == second);
}

// 約数列挙
vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


// 数字和
template<class T>
T digitSum(T num) {
    T dig;
    T sum = 0;
    while (num) {
        dig = num % 10;
        sum += dig;
        num /= 10;
    }
    return sum;
}

string background_black(string s) { return "\x1b[40m" + s; }
string background_red(string s) { return "\x1b[41m" + s + "\x1b[40m"; }
string background_green(string s) { return "\x1b[42m" + s + "\x1b[40m"; }
string background_yellow(string s) { return "\x1b[43m" + s + "\x1b[40m"; }
string background_bleu(string s) { return "\x1b[44m" + s + "\x1b[40m"; }
string background_white(string s) { return "\x1b[47m" + s + "\x1b[40m"; }

string black(string s) { return "\x1b[30m" + s + "\x1b[37m"; }
string red(string s) {return "\x1b[31m" + s + "\x1b[37m"; }
string green(string s) { return "\x1b[32m" + s + "\x1b[37m"; }
string yellow(string s) { return "\x1b[33m" + s + "\x1b[37m"; }
string blue(string s) { return "\x1b[34m" + s + "\x1b[37m"; }
string white(string s) { return "\x1b[37m" + s + "\x1b[37m"; }

const int ten = 10;
const int hundred = 100;
const int thousand = 1000;

typedef long long ll;
typedef unsigned long long ull;

string tolower(string s) {
  string c;
  for (int i = 0; i < s.size(); i++) {
    if ((s[i] >= 'A') && (s[i] <= 'Z')) {
        c.push_back((s[i] + 0x20));
    } else {
        c.push_back(s[i]);
    }
  }
  return c;
}
#include <cstdlib>
string solve() {
  string str = "";
// int->string: to_string, string->int: stoi
//=============================================================================


  string s, t;
  int a, b;
  string u;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if (u == s) {
    a--;
    str += to_string(a);
    str += " ";
    str += to_string(b);
  } else {
    b--;
    str += to_string(a);
    str += " ";
    str += to_string(b);
  }



//=============================================================================
  str += "\n";
  return str;
}

int main() {	
  std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
  cout << solve() << endl;
}


Measured memory_bytes: 256
n, k, c = map(int, input().split())
s = input()

bound_to_work = [0] * n

def get_days(s):
    days = [0] * n
    changes = [0] * n
    last_day = -1
    ndays = 0
    for i in range(n):
        if (last_day == -1 or i - last_day > c) and s[i] == 'o':
            ndays += 1
            last_day = i
            changes[i] = 1
        days[i] = ndays
    return days

ldays = get_days(s)
rdays = get_days(s[::-1])[::-1]


for i in range(n):
    lchanges = (i > 0 and ldays[i] != ldays[i - 1] or i == 0)
    rchanges = i == n - 1 or rdays[i + 1] != rdays[i]
    if  lchanges and rchanges and ldays[i] + rdays[i] == k + 1:
        bound_to_work[i] = 1

for i, f in enumerate(bound_to_work):
    if f:
        print(i + 1)


Measured memory_bytes: 58572
#include <stdio.h>

int 
main(){
	
	int N,i;
	scanf("%d",&N);
	long long h[100010];
	
	for(i=0;i<N;i++)scanf("%lld",&h[i]);
	
	int hantei =0;
	if(!(N==1)){
		for(i=N-1;i>0;i--){
		
			if(!(h[i]-h[i-1]>=0)){
				h[i-1]--;
				if(!(h[i]-h[i-1]>=0)){
					hantei = 1;
					break;
				}
			}	
		}
	}
	if(hantei)printf("No\n");
	else printf("Yes\n");
 return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 405, MAXM = 100005;
int fr[MAXM], to[MAXM], lab[MAXN], ban[MAXN], n, m;
bitset<MAXN> bt[MAXN];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++)
		scanf("%d%d", fr + i, to + i);
	for (int i = 1; i <= n; i++) {
		memset(lab, 0, sizeof(lab));
		lab[i] = 1;
		for (int j = m; j > 0; j--) {
			int &a = lab[fr[j]], &b = lab[to[j]];
			if (!a && !b) continue;
			if (a && b) { ban[i] = 1; break; }
			a = b = 1;
		}
		if (!ban[i]) {
			for (int j = 1; j <= n; j++)
				if (lab[j]) bt[i].set(j);
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) if (!ban[i])
	for (int j = 1; j < i; j++) if (!ban[j])
		ans += (bt[i] & bt[j]).none();
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline

# input functions
I = lambda : int(input())
M = lambda : map(int, input().split())
ARR = lambda: list(map(int, input().split()))
MOD = int(1e9 + 7)

def main():
    n = I()
    if n < 3:
        print(0)
        return
    dp = [0 for i in range(n + 1)]
    dp[0] = 1
    for i in range(3, n + 1):
        for j in range(3, i + 1):
            dp[i] += dp[i - j]
            dp[i] %= MOD
    print(dp[n])
main()

Measured memory_bytes: 69228
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;

struct edge{int to,cap,rev;};

vector<edge> G[300];
int level[300];
int iter[300];

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});
}

void bfs(int s){
    memset(level,-1,sizeof(level));
    queue<int>que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
        int v=que.front();que.pop();
        for(auto &e:G[v]){
            if(e.cap>0 && level[e.to]<0){
                level[e.to]=level[v]+1;
                que.push(e.to);
            }
        }
    }
}

int dfs(int start,int goal,int flow){
    if(start==goal)return flow;
    for(int &i=iter[start];i<(int)G[start].size();i++){
        edge &e=G[start][i];
        if(e.cap>0 && level[start]<level[e.to]){
            int d=dfs(e.to,goal,min(flow,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,INF=pow(10,9);
    while(true){
        bfs(s);
        if(level[t]<0)return flow;
        memset(iter,0,sizeof(iter));
        int f;
        while((f=dfs(s,t,INF))>0)
            flow+=f;
    }
}

int main(){
    int N;cin>>N;
    pair<int,int>p[210];
    int a,b;
    for(int i=1;i<=2*N;i++){
        cin>>a>>b;
        p[i]={a,b};
    }
    
    for(int i=1;i<=N;i++)
        add_edge(0,i,1);
    for(int i=N+1;i<=2*N;i++)
        add_edge(i,2*N+1,1);
    for(int i=1;i<=N;i++){
        for(int j=N+1;j<=2*N;j++){
            if(p[i].first<p[j].first && p[i].second<p[j].second)
                add_edge(i,j,1);
        }
    }

    cout<<max_flow(0,2*N+1)<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int E, Y;
string name[4] = { "M", "T", "S", "H" };
int L[4] = { 1868, 1912, 1926, 1989 };
int R[4] = { 1911, 1925, 1988, 2016 };
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> E >> Y;

    if (E == 0) {
        rep(i, 0, 4) if (L[i] <= Y and Y <= R[i]) {
            printf("%s%d\n", name[i].c_str(), Y - L[i] + 1);
            return;
        }
    } else {
        int year = L[E - 1] + Y - 1;
        printf("%d\n", year);
    }
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i > (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define IN(x) cin >> x
#define DE(x) cerr << (x) << " "
#define BR cerr << "\n"
#define OUT(x) cout << (x) << endl
#define FIX cout << fixed << setprecision(10)

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  
  IN(N);
  ret = 1000 - (N % 1000);
  ret %= 1000;
  OUT(ret);

}


Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,p,i,j,c[100000]={0},c2=0,c3=0,flg[100000]={0};
	char s[3];
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d %s",&p,s);
		if(flg[p]==0&&s[0]=='W') c[p]++;
		if(flg[p]==0&&s[0]=='A'){
			c2+=c[p];
			c3++;
			flg[p]=1;
		}
	}
	printf("%d %d\n",c3,c2);
	return 0;
}


Measured memory_bytes: 2516
# import sys
# input = sys.stdin.readline
# import re
import math
import itertools

def main():
    n, k, = input_list()
    a = input_list()
    if (n-1) % (k-1) == 0:
        print((n-1)//(k-1))
    else:
        print((n-1)//(k-1) + 1)

# 累積和
def get_camulative(l):
    return [0] + list(itertools.accumulate(l))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def count(mazes, hc, wc):
    hc = list(hc)
    wc = list(wc)
    r = 0
    for hi, row in enumerate(mazes):
        if hi in hc:
            continue
        for wi, m in enumerate(row):
            if wi in wc:
                continue
            if m == '#':
                r += 1
    return r

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

def input_list_str():
    return list(map(str, input().split()))

if __name__ == '__main__':
    main()



Measured memory_bytes: 83852
#include<stdio.h>
int main(void){
  int n,i,count=0;
 scanf("%d",&n);
 char s[104];
 scanf("%s",s);
  if(n%2 == 1)
    printf("No\n");
  else{
 for(i=0;i<n/2;i++)
 {
  if(s[i] == s[i+n/2])
    count++;
 }
  if(count == n/2)
    printf("Yes\n");
  else 
    printf("No\n");
}
return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N, L;

int main()
{
  scanf( "%d%d", &N, &L );

  int diff = 1<<30, ans = 0;
  int S = 0;

  rep( i, N )
    S += L+i;

  rep( i, N )
  {
    int sum = 0;

    rep( j, i )
      sum += L+j;

    repi( j, i+1, N )
      sum += L+j;

    if( diff > abs(S-sum) )
    {
      diff = abs(S-sum);
      ans = sum;
    }
  }

  printf( "%d\n", ans );

  return 0;
}

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

int main (void){  
    int n, l;
    cin >> n >> l;
    vector <string> array(n);
    for (int i = 0; i < n; i++) {
        cin >> array[i];
    }
    sort (array.begin(), array.end()); //ソート
    string result = "";
      for (int i = 0; i < n; i++) {
        result += array[i];
    }
    cout << result << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

bool cmp(pii lh, pii rh){
	if(lh.second != rh.second) return lh.second < rh.second;
	return lh.first < rh.first;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;

	vector<pii> v;
	rep(i, m){
		int a, b;
		cin >> a >> b;
		v.push_back((pii){a, b});
	}

	sort(v.begin(), v.end(), cmp);

	/*
	rep(i, m){
		cout << v[i].first << "," << v[i].second << endl;
	}
	cout << endl;
	*/

	int ans = 0;
	int tmp = -1;
	rep(i, m){
		pii x = v[i];
		// cout << i << "," << tmp << "," << x.first << "," << x.second << endl;
		if(tmp <= x.first){
			ans++;
			tmp = x.second;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main (void) {
  int a, b, c;

  scanf("%d %d %d", &a, &b, &c);
  
  if(b + c == a || a + c == b || a + b == c) {
    printf("Yes");
  } else {
    printf("No");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
int n,a[105],x,y,h;
int main(){
    scanf("%d",&n);
    for(int i=1; i<=n; i++){
        scanf("%d",&a[i]);
        h+=a[i];
    }
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",&x,&y);
        printf("%d\n",h-a[x]+y);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;


int main() {

	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	vector<int> broken(n + 1);
	rep(i, m) {
		cin >> a.at(i);
		broken.at(a.at(i)) = 1;
	}
	vector<long long> dp(n + 2);
	dp.at(n) = 1;

	for (int i = n - 1; i >= 0; i--) {
		if (broken.at(i) == 1) {
			dp.at(i) = 0;
			continue;
		}
		dp.at(i) = (dp.at(i + 1) + dp.at(i + 2)) % mod;
	}

	cout << dp.at(0) << endl;

	return 0;
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        long[][] dp = new long[N + 1][W + 1];

        for (int i = 1; i <= N; i++) {
            int wi = sc.nextInt(); // Weight of the item(i)
            int vi = sc.nextInt(); // Value of the item(i)
            for (int j = 0; j <= W; j++) {
                // Get max total value of items under weight j.
                if (wi <= W && wi <= j) {
                    // Compare weight of item, previous value, and summed value
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i - 1][j - wi] + vi);
                } else {
                    dp[i][j] = dp[i - 1][j];
                }
            }
        }
        System.out.println(Arrays.stream(dp[N]).max().getAsLong());
    }
}


Measured memory_bytes: 128468
#include <iostream>
#include <algorithm>
#include <cmath>

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
	int max = -1;
	int ans = 0;
	for (int i = 0; i < 5; i++) {
		int num;
		std::cin >> num;
		int ceiled = 10 * std::ceil(num / 10.f);
		max = std::max(max, ceiled - num);
		ans += ceiled;
	}

	std::cout << ans - max;


	return 0;


}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] line = br.readLine().split(" ", n);
		PriorityQueue<Long> queue = new PriorityQueue<>();
		for (int i = 0; i < n; i++) {
		    queue.add(- Long.parseLong(line[i]));
		}
		long total = 0;
		while(true) {
		    long target = - queue.poll();
		    if (target + total < n) {
		        break;
		    }
		    long count = (target + total) / n;
		    total += count;
		    target -= count * (n + 1);
		    queue.add(- target);
		}
		System.out.println(total);
    }
}



Measured memory_bytes: 22996
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  string s;
  cin >> s;
  if (s[sz(s) - 1] == 's'){
    s.pb('e');
    s.pb('s');
  }
  else{
    s.pb('s');
  }
  cout << s << ENDL;
  return 0;
}


Measured memory_bytes: 3652
xs = list(map(int, input().split()))
d1 = xs[2] - xs[0]
d2 = xs[3] - xs[1]
x3 = xs[2] - d2
y3 = xs[3] + d1
x4 = x3 - d1
y4 = y3 - d2
print(x3, y3, x4, y4)

Measured memory_bytes: 3060
// abc172_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int a;
    cin >> a;

    int ans = a + a*a + a*a*a;
    print(ans);

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath> 
#define ll long long
using namespace std;
int main(){
	ll a,b;
	char op;
	cin>>a>>op>>b;
	if(op=='+')
		cout<<a+b<<endl;
	else{
		cout<<a-b<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256