akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int N, a[100];
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	sort(a,a+N);
	
	int alice = 0, bob = 0;
	for(int i=0;i<N;i++){
		if(i%2 == 0){
			alice += a[N-i-1];
		}
		else{
			bob += a[N-i-1];
		}
	}
	cout << alice - bob << endl;
	return 0;
    }

Measured memory_bytes: 256
import numpy as np
n = int(input())
h = list(map(int, input().split()))
h = np.array(h)

count = 0

for k in range(max(h)):
    j = 0
    for i in range(0,len(h)):
        if h[i]==0 and i!=j:
            h[j:i] = h[j:i] -1
            count = count+1
            j = i + 1
        elif i ==len(h)-1 and h[n-1]!=0:
            count = count+1
            h[j:]= h[j:]-1
        elif h[i]==0 and i==j:
            j = i+1
print(count)

Measured memory_bytes: 22188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
using namespace std;

int main()
{
	int n, cnt = 0, sum = 0,digit=0;
	cin >> n;
	for (int i = 0;; i++) {
		if (pow(10, i) <= n)digit++;
		else { break; }
	}
	for (int i = 1; i <= digit; i++) {
		if (i % 2 == 0)continue;
		else {
			if (pow(10,i)>n) {
				sum += n - pow(10, i - 1) + 1;
			}
			else {
				sum += 9 * pow(10, cnt);
				cnt+=2;
			}
		}
	}
	cout << sum << endl;
}

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

int main(){
  int N; cin>>N;
  int A[N]; rep(i,N) cin>>A[i];
  int ans=0;
  for(int i=1;i<N;i++){
    if(A[i]==A[i-1]){
      A[i]=0;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f//3f3f3f3f
#define ll long long
#define ull unsigned long long
#define lowbit(a) ((a)&(-(a)))
using namespace std;
struct number{
    int cnt;
    int c[10];
    bool operator < (const number &b)const{
        if(cnt == b.cnt){
            for(int i = 9;i>=1;i++){
                if(c[i] == b.c[i])continue;
                return c[i] < b.c[i];
            }
            return false;
        }else{
            return cnt < b.cnt;
        }
    }
    void add(int x){
        c[x] ++, cnt ++;
    }
    void sub(int x){
        c[x] --, cnt --;
    }
    void init(){
        cnt = 0; memset(c,0,sizeof c);
    }
    void println(){
        for(int i = 9;i>=1;i--)
            for(int j = 0;j < c[i];j++)putchar((char)i+'0');
        putchar('\n');
    }
};
int n,m,u[10] = {0,2,5,5,4,5,6,3,7,6}, a[10], d[10];
vector<int> v;
number ans, now;
void dfs(int cnt, int k){
    if(now < ans && cnt > 100)return;
    if(cnt == 0){
        if(ans < now)ans = now;
        return;
    }
    for(int i = k;i<=7;i++){
        if(i > cnt)return;
        if(d[i] == 0)continue;
        now.add(d[i]);
        dfs(cnt - i,i);
        now.sub(d[i]);
    }
}
int main() {
    while(~scanf("%d %d",&n,&m)){
        memset(d,0,sizeof d);
        v.clear();
        for(int i = 1;i<=m;i++)scanf("%d",&a[i]), d[u[a[i]]] = max(a[i], d[u[a[i]]]);
        ans.init(); now.init();
        dfs(n,2);
        ans.println();
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

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

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;
typedef pair<Pa, ll> info;

info infos[100];
int main() {
	cin >> N;
    ll min_h = 1e9, max_h = 0;
    rep(i, N){
        cin >> A >> B >> C;
        infos[i] = info(Pa(A, B), C);
        min_h = min(min_h, C);
        max_h = max(max_h, C);
    }
    rep(x, 101){
        rep(y, 101){
            for(ll h = max_h; h<min_h + 201;h++){
                bool flag = true;
                rep(i, N){
                    flag &= (max(0ll, (h - abs(infos[i].first.first - x) - abs(infos[i].first.second - y))) == infos[i].second);
                }
                if(flag){
                    cout << x << " " << y << " " << h;
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()

t = [0] * N
t[0] = 0
for i in range(1,N):
    if S[i-1] == 'A' and S[i] == 'C':
        t[i] = t[i-1] + 1
    else:
        t[i] = t[i-1]

ans = []
for _ in range(Q):
    l, r = map(int, input().split())
    ans.append(t[r-1] - t[l-1])

for a in ans:
    print(a)


Measured memory_bytes: 10280
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

ll tmp[200001];
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int R = getint(), C = getint(), N = getint();
	int RC3 = R + C + R;
	int RC4 = R + C + R + C;
	ll A[200000];
	int k = 0;
	rep(i, N) {
		int x = getint(), y = getint();
		int mae = k;
		ll k2 = ll(i) << 32;
		if (y == 0) A[k++] = k2 + x;
		else if (x == R) A[k++] = k2 + y + R;
		else if (y == C) A[k++] = k2 - x + RC3;
		else if (x == 0) A[k++] = k2 - y + RC4;
		x = getint();
		y = getint();
		if (y == 0) A[k++] = k2 + x;
		else if (x == R) A[k++] = k2 + y + R;
		else if (y == C) A[k++] = k2 - x + RC3;
		else if (x == 0) A[k++] = k2 - y + RC4;
		if (mae + 2 != k) k = mae;
	}

	pakuri_sort(k, A);

	int kazu = 0;
	memset(tmp, 0, sizeof(tmp));
	int OK = 1;
	rep(i, k) {
		int j = A[i] >> 32;
		if (tmp[j]) {
			if (tmp[j] != kazu--) OK = 0;
		}
		else tmp[j] = ++kazu;
	}

	if (OK) printf("YES\n");
	else printf("NO\n");

	Would you please return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 2e9+7;
const ll  longinf = 1LL<<62;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};



int main(){
  int n,k;
  cin>>n>>k;
  ll x[n],y[n];
  vector<ll> xx,yy;
  rep(i,n){
    cin>>x[i]>>y[i];
    xx.push_back(x[i]);
    yy.push_back(y[i]);
    }
  sort(xx.begin(),xx.end());
  sort(yy.begin(),yy.end());
  ll ans=longinf;
  rep(i,n)REP(j,i+1,n)rep(l,n)REP(m,l+1,n){
    int cnt=0;
    rep(t,n){
      if(xx[i]<=x[t]&&x[t]<=xx[j]&&yy[l]<=y[t]&&y[t]<=yy[m])
        cnt++;
      }
    if(cnt>=k)ans=min(ans,(xx[j]-xx[i])*(yy[m]-yy[l]));
    }
  cout<<ans<<endl;
  return 0;
                                                
  }

Measured memory_bytes: 384
def lcs(X, Y):
    costs = [0]
    for c in Y:
        for i in range(len(costs) - 1, -1, -1):
            tmp = X.find(c, costs[i])
            if tmp + 1:
                if i + 1 < len(costs):
                    costs[i + 1] = min(costs[i + 1], tmp + 1)
                else:
                    costs.append(tmp + 1)
    return len(costs) - 1

n = int(input())
for _ in range(n):
    X, Y = (input() for _ in range(2))
    print(lcs(X, Y))

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



int main() {
	// your code goes here
	vector<long long int> vec,sums;
	long long int sum=0;
	long long int ans=0;
	long long int n,x;
	cin>>n>>x;
	for(int i=0;i<n;i++){
		long long int a;
		cin>>a;
		vec.push_back(a);
		sum+=a;
		sums.push_back(sum);
	}
	reverse(vec.begin(),vec.end());
	reverse(sums.begin(),sums.end());
	sums.push_back(0);
	ans=sum*5+x*2*n;
	if(n==1){
		cout<<ans<<"\n";
	}else if(n==2){
		cout<<sum*5+x*3;
	}else{
		for(int i=1;i<n;i++){
			long long int top=(sums[0]-sums[i])*5+x*i+x*n;
			long long int t2=5;
			for(int j=i;j<n;j+=i){
				if(j+i<n){
					top+=(sums[j]-sums[j+i])*t2;
				}else{
					top+=(sums[j])*t2;
				}
				t2+=2;
				//cout<<top<<" ";
				if(top>ans)break;
			}
			
			if(top<ans)ans=top;
		}
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
 
using namespace std;
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
	if(a>b)
		return a;
	return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
 
 
 
int main()
{
	
	int h,n;
    cin>>h>>n;
    vector <pair<int,int> > v(n);
    for(int i=0;i<n;i++)
        cin>>v[i].first>>v[i].second;
    vector <int> dp(h+1);
    dp[0]=0;
    for(int i=1;i<=h;i++)
    {
        dp[i]=INT_MAX;
        for(int j=0;j<n;j++)
        {
            if(i-v[j].first<=0)
                dp[i]=min(dp[i],v[j].second);
            else
                dp[i]=min(dp[i],v[j].second+dp[i-v[j].first]);
        }
    }
    cout<<dp[h]<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define M 100
#define I (1<<21)
#define W 0
#define G 1
#define B 2

int n,A[M][M];

int prim(){
    int u,mv,i,x,sum;
    int d[M],p[M],clr[M];

    for(i=0;i<n;i++){
        d[i]=I;
        p[i]=-1;
        clr[i]=W;
    }
    d[0]=0;

    while(1){
        mv=I;
        u=-1;
        for(i=0;i<n;i++){
            if(mv > d[i] && clr[i] != B){
                u=i;
                mv=d[i];
            }
        }
        if(u == -1)break;
        clr[u]=B;
            for(x=0;x<n;x++){
                if(clr[x] != B && A[u][x] != I){
                    if(d[x]>A[u][x]){
                        d[x]=A[u][x];
                        p[x]=u;
                        clr[x]=G;
                    }
                }
            }
    }
    sum = 0;
    for(i=0;i<n;i++){
        if(p[i] != -1)sum += A[i][p[i]];
    }

    return sum;
}

int main(){
    int i,j,k;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            scanf("%d",&k);
            A[i][j]=(k==-1)?I:k;
        }
    }
    printf("%d\n",prim());

    return 0;
}



Measured memory_bytes: 2052
#include<stdio.h>
int main(void){
  int m,f,r;
  do{
    scanf("%d%d%d",&m,&f,&r);
    if(m==-1&&f==-1&&r==-1)
      break;
    if(m==-1||f==-1)
      printf("F\n");
    else{
      if(m+f>=80)
        printf("A\n");
      else if(m+f>=65)
        printf("B\n");
      else if(m+f>=50)
        printf("C\n");
      else if(m+f>=30){
        if(r>=50)
          printf("C\n");
      else
        printf("D\n");
      }
      else
        printf("F\n");
    }
  }while(m!=-1||f!=-1||r!=-1);
  return 0;
}

Measured memory_bytes: 584
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#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++)
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;

int main(void) {

	string w;
	cin >> w;

	map <char, int> a = {};
	REP(i, w.size()) {
		a[w[i]]++;
	}
	REP(i, 27) {
		if (a[w[i]] % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<ll>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 1000000007
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000


int main(void) {
	string s;
	cin >> s;
	rep(i, 3) {
		cout << s[i];
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    int N;
    cin >> N;
    ll a[N], b[N];
    for (int i = 0; i < N; i++)
        cin >> a[i] >> b[i];

    ll n = 1;
    ll x = 1, y = 1;
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            n = 1;
        } else {
            n = max((a[i - 1] * n + a[i] - 1) / a[i],
                    (b[i - 1] * n + b[i] - 1) / b[i]);
        }
        x = a[i] * n;
        y = b[i] * n;
    }
    cout << x + y << endl;

    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

ll gcd(ll a, ll b){
    a = abs(a);
    b = abs(b);

    while(b != 0){
        ll t = a;
        a = b;
        b = t%b;
    }

    return a;
}

int main(){
    int N, X; cin >> N >> X;
    vector<ll> x(N);
    for(int i=0; i<N; i++){
        ll a; cin >> a;
        a -= X;
        x[i] = a;
    }

    ll ans = x[0];
    for(int i=0; i<N; i++) ans = gcd(ans, x[i]);
    

    cout << ans << endl;
}

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

using namespace std;

int dp[3010][3010];



int lcs(string a, string b) {
    
    memset(dp, 0, sizeof(dp));

    int n = a.size();
    int m = b.size();
    for(int i = 1 ; i <= n ; i++) {
        for(int j = 1 ; j <= m ; j++) {
            if(i == 0 or j == 0)
                dp[i][j] = 0;
            else {
                if(a[i - 1] == b[j - 1])    
                    dp[i][j] = 1 + dp[i - 1][j - 1];
                else 
                    dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    } 

    // for(int i = 0 ; i <= n ; i++) {
    //     for(int j = 0 ; j <= m ; j++) {
    //         cout << dp[i][j] << ' ';
    //     }cout << '\n';
    // }

    return dp[n][m];
}

int main() {
    string a, b;
    cin >> a >> b;
    lcs(a,b);
    string res;

    int i = a.size(), j = b.size();
    while(i >= 1 and j >= 1) {
        if(a[i - 1] == b[j - 1]) {
            res.push_back(a[i - 1]);
            i--;j--;
        }
        else if(dp[i - 1][j] > dp[i][j - 1])
            i--;
        else 
            j--;
    }
    reverse(res.begin(),res.end());
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 35712
/*
 * ABC101 B
 */

#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>

using namespace std;

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

int main()
{
	int n, x, sum;

	cin >> n;
	x = n;

	while(x > 0)
	{
		sum = sum + x%10;
		x = x/10;
	}


	if(n%sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
package main
import(
  "fmt"
)
func main(){
  var n, i int
  count:=0
  fmt.Scan(&n)
  a:=make([]int, n)
  for i=0;i<n;i++{
    fmt.Scan(&a[i])
    if a[i]%2==1{
      count++
    }
  }
  if count%2==1{
    fmt.Println("NO")
  }else{
    fmt.Println("YES")
  }
}


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

int main()
{
    int X;
    cin>>X;
    
    if(360%X==0)
    {
        cout<<360/X<<endl;
    }
    else
    {
       int Z=360;
       int tot=0;
       int c=0;
       while(1)
       { 
           tot+=X;
           c++;
           if(tot%360==0)
           {
               
               break;
           }
       }
       cout<<c<<endl;
    }
    
}

Measured memory_bytes: 3624
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)
	
using namespace std;

typedef pair<ll, ll> pll;	typedef pair<int, int> ii;
typedef vector<pll> vll;	typedef vector<string> vs;		typedef vector<ii> vii;
typedef vector<int> vi; 	typedef vector<ll> vl;

///=====code start here=====///

signed main() {
	fastio;
	int k; string s; cin >> k >> s;
	int n = s.length();
	int lim = min(n, k);
	rep(i, 0, lim) {
		cout << s[i];
	}
	if(n > k) cout << "...";
	return 0;
}


Measured memory_bytes: 3584
from collections import Counter
from math import factorial
N = int(input())
MOD = 10 ** 9 + 7

def prime(n):
    b = 2
    while b * b <= n:
        while n % b == 0:
            n //= b
            a.append(b)
        b += 1
    if n > 1:
        a.append(n)

a = []
prime(factorial(N))
A = Counter(a)
X = 1
for k, v in A.items():
    X *= (v + 1) % MOD
print(X % MOD)

Measured memory_bytes: 9420
num = (int)(input())
a = (list(map(int, input().split(" "))))
fu = 1
for i in range(num):
  if a[i] < 0:
    fu *= -1
    a[i] *= -1
  
print(sum(a) if fu == 1 else sum(a) - min(a) * 2)

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] nk = sc.nextLine().split(" ");
        int n = Integer.parseInt(nk[0]);
        int k = Integer.parseInt(nk[1]);

        int[] heights = new int[n];

        String[] ss = sc.nextLine().split(" ");
        for(int i = 0; i < n; i++) {
            heights[i] = Integer.parseInt(ss[i]);
        }

        sc.close();
        System.out.println(frog(n, k, heights));
    }

    public static int frog(int n, int k, int[] heights) {
        if(n == 0 || n == 1)    return 0;

        int[] dp = new int[n];
        dp[0] = 0;
        for(int i = 1; i <= k && i < n; i++) {
            dp[i] = Math.abs(heights[i] - heights[0]);
        }

        for(int i = 2; i < n; i++) {
            int min = Integer.MAX_VALUE;
            for(int j = 1; j <= k && j <= i; j++) {
                min = Math.min(Math.abs(heights[i] - heights[i - j]) + dp[i - j], min);
            }
            dp[i] = min;
        }
        return dp[n - 1];
    }
}



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

int main(){
  int n;
  long long dp[300];

  for(int i=1;i<300;i++)dp[i] = 0;
  dp[0] = 1;

  for(int i=1;i<=17;i++){
    for(int j=0;j<300-i*i;j++){
      if(dp[j])dp[j+i*i] += dp[j];
    }
  }

  while(scanf("%d",&n) && n)printf("%d\n",dp[n]);
}

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

int main(){
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    int m;
    cin >> m;
    while(m--){
        int x, y;
        cin >> x >> y;
        x--, y--;
        arr[x]++, arr[y]++;
    }
    int f = 0;
    for(int i = 0; i < n; i++){
        if(arr[i] %2 == 1) f = 1;
    }
    cout << (f == 1? "NO" : "YES");
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	ll N,K; cin >> N >> K;
	ll x[100],y[100];
	map<ll,ll> mpx,mpy; //val,point
	for (int i = 0;i < N;i++){
		cin >> x[i] >> y[i];
		mpx[x[i]] = i;
		mpy[y[i]] = i;
	}

	ll cmpx[100],cmpy[100];
	ll memox[100],memoy[100];

	ll cnt = 1;
	for(auto&& i:mpx){
		cmpx[i.second] = cnt;
		memox[cnt] = i.first;
		cnt++;
	}
	cnt = 1;
	for(auto&& i:mpy){
		cmpy[i.second] = cnt;
		memoy[cnt] = i.first;
		cnt++;
	}

	ll p[100][100]; memset(p,0,sizeof(p));
	for (int i = 0;i < N;i++){
		p[cmpy[i]][cmpx[i]]++;
	}

	ll sum[100][100]; memset(sum,0,sizeof(sum));

	for (int i = 1;i < 100;i++){
		for (int j = 1;j < 100;j++){
			sum[i][j] = p[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
		}
	}

	ll ans = LLONG_MAX;

	for (int x1 = 1;x1 <= N;x1++){
		for (int y1 = 1;y1 <= N;y1++){
			for (int x2 = x1+1;x2 <= N;x2++){
				for (int y2 = y1+1;y2 <= N;y2++){
					ll num_P = sum[y2][x2]-sum[y1-1][x2]-sum[y2][x1-1]+sum[y1-1][x1-1];
					if(num_P >= K){
						ll l1 = abs(memox[x2]-memox[x1]);
						ll l2 = abs(memoy[y2]-memoy[y1]);
						ans = min(ans,l1*l2);
					}
				}
			}
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int main(){
  int a[4]={0,0,0,0};
  int b[3][2];
  for(int i=0;i<3;i++){
    for(int j=0;j<2;j++){
      cin>>b[i][j];
      a[b[i][j]-1]++;
    }
  }
  sort(a,a+4);
  if(a[0]==1 && a[1]==1 && a[2]==2 && a[3]==2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

typedef long long   signed int LL;
typedef long long unsigned int LU;

template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

template<typename T> LL m_sort_(T a[], T b[], int l, int r, bool as) {
	if(r - l < 2) { return 0; }
	
	LL s = 0;
	int m = (l + r) / 2;
	s += m_sort_(a, b, l, m, as);
	s += m_sort_(a, b, m, r, as);
	
	int ll = l, rr = m, bb = 0;
	while(bb < r - l) {
		bool l_flag;
		if(rr == r || ll == m) { l_flag = (rr == r); }
		else { l_flag = ( as ? (a[ll] <= a[rr]) : (a[rr] <= a[ll]) ); }
		
		if(l_flag) { s += rr - m; }
		b[bb++] = (l_flag ? a[ll++] : a[rr++]);
	}
	
	for(int i = l; i < r; i++) { a[i] = b[i - l]; }
	return s;
}
template<typename T> LL m_sort(T a[], int l, int r, bool as = true) {
	T *b = new T[r - l];
	LL temp = m_sort_(a, b, l, r, as);
	delete[] b;
	return temp;
}


int n, a[3][100000];

int main() {
	scanf("%d", &n);
	inc(i, 3) {
	inc(j, n) {
		scanf("%d", &a[i][j]); a[i][j]--;
	}
	}
	
	bool ans = true;
	inc(i, n) {
		int x = a[0][i];
		int y = a[1][i];
		int z = a[2][i];
		
		if(y % 3 == 1 && (y / 3) % 2 == i % 2 && x / 3 == y / 3 && y / 3 == z / 3) { } else { ans = false; break; }
	}
	
	if(ans) {
		int me = 0, mo = 0;
		inc(i, n) {
			if(i % 2 == 0) { if(a[0][i] > a[2][i]) { me++; } }
			if(i % 2 == 1) { if(a[0][i] > a[2][i]) { mo++; } }
		}
		
		int b[100000];
		int c[100000];
		inc(i, n) {
			if(i % 2 == 0) { b[i / 2] = a[1][i]; }
			if(i % 2 == 1) { c[i / 2] = a[1][i]; }
		}
		
		int ie = m_sort(b, 0, (n + 1) / 2);
		int io = m_sort(c, 0, (n + 0) / 2);
		
		me %= 2;
		mo %= 2;
		ie %= 2;
		io %= 2;
		ans = (me == io && mo == ie);
	}
		
	printf("%s\n", ans ? "Yes" : "No");
	
	return 0;
}


Measured memory_bytes: 2048
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<Integer> hashSet = new HashSet<Integer>();

        for (int i = 0; i < n; i++) {
            hashSet.add(sc.nextInt());
        }

        int ans = hashSet.size();

        System.out.println(ans);
    }

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)


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

	ll S,W;
	cin >> S >> W;
	if (S <= W) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}
}


Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define sc(x) scanf("%d", &x)
#define sc2(x, y) scanf("%d%d", &x, &y)
#define sc3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define sc4(x, y, z, t) scanf("%d%d%d%d", &x, &y, &z, &t)
#define print(x) printf("%d ", x)
#define println(x) printf("%d\n", x)
#define println2(x, y) printf("%d %d\n", x, y)
#define println3(x, y, z) printf("%d %d %d\n", x, y, z)
#define println4(x, y, z, t) printf("%d %d %d %d\n", x, y, z, t)
#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define endl '\n'                           // CommentInInteractive
#define DB(x) cerr << #x << " = " << x << endl

const ld eps = 1e-6;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;

void solve() {
    string s_mid;
    cin >> s_mid;
    int q;
    cin >> q;
    string s_begin, s_end;
    bool rev = false;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) rev = !rev;
        else {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1) {
                if (rev) {
                    s_end += c;
                } else s_begin.insert(s_begin.begin(), c);
            } else {
                if (rev) {
                    s_begin.insert(s_begin.begin(), c);
                } else s_end += c;
            }
        }
    }
    if (rev) {
        string s = s_begin + s_mid + s_end;
        reverse(all(s));
        cout << s << endl;
    } else cout << s_begin + s_mid + s_end << endl;
}

//#define FILES
//#define TIME

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

#ifdef FILES
    freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    auto start = chrono::high_resolution_clock::now();
    solve();
    auto stop = chrono::high_resolution_clock::now();

#ifdef TIME
    cerr << chrono::duration_cast <chrono::milliseconds> (stop - start).count() << " ms\n";
#endif
    return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)
#define Reps(i, x, N) for(int i = x; i < N; i++)

const int LLINF = 1LL << 60;

int A, B, C;

int check(int val) {
  Reps(i, 1, A * 10 + 1) {
    int v = 100 * i / A + i;
    if(100 * i % A) v++;
    if(val == v - 1) return -1;
    if(val < v) return i - 1;
  }
}

signed main()
{  

  while(cin >> A >> B >> C, A || B || C) {
    int maxv = -LLINF;
    Reps(i, 1, C) {
      
      int a = check(i), b = check(C - i);
      if(!~a || !~b) continue;
      a = i - a, b = C - i - b;
      //cout << a << " " << b << " " << i << " " << C - i << endl;
      maxv = max(a * (100 + B) / 100 + b * (100 + B) / 100, maxv);
      //cout << maxv << endl;
    }
    cout << maxv << endl;
  }

  return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	vector<int> rec;
	rep(i, n) {
		if (s[i] == t[i]) rec.push_back(1);
		else rec.push_back(2), ++i;
	}
	ll ans = 1;
	if (rec.front() == 2) ans *= 6;
	else ans *= 3;
	int sz = rec.size();
	rrep(i, sz) {
		if (rec[i] == 1) {
			if (rec[i - 1] == 1) ans *= 2;
		}
		else {
			if (rec[i - 1] == 1) ans *= 2;
			else ans *= 3;
		}
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  string N;
  cin >> N;
  N = "0" + N;

  int L = N.size();

  const int INF = 1e9;
  vector<vector<int>> dp(L + 1, vector<int>(2, INF));
  dp[0][0] = 0;
  reverse((N).begin(), (N).end());
  for (int i = 0; i < (int)L; ++i) {
    int k = N[i] - '0';
    for (int j = 0; j < (int)2; ++j) for (int d = 0; d < (int)10; ++d) {
      int nj = 0, nd = d - j, c = d;
      if (nd < k) {
        nj = 1;
        c += 10 + nd - k;
      } else {
        c += nd - k;
      }

      if (dp[i][j] != INF) chmin(dp[i + 1][nj], dp[i][j] + c);
    }
  }

  cout << dp[L][0] << endl;

  return 0;
}


Measured memory_bytes: 55856
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int p, q; cin >> p >> q;
    int g = __gcd(p, q);
    q /= g;
    int ans = 1;
    for(int i=2; i*i<=q; i++) {
        if(q % i == 0) {
            ans *= i;
            while(q % i == 0) q /= i;
        }
    }
    ans *= q;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3104
<?php
// C
fscanf(STDIN, '%d %d', $N, $X);
$x = array_map('intval', explode(' ', trim(fgets(STDIN))));
$gcd = abs($x[0] - $X);
for ($i = 0; $i < $N; $i++) {
    $gcd = gcd($gcd, abs($x[$i] - $X));
}
echo $gcd;

// 最大公約数（2つ）
function gcd($m, $n)
{
    if (!$n) return $m;
    return gcd($n, $m % $n);
}

Measured memory_bytes: 17012
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.MArray as MA
import Control.Monad.ST



readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

solve :: Int -> [Int] -> [(Int, Int)] -> Int
solve n heights' abl = let 
    heights = IM.fromList $ zip [1..] heights'
    updator from to m = M.alter (\case 
            Nothing -> Just [to]
            Just l -> Just $ to : l
        ) from m
    paths = foldl' (\m (from, to) -> updator to from $ updator from to m) M.empty abl
    isGood i = case M.lookup i paths of
        Nothing -> True
        Just ps -> let
            myHeight = heights IM.! i
            in
            all ((myHeight > ) . (heights IM.!)) ps
    in 
    length $ filter isGood [1..n]


main :: IO ()
main = do
    (n, m) <- readTuple2
    heights <- readInts
    abl <- replicateM m readTuple2
    print $ solve n heights abl





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

const ll M = 1000000007;
vector<ll> fac(100005);
vector<ll> ifac(100005);

//べき乗高速化
ll mpow(ll x, ll n){
	ll ans = 1;
	while(n != 0){
		if (n&1) ans = ans * x % M;
		x = x*x % M;
		n  = n >> 1;
	}
	return ans;
}

//aCbを計算
ll comb(ll a, ll b){
	if (a == 0 && b == 0) return 1;
	if (a < b || a < 0){
		return 0;
	}
	ll temp = ifac[a-b] * ifac[b] % M;
	return temp * fac[a] % M;
}

int main(){
	ll n,k; cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(),a.end());
	
	ll ans = 0;
	
	fac[0] = 1;
	ifac[0] = 1;
	for(ll i = 0; i<= 100005; i++){
		fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
		ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
	
	rep(i,n){
		ans += a[i]*comb(i,k-1);
		ans %= M;
		ans -= a[i]*comb(n-i-1, k-1);
		ans %= M;
	}
	
	ans %= M;
	cout << ans << endl;
	
    return 0;
}



Measured memory_bytes: 2176
# -*- coding: utf-8 -*-
numbers = {str(i) for i in range(10)}
N, K = map(int, input().split())
*D, = map(str, input().split())
D = set(D)
available = numbers - D
ans = 0
for i in range(N, 100000):
    nums = set(str(i))
    if nums <= available:
        print(i)
        break

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

int main() {
  int H, W;
  scanf("%d %d\n", &H, &W);
  int S[H][W];
  char c;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      scanf("%c", &c);
      if (c == '#') {
        S[i][j] = 1;
      } else {
        S[i][j] = 0;
      }
    }
    scanf("%c", &c);
  }

  int vert[H][W], horizon[H][W];
  int start, count;
  for (int i=0; i<H; i++) {
    count = 0;
    start = 0;
    for (int j=0; j<W; j++) {
      if (S[i][j] == 0 && j<(W-1)) {
        count++;
      } else if (S[i][j] == 0 && j==(W-1)) {
        count++;
        for (int k=start; k<=j; k++) horizon[i][k] = count;
      } else {
        if (count > 0) {
          for (int k=start; k<j; k++) horizon[i][k] = count;
        }
        horizon[i][j] = 0;
        count = 0;
        start = j + 1;
      }
    }
  }
  for (int j=0; j<W; j++) {
    count = 0;
    start = 0;
    for (int i=0; i<H; i++) {
      if (S[i][j] == 0 && i<(H-1)) {
        count++;
      } else if (S[i][j] == 0 && i==(H-1)) {
        count++;
        for (int k=start; k<=i; k++) vert[k][j] = count;
      } else {
        if (count > 0) {
          for (int k=start; k<i; k++) vert[k][j] = count;
        }
        vert[i][j] = 0;
        count = 0;
        start = i + 1;
      }
    }
  }
  int len_max = 0;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if ((vert[i][j] + horizon[i][j]-1) > len_max) {
        len_max = vert[i][j] + horizon[i][j] - 1;
      }
    }
  }
  printf("%d\n", len_max);
}


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

const int inf = 10, maxn = 1e5;

int ans;

namespace MCMF{
	int head[maxn], nxt[maxn], to[maxn], c[maxn], r[maxn], tot = 1;
	void add(int u, int v, int w, int f) {
		assert(++tot < maxn);
		nxt[tot] = head[u];
		to[tot] = v;
		c[tot] = w;
		r[tot] = f;
		head[u] = tot;
	}
	void add2(int u, int v, int w, int f) {
		add(u,v,w,f), add(v,u,-w,0);
	}
#define mp make_pair
	typedef pair<long long, int> qnode;
	int dis[maxn], inq[maxn], pre[maxn];
	void spfa(int s) {
		memset(dis, 0x3f, sizeof(dis));
		memset(pre, 0, sizeof(pre));
		queue<int> q;
		dis[s] = 0;
		q.push(s);
		while (!q.empty()) {
			int u = q.front();
			q.pop(); inq[u] = 0;
			for (int e = head[u]; e; e = nxt[e]) {
				if (!r[e]) continue;
				int v = to[e], w = c[e];
				if (dis[u]+w < dis[v]) {
					pre[v] = e;
					dis[v] = dis[u]+w;
					if (!inq[v]) {
						q.push(v);
						inq[v] = 1;
					}
				}
			}
		}
	}
	void augment(int t) {
		int flow = inf;
		for (int e = pre[t]; e; e = pre[to[e^1]]) {
			flow = min(flow, r[e]);
		}
		for (int e = pre[t]; e; e = pre[to[e^1]]) {
			r[e] -= flow;
			r[e^1] += flow;
		}
		ans += flow*dis[t];
	}
}
using namespace MCMF;


int n, rx[maxn], ry[maxn], rc[maxn], bx[maxn], by[maxn], bc[maxn];
signed main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> rx[i] >> ry[i] >> rc[i];
		add2(1, i+10, 0, rc[i]);
		add2(i+10, 3, rx[i]+ry[i], inf);
		add2(i+10, 4, rx[i]-ry[i], inf);
		add2(i+10, 5, -rx[i]+ry[i], inf);
		add2(i+10, 6, -rx[i]-ry[i], inf);
	}
	for (int i = n; i < 2*n; ++i) {
		cin >> bx[i] >> by[i] >> bc[i];
		add2(3, i+10, -bx[i]-by[i], inf);
		add2(4, i+10, -bx[i]+by[i], inf);
		add2(5, i+10, bx[i]-by[i], inf);
		add2(6, i+10, bx[i]+by[i], inf);
		add2(i+10, 2, 0, bc[i]);
	}
	while (spfa(1), pre[2]) augment(2);
	cout << -ans;
}

Measured memory_bytes: 8448
#include <stdio.h>

int main(void)
{
    int a[3],max = 0,i,co = 0;
    for (i = 0; i < 3; i++) {
        scanf("%d",&a[i]);
        if (a[i] > max) {
            max = a[i];
        }
        co += a[i];
    }
    printf("%d\n",co - max);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;
int main(){
	ll n;
	std::cin >> n;
	std::vector<ll> a(n);
	rep(i,n)std::cin >> a[i];
	ll ans=INF64;
	ll snuke=0ll,kuma=sum(all(a),0ll);
	rep(i,n-1){
		snuke+=a[i];
		kuma-=a[i];
		ans=min(ans,abs(snuke-kuma));
	}
	std::cout << ans << std::endl;
}

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

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

  string s; cin >> s;
  for(char c = 'a'; c <= 'z'; ++c) {
    bool flag = false;
    rep(i, s.length()) {
      if(c == s[i]) flag = true;
    }
    if(!flag) {
      cout << c << '\n';
      return 0;
    }
  }
  cout << "None" << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <iostream>

int main()
{
	int x, y;
	bool ans=false;
	std::cin >> x >> y;
	for (int i = 0; i <= x; i++)
	{
		if (i * 2 + (x - i) * 4 == y)
		{
			ans = true;
			break;
		}
	}
	std::cout << (ans ? "Yes" : "No") << std::endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int r;
    cin >> r;
    cout << r*r*3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<utility>
#include<algorithm>
using namespace std;

int main(void)
{
	int N, M;
	cin >> N >> M;

	vector < pair<long long, long long>> ab(N);
	for (int i = 0; i < N; i++) {
		cin >> ab[i].first >> ab[i].second;
	}

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

	long long ans = 0;
	for (int i = 0; M && i < N; i++) {
		if (ab[i].second < M) {
			ans += ab[i].first * ab[i].second;
			M -= ab[i].second;
		}
		else {
			ans += ab[i].first * M;
			M = 0;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;
long long a[1<<18];

struct BestTwo {
    int id[2];
    BestTwo(){ id[0] = id[1] = -1; }


    void add(int x){
        if( x == -1 ) return;

        if( id[0] == x || id[1] == x ) return;

        if( id[0] == -1 ){
            id[0] = x;
            return;
        }
        if( id[1] == -1 ){
            id[1] = x;
            return;
        }

        if( a[id[0]] < a[id[1]] ) swap(id[0], id[1]);
        if( a[id[0]] < a[x] ){
            id[1] = id[0];
            id[0] = x;
            return;
        }
        if( a[id[1]] < a[x] ){
            id[1] = x;
            return;
        }
    }
    long long get(){
        return a[id[0]] + a[id[1]];
    }
};
BestTwo dp[1<<18];

int main(){
    int N;
    cin >> N;
    for(int i = 0 ; i < (1<<N) ; i++){
        cin >> a[i];
        dp[i].add(i);
    }
    for(int i = 0 ; i < (1<<N) ; i++){
        for(int j = 0 ; j < N ; j++){
            dp[i|(1<<j)].add(dp[i].id[0]);
            dp[i|(1<<j)].add(dp[i].id[1]);
        }
    }
    for(int i = 1 ; i < (1<<N) ; i++){
        long long ans = dp[i].get();

        for(int j = N - 1 ; j >= 0 ; j--){
            if( i >> j & 1 ){
                int bit = (i ^ (1<<j)) | ((1<<j)-1);
                if( bit > 0 ) ans = max(ans, dp[bit].get());
            }
        }
        cout << ans << endl;
    }


}

Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array
const ll mod=998244353;

int main() {
	ll n, k;
	cin >> n >> k;
	ll s[k][2];
	for (int i=0; i<k; i++) {
		cin >> s[i][0] >> s[i][1];
	}
	vector<ll> p(n+1, 0);
	p[1]=1LL;
	for (ll i=2; i<=n; i++) {
		p[i]+=p[i-1];
		p[i]%=mod;
		for (ll j=0; j<k; j++) {
			ll x=s[j][0], y=s[j][1];
			if (i-x>=1) p[i]+=(p[i-x]-p[i-min(y, i-1)-1]+mod)%mod;
			p[i]%=mod;
		}
		p[i]%=mod;
	}
	cout << (p[n]-p[n-1]+mod)%mod;
	return 0;
}

Measured memory_bytes: 4836
using System;
using System.Collections.Generic;//list用
using System.Text.RegularExpressions;//正規表現用
using System.Text;//StringBuilder用
using System.Collections;//ハッシュテーブル用
using System.Linq;
//デリゲータの使い方をマスターしたい

class Program
{
    Hashtable ht = new Hashtable();
    static List<double> s = new List<double>();
    static double result;
    static int K;
    StringBuilder strresult= new StringBuilder("");//Append(str ○○)関数で文字を追加していく



    static void Main()
    {
        //Modular mo = new Modular();//素数で割った余りを出せで使う★使い方：Modular型で宣言すると、その時点でのその素数で割った余りを保持する変数になる（powべき乗、Fac累乗、nCr組み合わせも関数として存在）()内は初期値
        //Node no = new Node<>();//UnionFind★Find関数で根っこの値を返す（根っこの値が一緒なら同グループ）、Unite関数で二つの木をくっつける
        //Permutation pe = new Permutation<>();//配列＆リストを並べ替えた場合の全ケースを出力★All関数でリスト形式で返す。
        //Treap tr = new Treap<>();//平衡二分木★Insert()関数で挿入、FindIndex()関数で該当する大きさの物が入るべき配列番号を返す。
        // delegate int CFunc();//下関数に使うデリゲータ。コイツと同じ引数と戻り値で関数作って、下の評価式の部分に関数名※（）いらないを入れる。
        //PriorityQueue pr = new PriorityQueue<>(評価式);//優先度付キュー★Enqueue()で格納、Dequeue()で取りだし。引数は評価式（大と小のどちらが優先か）。
        Read1();
        Read2(K);
      for(int i=0;i<K;i++){
        s.Sort();
        if(s[1]!=1001){
        s[0]=(double)(s[0]+s[1])/2;
        s[1]=1001;
        }
        }

      result=s[0];
      
      
        Console.WriteLine(result.ToString());
    }


    static void Read1()
    {
        string tmp = Console.ReadLine();
        K = int.Parse(tmp);
    }

    static void Read2(int kosuu)
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < kosuu; i++) { s.Add(double.Parse(tmp[i])); }
    }
}

Measured memory_bytes: 11348