akhauriyash/Code-Regression huggingface dataset:
import java.util.HashMap;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		HashMap<String,String> map = new HashMap<>();
		for(int i = 1;i<=N;i++) {
			map.put(sc.next(),String.valueOf(i));
		}
		for(int j = 1;j<=N;j++) {
			System.out.print(map.get(String.valueOf(j))+" ");
		}
	}
}


Measured memory_bytes: 78208
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
H,W = map(int,input().split())
Map = [["."]*(W+2)]
for _ in range(H):
    Map.append(["."]+list(input())[:-1] + ["."])
Map.append(["."]*(W+2))
flag = 0
for i in range(1,H+1):
    if flag == 1:
        break
    for j in range(1,W+1):
        if Map[i][j] == ".":
            continue
        if Map[i][j+1] == "." and Map[i][j-1] == "." and Map[i+1][j] == "." and Map[i-1][j] == ".":
            
            flag = 1
            break
if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 13564
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long ll;
int main() {
    FAST_IO;
    
    ll n;
    cin >> n;

    ll res = 1e13;
    for (int i = 1; i <= sqrt(n); ++i) {
        if (n % i == 0) {
            res = min(res, (i - 1) + (n/i - 1));
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
X = int(input())

# iがそんなに大きくないのでiについてループを回すことができる．dpiを"i円の買い物ができるなら，"Yes","No""とします．
# dp0を'Yes'とする．
# dpi-100~105が'True'ならばdpiは0．それ以外ならば'False'
DP = [True]
for i in range(X): 
    if i+1-105 >= 0:
        DP_n = DP[i+1-100] or DP[i+1-101] or DP[i+1-102] or DP[i+1-103] or DP[i+1-104] or DP[i+1-105] 
    elif i+1==100 or i+1==101 or i+1==102 or i+1==103 or i+1==104:
        DP_n = True
    else:
        DP_n = False
    DP.append(DP_n)
print(int(DP[X]))


Measured memory_bytes: 3860
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
    	ACBC146V.B();
    }
}

class ACBC146V {
	static Scanner sc = new Scanner(System.in);

	static void B() {
		int rot = sc.nextInt();
		String s = sc.next();
		StringBuilder out = new StringBuilder();
		for(char c : s.toCharArray()) {
			int pos = ((c - 'A') + rot) % 26;
			out.append((char)('A' + pos));
		}
		System.out.println(out);
	}
}

Measured memory_bytes: 23892
#include <cstdio>
#include <cstring>
#include <vector>

const int N = 100000 + 10, INF = 0x3f3f3f3f;

int n, m;
std::vector<int> adj[N];

int fa[N], dep[N];

int v[N], p[N];
int l[N], r[N];

void dfs(int a) {
  for (int i = 0; i < adj[a].size(); ++i) {
    int b = adj[a][i];
    if (b != fa[a]) {
      fa[b] = a;
      dep[b] = dep[a] + 1;
      dfs(b);
      l[a] = std::max(l[a], l[b] - 1);
      r[a] = std::min(r[a], r[b] + 1);
    }
  }
}

void solve(int a) {
  for (int i = 0; i < adj[a].size(); ++i) {
    int b = adj[a][i];
    if (b != fa[a]) {
      l[b] = std::max(l[b], l[a] - 1);
      r[b] = std::min(r[b], r[a] + 1);
      solve(b);
    }
  }
}

bool flag;

int val[N];

void get(int a) {
  val[a] = INF;
  for (int i = l[a]; i <= r[a]; ++i) {
    if (((i + dep[a]) & 1) == flag) {
      val[a] = i;
      break;
    }
  }
  for (int i = 0; i < adj[a].size(); ++i) {
    int b = adj[a][i];
    if (b != fa[a]) {
      l[b] = std::max(l[b], val[a] - 1);
      r[b] = std::min(r[b], val[a] + 1);
      get(b);
    }
  }
}

int main() {
  scanf("%d", &n);
  for (int i = n - 1; i--;) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  scanf("%d", &m);
  memset(l, -1, sizeof l);
  memset(r, 0x3f, sizeof r);
  for (int i = 1; i <= m; ++i) scanf("%d%d", &v[i], &p[i]), l[v[i]] = r[v[i]] = p[i];
  dfs(1);
  solve(1);
  flag = (dep[v[1]] + p[1]) & 1;
  for (int i = 2; i <= m; ++i) if (((dep[v[i]] + p[i]) & 1) != flag) return puts("No"), 0;
  get(1);
  for (int i = 1; i <= n; ++i) if (val[i] == INF) return puts("No"), 0;
  puts("Yes");
  for (int i = 1; i <= n; ++i) printf("%d\n", val[i]);
  return 0;
}


Measured memory_bytes: 14720
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int a,b,x;
	cin>>a>>b>>x;
	if(a>x){
		cout<<"NO"<<endl;
	}
	else{
		if(a+b>=x){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if (s.charAt(5)=='1'||s.charAt(6)>'4') {
			System.out.println("TBD");
		} else {
			System.out.println("Heisei");
		}
	}
}


Measured memory_bytes: 21972
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 六  9/23 20:01:14 2017
 * Ended  Time*  : 六  9/23 20:02:50 2017
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
char s[15];

int main()
{
	while(~scanf("%s", s)){
		if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') printf("Yes\n");
		else printf("No\n");
	}
    
    return 0;
}


Measured memory_bytes: 256
def do():
    n = int(input())
    data = list(map(int, input().split()))
    datb = list(map(int, input().split()))
    sa = sum(data)
    sb = sum(datb)
    if sb < sa:
        print("No")
        return 0
    diffcnt = sb - sa
    cnt1 = 0
    cnt2 = 0
    import math
    for i in range(n):
        if data[i] > datb[i]:
            cnt1 += data[i] - datb[i]
        if data[i] < datb[i]:
            cnt2 += math.ceil((datb[i] - data[i]) / 2)
    if cnt2 <= diffcnt:
        print("Yes")
    else:
        print("No")
    #print(diffcnt, cnt1, cnt2)


do()



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

int main() {
    int n, k;  cin >> n >> k;
    if (n % k == 0)  cout << 0 << endl;
    else  cout << 1 << endl;
}

Measured memory_bytes: 256
N,A,B,C,D=map(int,input().split())
s='$'+input()
 
if C<B:
    if not '##' in s[A:C]:
        if not '##' in s[B:D]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    if C<D:
        if '##' in s[A:D]:
            print('No')
        else:
            print('Yes')
    else:
        if '##' in s[A:C]:
            print('No')
        else:
            if '...' in s[B-1:D+2]:
                print('Yes')
            else:
                print('No')

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	private static String str;
	private static String[] keys = { "the ", "this ", "that " };

	public static void main(String args[]) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while ((str = br.readLine()) != null) {

			for (int i = 0; i < 27; i++) {
				String newStr = decryption(i);

				if (newStr.indexOf(keys[0]) != -1
						|| newStr.indexOf(keys[1]) != -1
						|| newStr.indexOf(keys[2]) != -1) {
					System.out.println(newStr);
					break;

				}
			}
		}
	}

	private static String decryption(int cnt) {
		char[] ret = str.toCharArray();

		for (int i = 0; i < str.length(); i++) {
			char c = str.charAt(i);
			if (c == ' ' || c == '.' || c == '\n') {
				ret[i] = c;
			} else {
				int s = c-cnt;
				if(s<97){
					s = 26 + s;
				}
				ret[i] = (char) s;
			}
		}
		return String.valueOf(ret);
	}
}

Measured memory_bytes: 15044
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long

const int maxn = 2e5 + 7;

int a[maxn];

int main() {
    LL n;
    while(cin >> n) {
        if(n&1LL) cout << 0 << endl;
        else {
            n /= 2LL;
            LL sum = 0;
            while(n) {
                sum += n/5LL;
                n /= 5LL;
            }
            cout << sum << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
bool check(int n) {
    return 1 <= n && n <= INF;
}
signed main(void) {
    int N; cin >> N;
    VI p(N);
    REP(i, N) scanf("%d", &p[i]);
    VI a(N), b(N);
    VI sum(N);
    REP(i, N) {
        sum[p[i] - 1] = INF - N + i - 1;
    }
    int cnt = 0;
    REP(i, N) {
        a[i] = i + 1 + cnt;
        b[i] = sum[i] - a[i];
        if (i == 0) continue;
        if (a[i] <= a[i - 1]) {
            int buf = a[i - 1] - a[i] + 1;
            a[i] += buf;
            b[i] -= buf;
            cnt += buf;
        }
        if (b[i] >= b[i - 1]) {
            int buf = b[i] - b[i - 1] + 1;
            a[i] += buf;
            b[i] -= buf;
            cnt += buf;
        }
        assert(check(a[i]) && check(b[i]));
    }
    for_each(ALL(a), [](int e){printf("%d ", e);});
    printf("\n");
    for_each(ALL(b), [](int e){printf("%d ", e);});
    printf("\n");
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;

void cinv(vector<ll> &V){
	ll t;
	cin >> t;
	V.push_back(t);
}

int main()
{
	ll N,M,X,S=0,G=0;
	vector<ll> v(100,0);
	cin >> N >> M >> X;
	fore(i,0,M){
		ll t;
		cin >> t;
		v[t]++;
	}
	fore(i,0,N+1){
		if(i<X&&v[i]==1)S++;
		if(X<i&&v[i]==1)G++;
	}
	cout << min(S,G) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iterator>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
using namespace std;


#ifdef LOCAL
#define DEBUGMSG()                                                              \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]" ;        \
}
#define DEBUGVAR(x)                                                             \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]:" ;       \
    cerr << "([" << typeid(x).name() << "]" << #x << ")" << x << endl ;         \
}
#define DEBUGARR(l, r)                                                          \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]:" ;       \
    copy(l, r, ostream_iterator<decltype(*l)>(cerr, " "));                      \
    cerr << endl ;                                                              \
}
#else
#define DEBUGMSG()
#define DEBUGVAR(x)
#define DEBUGARR(l, r)
#endif // LOCAL

#define getBit(x) (col##x << (10 * (4-x)))

using i64 = long long;

const int MAXN = 500 ;

int N;
i64 COL[MAXN][8], tmp[4], ans;
map <i64, i64> mp;

i64 getHash(i64 col1, i64 col2, i64 col3, i64 col4)
{
    return getBit(1) | getBit(2) | getBit(3) | getBit(4);
}

void ModifyMap(i64 h, i64 delta)
{
    // Rotation
    for(int i = 0; i < 4; i++)
    {
        mp[h] += delta;
        //DEBUGVAR(h);
        h = (h >> 10) | ((h & 0x3FF) << 30);
    }

}



int main()
{
    cin >> N ;

    for(int i = 0; i < N; i++)
    {
        for(int c = 0; c < 4; c++)
            cin >> COL[i][c],
            COL[i][c+4] = COL[i][c];
        ModifyMap(getHash(COL[i][0], COL[i][1], COL[i][2], COL[i][3]), 1);
    }

    for(int i = 0; i < N; i++)
    {
        ModifyMap(getHash(COL[i][0], COL[i][1], COL[i][2], COL[i][3]), -1);
        for(int j = i+1; j < N; j++)
        {
            ModifyMap(getHash(COL[j][0], COL[j][1], COL[j][2], COL[j][3]), -1);
            for(int k = 0; k < 4; k++)
            {
                i64 tmpans = 1;
                tmp[0] = getHash(COL[j][k+1], COL[j][k+0], COL[i][1], COL[i][0]);
                tmp[1] = getHash(COL[j][k+0], COL[j][k+3], COL[i][2], COL[i][1]);
                tmp[2] = getHash(COL[j][k+3], COL[j][k+2], COL[i][3], COL[i][2]);
                tmp[3] = getHash(COL[j][k+2], COL[j][k+1], COL[i][4], COL[i][3]);

                for(int c = 0; c < 4; c++)
                    if(!mp[tmp[c]])
                        goto JMP;

                for(int c = 0; c < 4; c++)
                    tmpans *= mp[tmp[c]],
                    ModifyMap(tmp[c], -1);

                for(int c = 0; c < 4; c++)
                    ModifyMap(tmp[c], 1);
                ans += tmpans;

                JMP:
                    ;
            }
            ModifyMap(getHash(COL[j][0], COL[j][1], COL[j][2], COL[j][3]), 1);
        }
    }

    cout << ans << endl ;
    return 0;
}


Measured memory_bytes: 20352
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a+b == 3 {
		fmt.Println(3)
	} else if a+b == 4 {
		fmt.Println(2)
	} else {
		fmt.Println(1)
	}
}


Measured memory_bytes: 512
f=input().split(" ")
a,b,m=[int(f[i]) for i in range(3)]
coup=[]
As=[]
Bs=[]
f=input().split(" ")
for each in f:
    As.append(int(each))

f=input().split(" ")
for each in f:
    Bs.append(int(each))

for i in range(m):
    f=input().split(" ")
    vac=[]
    for each in f:
        vac.append(int(each))
    coup.append(vac)
        
price=min(As)+min(Bs)
for each in coup:
    price_c=As[each[0]-1]+Bs[each[1]-1]-each[2]
    if price_c<price:
        price=price_c
print(price)
    

Measured memory_bytes: 32468
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}




int main() {
  long n;
  cin >> n;

  std::vector<double> x(n,0);
  vector<string> u(n);



  for (int i = 0; i < n; ++i){
    cin >> x[i] >>u[i];
  }

  double ans = 0;


  for (int i = 0; i < n; ++i){
    if (u[i] == "JPY"){
      ans += x[i];
    }else{
      ans += (x[i] * (double)380000 );
    }
  }




  cout <<ans;



}




















Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split())) 
stock = 0
money = 1000
for i in range(N-1):
    money += (stock * A[i])
    stock = 0
    if A[i] < A[i+1]:
        stock += money//A[i]
        money -= (money//A[i] * A[i])
        if i == N-2:
            money += stock*A[i+1]
print(money)

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

int main() {
  int a, b;
  cin >> a >> b;
  int c;
  
  int pro = 1;
  for (int i = 0; i < 3; i++) {
    pro *= 10;
    if (b / pro == 0) {
      c = a * pro + b;
      break;
    }
  }
  
  for (int i = 1; i < 321; i++) {
    if (c == i * i) {
      cout << "Yes" << endl;
      break;
    }
    else if (i == 320) {
      cout << "No" << endl;
    }
  }
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 2005;
int n, m, r[MX][MX], c[MX][MX];
char a[MX][MX];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> a[i];

	for (int i = 0; i < n; i++) {
		int cn = 0;
	
		for (int j = 0; j < m; j++) {
			if (a[i][j] == '#') {
				for (int k = j - cn; k < j; k++)
					r[i][k] = cn;
				cn = 0;
			} else {
				cn++;
			}
		}

		for (int k = m - cn; k < m; k++)
			r[i][k] = cn;
	}

	for (int j = 0; j < m; j++) {
		int cn = 0;

		for (int i = 0; i < n; i++) {
			if (a[i][j] == '#') {
				for (int k = i - cn; k < i; k++)
					c[k][j] = cn;
				cn = 0;
			} else {
				cn++;
			}
		}

		for (int k = n - cn; k < n; k++)
			c[k][j] = cn;
	}

	int res = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			res = max(res, c[i][j] + r[i][j] - 1);
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 35584
#include<stdio.h>

int main(){
	
	int a,c;
	char b;
	
	scanf("%d %c %d",&a,&b,&c);
	
	if(b=='+'){
		printf("%d\n",a+c);
	}
	
	if(b=='-'){
		printf("%d\n",a-c);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <atcoder/twosat>

using namespace std;

int main(){
    int N, D; cin >> N >> D;
    vector<int> p(2*N);
    for(auto& t : p) cin >> t;
    atcoder::two_sat ts(N);
    for(int i=0;i<2*N;i++){
        for(int j=2*(i/2+1);j<2*N;j++){
            if(abs(p[i]-p[j]) >= D) continue;
            ts.add_clause(i/2, !(i%2), j/2, !(j%2));
        }
    }
    if(ts.satisfiable()){
        cout << "Yes" << endl;
        auto b = ts.answer();
        for(int i=0;i<N;i++) cout << p[2*i+b[i]] << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define sz 100010
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back

int const mod = 1e9;
int const N = 2e5;

int main()
{
    BeatMeScanf;
    ll n;
    cin>>n;
    if(n%1000==0) {
        cout<<0<<endl;
        return 0;
    }
    ll ans = 1000-(n%1000);
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 3648
n = int(input())
if n == 10 or n == 10**2 or n == 10**3 or n == 10**4 or n == 10**5:
    print(10)
else:
    x = str(n)
    a = list(x)
    b = sum([int(i) for i in a])
    print(b)


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

struct UnionFind{
  int n;
  vector<int> p,r;
  UnionFind(){}
  UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    if(p[x]==x)return x;
    else return p[x]=find(p[x]);
  }
  void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(r[x]<r[y])p[x]=y;
    else {
      p[y]=x;
      if(r[x]==r[y])r[x]++;

    }
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
};

int main(){
  int n,q;
  cin>>n>>q;
  UnionFind uf(n);
  for(int i=0;i<q;i++){
    int c,x,y;
    cin>>c>>x>>y;
    if(c)cout<<uf.same(x,y)<<endl;
    else uf.unite(x,y);
  }
  return 0;
}



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

ll int pos[100005],sum[100005];

int main(void)
{
    int n,k;
    cin >>n>>k;
    for(int i=1; i<=n; i++) {
        scanf("%lld", &pos[i]);
        sum[i]=sum[i-1]+pos[i];
    }

    ll int ans=1e17;
    for(int i=1; i<=n-k+1; i++) {
        //clearcout <<pos[i+k-1]<<" "<<pos[i]<<" "<<min(abs(pos[i+k-1]), abs(pos[i]))<<endl;
        ans =min(ans, pos[i+k-1]-pos[i]+min(abs(pos[i+k-1]), abs(pos[i])));
    }

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

    return 0;
}

Measured memory_bytes: 1920
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize,
    }
    let mut table: Vec<i64> = (0..=n).map(|i| i as i64).collect();
    'loop1: for i in 2..=n {
        if *table.get(i).expect("") < i as i64 {
            continue 'loop1;
        }
        for j in (i..=n).step_by(i) {
            table[j] = i as i64;
        }
    }
    let mut ans = 0;

    for mut i in 1_i64..=n as i64 {
        let mut cnt: HashMap<i64, usize> = HashMap::new();
        let mut ret = i as i64;
        while i != 1 {
            let prime = table[i as usize];
            *cnt.entry(prime).or_insert(0) += 1;
            i /= prime;
        }
        cnt.values().for_each(|val| {
            ret *= *val as i64 + 1;
        });
        ans += ret;
    }
    println!("{}", ans);
}


Measured memory_bytes: 80208
#include<iostream>
#include<vector>
#include<set>
using namespace std;
#define MAX 100
int main()
{
  while(true){
    int N;
    pair<int,int> M[MAX][MAX];
    set< set< pair<int, int > > > ans;
    cin >> N;
    if( N == 0 ) break;
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < N; ++j){
	int X, Y;
	cin >> X >> Y;
	M[i][j] = make_pair(X,Y);
      }
    }

    /*
    for(int x=0;x<N;++x){
      for(int y=0;y<N;++y){
	cout << x << ' ' << y << " GOTO " << M[y][x].first << ' ' << M[y][x].second << endl;
      }
    }
    cout << endl;
//    continue;
*/

    for(int x = 0; x < N; ++x){
      for(int y = 0; y < N; ++y){
	
	int vis[MAX][MAX];
	for(int k = 0; k < MAX; ++k){
	  for(int l = 0; l < MAX; ++l){
	    vis[k][l] = -1;
	  }
	}
	vector<pair<int,int> > hist;
	
	int nx = x;
	int ny = y;
	int step = 0;
	while( true ){
	  if( vis[ny][nx] >= 0 ){  
	    set< pair<int,int> > s;

	    //cout << "END : " << nx << ' ' << ny << endl;
	    //cout << "START AT : " << x << ' ' << y << endl;
	    if( vis[ny][nx] > 0 ){
	      hist.erase( hist.begin(), hist.begin() + vis[ny][nx] );
	    }
	    for(int k = 0; k < hist.size(); ++k){
	      s.insert( hist[k] );
	      //cout << hist[k].first << ' ' << hist[k].second << endl;
	    }
	    //cout << endl;
	    ans.insert( s );
	    break;
	  }else{
	    hist.push_back( make_pair(nx,ny) );
	    vis[ny][nx] = step;
	    step++;
	  }
	  //cout << " NOW : " << nx << ' ' << ny << " NEXT : ";
	  int tx = nx, ty = ny;
	  nx = M[ty][tx].first;
	  ny = M[ty][tx].second;
	  //cout << nx << ' ' << ny << endl;
	}
	
      }
    }
    /*
    for(set< set< pair<int,int> > >::iterator its = ans.begin();
	its != ans.end(); ++its){
      for(set< pair<int,int> >::iterator its2 = its->begin();
	  its2 != its->end(); ++its2){
	cout << its2->first << ' ' << its2->second << endl;
      }
      cout << endl;
    }
    */
    cout << ans.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1764
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    long N;
    scan(N);

    long[] n1divs;
    for (long i = 1; i*i <= N - 1; i++) {
        if ((N - 1) % i == 0) {
            n1divs ~= i;
            n1divs ~= (N - 1) / i;
        }
    }

    long ans = n1divs.sort().uniq.count.to!long - 1;

    long[] ndivs;

    for (long i = 1; i*i <= N; i++) {
        if (N % i == 0) {
            ndivs ~= i;
            ndivs ~= N / i;
        }
    }

    ndivs = ndivs.sort().uniq.array[1..$];

    foreach (d ; ndivs) {
        long M = N;
        while (M % d == 0) {
            M /= d;
        }
        if (M % d == 1) ans++;
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int n = s.size() + 1;
  vector<int> left(n,0), right(n,0);
  REP(i,n-1){
    if(s[i]=='<') left[i+1] += left[i] + 1;
  }
  REPR(i,n-1){
    if(s[i]=='>') right[i] += right[i+1] + 1;
  }
  ll ans = 0;
  REP(i,n) ans += (ll)max(left[i],right[i]);
  cout << ans << '\n';
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  if(s.size() < 4) cout << "No" << endl;
  else if(s.substr(0, 4) == "YAKI") cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Fifty-Fifty
            var s = Console.ReadLine();

            var chars = new Dictionary<char, int>();

            foreach(var c in s)
            {
                if (chars.ContainsKey(c))
                {
                    chars[c]++;
                }
                else
                {
                    chars.Add(c, 1);
                }
            }

            if(chars.Count == 2 && chars[s[0]] == 2)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)

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

const Int MOD = 1000000007;


Int modpow(Int a, Int n) {
    Int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

map<Int, int> prime_factor(Int n) {
    map<Int, int> res;
    for(Int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}


int main() {
    int N;
    cin >> N;
    vector<Int> A(N), C(N);
    vector<map<Int,int>> Afac(N);
    rep(i,N) {
        cin >> A[i];
        C[i] = modpow(A[i], MOD-2);
        Afac[i] = prime_factor(A[i]);
    }

    map<Int,int> fac = Afac[0];
    rep1(i,N-1) {
        for (auto ite = Afac[i].begin(); ite != Afac[i].end(); ++ite) {
            Int p = ite->first;
            int e = ite->second;
            auto ite2 = fac.find(p);
            if (ite2 != fac.end()) {
                if (e > fac[p]) fac[p] = e;
            }
            if (ite2 == fac.end()) {
                fac[p] = e;
            }
        }
    }

    /*for (auto ite = fac.begin(); ite != fac.end(); ++ite) {
        cout << ite->first << " " << ite->second << endl;
    }*/

    Int LCM = 1;
    for (auto ite = fac.begin(); ite != fac.end(); ++ite) {
        LCM = (LCM * modpow(ite->first, ite->second)) % MOD;
    }

    //cout << LCM << endl;

    Int ans = 0;

    rep(i,N) {
        ans = (ans + (LCM * C[i]) % MOD) % MOD;
        //cout << ans << endl;
    }

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 3968
A,B,C = map(int,input().split())

abc = [A,B,C]
ieven = []
iodd = []
for i in range(3):
    if abc[i] % 2 == 0:
        ieven += [i]
    else:
        iodd += [i]
        
if len(ieven) == 3 or len(iodd) == 3:
    abc.sort()
    ans = (abc[2]-abc[1])//2 + (abc[2]-abc[0])//2
else:
    if len(ieven) > len(iodd):
        abc[ieven[0]] += 1
        abc[ieven[1]] += 1
        abc.sort()
        ans = 1 + (abc[2]-abc[1])//2 + (abc[2]-abc[0])//2
    else:
        abc[iodd[0]] += 1
        abc[iodd[1]] += 1
        abc.sort()
        ans = 1 + (abc[2]-abc[1])//2 + (abc[2]-abc[0])//2
        
print(ans)

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

#define INF (1LL<<60)

int a[20],b[20];

int main(){
	int n,k;	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];

	long long ans=INF;
	for(int i=0; i<(1<<n); i++){
		int b_cnt=0;
		int maxH=0;
		long long cost=0;
		for(int j=0;j<n;j++){
			b[j]=a[j];

			if((i>>j)&1){
				b_cnt++;
				if(maxH>=b[j]){
					++maxH;
					cost+=maxH-b[j];
					b[j]=maxH;
				}
			}
			maxH=max(maxH,b[j]);
		}
		if(b_cnt<k)continue;

		ans=min(ans,cost);

	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
g = [list(map(int, input().split())) for _ in range(3)]
for i in range(101):
    b1, b2, b3 = g[0][0] - i, g[0][1] - i, g[0][2] - i
    if g[1][0] - b1 == g[1][1] - b2 and g[1][1] - b2 == g[1][2] - b3:
        if g[2][0] - b1 == g[2][1] - b2 and g[2][1] - b2 == g[2][2] - b3:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 3064
s = input().strip()

first = int(s[0] + s[1])
second = int(s[2] + s[3])

if (first == 0):
    if (second == 0):
        print("NA")
    elif (1 <= second <= 12):
        print("YYMM")
    elif (13 <= second <= 99):
        print("NA")
    else:
        print("NA")
elif (1 <= first <= 12):
    if (second == 0):
        print("MMYY")
    elif (1 <= second <= 12):
        print("AMBIGUOUS")
    elif (13 <= second <= 99):
        print("MMYY")
    else:
        print("NA")
elif (13 <= first <= 99):
    if (second == 0):
        print("NA")
    elif (1 <= second <= 12):
        print("YYMM")
    elif (13 <= second <= 99):
        print("NA")
    else:
        print("NA")
else:
    print("NA")


Measured memory_bytes: 38256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <memory>        // unique_ptr, shared_ptr, weak_ptr

using namespace std;

int main() {
    int H, W;
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        
        for (int i=0; i<H; i++) {
            for (int j=0; j<W; j++) {
                if (i%2 == 0 && j%2 == 0) cout << '#';
                else if (i%2 == 0 && j%2 != 0) cout << '.';
                else if (i%2 != 0 && j%2 == 0) cout << '.';
                else cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;		 
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    ll zolo = 0;
    bool flag = false;
    rep(i,n){
        ll c,d;
        cin >> c >> d;
        if(c == d) ++zolo;
        else zolo = 0;
        if(zolo >= 3) flag = true;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = a + a + b + b;
        System.out.println(area + " " + length);
        sc.close();
    }
} 


Measured memory_bytes: 26340
#include <iostream>

using namespace std;

int main(){
    int a, b, k;
    cin >> k;
    cin >> a >> b;
    for(int i = a;i <= b;i++){
        if(i % k == 0){
            cout << "OK" << endl;
            a = -1;
            break;
        }
    }
    if(a != -1){
        cout << "NG" << endl;
    }
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    double N;
    cin >> N;
    vector<double> x(N), y(N);
    rep(i, N) {
        cin >> x[i] >> y[i];
    }

    vector<int> v;
    rep(i, N) v.push_back(i);
    double ans = 0;
    double cnt = 0;
    do {
        cnt++;
        double res = 0;
        repd(i, 1, N) {
            double tx = x[v[i]], ptx = x[v[i - 1]];
            double ty = y[v[i]], pty = y[v[i - 1]];
            double tmp = (tx - ptx) * (tx - ptx) + (ty - pty) * (ty - pty);
            res += sqrt(tmp);
        }
        ans += res;
    } while (next_permutation(all(v)));

    ans /= cnt;
    printf("%lf\n", ans);
    return 0;
}

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

int ctoi(char);

int main(void){
    string s;
    cin >> s;
    
    int res1=0,res2=0;
    for(int i=0;i<s.length();i++){
        if(i%2 != ctoi(s[i])){
            res1++;
        }else if(-(i%2-1) != ctoi(s[i])){
            res2++;
        }
    }
    
    if(res1<=res2){
        cout << res1 << endl;
    }else{
        cout << res2 << endl;
    }
    
    
}

int ctoi(char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
int n, l[10], d[10];
int a, b, c;
int f(int k) {
	if (k == n) {
		int p = 0, q = 0, r = 0;
		int cost = 0;
		for (int i = 0; i < n; i++) {
			if (d[i] == 1) {
				if (p > 0)cost += 10;
				p += l[i];
			}
			else if (d[i] == 2) {
				if (q > 0)cost += 10;
				q += l[i];
			}
			else if (d[i] == 3) {
				if (r > 0)cost += 10;
				r += l[i];
			}
		}
		if (p*q*r == 0)return 1145141919810;
		else return cost + abs(a - p) + abs(b - q) + abs(c - r);
	}
	int r = 1145141919810;
	for (int i = 0; i <= 3; i++) {
		d[k] = i;
		r = min(r, f(k + 1));
	}
	return r;
}
signed main() {
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++)cin >> l[i];
	cout << f(0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#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--)
typedef long long LL;
int A[120];
LL N;



int main(){
	REP(i,120){
		A[i]=0;
	}
	cin>>N;
	if(N==0){
		cout<<0<<endl;
		return 0;
	}
	bool d=false;
	if(N<0){
		N*=-1;
		d=true;
	}
	
	REP(i,101){
		if(N==0)break;
		if(d==false){
			if(N%2==1){
				A[i]=1;
				if(i%2==1)N++;
			}
		}else{
			if(N%2==1){
				A[i]=1;
				if(i%2==0)N++;
			}
		}
		N/=2;
	}
	
	bool c=false;
	for(int i=110;i>=0;i--){
		if(A[i]==1)c=true;
		if(c){
			cout<<A[i];
		}
	}
	cout<<endl;
	return(0);
}

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

typedef long long ll;

int main() {
	ll n;
	int l[10000];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> l[i];
	}
	sort(l, l + n);
	ll c = 0;

	for (int i = 0; i < n - 2; i++)
	{
		//if (l[i] != l[i + 1])
		//{
			for (int j = i + 1; j < n - 1; j++)
			{
				//if (l[j] != l[j + 1])
				//{
					for (int k = j + 1; k < n; k++)
					{
						//if (l[k] != l[k + 1])
						//{
							if (l[i] + l[j] >l[k])c++;
							else k = n;
						//}
					}
				//}
			}
		//}
	}
	cout << c;

}

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

int w, h, x, y, r;

int main() {
	//freopen("test.txt", "r", stdin);
	int i, j;
	while (~scanf("%d%d%d%d%d", &w, &h, &x, &y,&r)) {
		bool flag = true;
		if (x < r || y < r) flag = false;
		else if (x > w || y > h) flag = false;
		else if (w - x < r || h - y < r) flag = false;
		printf("%s\n", flag ? "Yes" : "No");
	}
	return 0;
}

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

int check(int arr[], int size, int x)
{
    int i;
    for(i=0;i<size;i++)
    {
        if(arr[i]==x) return 1;
        
    }
    if(i==size) return 0;
}
int main()
{
    int x;
    cin >> x;
    int n;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;i++) cin >> arr[i];
    int arr1[200];
    int l=0;
    for(int j=0;j<102;j++)
    {
        if(check(arr,n,j)==0)
        {
            arr1[l]=j;
            l+=1;
        }
    }
    int arr2[l];
    for(int z=0;z<l;z++)
    {
        arr2[z]=abs(x-arr1[z]);
    }
    sort(arr2,arr2+l);
    int q = arr2[0];
    
    int p,r;
    p = x-arr2[0];
    r = x+arr2[0];
    if(check(arr,n,p)==0) cout << p << endl;
    else if(check(arr,n,p)==1) cout << r << endl;

  return 0;
}

Measured memory_bytes: 3636
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<ll> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(ll i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	ll i,n,x,s=0;
	cin>>n;
	vi a(n+1),b(n);
	for0(i,n+1) cin>>a[i];
	for0(i,n) cin>>b[i];
	for0(i,n){
		x = min(b[i],a[i]);
		s += x;
		b[i] -= x;
		if(b[i]){
			x = min(b[i],a[i+1]);
			a[i+1] -= x;
			s += x;
			}
		}
	cout<<s<<nw;
	
	return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include<stdio.h>
int main(void)
{
  char buf[400002];
  int i = 0;
  while(1) if(EOF == (buf[++i] = getchar_unlocked())) break;
  int ans = 0;
  i >>= 1;
  char* x = buf + i;
  while(--i) ans += buf[i] != x[i];
  printf("%d", ans);
}


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

int main(){
    int A = 0, B = 0;
    for(long i = 0; i < 1000000000000000; i++)
      for(long j = 0; j < 1000000000000000; j++)
      if(1 < 2) A++;
  cin >> A >> B;
  cout << A * B << endl;
  return 0;
}


Measured memory_bytes: 3660
#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 BBuBBBlesort | diff BBuBBBlesort.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address BBuBBBlesort.cpp && ./a.out

/*

 7/3/2020

 10:28-

 */

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

void solve() {
  VI as(A,A+N);
  sort(ALL(as));
  map<LL,int> par;
  REP(i,N) par[as[i]]=i%2;
  int cnt=0;
  REP(i,N) cnt+=par[A[i]]!=(i%2);
  assert(cnt%2==0);
  cout<<cnt/2<<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: 10684
#include <bits/stdc++.h>
using namespace std;

bool isPrime[1000010];

int main() {
    for (int i = 1; i < 1000010; i++) isPrime[i] = 1;
    for (int i = 2; i < 1000010; i++) {
        if (!isPrime[i]) continue;
        for (int j = i + i; j < 1000010; j += i) {
            isPrime[j] = 0;
        }
    }
    vector<int> v;
    for (int i = 2; i < 1000010; i++) {
        if (isPrime[i]) v.push_back(i);
    }
    int n;
    cin >> n;
    cout << *lower_bound(v.begin(),v.end(),n) << endl;
    return 0;
}

Measured memory_bytes: 1916
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
int n;
int color[MAX];
vector<int> v[MAX];
void b(int s, int t){
	stack<int> S;
	S.push(s);
	int tp;
	color[s] = t;
	while (!S.empty()){
		int tp = S.top(); S.pop();
		for (int i = 0; i < v[tp].size(); i++){
			if (color[v[tp][i]] == MAX){
				color[v[tp][i]] = t;
				S.push(v[tp][i]);
			}
		}
	}
}
void a(){
	for (int i = 0; i < n; i++){
		color[i] = MAX;
	}
	int id = 0;
	for (int i = 0; i < n; i++){
		id++;
		if(color[i] == MAX)b(i,id);
	}
}
int main(){
	int m, s, t;
	int q;
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		cin >> s >> t;
		v[s].push_back(t);
		v[t].push_back(s);
	}
	a();
	cin >> q;
	for (int i = 0; i < q; i++){
		cin >> s >> t;
		if (color[s] == color[t]) cout << "yes" << endl;
		else cout << "no" << endl;
 	}
	return 0;
}

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

#define range 524289
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;


int main(int argc, char const *argv[])
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.txt", "r", stdin);
 //    	freopen("output.txt", "w", stdout);
	// #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,l;
    cin>>n;
    int count =0;
    for (int i = 1; i <=n; ++i)
    {
    	int digits  = (int)log10(i);
    	digits++;
    	if(digits%2) count++;
    }
    cout<<count<<endl;
    return 0;
}


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

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

ll N;
vector<ll> A;
int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;
    // for (int i = 0; i < 60; i++) {
    for (int i = 0; i < 60; i++) {
        ll cnt = 0;

        // j 桁目が1の個数を調べる
        for (int j = 0; j < N; j++) {
            if (A[j] >> i & 1) cnt++;
        }
        ll tmp = (N - cnt) * cnt;

        // cout << cnt << " " << tmp << endl;

        for (int j = 0; j < i; j++) {
            tmp *= 2;
            tmp %= MOD;
        }

        ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5564
#include <iostream>
#include <vector>
#include <string>

using namespace std;

void solve()
{
	string col = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int H, W;
	cin >> H >> W;
	string S;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			cin >> S;
			if (S == "snuke")
			{
				cout << col[j] << i + 1 << endl;
				return;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
typedef pair<li, li> PI;

int main(void) {
	li n;
	cin >> n;
	vector<li> p;
	vector<li> q;
	vector<li> tmp(n);
	rep(i, n) {
		li x;
		cin >> x;
		p.push_back(x);
	}
	rep(i, n) {
		li x;
		cin >> x;
		q.push_back(x);
	}

	rep(i, n) {
		tmp[i] = i + 1;
	}

	li pp = -1;
	li qq = -1;
	li order = 0;
	do {
		if (tmp == p) {
			pp = order;
		}
		if (tmp == q) {
			qq = order;
		}
		++order;
	} while (next_permutation(tmp.begin(), tmp.end()));

	cout << abs(pp - qq) << endl;
	return 0;
}

Measured memory_bytes: 256