akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
const int mxn=2e5+5;
const int inf=1e9;

int sz[mxn];

int par[mxn];


int findrep(int u) {
	return par[u]==u ? u : (par[u]=findrep(par[u]));
}

void unite(int u,int v) {
	u=findrep(u);
	v=findrep(v);

	if(u==v)return;
	if(sz[u]>sz[v])swap(u,v);

	sz[v]+=sz[u];
	par[u]=v;
}

int main() {
	int n,m;
	cin>>n>>m;

	for(int i=1;i<=n;i++) {
		par[i]=i;
		sz[i]=1;
	}

	for(int i=1;i<=m;i++) {
		int u,v;
		cin>>u>>v;
		unite(u,v);
	}
	int ans=0;
	for(int i=1;i<=n;i++) {
		if(findrep(i)==i) {
			ans=max(ans,sz[i]);
		}
	}

	cout<<ans<<endl;
	
}

Measured memory_bytes: 5184
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

const long double Pi=acos(-1),e=2.718;
const int N=2e3+10, mod=1e9+7;

int main ()
{
    FASTIO
    ll n ;
    cin >> n;
    vector<ll> cnt(n+1,0);
    for(int i=1;i<n;i++){
        ll a;
        cin >> a;
        cnt[a]++;
    }
    for(int i=1;i<=n;i++){
        cout << cnt[i] << endl;
    }
    return 0;
}
/**

*/


Measured memory_bytes: 4768
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
using namespace std;

string str;
int ans=0;

int main(void){
	while(1){
		cin >> str;
		ans=0;
		bool ch=true;
		if(str=="0000")break;
		if(str[0]==str[1] && str[1]==str[2] && str[2]==str[3])cout << "NA" << endl;
		else{
			while(1){
				if(str=="6174")break;
				int na,ni,nn;
				string min=str;
				sort(min.begin(),min.end());
				string max=min;
				reverse(max.begin(),max.end());
				stringstream ss;
				ss << min;
				ss >> ni;
				stringstream sk;
				sk << max;
				sk >> na;
				nn=na-ni;
				stringstream sc;
				sc << nn;
				string nstr;
				string sstr;
				sc >> nstr;
				while(nstr.size()+sstr.size()<4)sstr+="0";
				sstr+=nstr;
				str=sstr;
				ans++;
			}
			cout << ans << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 1252
#include<stdio.h>
#include<string.h>
int main()
{
	int c=0,i,a=0;
	char s[10];

	scanf("%s",s);
	for(i=0;i<strlen(s);i++){
		if((s[i]=='A')||(s[i]=='C')||(s[i]=='G')||(s[i]=='T'))
			c++;
		else
			c=0;
		if(a<c)
			a=c;
	}
	printf("%d",a);
	return 0;
}

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

template<typename T>
T gcd(T a,T b) {
    if (a < b) swap(a,b);
    return b != 0 ? gcd(b, a % b) : a;
}

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

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >>  a >> b;
    cout <<  gcd(a,b) <<  endl;
}





Measured memory_bytes: 3220
from fractions import gcd

A, B, C, D = map(int, input().split())
lcm = C*D//gcd(C, D)


divC = B//C - (A-1)//C
divD = B//D - (A-1)//D
divL = B//lcm - (A-1)//lcm

print((B-A+1) - divC - divD + divL)


Measured memory_bytes: 5560
#include <stdio.h>

int main(){
    int a,b,c,r=1,p;
    scanf("%d%d%d",&a,&b,&c);
    p=a%b;
    while(r!=0){
    	r=a%b;
    	a=b;
    	b=r;
    }
    p-=c;
    if(p<0)
    p=-p;
    if(p%a==0)
    printf("YES");
    else
    printf("NO");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m, k, i, j;
	ll ans = 0;
	cin >> n >> m >> k;
	vector<ll> a(n+2), b(m+2);
	a[0] = b[0] = 0;
	a[n+1] = b[m+1] = LLONG_MAX;
	for (i=1; i<=n; ++i) {
		cin >> a[i];
		a[i] += a[i-1];
	}
	for (i=1; i<=m; ++i) {
		cin >> b[i];
		b[i] += b[i-1];
	}
	for (i=0; i<=n; ++i) {
		if (a[i] > k) break;
		j = lower_bound(b.begin(), b.end(), k - a[i]) - b.begin();
		if (b[j] > k - a[i]) j--;
		ans = max(ans, i + j);
	}
	cout << ans << "\n";;
	return 0;
}


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

int main(){
  int64_t N,M;
  cin >> N >> M;
  vector<int64_t> H(N),A(M),B(M),C(N,0);
  for(int64_t i=0;i<N;i++){
    cin >> H.at(i);
  }
  for(int64_t i=0;i<M;i++){
    cin >> A.at(i) >> B.at(i);
    if(H.at(A.at(i)-1)>H.at(B.at(i)-1)){
      C.at(B.at(i)-1)++;
    }else if(H.at(A.at(i)-1)<H.at(B.at(i)-1)){
      C.at(A.at(i)-1)++;
    }else{
      C.at(A.at(i)-1)++;
      C.at(B.at(i)-1)++;
    }
  }
  int64_t ans=0;
  for(int64_t i=0;i<N;i++){
    if(C.at(i)==0){
      ans++;
    }
  }
    
  cout << ans << endl;
}

Measured memory_bytes: 6428
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
const int INF = 1 << 29;

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

    vector<int> reiz(A);
    vector<int> renj(B);
    int x[100010], y[100010], c[100010];
    for (int i = 0; i < A; ++i) cin >> reiz[i];
    for (int i = 0; i < B; ++i) cin >> renj[i];
    for (int i = 0; i < M; ++i) cin >> x[i] >> y[i] >> c[i];

    // 割引券を使う場合
    int ans = INF;
    for (int i = 0; i < M; ++i) {
        int t = reiz[x[i] - 1] + renj[y[i] - 1] - c[i];
        ans = min(ans, t);
    }

    // 割引券を使わない場合
    sort(reiz.begin(), reiz.end());
    sort(renj.begin(), renj.end());
    ans = min(ans, reiz[0] + renj[0]);

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

Measured memory_bytes: 2176
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  char op;
  cin >> a >> op >> b;
  while(op!='?'){
    int c;
    if(op=='+') c=a+b;
    if(op=='-') c=a-b;
    if(op=='*') c=a*b;
    if(op=='/') c=a/b;
    cout << c << endl;
    cin >> a >> op >> b;
  }
  return 0;
}


Measured memory_bytes: 3068
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#define pi acos(-1)
using namespace std;
int main()
{
    char a[1007];
    while(~scanf("%s",a))
    {
        if(a[0]=='0')break;
        int sum=0;
        for(int i=0;i<strlen(a);i++)sum+=(a[i]-48);
        cout<<sum<<endl;
    }
    return 0;
}



Measured memory_bytes: 3160
import javax.print.attribute.SupportedValuesAttribute;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.util.function.Predicate;

public class Main{
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(in, out);
        out.close();
    }

    static class TaskB {


        public static int binarySearch(int arr[], int low, int high, int key)
        {
            int mid = (low + high)/2;
            while( low <= high )
            {
                if ( arr[mid] < key )
                {
                    low = mid + 1;
                }
                else if ( arr[mid] == key )
                {
                    return mid;
                }else
                {
                    high = mid - 1;
                }
                mid = (low + high)/2;
            }
            if( low > high )
            {
                return -1;
            }
            return -1;
        }

        public static int[][] maxPos;

        public void solve(InputReader in, PrintWriter out) {
            double money = Double.parseDouble(in.next());

            int bills = (int)Math.ceil(money/1000);

            out.println((bills*1000)-((int)money));
        }
    }


    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer = new StringTokenizer("");

        public InputReader(InputStream inputStream) {
            this.reader = new BufferedReader(
                    new InputStreamReader(inputStream));
        }

        public String next() {
            while (!tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

    }
}

Measured memory_bytes: 33060
sa = input()
sb = input()
sc = input()

ai = bi = ci = -1
turn = 'a'
while True:
    exec(turn + 'i += 1')
    turn = eval('s' + turn + '[' + turn + 'i-1]')
    if eval(turn + 'i == len(s' + turn + ')'):
        print(turn.upper())
        exit()

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int MaxN = 1e5, MaxM = 2e5;
int n, m, Q, all;
int pre[MaxM + 5], last[MaxN + 5], other[MaxM + 5];
int D[MaxN + 5];
int col[MaxN + 5];
struct Query{
	int u, d, c;
}q[MaxM + 5];

void Build(int x, int y)
{
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
}

void Init()
{
	all = -1; memset(last, -1, sizeof(last));
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		Build(u, v);
		Build(v, u);
	}
	scanf("%d", &Q);
	for (int i = 1; i <= Q; i++) {
		scanf("%d%d%d", &q[i].u, &q[i].d, &q[i].c);
	}
}

void Dfs(int x, int d, int c, int dep)
{
	if (d < dep) return;
	if (col[x] == 0) col[x] = c;
	if (D[x] >= d - dep) return;	 
	D[x] = max(D[x], d - dep);
	int ed = last[x], dr;
	while (ed != -1) {
		dr = other[ed];
		Dfs(dr, d, c, dep + 1);
		ed = pre[ed];
	}
}

void Solve()
{
	memset(col, 0, sizeof(col));
	memset(D, 0, sizeof(D));
	for (int i = Q; i >= 1; i--) {
		Dfs(q[i].u, q[i].d, q[i].c, 0);	
	}
	for (int i = 1; i <= n; i++) printf("%d\n", col[i]);
}

int main()
{
	while (~scanf("%d%d", &n, &m)) {
		Init();
		Solve();
	}
	return 0;
}

Measured memory_bytes: 4736
x, y = gets.chomp.split.map(&:to_i)

MOD = 10**9 + 7

def comb_inv(n, r)
  res = 1
  i = r
  j = 1
  while i > 0
    res = res * (n-i+1)
    res %= MOD
    j *= i
    j %= MOD
    i -= 1
  end
  res *= inv(j)
  res %= MOD
  res
end

def inv(x)
  res = 1 # 逆元をどんどんかけるやつ
  beki = x # 逆元を計算したい値のMOD化でのべき乗
  (MOD - 2).to_s(2).reverse.chars do |digest|
    res = (beki * res) % MOD if digest == '1'
    beki = (beki * beki) % MOD
  end
  res
end

if (x + y) % 3 != 0
  puts 0
  exit
end


q = (x+y) / 3


if x < q || y < q
  puts 0
  exit
end

r = x % q

p (comb_inv(q, r)) % MOD





Measured memory_bytes: 1788
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

b = input()

if b == "A":
	print("T")
if b == "T":
	print("A")
if b == "C":
	print("G")
if b == "G":
	print("C")


Measured memory_bytes: 59628
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max=-1000000;
        int min=1000000;
        long sum = 0;
        for(int i=0;i<n;i++){
            int a = sc.nextInt();
            sum +=a;
            if(max<a){
                max=a;
            }
            if(min>a){
                min=a;
            }
        }
        System.out.printf("%d %d %d\n",min,max,sum);
    }  
}


Measured memory_bytes: 42644
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N+2);
    for(int i=1; i<=N; i++) {
        cin >> A[i];
    }

    vector<int> spot(N+2);
    for(int i=1; i<=N+1; i++) {
        spot[i] = spot[i-1] + abs(A[i-1] - A[i]);
    }

    for(int i=1; i<=N; i++) {
        cout << spot[i-1] + (spot[N+1] - spot[i+1]) + abs(A[i+1] - A[i-1]) << endl;;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

int k, a, b;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> k >> a >> b;
    if(b / k > (a - 1) / k)
        cout << "OK\n";
    else
        cout << "NG\n";
    return 0;
}


Measured memory_bytes: 3652
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
const ll mod=10000;
ll n,k;
ll p[100];
bool rsv[100];
ll dp[100][6];//day:i  pasta:j 0 1 2 00 11 22
int main()
{
	scanf("%lld%lld",&n,&k);
	for(ll i=0;i<k;i++){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		a--;
		b--;
		rsv[a]=1;
		p[a]=b;
	}
	if(rsv[0]) dp[0][p[0]]=1;
	else{
		dp[0][0]=dp[0][1]=dp[0][2]=1;
	}
	for(ll i=1;i<n;i++){
		if(rsv[i]){
			for(ll j=0;j<6;j++){
				if(j!=p[i]&&j!=p[i]+3) dp[i][p[i]]=(dp[i][p[i]]+dp[i-1][j])%mod;
			}
			dp[i][p[i]+3]=dp[i-1][p[i]];
		}
		else{
			for(ll s=0;s<3;s++){
				for(ll j=0;j<6;j++){
					if(j!=s&&j!=s+3) dp[i][s]=(dp[i][s]+dp[i-1][j])%mod;
				}
				dp[i][s+3]=dp[i-1][s];
			}
		}
	}
	
	printf("%lld\n",(dp[n-1][0]+dp[n-1][1]+dp[n-1][2]+dp[n-1][3]+dp[n-1][4]+dp[n-1][5])%mod);
}

Measured memory_bytes: 3204
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n, d;
    cin>>n>>d;
    vvi x(n, vi(d));
    rep(i,n){
        rep(j,d){
            cin>>x[i][j];
        }
    }
    lli ans=0;
    rep(i,n){
        for(lli j=i+1;j<n;j++){ 
            lli tmp=0;
            rep(k,d){
                tmp+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            ld now=sqrt(tmp);
            tmp=sqrt(tmp);
            if(tmp==now){ 
                ans++;
            }
        }
    }
    out(ans);
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 1; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

struct UnionFind {
    vector<ll> par, size;
    UnionFind(ll n) : par(n), size(n,1) {
        for(int i = 0; i < n; i++) par[i] = i;
    }
    void Union(ll x, ll y) {
        x = Find(x), y = Find(y);
        if(x == y) return;
        if(size[x] < size[y]) swap(x,y);
        size[x] += size[y];
        par[y] = x;
    }
    ll Find(ll x) {
        if(par[x]==x) return x;
        else return par[x] = Find(par[x]);
    }
    bool Same(ll x, ll y) {
        return Find(x) == Find(y);
    }
    ll Size(ll x) {
        return size[Find(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    vector<int> a(m), b(m);
    REP(i,m) {
        cin >> a[i] >> b[i]; a[i]--, b[i]--;
    }
    UnionFind uf(n);
    vector<ll> ans(m);
    ans[m-1] = (n*(n-1))/2;
    REPR(i,m) {
        if(uf.Same(a[i], b[i])) {
            ans[i-1] = ans[i];
        }
        else {
            ans[i-1] = ans[i] - (uf.Size(a[i]) * uf.Size(b[i]));
            uf.Union(a[i],b[i]);
        }
    }
    REP(i,m) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4480
import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			while (true) {
				BigDecimal x = new BigDecimal(sc.next());
				BigDecimal ten = new BigDecimal(10);
				
				if (x.equals(BigDecimal.ZERO)) {
					break;
				}

				int cnt = String.valueOf(x).toCharArray().length;
				int sum = 0;
				for (int i = 0; i < cnt; i++) {
					sum += Integer.valueOf(x.remainder(ten).toString());
					x = x.divide(ten, RoundingMode.DOWN);
				}
				System.out.println(sum);
			}
		}
	}
}


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

int main() {
  int N, K, result;
  result = 1;
  cin >> N >> K;
  
  for(int i = 0; i < N; i++){
    if(result * 2 < result + K){
      result *= 2;
    }
    else{
      result += K;
    }
  }
  
  cout << result << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif

static void B_DifferentDistribution();

int main()
{
	B_DifferentDistribution();

	fflush(stdout);
	return 0;
}

static void B_DifferentDistribution()
{
	int N = 0;
	scanf(" %d", &N);

	U_L_LONG rank = 0, score = 0;
	U_L_LONG lowestRank = 0, minScore = 0xFFFFFFFFFFFFFFFF;
	for (int i = 0; i < N; i++) {
		scanf(" %llu %llu", &rank, &score);

		if (lowestRank < rank) {
			lowestRank = rank;
		}
		if (minScore > score) {
			minScore = score;
		}
	}

	printf( "%llu\n", lowestRank + minScore);

}


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

const int mxn=1e5;
int n,m;
vector<int> adj[mxn];
ll d[mxn],indegree[mxn];
bool vis[mxn];

void bfs(int node)
{
	queue<int> q;
	q.push(node);
	vis[node]=true;
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(auto i:adj[u])
		{
			//if(!vis[i])
			{
				d[i]=max(d[i],d[u]+1);
				indegree[i]--;
				vis[i]=true;
				if(indegree[i]<=0)
					q.push(i);
			}	
		}
	}
}
int main()
{
	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif
	
	//int t;
	//cin>>t;
	//while(t--)
	{
		cin>>n>>m;
		for(int i=0;i<m;i++)
		{
			int x,y;
			cin>>x>>y;
			--x,--y;
			adj[x].push_back(y);
			indegree[y]++;
		}
		
		for(int i=0;i<n;i++)
		{
			if(!vis[i]&&indegree[i]==0)
			{
				bfs(i);
			}
		}
		//for(int i=0;i<n;i++)
		//{
			//cout<<indegree[i]<<' ';
		//}
		//cout<<'\n';
		ll ans=0;
		for(int i=0;i<mxn;i++)
		{
			ans=max(ans,d[i]);
		}
		cout<<ans<<'\n';
		
	}
		
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

constexpr ll MOD = 1000000007;

ll N;

template <class T>
inline map<T, int> prime_factor(T n)
{
    map<T, int> ret;
    for (T i = 2; i * i <= n; ++i)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }

    if (n != 1)
        ret[n] = 1;
    return ret;
}

int main(void) {
    cin >> N;

    vecll cnt(N + 1);

    for(int i = 2; i <= N; ++i) {
        auto pm = prime_factor(i);
        for(auto pair : pm) {
            cnt[pair.first] += pair.second;
        }
    }

    ll ans = 1;
    for(int i = 2; i <= N; ++i) {
        if (cnt[i] != 0) ans = (ans * (cnt[i] + 1)) % MOD;
    }

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	static int mod = 1000000007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char []c = sc.next().toCharArray();
		
		int n = c.length;
		
		int [][]dp = new int [n+1][13];
		
		dp[0][0] = 1;
		
		for(int i = 0 ;i < n ;i++) {
			for(int j = 0 ; j < 10 ; j++) {
				if(c[i] == '?' || c[i] == j +'0') {
					for(int k = 0 ; k < 13 ;k++) {
						dp[i+1][(k*10+j)%13] = (dp[i+1][(k*10+j)%13] + dp[i][k])%mod;
					}
				}
			}
		}
		
		System.out.println(dp[n][5]);
	}
}


Measured memory_bytes: 34256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
using ll = long long;


int main() {
  int A,B;
  cin >> A >> B;
  cout << A*B << endl;


  /*string <-> int*/
  //string numStr = "1234";
  //int num = atoi(numStr.c_str());
  //cout << num << endl;
  
  return 0;
  /* 数字型同士の変換
  （型）値
  int a = 5;
  cout << (double)a << endl;

  /* 桁数を指定したい場合
  //小数点以下10位まで
  cout << fixed << setprecision(10);
  cout << 3.14159265358979 << endl;
  */

  /* intより広い範囲を扱いたい場合
  int64_t a = 200000000;
  
  cout << 200000000LL * 2LL << endl;
  */


}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;
const int N = 1e5 + 10;


int main(){
	int a, b, c;
	while(~scanf("%d%d%d",&a, &b, &c)){
		if((a + b) >= c)
			printf("Yes\n");
		else
			printf("No\n");
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int N, d[100];
int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> d[i];
    sort(d, d + N, less<int>());
    int ret = 1;
    for (int i = 1; i < N; i++)
    {
        ret += (d[i] > d[i - 1] ? 1 : 0);
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] array = new int[n];
		for(int i = 0; i < n; i++) {
			array[0] = 0;
		}

		for(int i=0; i < n - 1; i++) {
			array[sc.nextInt() - 1] += 1;
		}

		for(int i = 0; i < n ; i++) {
			System.out.println(array[i]);
		}

		sc.close();

	}

}

Measured memory_bytes: 60156
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    	s:chars
    }
    let ss = s.into_iter().collect::<String>();
    println!("{}",
             match ss.trim() {
                 "SUN" => 7,
                 "MON" => 6,
                 "TUE" => 5,
                 "WED" => 4,
                 "THU" => 3,
                 "FRI" => 2,
                 "SAT" => 1,
                 _ => 0
             });
}

Measured memory_bytes: 4352
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  if n == 0
    then return ()
    else do
      ls <- replicateM n getLine
      let ls' = map (map read . words) ls
      mapM_ putStrLn $ solve ls'
      main

solve :: [[Int]] -> [String]
solve = map (format . cross)
  where
    cross :: [Int] -> [Int]
    cross [x1,y1,z1,w1,x2,y2,z2,w2] = [x1 * x2 - y1 * y2 - z1 * z2 - w1 * w2,
                                       x1 * y2 + x2 * y1 + z1 * w2 - z2 * w1,
                                       x1 * z2 + x2 * z1 + w1 * y2 - y1 * w2,
                                       x1 * w2 + x2 * w1 + y1 * z2 - z1 * y2]
    format :: [Int] -> String
    format [x,y,z,w] = (show x) ++ " " ++ (show y) ++ " " ++ (show z) ++ " " ++ (show w) 

Measured memory_bytes: 3928
#include <stdio.h>   
int main(void) {         
int W,H,x,y,r;     
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);     
if(x>=r&&x+r<=W&&y>=r&&y+r<=H){         
printf("Yes\n");     
} 
else{         
printf("No\n");     }     
return 0; 
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<vector<char>> vec(3,vector<char>(3));
  for(int i=0;i<3;i++){
    for(int x=0;x<3;x++)cin>>vec.at(i).at(x);
  }
  cout << vec.at(0).at(0)<<vec.at(1).at(1)<<vec.at(2).at(2) <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

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

    if(s == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


int main() {
	int n, m;
	cin >> n >> m;
	string k = "";
	for (int i = 0; i < n; i++) {
		k += ".";
	}
	bool ans = true;
	for (int i = 0; i < m; i++) {
		int s;
		cin >> s;
		s--;
		char c;
		cin >> c;

		if (k[s] == '.') {
			k[s] = c;
		}
		else {
			if (k[s] != c) ans = false;
		}
	}
	if (k[0] == '.' && n != 1) k[0] = '1';
	if (k[0] == '.' && n == 1) k[0] = '0';
	if (n != 1 && k[0] == '0') ans = false;
	for (int i = 1; i < n; i++) {
		if (k[i] == '.') k[i] = '0';
	}
	if (ans)
		cout << k << endl;
	else
		cout << -1 << endl;
}


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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n, -1) {}
	int find(int x) { return (v[x] < 0) ? x : (v[x] = find(v[x])); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x != y) {
			// if (-v[x] < -v[y]) swap(x, y);
			v[x] += v[y]; v[y] = x;
		}
	}
	int size(int x) { return -v[find(x)]; }
	bool same(int x, int y) { return find(x) == find(y); }
};

int par[100001], a[100001];
char c[100000]; int v[100000];

int main() {
	for (;;) {
		int N, Q;
		scanf("%d%d", &N, &Q);
		if (N == 0 && Q == 0)
			break;
		for (int _v = 2; _v <= N; _v++)
			scanf("%d", &par[_v]);
		fill(a, a + 100001, 0);
		for (int i = 0; i < Q; i++) {
			char s[2]; int _v;
			scanf("%s%d", s, &_v);
			c[i] = s[0];
			v[i] = _v;
			if (s[0] == 'M')
				a[_v]++;
		}
		UnionFind uf(N + 1);
		for (int _v = 2; _v <= N; _v++)
			if (a[_v] == 0)
				uf.unite(par[_v], _v);
		long long ans = 0;
		for (int i = Q - 1; i >= 0; i--) {
			int _v = v[i];
			if (c[i] == 'M') {
				if (--a[_v] == 0 && _v != 1)
					uf.unite(par[_v], _v);
			}
			else if (c[i] == 'Q')
				ans += uf.find(_v);
		}
		printf("%lld\n", ans);
	}
}

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

using namespace std;

int main()
{

    long double n, a;
    long double min = 10e15;


    cin >> n;

    for(int i = 0 ; i < 5; ++i)
    {
        cin >> a;
        if(a <= min) min = a;
    }

    cout << (long long)ceil(n/min) + 4 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int N, K;
    cin >> N >> K;
    double ans = 0.0;
    for (int i=1;i<N+1;i++){
        double p = 1.0/(double)N;
        int v = i;
        while (v < K){
            v *= 2;
            p /= 2.0;
        }
        ans += p;
    }
    cout << fixed << setprecision(9) <<  ans << endl;
}


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

int main() {
    int n, cnt = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n-2; i++)
    {
        if (s[i] == 'A') {
            if (s[i+1] == 'B') {
                if (s[i+2] == 'C') {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	a = int(input())
	al = list(IN())
	set_l=set(al)
	if len(set_l) == a:
		print('YES')
	else:
		print('NO')

	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 100692
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (int i = k; i < (int)(n); ++i)
#define MAX 500010
typedef long long int ll;

using namespace std;

ll N, ans, cnt;
string s;

int main() {
	cin >> N;

	int n = sqrt(N);

	ll minz = N + 1;
	
	repk(i, 1, n + 1) {
		if (N%i == 0) {
			ll j = N / i;
			if (minz > (i + j)) minz = (i + j);
		}
	}
	
	cout << minz - 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<cmath>
#include<functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void sort(int &a,int &b)
{
	if(a>b)
		swap(a,b);
}
void open(const char *s)
{
#ifndef ONLINE_JUDGE
	char str[100];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
	sprintf(str,"%s.out",s);
	freopen(str,"w",stdout);
#endif
}
int rd()
{
	int s=0,c;
	while((c=getchar())<'0'||c>'9');
	do
	{
		s=s*10+c-'0';
	}
	while((c=getchar())>='0'&&c<='9');
	return s;
}
int upmin(int &a,int b)
{
	if(b<a)
	{
		a=b;
		return 1;
	}
	return 0;
}
int upmax(int &a,int b)
{
	if(b>a)
	{
		a=b;
		return 1;
	}
	return 0;
}
const int p=1000000007;
int n,m;
short a[310][310][310];
short b[310][310][310];
int f[310][310][310];
void add(int &a,int b)
{
	a=(a+b)%p;
}
void gao(int x,int y,int z)
{
	if(!f[x][y][z])
		return;
	int mi=min(x,min(y,z));
	int ma=max(x,max(y,z));
	int mid=x+y+z-mi-ma;
	if(!mi)
	{
		if(!mid)
		{
			if(a[1][ma][ma]>1)
			{
				f[x][y][z]=0;
				return;
			}
		}
		else
		{
			if(a[mid+1][ma][ma]>1)
			{
				f[x][y][z]=0;
				return;
			}
			if(a[1][mid][ma]>2||b[1][mid][ma]<2)
			{
				f[x][y][z]=0;
				return;
			}
		}
	}
	else
	{
		if(a[mid+1][ma][ma]>1)
		{
			f[x][y][z]=0;
			return;
		}
		if(a[mi+1][mid][ma]>2||b[mi+1][mid][ma]<2)
		{
			f[x][y][z]=0;
			return;
		}
		if(b[1][mi][ma]<3)
		{
			f[x][y][z]=0;
			return;
		}
	}
	if(ma<n)
	{
		add(f[ma+1][y][z],f[x][y][z]);
		add(f[x][ma+1][z],f[x][y][z]);
		add(f[x][y][ma+1],f[x][y][z]);
	}
}
int qx[310];
int qy[310];
int qz[310];
int main()
{
//	open("arc074e");
	scanf("%d%d",&n,&m);
	memset(a,0,sizeof a);
	memset(b,0x7f,sizeof b);
	int i,x,y,z,j,k;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		qx[i]=x;
		qy[i]=y;
		qz[i]=z;
	}
	for(i=1;i<=m;i++)
		for(j=1;j<=m;j++)
			if(j!=i)
				if(qx[j]<=qx[i]&&qy[j]>=qy[i]&&qz[j]<qz[i])
				{
					printf("0\n");
					return 0;
				}
	for(i=1;i<=m;i++)
		b[qx[i]][qx[i]][qy[i]]=a[qx[i]][qx[i]][qy[i]]=qz[i];
	for(i=1;i<=n;i++)
		for(j=i;j>=1;j--)
			for(k=j+1;k<=i;k++)
			{
				a[j][k][i]=max(a[j][k-1][i],a[j+1][k][i]);
				b[j][k][i]=min(b[j][k-1][i],b[j+1][k][i]);
			}
	f[0][0][0]=1;
	for(i=0;i<=n;i++)
	{
		gao(i,0,0);
		if(i)
		{
			gao(0,i,0);
			gao(0,0,i);
		}
		for(j=0;j<i;j++)
			for(k=0;k<j;k++)
			{
				gao(i,j,k);
				gao(i,k,j);
				gao(j,i,k);
				gao(j,k,i);
				gao(k,i,j);
				gao(k,j,i);
			}
	}
	int ans=0;
	for(i=0;i<=n;i++)
		for(j=0;j<=n;j++)
			for(k=0;k<=n;k++)
				if(i==n||j==n||k==n)
					add(ans,f[i][j][k]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 232960
#include<stdio.h>

int main(){
    int n, q, i, j, S[10000], T[500], count = 0;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    for (i = 0; i < q; i++){
        scanf("%d", &T[i]);
        for (j = 0; j < n; j++){
            if(T[i] == S[j]){
                count++;
                break;
            }
        }
    }
    
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 1932
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	if (a>b){
		swap(a,b);
	}
	if (a>c){
		swap(a,c);
	}
	if (b>c){
		swap(b,c);
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}
  



Measured memory_bytes: 3084
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

int main()
{
  string s;
  string a;
  string b;
  cin >> s;
  int countA = 0;
  int countB = 0;
  
  rep(i,s.length())
  {
    a += to_string(i%2);
    b += to_string((i+1)%2);
  }
  rep(i, s.length())
  {
    if(a.substr(i,1) == s.substr(i,1)){
      countA++;
    } else if (b.substr(i,1) == s.substr(i,1)) {
      countB++;
    }
  }
  
  if (countA > countB){
    cout << countB << endl;
  } else {
    cout << countA << endl;
  }
  return 0;
}


Measured memory_bytes: 768
n, m = map(int, input().split())
ans = -1
inp = sorted([n, m])
if inp[0] == 1:
    if inp[1] == 1:
        ans = 1
    else:
        ans = inp[1] - 2
else:
    ans = (inp[0] - 2) * (inp[1] - 2)
print(ans)

Measured memory_bytes: 3060
def f(b,n):
  if 0<n:
    return n%b+f(b,n//b)
  else:
    return 0

n = int(input())
s = int(input())

for i in range(2,5**8):
  if f(i,n)==s:
    print(i)
    exit()

for i in range(n-s>>18,0,-1):
  if f((n-s)//i+1,n)==s:
    print((n-s)//i+1)
    exit()

if n==s:
  print(n+1)
else:
  print(-1)

Measured memory_bytes: 9188
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int N, W_max;
    cin >> N >> W_max;
    vector<int> V(110), W(110);
    for(int i = 1; i <= N; i++) cin >> V[i] >> W[i];

    Graph dp(110, vector<int>(10010, 0));
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= W_max; j++){
            if(j < W[i]) dp[i][j] = dp[i - 1][j];
            else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - W[i]] + V[i]);
        }
    }

    cout << dp[N][W_max] << endl;
}


Measured memory_bytes: 7100
a,b=map(str,input().split())

if b == "H" : #AtCoDeerくんは「TopCoDeerくんは正直者だ」
    if a == "H":
        print("H")
    else :
        print("D")
    
else : #aAtCoDeerくんは「TopCoDeerくんは嘘つきだ」
    if a == "H":
        print("D")
    else :
        print("H")

Measured memory_bytes: 2940
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 200002;

int n;
ll k;

ll a[N_MAX];

bool f (int mx)
{
    ll cnt = 0;
    for(int i = 1; i <= n; i++)
    {
        cnt += (a[i] - 1) / mx;
        if(cnt > k)
            return false;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    ll l = 1, r = 1000000000;
    while(l < r)
    {
        ll mid = ((l + r) >> 1);
        if(f(mid))
            r = mid;
        else
            l = mid + 1;
    }
    cout << l << "\n";
    return 0;
}


Measured memory_bytes: 5252
r,c=map(int,input().split())
l=[list(map(int,input().split())) for i in range(r)]
for i in range(r):
    l[i].append(sum(l[i]))
l.append(list(map(sum,zip(*l))))
for i in range(r):
    print(*l[i])
l2=[]
for j in range(c+1):
    sum=0
    for i in range(r):
        sum+=l[i][j]
    l2.append(sum)
print(' '.join(list(map(str,l2))))


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

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		int k, p;
		scanf("%d %d", &k, &p);
		int r = k % p;
		if (!r) r = p;
		printf("%d\n", r);
	}
	return 0;
}

Measured memory_bytes: 1188
from collections import deque
a = deque(list(input()))
b = deque(list(input()))
c = deque(list(input()))
now = "a"
win = None
while 1:
    if now == "a":
        if not a:
            win = "A"
            break
        now = a.popleft()
    elif now == "b":
        if not b:
            win = "B"
            break
        now = b.popleft()
    else:
        if not c:
            win = "C"
            break
        now = c.popleft()
print(win)

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

ll knapsack(ll wt[],ll v[],ll n,ll W)
{
  ll dp[n+1][W+1];
  for(ll i=0;i<=n;i++)
  {
    for(ll w=0;w<=W;w++)
    {
      if(i==0 or w==0)
        dp[i][w] = 0;
      else if(wt[i-1] <= w)
      {
          dp[i][w] = max(v[i-1] + dp[i-1][w - wt[i-1]],dp[i-1][w]);
      }
      else
      {
        dp[i][w] = dp[i-1][w];
      }

    }
  }

  return dp[n][W];

}

int main()
{
 

ll n,W;
cin>>n>>W;
ll wt[100001],val[100001];
for(ll i=0;i<n;i++)
{
  cin>>wt[i]>>val[i];
}


  cout<<knapsack(wt,val,n,W);
  return 0;
}

Measured memory_bytes: 82500
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

const int maxq = 200001;

int T[maxq];
int F[maxq];
char C[maxq];

int main(){
    string s;int q;

    cin >> s >> q; 
    
    bool reverse = false;
    int j = 0;
    rep(i,q) {
        cin >> T[i];
        if(T[i] == 1) {
            reverse = !reverse; 
        }else {
            cin >> F[j] >> C[j];
            j++;
        }
    }
    if(reverse)std::reverse(s.begin(), s.end());
    std:deque<char> deq;
    rep(i,s.length()) {
        deq.push_back(s[i]);
    }
    reverse = !reverse;
    j = 0;
    rep(i,q) {
        if(T[i] == 1) {
            reverse = !reverse; 
        }else {
            if(reverse) {
                if(F[j] == 1) deq.push_front(C[j]);
                else deq.push_back(C[j]);
            }else {
                if(F[j] == 1) deq.push_back(C[j]);
                else deq.push_front(C[j]);
            }
            j++;
        }
    }
    if(reverse) {
        std::for_each(deq.begin(), deq.end(), [](char x) {
            std::cout << x ;
        });
    }else{
        std::reverse_iterator<decltype(deq)::iterator> first(deq.end());
        std::reverse_iterator<decltype(deq)::iterator> last(deq.begin());
        std::for_each(first, last ,[](char x) {
            std::cout << x ;
        });
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5768
#include <stdio.h>
#include <math.h>
 
int main(){
 
  /* 三角形の辺 */
  int a, b, c;
 
  /* 辺の長さを入力 */
  scanf("%d %d %d",&a,&b,&c);
 
  /* 三角形の種類を判別・出力 */
  if ((a + b > c && a + c > b && b + c > a)&& (a > 0 && b > 0 && c > 0)&&(a == b && b == c)) 
  {
  	printf("Yes");
  }
  
  else 
  {
    printf("No");
  }
   return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
    string s;
    while (cin >> s && s != "#") {
        vector<int> p(s.size());
        REP(i, s.size()) p[i] = (s[i]-'1')%3;
        auto dp = make_v<int64>(p.size(), 2);
        fill_v<int64>(dp, INF);
        dp[0][0] = dp[0][1] = 0;
        REP(i, s.size()-1) {
            if (p[i] <= p[i+1]) {
                chmin(dp[i+1][1], min(dp[i][0], dp[i][1]+1));
            }
            if (p[i] >= p[i+1]) {
                chmin(dp[i+1][0], min(dp[i][0]+1, dp[i][1]));
            }
        }
        cout << *min_element(all(dp[s.size()-1])) << endl;
    }
}




Measured memory_bytes: 8764
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int N;
    int[] A,B;
    private class Task implements Comparable<Task> {
        int take, end;
        public Task(int take, int end) {
            this.take = take;
            this.end = end;
        }

        public int compareTo(Task task) {
            if (this.end == task.end) {
                return this.take - task.take;
            }
            return this.end - task.end;
        }
    }
    private void solve() {
        N = nextInt();
        A = new int[N];
        B = new int[N];
        for(int i = 0;i < N;i++) {
            A[i] = nextInt();
            B[i] = nextInt();
        }

        PriorityQueue<Task> pq = new PriorityQueue<>();
        for(int i = 0;i < N;i++) {
            pq.add(new Task(A[i], B[i]));
        }

        int now = 0;
        while(!pq.isEmpty()) {
            Task task = pq.poll();

            if (now + task.take > task.end) {
                out.println("No");
                return;
            }
            now = now + task.take;
        }

        out.println("Yes");
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 57212
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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 ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

ll N,Q,q;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> N;
    vector<int> S(N);
    REP(i,N) cin >> S[i];
    ll ans = 0;
    cin >> Q;
    REP(i,Q){
        cin >> q;
        int l = 0, r = N-1, t = 0;
        while(r - l > 1){
            t = (l+r) / 2;
            if(S[t] < q) l = t;
            else r = t;
        }
        if(S[r]==q) ++ans;
    }
    cout << ans << "\n";
    return 0;
}


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

int a[20];
int b[20];
int c[20];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) { cin >> a[i]; --a[i]; }
  for (int i = 0; i < n; ++i) cin >> b[i];
  for (int i = 1; i < n; ++i) cin >> c[i];
  
  int sum = 0;
  int pi = 1e9;
  for (int k = 0; k < n; ++k) {
    int i = a[k];
    sum += b[i];
    if (pi + 1 == i) {
      sum += c[i];
    }
    pi = i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256