akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int ans;
int k;
int t;
int iindex;
int mm;
int a[105];
int before;
int main()
{
	cin>>k>>t;
	rep(i,t)cin>>a[i];
	before=-1;
	rep(kkk,k)
	{
		mm=0;
		rep(i,t)
		{
			if(mm<a[i]&&before!=i)
			{
				mm=a[i];
				iindex=i;
			}
		}
		if(mm==0)
		{
			ans++;
			a[iindex]--;
		}
		else
		{
			a[iindex]--;
			before=iindex;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if ((max(a, b) + min(a, b)) % 2 == 0)
    {
        cout << (max(a, b) + min(a, b)) / 2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
int gcdEx(int a, int b, int *x, int *y){if(!a){*x=0;*y=1;return b;} 
int x1,y1,gcd=gcdEx(b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
int modI(int b, int m)      {int x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(b,n)           for(int i=b;i<n;i++)
#define loopv(b,n,a)         for(int i=b;i<n;i+=a)
#define loopr(b,n)           for(int i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define MOD                 1000000007 
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(int)(MOD+((a%MOD)-(b%MOD))%MOD):(int)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (int)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;}
y=y>>1; x=(x*x)%MOD;} return r;}


int main()
{ 
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    ll l,r,m=2019,k=0,kl=0;;
    cin>>l>>r;
    ll ans=INT_MAX,x,i,j;
    for(ll i=l;i<=r;i++)
    {  kl++;
    
        for(ll j=i+1;j<=r;j++)
       {
           x=((i%m)*(j%m))%m; 
       ans=min(ans,x);
       k++;
      if(k==5000) {   kl=k; break;}
       }
       if(kl==5000) break;
    }
    
    
    cout<<ans<<"\n";
    
    return 0;
}


Measured memory_bytes: 764
import java.io.*;
import java.util.concurrent.LinkedBlockingQueue;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] input = br.readLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int q = Integer.parseInt(input[1]);
        String[] names = new String[n];
        LinkedBlockingQueue<int[]> processes = new LinkedBlockingQueue<int[]>();
        int[] currentProcess;
        int time = 0;
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < n; i++) {
            input = br.readLine().split(" ");
            names[i] = input[0];
            processes.offer(new int[] {i, Integer.parseInt(input[1])});
        }

        while ((currentProcess = processes.poll()) != null) {
            if (currentProcess[1] <= q) {
                time += currentProcess[1];
                sb.append(names[currentProcess[0]]).append(" ").append(time).append("\n");
            } else {
                time += q;
                currentProcess[1] -= q;
                processes.offer(currentProcess);
            }
        }
        System.out.print(sb.toString());
    }
}

Measured memory_bytes: 59776
#include <cstdio>

int main()
{
  int sx, sy, tx, ty;
  scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
  int X = tx - sx;
  int Y = ty - sy;
  for (int i = 0; i < X; ++i)
  {
    putchar('R');
  }
  for (int i = 0; i < Y; ++i)
  {
    putchar('U');
  }
  for (int i = 0; i < X; ++i)
  {
    putchar('L');
  }
  for (int i = 0; i <= Y; ++i)
  {
    putchar('D');
  }

  for (int i = 0; i <= X; ++i)
  {
    putchar('R');
  }
  for (int i = 0; i <= Y; ++i)
  {
    putchar('U');
  }
  printf("LU");
  for (int i = 0; i <= X; ++i)
  {
    putchar('L');
  }
  for (int i = 0; i <= Y; ++i)
  {
    putchar('D');
  }
  puts("R");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
using namespace std;
int Q,A,B,C,D,k,l,r,mid,bs,as;
int calc(int x)
{
	if(x<=l*(k+1)) return x%(k+1)==0; x-=l*(k+1);
	if(x<=as) return 0; x-=as;
	if(x<=bs) return 1; x-=bs;
	return x%(k+1)!=1;
}
void solve(int A,int B,int C,int D)
{
	k=(max(A,B)-1)/(min(A,B)+1)+1;
//	cout<<k<<endl;
	l=0,r=A/k,mid;
	while(l<r)
	{
		mid=(l+r+1)/2;
		if((B-mid)/k>A-mid*k) r=mid-1;
		else l=mid;
	}
	bs=(B-l)%k,as=A-l*k-(B-l-bs)/k;
//	cout<<l<<" "<<as<<" "<<bs<<endl;
	for(int i=C;i<=D;i++)
	printf("%c",calc(i)+'A');
	puts("");
}
int main()
{
	scanf("%d",&Q);
	while(Q--)
	{
		scanf("%d%d%d%d",&A,&B,&C,&D);
		solve(A,B,C,D);
	}
	return 0;
}

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

int main(){
	string s;
	cin >> s;
	int n = s.length();
	int ans = 0;
	for(int i=0; i*2<n; i++){
		if((s[i]=='w' || s[i]=='i') && s[i]==s[n-i-1]) continue;
		if((s[i]=='(' && s[n-i-1]==')') || (s[i]==')' && s[n-i-1]=='(')) continue;
		ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include<algorithm>
#include<vector>
// #define i long long
using namespace std;

int main(void){
    int n,w;
    cin >> n>>w;
    std::vector<std::vector<long>> pd(n+1,vector<long>(w+1,0));
    
    std::vector<vector<long>> object(n+1,vector<long>(2,0));
    for(int i=1;i<=n;i++){
        cin >> object[i][0]>>object[i][1];
        // cout << object[i][0]<< ' '<<object[i][1]<<endl;
    }
    
    for(int i=1;i<n+1;i++){
        long weight=object[i][0],value = object[i][1];
        for(int j=0;j<w+1;j++){
            if(0<=j-weight){
                pd[i][j]=max(pd[i-1][j],pd[i-1][j-weight]+value);
            }else{
                pd[i][j]=pd[i-1][j];
            }
        }
    }
    
    // for(int i=0;i<n+1;i++){
    //     for(int j=0;j<w+1;j++){
    //         cout << pd[i][j]<< ' ';
    //     }
    //     cout << endl;
    // }
    // cout << endl;
    cout << *max_element(pd[n].begin(),pd[n].end())<<endl;
    
    
}


Measured memory_bytes: 80256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    while(cin >> N, N) {
        vector<pii> P(N);
        set<pii> se;
        rep(i, N) {
            cin >> P[i].first >> P[i].second;
            se.insert(P[i]);
        }
        sort(All(P));
        int res = 0;
        for(int i = 0; i < N; i++) {
            for(int j = i + 1; j < N; j++) {
                int dx = P[j].first - P[i].first;
                int dy = P[j].second - P[i].second;
                pii a = MP(P[i].first - dy, P[i].second + dx);
                pii b = MP(P[j].first - dy, P[j].second + dx);
                if(se.count(a) && se.count(b))
                    res = max(res, dx * dx + dy * dy);
                pii c = MP(P[i].first + dy, P[i].second - dx);
                pii d = MP(P[j].first + dy, P[j].second - dx);
                if(se.count(c) && se.count(d))
                    res = max(res, dx * dx + dy * dy);
            }
        }
        cout << res << "\n";
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

int n, k;
int lim;
int ans = INT_MAX;
vi e[2006];

int dfs(int x, int p, int h) {
	int s = h > lim;
	for (auto i : e[x]) if (i != p)
		s += dfs(i, x, h + 1);
	return s;
}

int main() {
	cin >> n >> k;
	for (int i = 1; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		e[x].pb(y);
		e[y].pb(x);
	}
	
	if (k % 2 == 0) {
		lim = k / 2;
		for (int i = 1; i <= n; ++i)
			ans = min(ans, dfs(i, 0, 0));
	} else {
		lim = k / 2;
		for (int i = 1; i <= n; ++i)
			for (auto j : e[i]) if (i < j)
				ans = min(ans, dfs(i, j, 0) + dfs(j, i, 0));
	}
	
	cout << ans << endl;
	
	return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-indexか1-indexでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-index昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-index昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-index降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-index降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n,m; cin >> n >> m;
    int c = 1; rep(i,m) c *= 2;
    cout << (1900*m + 100*(n-m)) * c << '\n'
;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 500010
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
int a[maxn];
int read() 
{
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x*f;
}
int main() 
{   int n=rd;
    fo(i,1,n)
    {
      a[i]=rd;
	}
	sort(a+1,a+n+1);
	printf("%d\n",a[n]-a[1]);

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;

string s[maxn];
int f[maxn][maxn][3];

void pd(int &ret, int val){
  if(ret==-1||ret>val)ret=val;
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>s[i];
  memset(f,-1, sizeof(f));
  if(s[0][0]=='.'){
    f[0][0][0] = 0;
  } else {
    f[0][0][1] = f[0][0][2] = 1;
  }
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
      for(int k=0;k<3;k++){
        if(f[i][j][k]==-1)continue;
        if(i+1<n){
          if(s[i+1][j]=='.'){
            pd(f[i+1][j][0], f[i][j][k]);
          } else {
            if(k==0){
              pd(f[i+1][j][1], f[i][j][k]+1);
              pd(f[i+1][j][2], f[i][j][k]+1);
            } else {
              pd(f[i+1][j][k], f[i][j][k]);
              pd(f[i+1][j][3-k], f[i][j][k]+1);
            }
          }
        }
        if(j+1<m){
          if(s[i][j+1]=='.'){
            pd(f[i][j+1][0], f[i][j][k]);
          } else {
            if(k==0){
              pd(f[i][j+1][1], f[i][j][k]+1);
              pd(f[i][j+1][2], f[i][j][k]+1);
            } else {
              pd(f[i][j+1][k], f[i][j][k]);
              pd(f[i][j+1][3-k], f[i][j][k]+1);
            }
          }
        }
      }
  int ret = -1;
   for(int i=0;i<3;i++)if(f[n-1][m-1][i]!=-1)pd(ret, f[n-1][m-1][i]);
   cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 384
N = int(input())
c = [0]
a = list(map(int, input().split()))
b = [0 for _ in range(N + 1)]

d = c + a

for i in range(N, 0, -1):
    s = 0
    for j in range(2 * i, N + 1, i):
        s ^= b[j]

    b[i] = (s ^ d[i])

# print(b)
print(b.count(1) if b.count(1) else 0)
if len(b):
    for i in range(1, len(b)):
        if b[i] != 0:
            print(i, end=' ')
else:
    print(0)

Measured memory_bytes: 72412
#include <bits/stdc++.h>
using namespace std;
int main(){
	vector<string> v;
	int n, m;
	cin>>n>>m;
	for(int i = 0; i < n; ++i){
		string s;
		cin>>s;
		v.push_back(s);
	}
	sort(v.begin(), v.end());
	string res = "";
	for(int i = 0; i < n; ++i){
		res += v[i];
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    ll N;
    cin >> N;

    ll ans = 0;
    for(ll k = 1; k <= N; k++) {
        ll m = N / k;
        ans += k * m * (m + 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
const double PI=acos(-1);
using namespace std;
#define ll long long
#define ull unsigned long long
#define ul unsigned long
#define MOD 1000000007

long findmin(long a,long b) {
	return a<b?a:b;
}
long findmax(long a,long b) {
	return a>b?a:b;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long n;
	cin>>n;
	int h[n],rc[n];
	for(long i=0;i<n;i++) {
		cin>>h[i];
		rc[i]=0;
	}
	//h[1]+=h[0];
	rc[1]=abs(h[0]-h[1]);
	for(long i=2;i<n;i++) {
		//rc[i]+=findmin(rc[i-1],rc[i-2])+abs();
		long x=0,y=0;
		//if(rc[i-1]<rc[i-2]) {
			x=(rc[i-1]+abs(h[i]-h[i-1]));
		//}
		//else {
			y=(rc[i-2]+abs(h[i]-h[i-2]));
		//}
		rc[i]+=findmin(x,y);
	}
	//for(long i=0;i<n;i++) {
		//cout<<rc[i]<<" ";
	//}
	cout<<rc[n-1]<<"\n";
	cout.flush();
	return 0;
}


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

long long dp[100][100];

long long solve2(vector<int>vec1, vector<int>vec2) {
	for (int i = 0; i <= vec1.size(); i++) { for (int j = 0; j <= vec2.size(); j++) dp[i][j] = 0; }
	dp[0][0] = 1;
	for (int i = 0; i < vec1.size(); i++) {
		for (int j = 0; j <= vec2.size(); j++) {
			dp[i + 1][j] += dp[i][j];
			for (int k = j; k < vec2.size(); k++) {
				if (vec1[i] == vec2[k]) dp[i + 1][k + 1] += dp[i][j];
				if (j == 0 && k == 0) break;
			}
		}
	}
	long long F = 0;
	for (int i = 1; i <= vec2.size(); i++) F += dp[vec1.size()][i];
	return F;
}

long long solve(vector<int>vec) {
	long long ret = 0;
	for (int i = 1; i < vec.size(); i++) {
		vector<int>vec1, vec2;
		for (int j = 0; j < i; j++) vec1.push_back(vec[j]);
		for (int j = i; j < vec.size(); j++) vec2.push_back(vec[j]);
		ret += solve2(vec1, vec2);
	}
	return ret;
}

vector<pair<long long, vector<int>>>vec;

void init() {
	for (int i = 1; i <= 40; i++) {
		vector<int>V;
		for (int j = 0; j < i; j++) V.push_back(j);
		long long ret = solve(V);
		vec.push_back(make_pair(ret, V));
	}
	for (int i = 1; i <= 55; i++) {
		for (int j = 0; j < 100; j++) {
			vector<int>V;
			for (int k = 0; k < i; k++) V.push_back(rand() % 2);
			long long ret = solve(V);
			vec.push_back(make_pair(ret, V));
		}
	}
	sort(vec.begin(), vec.end());
}

long long n;

int main() {
	init();
	cin >> n;
	int cnt = 0; vector<int>ans;
	while (n >= 1) {
		int pos = 0;
		for (int i = 0; i < vec.size(); i++) {
			if (vec[i].first <= n) pos = i;
		}
		vector<int>G = vec[pos].second;
		for (int i = 0; i < G.size(); i++) ans.push_back(cnt * 2 + G[i] + 1);
		n -= vec[pos].first;
		cnt++;
	}
	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) { if (i)cout << " "; cout << ans[i]; } cout << endl;
	return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main() {
	char x,y;
	cin>>x>>y;
	if((int)(x)==(int)(y)) cout<<"=";
	else if((int)(x)>(int)(y)) cout<<">";
	else cout<<"<";
	return 0;
}

Measured memory_bytes: 3588
using System;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            var arry = new int[3];

            for (int i = 0; i < s.Length; i++)
            {
                arry[i] = int.Parse(s[i]);
            }
            Array.Sort(arry);
            Console.WriteLine(string.Format("{0} {1} {2}", 
                arry[0], arry[1], arry[2]));
        }
    }
}

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

int main() {
	vector<int> adj[51];
	int n, m;
	cin>>n>>m;

	while(m--){
		int u,v;
		cin>>u>>v;
		adj[--u].emplace_back(--v);
		adj[v].emplace_back(u);
	}
	for(int i=0;i<n;i++){
		cout<<adj[i].size()<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val grid = Array(14, { IntArray(14) })
    while (sc.hasNext()) {
        var (x, y, s) = sc.next().split(",").map { Integer.parseInt(it) }
        x+=2; y+=2
        if (s >= 2) {
            for (i in y-1..y+1) {
                for (j in x-1..x+1) grid[i][j]++
            }
            if (s == 3) {
                for ((i, j) in arrayOf(Pair(y-2, x), Pair(y+2, x), Pair(y, x-2), Pair(y, x+2))) grid[i][j]++
            }
        }
        else {
            for ((i, j) in arrayOf(Pair(y, x), Pair(y-1, x), Pair(y+1, x), Pair(y, x-1), Pair(y, x+1))) {
                grid[i][j]++
            }
        }
    }
    var white = 0
    var depth = 0
    for (i in 2..11) for (j in 2..11) {
        if (grid[i][j] == 0) white++
        depth = Math.max(depth, grid[i][j])
    }
    println(white)
    println(depth)
}


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

int main()
{
	int n;
	cin>>n;
	set<int> a;
	a.insert(n);
	for(int i=2;;i++)
	{
		if(n%2==0) n/=2;
		else n=n*3+1;
		a.insert(n);
		if(i!=a.size()){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
    
    static double[] x;
    static double[] y;
    static double ans;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        x = new double[n];
        y = new double[n];
        for(int i = 0; i < n; i++){
            x[i] = Double.parseDouble(sc.next());
            y[i] = Double.parseDouble(sc.next());
        }
        ans = 0;
        
        LinkedList<Integer> listA = new LinkedList<>();
        LinkedList<Integer> listB = new LinkedList<>();
        for(int i = 0; i < n; i++){
            listA.add(i);
        }
        permutation(listA, listB);
        
        int a = 1;
        for(int i = 2; i <= n; i++){
            a *= i;
        }
        ans /= a;
        
        System.out.println(ans);
    }
    
    static void permutation(LinkedList<Integer> a, LinkedList<Integer> b){
        
        if(a.isEmpty()){
            for(int i = 0; i < b.size()-1; i++){
                int j = b.get(i);
                int k = b.get(i+1);
                ans += Math.sqrt((x[j]-x[k])*(x[j]-x[k]) + (y[j]-y[k])*(y[j]-y[k]));
            }
            return;
        }
        
        for(int i = 0; i < a.size(); i++){
            b.addLast(a.removeFirst());
            permutation(a, b);
            a.addLast(b.removeLast());
        }
    }
}

Measured memory_bytes: 30160
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll MP[100002]={};
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    MP[a]++;
  }
  ll cnt=0,cnt2=0;
  for(int i=1;i<=100000;i++){
    if(MP[i]>0)
      if(MP[i]%2)cnt++;
      else cnt2++;
  }
  cout<<cnt+cnt2-cnt2%2<<endl;
  return 0;
}
  


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
int main() {
  double *x = new double[101];
  double *y = new double[101];
  int i, n;
  long sum2 = 0, sum3 = 0;
  double D1 = 0, D2 = 0, D3 = 0, Dm = 0;
  cin >> n;
  for(i = 0; i < n; i++) {
	cin >> x[i];
  }
  for(i = 0; i < n; i++) {
	cin >> y[i];
  }
  
  for(i = 0; i < n; i++) {
	D1 += abs(x[i] - y[i]);
	
	sum2 += pow(abs(x[i] - y[i]), 2);
	sum3 += pow(abs(x[i] - y[i]), 3);
	
	if(i == 0) {
	  Dm = abs(x[i] - y[i]);
	}
	else {
	  if(abs(x[i] - y[i]) > Dm) {
		Dm = abs(x[i] - y[i]);
	  }
	}
  }
  D2 = sqrt(sum2);
  D3 = cbrt(sum3);
  printf("%lf\n%lf\n%lf\n%lf\n", D1, D2, D3, Dm);
  return 0;
}

Measured memory_bytes: 3416
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
    int n,a[101],i,w,flg,m;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    scanf("%d",&a[i]);
	}
	sort(a,a+n);
	w=0;
	i=0;
	while(1){
	    i++;
		if(i<=a[w]&&i<=n-w){
		    m=i;
		}
		else if(i>a[w]){
		    w++;
			i--;
		}
		if(n==w) break;
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 2788
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np
 
K = INT()
sum = 0
 
for n in range(K):
  for m in range(K):
    sum1 = gcd(n+1, m+1)
    for l in range(K):
      sum += gcd(l+1, sum1)
 
print(sum)

Measured memory_bytes: 27140
import sys
K, X = map(int, input().split())

stone = [0 for i in range(-1000000, 1000001)]
for i in range(X-K+1, X+K):
    if i >= -1000000 and i <= 1000000:
        stone[i] = 1

for i in range(-1000000, 1000001):
    if stone[i] == 1:
        print(i)


Measured memory_bytes: 123624
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] cmd=br.readLine().split(" ");
		int n=Integer.valueOf(cmd[0]);
		int[] arr=new int[n];
		cmd=br.readLine().split(" ");
		for(int i=0;i<n;i++)
		{
			arr[i]=Integer.valueOf(cmd[i]);
		}
		HashMap<Integer,Long> map1=new HashMap<>();
		HashMap<Integer,Long> map2=new HashMap<>();
		for(int i=0;i<n;i++)
		{
			int x=i+arr[i];
			int y=i-arr[i];
			if(map1.containsKey(x))
				map1.replace(x,map1.get(x)+(long)1);
			else
				map1.put(x,(long)1);
			if(map2.containsKey(y))
				map2.replace(y,map2.get(y)+(long)1);
			else
				map2.put(y,(long)1);
		}
		long ans=0;
		for(int i=0;i<n;i++)
		{
			int x=i+arr[i];
			int y=i-arr[i];
			if(map1.containsKey(y))
				ans=ans+map1.get(y);
			if(map2.containsKey(x))
				ans=ans+map2.get(x);
		}
		System.out.println(ans/2);
	}

}


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

char a,b;

int main(){

	scanf("%c %c",&a,&b);
	if(a=='H'&&b=='H'||a=='D'&&b=='D'){
		printf("H\n");
	}else if(a=='H'&&b=='D'||a=='D'&&b=='H'){
		printf("D\n");
	}

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

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  bool flag = true;
  if (s.at(2) == s.at(3)) {
    if (s.at(4) == s.at(5)) {
      coYes;
      flag = false;
    }
  }
  if (flag) {
    coNo;
  }
}


Measured memory_bytes: 3576
#include <stdio.h>
 
int main(void){
  int i,j,n,taro_p=0,hana_p=0;
  char taro[101], hana[101];
 
  scanf("%d", &n);
 
  for(i=0;i<n;i++){
    scanf("%s %s", taro, hana);
 
    for(j=0;;j++){
      if(taro[j] > hana[j]){
        taro_p += 3;
        break;
      }else if(taro[j] < hana[j]){
        hana_p += 3;
        break;
      }else if(taro[j] + hana[j] == 0){
        hana_p++;
        taro_p++;
        break;
      }
    }
  }
 
  printf("%d %d\n", taro_p , hana_p);
  return 0;
}


Measured memory_bytes: 2088
from decimal import Decimal, getcontext

getcontext().prec = 1000
a,b,c = map(int,input().split())

sq_a = Decimal(a).sqrt()
sq_b = Decimal(b).sqrt()
sq_c = Decimal(c).sqrt()

eps = Decimal(10) ** (-100)

cond = sq_a + sq_b + eps < sq_c
answer = 'Yes' if cond else 'No'
print(answer)


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

bool check(ll n, ll s, ll b){
	//cout << n << " " << b << " " << " " << s << endl;
	ll s1 = 0;
	for(; n; n /= b){
		s1 += n % b;
	}
	return s1 == s;
}

void solve(){
	ll n, s;
	cin >> n >> s;
	if (n < s){
		cout << -1 << endl;
		return;
	}
	if (n == s){
		cout << n + 1 << endl;
		return;
	}
	ll ans = INF;
	for(ll i = 1; i * i <= n - s; i++){
		if ((n - s) % i == 0){
			if (check(n, s, i + 1)){
				ans = min(ans, i + 1);
			}
			if (check(n, s, (n - s) / i + 1)){
				ans = min(ans, (n - s) / i + 1);
			}
		}
	}
	if (ans == INF){
		ans = -1;
	}
	cout << ans << endl;
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 256
from itertools import product
lst = ["3","5","7"]
x = input()
n = len(x)
cnt = 0

for i in range(3, n+1):
    for j in product(lst, repeat=i):
        y = "".join(j)
        if ("3" in y) & ("5" in y) & ("7" in y):
            if int(x) >= int(y):
                cnt += 1

print(cnt)

Measured memory_bytes: 3064
def submit():
    k, n = map(int, input().split())
    a = list(map(int, input().split()))
    # 家間の距離を計算
    gaps = [a[i + 1] - a[i] for i in range(n - 1)]
    gaps.append(a[0] + k - a[n - 1])
    # 一番距離が大きいパスを省けば良い
    print(sum(gaps) - max(gaps))


submit()

Measured memory_bytes: 26444
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n,t,mi=1001;
	cin>>n>>t;
	vector<pair<int,int>>v(n);
	for(int i=0;i<n;i++){
		cin>>v.at(i).first>>v.at(i).second;
		if(v.at(i).second<=t){
			mi=min(v.at(i).first,mi);
		}
	}
	if(mi==1001){
		cout<<"TLE"<<endl;
	}else{
		cout<<mi<<endl;
	}return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); (i)++)
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x, T) sort(ALL(x), greater<T>())
#define REVERCE(x) reverce(ALL(x))

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

itn main() {
	ios::sync_with_stdio(false);

	string s;

	cin >> s;

	if (s == "MON") {
		cout << 6;
	}
	if (s == "TUE") {
		cout << 5;
	}
	if (s == "WED") {
		cout << 4;
	}
	if (s == "THU") {
		cout << 3;
	}
	if (s == "FRI") {
		cout << 2;
	}
	if (s == "SAT") {
		cout << 1;
	}
	if (s == "SUN") {
		cout << 7;
	}

	return 0;
}


Measured memory_bytes: 256
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            double a = int.Parse(In[0]);
            double b = int.Parse(In[1]);
            double x = int.Parse(In[2]);
            double rad = 0, t=0;
            if (x >= (a * a * b) / 2)
            {
                t = 2 * (a * b - (x/a)) / a;
                rad = Math.Atan2(t,a);
            }
            else
            {
                t = 2 * x / (a * b);
                rad = Math.Atan2(b,t);
            }
            double ans = rad / (2 * Math.PI) * 360;
            Console.WriteLine(ans);
        }
    }
}


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

int main() {
    int N;
    int a1[100], a2[100];
    int answer;
    int sum = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a1[i];
    }
    sum += a1[0];
    for (int i = 0; i < N; i++) {
        cin >> a2[i];
        sum += a2[i];
    }
    answer = sum;
    for (int i = 1; i < N; i++) {
        sum = sum + a1[i] - a2[i - 1];
        if (answer < sum) answer = sum;
    }
    cout << answer << endl;
}

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

long long int bikkuri(long long int a,long long int b){
    long long int ans=1;
    long long int c=a;
    for(long long int i=1;i<=b;i++){
        ans*=c;
        ans/=i;
        c--;
    }
    return ans;
}

int main(){
    
    long long int N,A,B;cin>>N>>A>>B;
    vector<long long int> S(N);
    for(long long int i=0;i<N;i++){
        cin>>S[i];
    }
    sort(S.rbegin(),S.rend());
    bool flag=true;
    for(long long int i=1;i<A;i++){
        if(S[i]!=S[0]) flag=false;
    }
    if(flag){
        long long int cnt=A;
        for(long long int i=A;i<N;i++){
            if(S[i]==S[0]) cnt++;
        }
            long long int ans=0;
            for(long long int i=A;i<=min(cnt,B);i++){
                ans+=bikkuri(cnt,i);
            }
        cout<<S[0]<<endl<<ans<<endl;
        
    }else{
        long long int cnt1=0,cnt2=0;
        for(long long int i=0;i<A;i++){
            if(S[i]==S[A-1]) cnt1++;
        }
        for(long long int i=A;i<N;i++){
            if(S[i]==S[A-1]) cnt2++;
        }
        long long int sum=0;
        for(int i=0;i<A;i++){
            sum+=S[i];
        }
        double C=double(A);
        cout<<fixed<<setprecision(30)<<sum/C<<endl;
        cout<<bikkuri(cnt1+cnt2,cnt1)<<endl;
    }
    
    }


Measured memory_bytes: 256
n,d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n-1):
  for j in range(i+1,n):
    s = 0
    for k in range(d):
      s += abs(x[i][k] - x[j][k])**2
    s = s**0.5
    if s.is_integer(): ans += 1
print(ans)

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  bool prevIsWhite = false;
  int res = 0;
  for (int i = 0; i < s.size(); i++) {
    char c = s[i];
    if (c == '1') {
      if (prevIsWhite && i != 0) {
        res++;
        prevIsWhite = false;
      } else {
        prevIsWhite = true;
      }
    } else {
      if (!prevIsWhite && i != 0) {
        res++;
        prevIsWhite = true;
      } else {
        prevIsWhite = false;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3756
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string s;
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='C'){
            for(int j=i+1;j<s.size();j++){
                if(s[j]=='F'){
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    
  int S,s,m,h;cin >> S; 
  h=S/(60*60);
  cout << h ; cout<<":";
  m=(S%(60*60))/60;
  cout << m ; cout<<":";
  s=(S%(60*60))%60;   cout << s;
  cout<<endl;
    
}


Measured memory_bytes: 3104
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> a(3*N);
  rep (i, 3*N) cin >> a[i];
  sort(a.rbegin(), a.rend());
  long ret = 0;
  rep (i, N) ret += a[2*i + 1];
  cout << ret << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

long long MOD = 1000000007;

int main()
{
    int n;
    long long a[300010];
    
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> a[i];
    }
    
    
    long long ans = 0;
    for (int i = 0;i < 60;i++){
        long long box1 = 0;
        for (int j = 0;j < n;j++){
            if (a[j] & (1LL<<(long long)i)){
                box1++;
            }
        }
        long long box0 = n-box1;
        long long tmp = box1*box0%MOD*((1LL<<(long long)i)%MOD)%MOD;
        ans = (ans+tmp)%MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>

using namespace std;

const int z = 1e9+7;

int main() {
    bool flag = true;
    int n, m;
    cin >> n >> m;

    int r[n*m], c[n*m];
    fill(r, r+n*m, -1);
    fill(c, c+n*m, -1);

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a--;
        if (r[a] == -1) {
            r[a] = i;
        } else {
            flag = false;
            break;
        }
    }

    for (int i = 0; i < m; i++) {
        int b;
        cin >> b;
        b--;
        if (c[b] == -1) {
            c[b] = i;
        } else {
            flag = false;
            break;
        }
    }

    int ans = 1;
    int cr = 0, cc = 0;
    for (int i = n * m - 1; i >= 0; i--) {
        if (r[i] == -1 && c[i] == -1) {
            ans = 1ll * ans * (cr * cc - (n * m - 1 - i)) % z;
        } else if (r[i] == -1) {
            ans = 1ll * ans * cr % z;
            cc++;
        } else if (c[i] == -1) {
            ans = 1ll * ans * cc % z;
            cr++;
        } else {
            cr++;
            cc++;
        }

        if (cr > n || cc > m) {
            flag = false;
        }
    }

    cout << (flag ? ans : 0) << endl;

    return 0;
}


Measured memory_bytes: 8064
while True:
    H,W = map(int,input().split())
    if H == W == 0:
        break
    
    for i in range(H):
        if i % 2 ==0:
            if W % 2 == 0:
                print("#."*(W//2))
            else:
                print("#."*(W//2)+"#")
        else:
            if W % 2 == 0:
                print(".#"*(W//2))
            else:
                print(".#"*(W//2)+".")
    print()


Measured memory_bytes: 5608
def Get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def Get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def Get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def Get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end

n=gets.to_i
a=Get_i()
color=Array.new(8){false}
free=0
n.times do|i|
  unless a[i]>=3200
    color[a[i]/400]=true 
  else
    free+=1
  end
end
sum=color.select{|x| x}.size
print sum.zero? ? 1 : sum," "
ans=0
ans=sum+free 
puts ans

Measured memory_bytes: 1788
n , m = gets.chop.split.map(&:to_i)
x = gets.chop.split.map(&:to_i)

x.sort!.reverse!


# print x

sa = []

if m > n then
  for i in 1..m-1 do
    sa << (x[i-1] - x[i]).abs
  end

  sa.sort!.reverse!

  ans = x.max-x.min

  (n-1).times do |i|
    ans -= sa[i]
  end


  puts ans
else
  puts 0
end


Measured memory_bytes: 10608
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

def lcm(a, b):
  return a * b // gcd(a, b)

n, x = map(int, input().split())
a = list(map(int, input().split()))
a.append(x)
a = sorted(a)

d = []
for i, j in zip(a, a[1:]):
  d.append(j - i)

ans = d[0]
for i in d:
  ans = gcd(i, ans)

print(ans)

Measured memory_bytes: 14480
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	
	int ans = H * W;
	ans -= h * W;
	H -= h;
	ans -= H * w;	
	cout << max(0, ans) << endl;

	return 0;
}


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

const long long INF = 9e18;
const int N = 2e5 + 10;
const int MOD = 1e9 + 7;

typedef long long ll;

int f[N], inv[N], finv[N];
int n, m;

void initInv() {
    f[0] = 1;
    for (int i = 1; i < N; i++) {
        f[i] = (ll)f[i - 1] * i % MOD;
    }
    inv[0] = inv[1] = 1;
    for (int i = 2; i < N; i++) {
        inv[i] = (ll)(MOD - MOD / i) * inv[MOD % i] % MOD;
    }
    finv[0] = finv[1] = 1;
    for (int i = 2; i < N; i++) {
        finv[i] = ((ll)finv[i - 1] * inv[i]) % MOD;
    }
}

int C(int x, int y) {
    if (y < 0) return 0;
    return ((ll)f[x] * finv[y] % MOD) * finv[x - y] % MOD;
}

int Lucas(int u, int v) {
    if (v == 0) return 1;
    return (ll)C(u % MOD, v % MOD) * Lucas(u / MOD, v / MOD) % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    initInv();
    cin >> n >> m;
    ll ans = 1;
    if (n > m) swap(n, m);
    if (m > n + 1) {
        cout << 0 << endl;
    } else if (m == n){
        cout << 2ll * f[n] % MOD * f[n] % MOD << endl;
    } else {
        cout << (ll)f[m] * f[n] % MOD << endl;
    }
    return 0;
}



Measured memory_bytes: 2560
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

int main () {
	string s;
	string jud = "keyence";
	cin >> s;

	int n = jud.size ();
	bool flag = false;

	REP (i, 1,7 ) {
		string s1 = jud.substr (0, i);
		string s2 = jud.substr (i, n - i);

		//cout << s1 <<" "<< s2 << endl;

		auto pos1 = s.find (s1);
		auto pos2 = s.find(s2,s.size()-s2.size());
		
		if (pos1 == 0 && pos2 == s.size () - s2.size()) {
			flag = true;
		}

		//auto pos2 = s.find (s2, pos1);
	}

	if (s.find (jud) == 0 || s.find (jud) == s.size () - 7) {
		flag = true;
	}

	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    int k,x;
    cin >> k>>x;
    for(int i=x-k+1;i<=x+k-1;i++){
        cout << i<<' ';
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int N,K;
	int i,j;
	int tmp;
	int answer=0;
	int counter=0;
	vector<int> given;

	cin >> N >> K;

	for(i=0;i<N;i++){
		cin >> tmp;
		given.push_back(tmp);
	}

	sort(given.begin(),given.end());
	
	for(i=0;i<K;i++)
		answer+=given[i];

	cout << answer << endl;

	return 0;
}




Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n, ans = 0;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    rep(i, n)
    {
        if (p[i] == i + 1)
        {
            if (p[i + 1] == i + 2)
            {
                ans++;
                i++;
            }
            else
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int a, b;
  cin >> a >> b;

  if (a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) pr("Possible");
  else pr("Impossible");


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <cmath> 
#include <algorithm>
using namespace std;
char a[20]; 
int N; 
long long ans = 0; 
void dfs(int x, int pre, long long res) { 
	if (x == N + 1) {
		long long nw = 0; 
		for (int i = pre + 1; i <= N; i++) nw = nw * 10 + a[i] - '0'; 
		ans += res + nw; 
		return ; 
	} 
	dfs(x + 1, pre, res); 
	long long nw = 0; 
	for (int i = pre + 1; i < x; i++) nw = nw * 10 + a[i] - '0'; 
	dfs(x + 1, x, res + nw); 
} 
int main () { 
	scanf("%s", a + 1); N = strlen(a + 1); 
	dfs(1, 0, 0); 
	printf("%lld\n", ans); 
    return 0; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n==3){
        cout<<"2 5 63"<<endl;
        return 0;
    }
    if(n==4){
        cout<<"2 5 20 63"<<endl;
        return 0;
    }
    if(n==6){
        cout<<"2 3 4 5 6 10"<<endl;
        return 0;
    }
    if(n==19999){
        rep(k,0,10000){
            cout<<3*(k+1)<<endl;
        }
        
        int now=0;
        rep(k,0,9999){
            now+=2;
            if(now%3==0) now+=2;
            
            if(now==29966) cout<<29965<<endl;
            else if(now==29996) cout<<29995<<endl;
            else cout<<now<<endl;
        }
        return 0;
    }
    for(int i=3;i<=15000;i+=3){
        if((n-i)%2!=0) continue;
        int j=n-i;
        if(j<=0 || j>5000) continue;
        
        rep(k,0,i){
            cout<<2*(k+1)<<endl;
        }
        rep(k,0,j){
            cout<<6*k+3<<endl;
        }
        break;
    }
}


Measured memory_bytes: 384
import java.util.*;

class Main{
	public static void main(String[] Args){
		Scanner sc = new Scanner(System.in);
		int q = Integer.parseInt(sc.next());
		LinkedList<Integer> la = new LinkedList<Integer>();
		ListIterator<Integer> it = la.listIterator();
		for(int i = 0; i < q; i++){
			int op = Integer.parseInt(sc.next());
			if(op == 0){
				int x = Integer.parseInt(sc.next());
				it.add(x);
				it.previous();
			}else if(op == 1){
				int d = Integer.parseInt(sc.next());
				if(d < 0){
					for(int j = 0; j < -d; j++) it.previous();
				}else{
					for(int j = 0; j < d; j++) it.next();
				}
			}else{
				it.next();
				it.remove();
			}
		}
		while(!la.isEmpty()){
			System.out.println(la.get(0));
			la.remove(0);
		}
	}
}



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

int main()
{
    string s;
    getline(cin, s);
    
    for (int i = 0; i < s.size(); i++) {
        if (islower(s[i])) s[i] = toupper(s[i]);
        else if (isupper(s[i])) s[i] = tolower(s[i]);
    }
    
    cout << s << endl;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
 string S;
  cin >> S;
  int price = 700;
  
  for(int i = 0; i < 3; i++) {
    if(S.at(i) =='o') {
      price +=100;
    }
  }
  
  cout << price << endl;
}

Measured memory_bytes: 3600