akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
  
int main(void)
{   int a,b,i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+')
        {printf("%d\n",a+b);
        }
        else if(op=='-')
        {printf("%d\n",a-b);
        }
        else if(op=='*')
        {printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }else if(op=='?') {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;

    vector<pair<int, int>> l;
    for(int i=0; i<N; i++){
        int a, b;
        cin >> a >> b;
        l.push_back(make_pair(b, a));
    }

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

    long sum=0;
    for(auto it=l.begin(); it != l.end(); it++){
        sum += it->second;
        if(sum > it->first){
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";

    return 0;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
     
int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    string s1,s2;
    cin >> s1 >> s2;
    int len = max(sz(s1),sz(s2));
    for(int i = 1; i <= len; ++i){
        if(sz(s1) != 0 ){
            cout << s1[0];
            s1.erase(0,1);
        }
        if(sz(s2) != 0){
            cout << s2[0];
            s2.erase(0,1);
        }
    }
}


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

int main(){
    int n = 0, x = 0;
    cin >> n >> x;

    int l[n+1];

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

    int d[n+1];
    d[0] = 0;
    for (int i = 1; i < n+1; i++) {
        d[i] = d[i-1] + l[i-1];
    }

    int count = 0;

    for (auto j: d) {
        if (j <= x) {
            count++;
        }
    }

    cout << count << endl;
}

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

typedef long long int ll;


int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }

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

    ll k = 1;
    for(ll i = 0;i < n - 1;i++){
        if(a[i] != a[i + 1]){
            k++;
        }
    }

    if(k % 2 == 0){
        cout << k - 1;
    }
    else{
        cout << k;
    }


    return 0;
}

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

using namespace std;

#define ll long long

int main()
{
	ll N;
	cin >> N;

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

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

	ll prod = 1;
	for (ll i = 0; i < N; i++) {
		if (A[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
		if (A[i] <= (ll) 1e18 / prod) {
			prod *= A[i];
		} else {
			cout << -1 << endl;
			return 0;
		}

	}

	cout << prod << endl;

	return 0;
}


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

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

const int INF = 100000000;
const double PI=acos(-1);

bool comp(P p1, P p2){
    if (p1.first != p2.first) {
        return p1.first < p2.first;
    }
    else if (p1.second != p2.second) {
        return p1.second > p2.second;
    }
    else {
        return true;
    }
}

int main () {
    int N, M;
    cin >> N >> M;
    int P[M],Y[M];
    vector<vector<int>> a(N,vector<int>(0));
    rep(i,M) {
        cin >> P[i] >> Y[i];
        P[i]--;
        a[P[i]].push_back(Y[i]);
    }
    rep(i,N) {
        if(a[i].size()!=0) {
            sort(a[i].begin(),a[i].end());
        }
    }

    rep(i,M) {
        int idx = lower_bound(a[P[i]].begin(),a[P[i]].end(),Y[i])-a[P[i]].begin();
        idx++;
        int p = P[i];
        p++;
        printf("%06d",p);
        printf("%06d",idx);
        cout << endl;
    }
    
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
if A+B > N:
    if A == 0:
        print(0)
    elif A <= N:
        print(A)
    else:
        print(N)
elif A+B == N:
    print(max(A, 0))
else:
    x, y = divmod(N, A+B)
    if A == 0:
        print(0)
    else:
        if y > A:
            print(x*A+A)
        else:
            print(x*A+y)


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

vector<int> g[100000];

int con[100000] = {};

void dfs(int u, int id)
{
    con[u] = id;

    rep(i, g[u].size())
    {
        if (con[g[u][i]] == 0)
            dfs(g[u][i], id);
    }
}

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

    rep(i, m)
    {
        cin >> s >> t;
        g[s].push_back(t);
        g[t].push_back(s);
    }
    int id = 1;
    rep(i, n)
    {
        if (con[i] == 0)
            dfs(i, id++);
    }

    int q;
    cin >> q;
    rep(i, q)
    {
        cin >> s >> t;
        con[s] == con[t] ? OP("yes") : OP("no");
    }

    return 0;
}


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

int main(){
    int x, y;
    cin >> x >> y;
    int sum = 0;
    if (x == 1)
        sum += 300000;
    if (y == 1)
        sum += 300000;
    if (x == 2)
        sum += 200000;
    if (y == 2)
        sum += 200000;
    if (x == 3)
        sum += 100000;
    if (y == 3)
        sum += 100000;
    if (x == 1 && y == 1)
    {
        sum += 400000;
    }
    cout << sum << endl;
    
}

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

int main() {
	int arr[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	int k;
	std::cin >> k;

	std::cout << arr[k - 1] << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

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

    vl a(n+1);
    exrep(i, 1, n) {
        cin >> a[i];
    }

    vl dp(n+1);  // dp[i] : i日目(iは1-index)終了時点での所持金の最大値
    dp[1] = 1000;
    exrep(i, 2, n) {
        chmax(dp[i], dp[i-1]);
        exrep(j, 1, i-1) {
            chmax(dp[i], (dp[j]/a[j])*a[i] + dp[j]%a[j]);
        }
    }

    out(dp[n]);
    re0;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int f(int f, int t) {
    if (t >= f) {
        return (t - f + 1) / 2 + ((t - f) % 2);
    } else {
        return f - t;
    }
}

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

    int min = 1e8;

    for (int i = 0; i < 100; i++) {
        int d = f(a, i) + f(b, i) + f(c, i);
        if (min > d) {
            min = d;
        }
    }

    cout << min << endl;
}


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

int main(int argc, char const *argv[])
{
    char str[3];
    scanf("%s",&str);
    char a[4],b[4],c[4];
    int x = atoi(str);
    int m = 99999;

    for(char i = '0'; i <= '9'; i++)
    {
        char s[4];
        s[0] = s[1] = s[2] = i;
        s[3] = '\0';
        int y = atoi(s);
        if (x <= y) {
            printf("%d\n",y);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<bits/stdc++.h>
#define f(a,b,c) for(register int a=(b);a<=(c);++a)
#define ff(a,b,c) for(register int a=(b);a>=(c);--a)
#define ll long long
//#define int long long
char pbuf[1<<20],*pp1=pbuf;
inline void push(char c){*pp1=c;pp1=(pp1-pbuf==(1<<20)-1)?(fwrite(pbuf,1,1<<20,stdout),pbuf):(pp1+1);}
#define pc push
//#define pc putchar
#define pe pc('\n')
#define ps pc(' ')
#define wer rd()
char *p1,*p2,buf[1<<20];
#define GC (p1==p2&&(p1=buf,p2=buf+fread(buf,1,1<<20,stdin),p1==p2)?0:(*(p1++)))
//#define GC getchar()
using namespace std;
inline ll wer{
	ll ans;char t,k;
	while(((t=GC)!='-')&&(t>'9'||t<'0'));
	k=(t=='-');
	ans=k?0:(t-'0');
	while((t=GC)>='0'&&t<='9')ans=ans*10+t-'0';
	return k?-ans:ans;
}
inline void wt(ll k)
{
	if(k<0)pc('-'),wt(-k);
	else
	{
		if(k<10)pc('0'+k);
		else wt(k/10),pc('0'+k%10);
	}
	return;
}

int n;ll t1,t2,t3;
ll a[100001],b[100001];
int isp[100001],pr[100001],pt;
void oula()
{
	f(i,2,10005)
	{
		if(isp[i]==0)pr[++pt]=i;
		for(int j=1;j<=pt&&i*pr[j]<=10005;j++)
		{
			isp[i*pr[j]]=1;
			if(i%pr[j]==0)break;
		}
	}
}
vector<int>v;
main()
{
//	freopen("poly.in","r",stdin);
//	freopen("poly.out","w",stdout);
	n=wer;
	oula();
//	cerr<<"DEAFAKIOI\n";
//	cout<<"fuck\n";
    f(i,0,n)a[n-i]=wer;
    ll qwq;
    qwq=abs(a[n]); 
    for(int i=2;i*i<=qwq;i++)
    {
    	if(qwq%i==0)v.push_back(i);
    	while(qwq%i==0)qwq/=i;
	}
	if(qwq!=1&&qwq!=0)v.push_back(qwq);
	f(i,2,n+3)
	{
		if(!isp[i])v.push_back(i);
	}
	sort(v.begin(),v.end());
	v.resize(unique(v.begin(),v.end())-v.begin());
//	f(i,0,(int)v.size()-1)cout<<v[i]<<"    deafakioi\n";
	int qwqwq=0;
	f(deafakioi,0,(int)v.size()-1)
	{
		ll p=v[deafakioi];int f=0;
		f(i,0,n)b[i]=0;
		f(i,0,n)b[i%(p-1)]+=a[i];
		f(i,0,min((ll)n,p-2))if(b[i]%p!=0){f=1;break;}
		if(!f&&a[0]%p==0)cout<<p<<"\n",qwqwq=1;
	}
	if(!qwqwq)
	cout<<"\n";
    fwrite(pbuf,1,pp1-pbuf,stdout);
    return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,K;
ll ret;
ll num[202020];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	
	for(i=1;i<=N;i++) num[i%K]++;
	
	// all same
	ret+=num[0]*num[0]*num[0];
	if(K%2==0) ret+=num[K/2]*num[K/2]*num[K/2];
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main()
{
    bool ans = true;
    int k;
    vector<int> v;
    for (int i = 0; i < 5; i++)
    {
        int n;
        cin >> n;
        v.push_back(n);
    }
    sort(v.begin(), v.end());
    cin >> k;
    for (int i = 0; i < v.size() - 1; i++)
    {
        for (int j = i + 1; j < v.size(); j++)
        {
            if ((abs(v[i] - v[j])) > k)
            {
                ans = false;
                break;
            }
        }
    }
    if (ans)
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n, m, c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
count = 0
n.times do
  a = gets.split.map(&:to_i)
  sum = 0
  for i in 0...m do
    sum += a[i] * b[i]
  end
  count += 1 if sum + c > 0
end
puts count


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) 
	{ 
		cerr << name << " : " << arg1 << endl;
	}
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) 
    {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#endif
 
 
const int N = 3e5 + 5;
const int MAXN = 1e5 + 5;
const int M = 1e5;
const int mod = 998244353;
const int MOD = 998244353;
const ll INF = 1e15;
const int LG = 21;


int arr[N];
int n, m, x;

int fact[N], invfact[N];

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}

int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}

void solve() 
{
	precompute();
	int n, m, k;
	cin >> n >> m >> k;
	int curr = 0;
	for(int i = 0; i <= k; i++)
	{
		int no = n - 1;
		int r = n - 1 - i;
		int temp = nCr(no, r) * m;
		temp %= mod;
		temp *= pow(m - 1, r, MOD);
		temp %= MOD;
		curr += temp;
		curr %= MOD;
	}
	cout << curr << endl;
}
 
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; 

        
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

       
        res.push_back({a, ex});
    }

   
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    cin >> N;
    const auto &res = prime_factorize(N);
  
    long long int ans = 0;
  
    for (auto p : res) {
        for(int i=2;i<20;i++){
          if(p.second < i*(i+1)/2){
            ans += i-1;
            break;
          }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

typedef long long int ll;

const ll mod = 1e9+7;

int main()
{
	ll h,w,k;
	cin >> h >> w >> k;

	ll fib[10] = {0};
	fib[0] = 1;
	fib[1] = 1;
	for(int i = 2; i < 10; i++){
		fib[i] = fib[i-1]+fib[i-2];
	}

	ll dp[120][10] = {0};

	dp[0][1] = 1;
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			if(j>1){
				dp[i][j] += dp[i-1][j-1]*fib[j-2]*fib[w-j];
				dp[i][j] %= mod;
			}
			if(j<w){
				dp[i][j] += dp[i-1][j+1]*fib[j-1]*fib[w-j-1];
				dp[i][j] %= mod;
			}

			dp[i][j] += dp[i-1][j]*fib[j-1]*fib[w-j];
			dp[i][j] %= mod;
		}
	}

	cout << dp[h][k] << endl;

	return 0;
}

Measured memory_bytes: 256
# import bisect
# from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    a, b, c = list(map(int,ipti().split()))
    print(a+b+c-max(a,b,c))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main (){
    int N;
    cin >> N;
    int flg = 1;
    for (int j = 0;j<N;j++){
        int i;
       cin >> i;
       if(i%2 == 0){
           if(i%3 != 0 && i%5 != 0){
               flg = 0;
           }
       }
    }
    if(flg){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
 
struct die{
  int t[6];
  void ra(){
    int tmp=t[0];
    t[0]=t[2];
    t[2]=t[5];
    t[5]=t[3];
    t[3]=tmp;
  }
  void rb(){
    int tmp=t[1];
    t[1]=t[2];
    t[2]=t[4];
    t[4]=t[3];
    t[3]=tmp;
  }
  void rc(){
    int tmp=t[0];
    t[0]=t[4];
    t[4]=t[5];
    t[5]=t[1];
    t[1]=tmp;
  }
};
 
vector<die> calc(die d){
  vector<die> res;
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      res.push_back(d);
      d.rc();
    }
    d.ra();
  }
  d.rb();
  for(int i=0;i<4;i++){
    res.push_back(d);
    d.rc();
  }
  d.rb();d.rb();
  for(int i=0;i<4;i++){
    res.push_back(d);
    d.rc();
  }
  return res;
}
 
int n,cnt,ans;
die A[4];
map<string,int> mp;
vector<die> B[4];
 
void check(){
  int cnt=0;
  for(int i=0;i<6;i++){
    int maxm=0;
    map<int,int> mp;
    for(int j=0;j<n;j++){
      int num=A[j].t[i];
      mp[num]++;
      maxm=max(maxm,mp[num]);
    }
    cnt+=(n-maxm);
  }
  ans=min(ans,cnt);
}
 
void solve(int x){
  if(x==n){
    check();
  }else{
    for(int i=0;i<24;i++){
      A[x]=B[x][i];
      solve(x+1);
    }
  }
}
 
int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    cnt=0;
    mp.clear();
    string str;
    for(int i=0;i<n;i++){
      for(int j=0;j<6;j++){
    cin>>str;
    if(mp[str]==0){
      cnt++;
      mp[str]=cnt;
    }
    A[i].t[j]=mp[str];
      }
      B[i]=calc(A[i]);
    }
     
    ans=(1<<24);
    solve(0);
    cout<<ans<<endl;
  }
  return 0;
}

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

#define SQRT_MAX ((40*40)*10)

int X[10][10];

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

	set <int> good_distance;
	int work = 0;
	int i = 0;
	while (work < SQRT_MAX) {
		work = i*i;
		good_distance.insert(work);
		i++;
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) {
			cin >> X[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			int sqrt_sum = 0;
			for (int k = 0; k < D; k++) {
				sqrt_sum += ((X[i][k]-X[j][k])*(X[i][k]-X[j][k]));
			}
			if (good_distance.find(sqrt_sum) != good_distance.end()) {
				ans++;
			}
		}
	}
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
        "sort"
)

func solution(a, b, c int) int {
        memo := []int{a, b, c}
        sort.Ints(memo)
        hi := memo[2]
        lo := memo[0]
        mi := memo[1]
        if (mi-lo)%2 == 1 {
                return hi - mi + 2 + (mi-lo)/2

        }
        return hi - mi + (mi-lo)/2
}

func abs(x int) int {
        if x < 0 {
                return -x
        }
        return x
}

func max(x, y int) int {
        if x > y {
                return x
        }
        return y
}

func min(x, y int) int {
        if x < y {
                return x
        }
        return y
}

func main() {
        var a, b, c int
        fmt.Scan(&a, &b, &c)
        fmt.Println(solution(a, b, c))
}


Measured memory_bytes: 1840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
#define all(a) a.begin(), a.end()
#define mp(a, b) make_pair(a, b)

const int MOD = 1e9+7;
const int INF = 1001001001;

int main(){
    ll N,M;
    cin >> N >> M;
    int ans = 0;
    while (N <= M){
        N *= 2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    exit()
    
upto = 10 ** 18
ans = 1
for num in A:
    ans *= num
    if ans > upto:
        print("-1")
        exit()
print(ans)

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

using namespace std;

int main() {
    double r;
    cin >> r;

    // 2pi = 360°　because 2 * 1 + pi = 360°
    // cout << acos(-1) << endl;

    cout << fixed << setprecision(6) << r * r * acos(-1) << " " << 2 * r * acos(-1) << endl;

    return 0;
}


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

int main(){
 int N;
 
 cin >> N;
 
 vector<int64_t> Lu(N+1);

 Lu.at(0) = 2LL;
 Lu.at(1) = 1LL;

 //リュカ数の計算
 if(N >= 2) {
	for (int i = 2; i < N + 1; i++) {
  		Lu.at(i) = Lu.at(i - 1) + Lu.at(i - 2);
    }
 }
 cout << Lu.at(N) <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e17;
const ll N = 3e5+10;
const ll bits = 63;
const ll mod = 1e9+7;

ll power(ll x, ll n){

    if(n==0){
        return 1;
    }

    ll ans = power(x,n/2);
    ans*=ans;
    ans%=mod;

    if(n%2){
        ans*=x;
        ans%=mod;
    }
    return ans;
}

ll modInv(ll n){
    return power(n,mod-2);
}

int main(){

    ll n;
    cin>>n;

    vector<ll>arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];



    // vector<ll>power(bits+1);

    // power[0] = 1;

    // for(int i=1;i<bits;i++){
    //     power[i] = (2*power[i-1])%mod;
    // }


    ll ans = 0;

    for(int x=0;x<bits;x++){
        ll var = pow(2,x);
        
        // ll var2 = pow(2,x);
        // cout<<x<<" "<<var<<" "<<var2<<"\n";

        ll e=0,o=0;

        for(int i=0;i<n;i++){
            if((arr[i]&var)==var){
                e++;
            }else{
                o++;
            }
        }

        var%=mod;

        // store[x].push_back((((e*(n-e))%mod) *var)%mod);
        ll delta = e*o;
        delta%=mod;

        ans+= (delta *var)%mod;
        ans%=mod;
    }

    // ll ans2=0;

    // for(int x=0;x<=bits;x++){
    //     ll sum = 0;
    //     ll var = 1<<x;
    //     for(int i=0;i<n;i++){
    //         for(int j=i+1;j<n;j++){
    //             ans2+= arr[i] ^ arr[j];
    //             ans2%=mod;
    //             sum+= (arr[i] ^ arr[j])&var;
    //             sum%=mod;
    //         }
    //     }

    //     store[x].push_back(sum);
    // }

    // for(int i=0;i<store.size();i++){
    //     cout<<i<<" "<<store[i][0]<<" "<<store[i][1]<<"\n";
    // }

    
    cout<<ans<<"\n";

}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>

#define rep(i,n) for((i)=0;i<(int)(n);i++)
using namespace std;

int main() {
	int A,x;
	cin >>A >> x;
	int ans = (x - 1) / (A - 1);
	if ((x - 1) % (A - 1) != 0) {
		ans++;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int N, L;
	cin >> N >> L;
    int min = abs(L);
    int sum = 0;
    for(int i = 0; i < N; i++){
        int taste = L + i;
        if(abs(taste) < abs(min)){
            min = taste;
        }
        sum += taste;
    }

    cout << sum - min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cstring>
#include <algorithm>
#include <vector>
//#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
using namespace std;
#define fin << '\n'
#define finl << '\n';
#define finn cout << '\n'
#define unless(flg) if(!(flg))
#define alles(obj) obj.begin(), obj.end()
// bashise
#define elif else if
#define echo cout <<
#define read cin >>
// javaise
#define bash push_back
#define makePair make_pair
#define isEmpty empty
// germanise
#define drucken(obj) cout << obj << '\n'
#define lesen(obj) cin >> obj
#define fur for
#define wenn if
#define sonst else
#define Zahl int
// type-define
#define String string
#define Stack stack
#define Queue queue
#define pQueue priority_queue
#define Vector vector
#define Pair pair
#define Map map
typedef long long llong;
typedef bool boolean;
typedef Pair<int,int> Pii;
typedef Vector<int> Vi;
// utils
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
boolean isMovable(int x,int y,int w,int h){return (x>=0&&y>=0&&x<w&&y<h);};
const int INF = 1 << 29;

int ans = 1;

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

    int n, k;
    read n >> k;
    for ( int i = 0; i < n; i++ ) {
        ans = min ( ans * 2, ans + k );
    }

    echo ans fin;


    return 0;
}


Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        s: chars
    }
    let mut display = Vec::new();
    for ch in s {
        match ch {
            '0' => display.push('0'),
            '1' => display.push('1'),
            'B' => { display.pop(); },
            _ => (),
        }
    }
    let ans = display.into_iter().collect::<String>();
    println!("{}", ans);
}


Measured memory_bytes: 4352
//42
#include<iostream>
#include<utility>
#include<cctype>
#include<cstdio>
#include<climits>
#include<cstdlib>

using namespace std;

char s[101];
bool f;
int i;
typedef pair<int,int> pii;

void co(pii a){
  f|=a.first<-10000||10000<a.first||a.second<-10000||10000<a.second;
}

pii pp();
pii pm();
pii pn();

pii pn(){
  if(s[i]=='i'){
    i++;
    return make_pair(0,1);
  }else if(isdigit(s[i])){
    int d,n;
    long dd;
    char *p;
    sscanf(s+i,"%ld%n",&dd,&n);
    f|=dd<-10000||10000<dd;
    i+=n;
    d=dd;
    /*    if(1){
      d=0;
      while(isdigit(s[i])){
	d=(d*10+s[i]-'0');
	i++;
      }
    }else{

      //      i+=n;
      f|=d==INT_MAX;
      while(isdigit(s[i])){
	i++;
      }
      }*/
    pii r=pii(d,0);
    co(r);
    return r;
  }else if(s[i]=='('){
    i++;
    pii r=pp();
    i++;
    return r;
  }else{
    return pii();
  }
}

pii pm(){
  pii a=pn();
  while(s[i]=='*'){
    i++;
    pii b=pn();
    pii c=pii(a.first*b.first-a.second*b.second,a.first*b.second+a.second*b.first);
    a=c;
    co(a);
  }
  return a;
}

pii pp(){
  pii a=pm();
  while(s[i]=='+'||s[i]=='-'){
    char o=s[i];
    i++;
    pii b=pm();
    a.first+=b.first*((o=='+')?1:-1);
    a.second+=b.second*((o=='+')?1:-1);
    co(a);
  }
  return a;
}

int main(){
  while(cin.getline(s,100)){
    f=false;
    i=0;
    pii r=pp();
    if(f){
      cout<<"overflow"<<endl;
    }else{
      if(r.first==0&&r.second==0){
	cout<<0<<endl;
      }else{
	if(r.first){
	  cout<<r.first;
	}
	if(r.second){
	  if(r.first&&r.second>0){
	    cout<<'+';
	  }
	  cout<<r.second<<'i';
	}
	cout<<endl;
      }
    }
  }
  return 0;
}

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

int main(){
	int n;
	cin >> n;
	if(n == 3 || n == 5 || n == 7) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

int main(){
  cin.sync_with_stdio(false);
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A+B > C + D){
    cout << "Left" << endl;
  }else if(A + B == C + D){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

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

using namespace std;

int main(){
    int M,D;cin >> M >> D;
    int count=0;
    for(int i=1;i<=M;i++){
        for(int j=2;j<=D/10;j++){
            for(int k=2;k<=9;k++){
                if(10*j+k>D)break;
                if(j*k==i){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#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()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<P> p(m);
	rep(i, m) {
		cin >> p[i].second >> p[i].first;
	}
	sort(all(p));
	int ans = 0;
	int now = -1;
	rep(i, m) {
		if (p[i].second >= now) {
			ans++;
			now = p[i].first;
		}
		else {
			now = min(now, p[i].first);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long lld;
typedef long double Lf;
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))

int main() {
	int n, k, t, all[6] = { 0 }, d[10] = { 0 };
	scanf("%d%d", &n, &k);
	rep(i, k) { scanf("%d", &t); d[t]++; }
	if (n == 1 && d[1] != 1) { printf("1"); return 0; }
	t++;
	Rep(i, 2 < n ? n : 2, 1e9) {
		rep(j, log10(i) + 1) {
			all[j] = (i % (int)pow(10, j + 1)) / (int)pow(10, j);
			rep(x, 10)if (d[all[j]])t = 0;
		}
		if (t) { printf("%d", i); return 0; }
		t++;
	}
}

Measured memory_bytes: 128
/**
 *    author:   K.R.Surrya  
 *    created:  10/05/2020 17:44:09
**/
#include<bits/stdc++.h>
#define vi vector<int>
#define vii vector<vector<int> >
#define vpi vector<pair<int,int> >
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
using namespace std; 

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)  { return ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a,Args... args)
{
    cerr << *it << " = " << a <<endl;
    err(++it,args...);   //args is going to end.
}

void solve() { 
    int n,m,X;
    cin >> n >> m >> X;
    vector<int> cost(n);
    vector<vector<int>> understanding(n,vector<int>(m));
    for(int i=0;i<n;++i) {
        cin >> cost[i];
        for(int j=0;j<m;++j) {
            cin >> understanding[i][j];
        }
    }
    int ret=INT_MAX;
    for(int mask=0;mask<=((1<<n)-1);++mask) {
         vector<int> limit(m);
         int cc=0;
         for(int j=0;j<n;++j) { //jth book
             if(((mask>>j)&1)) { //ith algorithm;
                 for(int i=0;i<m;++i)  limit[i]+=understanding[j][i];
                 cc+=cost[j];
             }
         }
         bool ok=true;
         for(int i=0;i<limit.size();++i){
              if(limit[i]<X) {
                  ok=false;
                  break;
              }
         }
         if(ok) {
             ret=min(ret,cc);
         }
    }
    cout << (ret==INT_MAX?-1:ret) << '\n';
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

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

     cerr << " Execution time : " << chrono::duration_cast<chrono::milliseconds>(end-start).count()<<"ms"<<endl;

   
    return 0;
}


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

int n;

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);    
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    ll k = 0;
    int ans = 0;
    for (int i = 1; k < n; ++i) {
        k += i;
        ans = i;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
 
        if (a.charAt(a.length() - 1) == b.charAt(0) && b.charAt(b.length() - 1) == c.charAt(0)) {
            _out.println("YES");
        } else {
            _out.println("NO");
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

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

bool prime[246913];

int main(){
	for(int i=2; i<=246912; i++)	prime[i] = true;
	for(int i=2; i<=123456; i++){
		if(prime[i]){
			for(int j=i*2; j<=246912; j+=i){
				prime[j] = false;
			}
		}
	}
	int n;
	while(cin >> n, n){
		int cnt = 0;
		for(int i=n+1; i<=2*n; i++){
			if(prime[i]) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    map<int,int> mp,cnt;
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 0;i < n;++i) cnt[a[i]]++;
    for (int i = n-1;i >= 0;--i) mp[a[i]] = i;
    mp[0] = 0;
    vector<ll> ans(n);
    ll sum = 0;
    for (auto it = mp.end();;) {
        if (it == mp.end()) --it;
        if (it->first == 0) break;
        int i = it->first,j = it->second;
        sum += cnt[i];
        ans[j] += sum*i;
        while ((--it)->second > j) {
            sum += cnt[it->first];
            ans[j] += cnt[it->first]*(it->first);
        }
        ans[j] -= sum*(it->first);
    }
    for (int i = 0;i < n;++i) cout << ans[i] << "\n";
    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] X = new long[N];
		long[] Y = new long[N];
		long[] Z = new long[N];
		
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextLong();
			Y[i] = X[i];
		}
		
		Arrays.sort(Y);
		long mid = Y[N / 2 - 1];
		
		for(int i = 0; i < N; i++) {
			if(X[i] > mid) {
				System.out.println(mid);
			} else {
				System.out.println(Y[N / 2]);
			}
		}
	}
}


Measured memory_bytes: 96256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
const int N = 2e5 + 1;

void findAns()
{
    int n, k;
    cin >> n >> k;

    int data[n];

    for (auto&it : data) cin >> it;

    sort(data, data + n);

    int sum = 0;

    for (int i = 0; i < k; i++) sum += data[i];

    cout << sum;


}
int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("o1.txt", "w", stdout);
// #endif

    fastio;

    // ll int t;
    // cin >> t;

    // while (t--)
    findAns();
}

Measured memory_bytes: 3644
#include<iostream>
#include<climits>
#include<numeric>
#include<algorithm>
#include <sstream>
#include<cstring>
#include<cmath>
#include<iterator>
#include<utility>
#include<array>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<forward_list>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif
ll t;
cin>>t;
ll arr[t];
std::vector<int> n;
ll rahul[t];
for (int i = 0; i < t; ++i)
{
	cin>>arr[i];
	//.//n[i]=arr[i];
		//n.push_back(arr[i]);
	/* code */
	rahul[i]=arr[i];
}
sort(rahul,rahul+t);
//
ll count=0;
for (int i = 0; i < t; ++i)
{
	if(arr[i]!=rahul[i])
		count++;
	/* code */
}
if (count==2 ||count==0)
{
	cout<<"YES"<<endl;
	/* code */
}
else{
	cout<<"NO"<<endl;
}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define ALLG(v) v.begin(), v.end() ,greater<int>()
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }
ll GetDigit(ll num) {
	ll digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

using namespace std;
int main() {

	ll x;
	cin >> x;

	ll ans = 0;

	for (int i = 1; i <= x; i++)
	{
		if (!(i % 3 == 0 || i % 5 == 0)) ans += i;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=333;
int d[mx][mx];
int main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      scanf("%d",&d[i][j]);
    }
  }
  uli ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      bool good=true;
      for(int k=0;k<n;k++)if(k!=i && k!=j){
        if(d[i][j]>d[i][k]+d[k][j]){
          puts("-1");
          return 0;
        }
        if(d[i][j]==d[i][k]+d[k][j])good=false;
      }
      if(good)ans+=uli(d[i][j]);
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    
    int n ,ac = 0 ,wa = 0 ,tle = 0 ,re = 0 ;
    string c;
    cin >> n;
    
    for(int i = 0;i < n;i++){
        cin >> c;
    
        if(c == "AC") ac += 1;
        if(c == "WA") wa += 1;
        if(c == "TLE") tle += 1;
        if(c == "RE") re += 1;
        
    }
    
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}


Measured memory_bytes: 3620
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	static int gcd(int a, int b) 
	{ 
	    if (a == 0) 
	        return b; 
	    return gcd(b % a, a); 
	}
	static int GCD(int a, int b, int c) {
		return gcd(a , gcd(b , c));
	}
	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		int n = sc.nextInt();long sum = 0;
		
		for(int i = 1; i <= n; i++) {
			for(int j = 1; j <= n; j++) {
				for(int k = 1; k <= n; k++) {
					
					sum += GCD(i , j , k);
					
				}
			}
			
		}
		System.out.println(sum);
	}

	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}

}


Measured memory_bytes: 32928
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	//入力
	int A, B;
	cin >> A >> B;

	if (B % A == 0) {
		cout << (A + B);
	}
	else {
		cout << (B - A);
	}

}

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

using namespace std;

const int N=8010,P=1e9+7;

int n,a[200010],b[200010],fac[N],inv[N];
int f[N][N];

inline int &F(int x,int y){ return f[x+2005][y+2005]; }

inline void Pre(){
  fac[0]=1; for(int i=1;i<=8000;i++) fac[i]=1LL*fac[i-1]*i%P;
  inv[1]=1; for(int i=2;i<=8000;i++) inv[i]=1LL*(P-P/i)*inv[P%i]%P;
  inv[0]=1; for(int i=1;i<=8000;i++) inv[i]=1LL*inv[i]*inv[i-1]%P;
}

inline int C(int x,int y){
  return 1LL*fac[x]*inv[y]%P*inv[x-y]%P;
}

int main(){
  scanf("%d",&n); Pre();
  for(int i=1;i<=n;i++)
    scanf("%d%d",&a[i],&b[i]),F(-a[i],-b[i])++;
  for(int i=-2000;i<=2000;i++)
    for(int j=-2000;j<=2000;j++)
      F(i,j)=((long long)F(i,j)+F(i-1,j)+F(i,j-1))%P;
  int ans=0;
  for(int i=1;i<=n;i++) ans=((long long)ans+F(a[i],b[i])-C(a[i]+a[i]+b[i]+b[i],b[i]+b[i]))%P;
  ans=1LL*ans*(P+1>>1)%P;
  printf("%d\n",(ans+P)%P);
  return 0;
}


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

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main()
{
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; ++i)
        cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i)
        dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    // 答え
    cout << dp[N - 1] << endl;
}

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

#define min3(a,b,c)   min(a,min(b,c))
#define max3(a,b,c)   max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))

#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)    __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)       __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)       __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define PI   M_PI
#define endl "\n"
#define sc   scanf
#define pf   printf

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep1(i,n)       for(int i = 0; i < n; i++)
#define rep2(a,b)       for(int i = a; i <= b; i++)
#define rep3(a,b,c)     for(int i = a; i <= b; i+=c)
#define irep(a,b,c)     for(int i = b; i >=a; i-=c)
#define repit(it,type)  for(it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
using namespace __gnu_cxx;

int main()
{
     IOS
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
     ll n,m,i,x,ans=0;
     priority_queue<ll> pq;

     cin>>n>>m;
     ll a[n];
     rep1(i,n)
     {
          cin>>a[i];
          pq.push(a[i]);
     }
     W(m)
     {
          x = pq.top();
          pq.pop();
          pq.push(x/2);
     }
     while(!pq.empty())
     {
          ans += pq.top();
          pq.pop();
     }
     cout<<ans<<endl;

     return 0;
}



Measured memory_bytes: 5028