akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  vector<int> a(n + 2);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }

  int sum = 0;
  for (int i = 1; i < n + 2; i++) {
    sum += abs(a[i] - a[i - 1]);
  }

  for (int i = 1; i <= n; i++) {
    int cur = a[i];
    int from = a[i - 1];
    int nxt = a[i + 1];

    int tmp = -abs(cur - from) - abs(cur - nxt) + abs(nxt - from);
    cout << sum + tmp << '\n';
  }

  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
void solve()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(true)
	{
		c=c-b;
		if(c<=0)
		{
			cout<<"Yes";
			return;		}
		a=a-d;
		if(a<=0)
		{
			cout<<"No";
			return;
		}
		
	}
}
int main()
{
	 solve();
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string> 
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g;}
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int main()
{
	int n;
	cin >> n;
	vl a(n);
	rep(i, n)cin >> a[i];
	sort(all(a));
	vl sum(n + 1,0);
	rep(i, n + 1)sum[i] = i == 0 ? 0 : sum[i - 1] + a[i - 1];
	int l = -1, r = n;
	while (l + 1 < r)
	{
		int mid = (l + r) / 2;
		bool eat_all = true;
		mrep(i, mid + 1, n)
		{
			if (sum[i] * 2 < a[i])eat_all = false;
		}
		if (eat_all)r = mid;
		else l = mid;
	}
	co(n - r);
	return 0;
}


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

const int N = 1000005;

int n;
char s[N];

long long sum[3][N];

long long get(long long sum[N], int x) {
  if (x < 0) return 0;
  return sum[x];
}

long long get(long long sum[N], int l, int r) {
  return get(sum, r) - get(sum, l);
}

int main() {
  scanf("%d", &n);
  scanf("%s", s);
  
  for (int i=0; i<n; i++) sum[0][i] = (s[i] == 'M');
  for (int i=n-2; i>=0; i--) sum[0][i] += sum[0][i+1];
  
  for (int i=0; i<n; i++) sum[1][i] = sum[0][i] * (s[i] == 'D');
  for (int i=1; i<n; i++) sum[1][i] += sum[1][i-1];
  
  for (int i=0; i<n; i++) sum[2][i] = (s[i] == 'D');
  for (int i=0; i<n; i++) sum[2][i] += sum[2][i-1];
  
  int q;
  scanf("%d", &q);
  while (q--) {
    int k;
    scanf("%d", &k);
    
    long long ans = 0;
    
    for (int i=0; i<n; i++) {
      if (s[i] == 'C') {
        ans += get(sum[1], i-k, i) - get(sum[2], i-k, i) * sum[0][i];
      }
    }
    
    printf("%lld\n", ans);
  }
  
  return 0;
}


Measured memory_bytes: 24704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int a = fs.nextInt();
		int b = fs.nextInt();
		
		int gcdVal = gcd(a,b);
		
		long ans = ((long)(a/gcdVal)) * (b/gcdVal) * gcdVal;
		System.out.println(ans);
	}

	int gcd(int a , int b) {
		if(a < b) {
			int swap = a;
			a = b;
			b = swap;
		}
		
		int r = a % b;
		while(r != 0) {
			
			a = b;
			b = r;
			r = a % b;
		}
		
		return b;
	}
	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

using ll = long long;

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

    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    REP(i, N) cin >> H[i];

    sort(all(H));
    ll result = accumulate(H.begin(), H.begin() + max(N - K, 0), 0ll);
    cout << result << endl;

    return 0;
}


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

const int N = 2;
const int INF = 2e9;
const int mod = 1e9+7;

int ans, n, m, k;
int a[N];

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  for (int i = 0; i < min(s.size(), t.size()); ++i) {
    if (s[i] < t[i]) return !printf("Yes");
    if (t[i] < s[i]) return !printf("No");
  }
  if (s.size() < t.size()) return !printf("Yes");
  printf("No");



  //~ printf("%d", ans);
  return 0;
}


Measured memory_bytes: 256
/* vo00_06.cpp */
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string str;
	string::iterator istr;
	cin >> str;

	while (str.size()) {
		istr = str.end();
		cout << str.at(str.size() - 1);
		str.erase(istr - 1, istr);
	}

	cout << '\n';

	return 0;
}

Measured memory_bytes: 1156
n=int(input())
l = list(map(int, input().split()))

cnt = 0

# ３つの相異なる数字（i, j, k）の組み合わせを調べること
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            a = l[i]
            b = l[j]
            c = l[k]
            if a == b or b == c or c == a:
                continue
            else:
                if a<b+c and b<c+a and c<a+b:
                    cnt+=1
print(cnt)

Measured memory_bytes: 9176
#include <iostream>
#include <string>
#include <stdlib.h>
#define INF 0x7fffffff
#define MAX_V 100
using namespace std;

int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];
int V; // V<=100

int prim(){
  for( int i=0;i<V;++i ){
    mincost[i]=INF;
    used[i] = false;
  }
  mincost[0] = 0;
  int res = 0;
  while( true ){
    int v=-1;
    for( int u=0;u<V;u++ ){
      if( !used[u] && (v==-1 || mincost[u] < mincost[v])) v=u;
    }
    if( v==-1 ) break;
    used[v] = true;
    res += mincost[v];

    for( int u=0;u<V;u++ )
      mincost[u] = min( mincost[u], cost[v][u] );
  }
  return res;
}

int main(){
  int m;
  string line;
  char buf[256];

  while(  cin >> V,V ){
    cin >> m;
    //    cout << "V="<<V <<" m="<<m<<endl;

    int x,y;
    int k;
    for( int i=0;i<V;i++ )
      for( int j=0;j<V;j++ )
	cost[i][j] = INF;
    for( int i=0,j;i<m;i++ ){
      cin >> line;
      for( j=0;j<line.size();j++ ) buf[j] = line.at(j);
      buf[j] = '\0';
      x = atoi( buf );
      for( j=0; buf[j]!=',';j++ );
      y = atoi( ++j+buf );
      for( ; buf[j]!=',';j++ );
      k = atoi( ++j+buf );
      //       cout << x <<"_"<<y<<"_"<<k<< endl;
      k = k/100 -1; // UÌ
      cost[x][y] = k;
      cost[y][x] = k;
    }
    cout << prim() << endl;
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.HashMap;


public class Main
{
    String a, b;
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	if(a.length() == b.length()) {
	    int diff = a.compareTo(b);
	    
	    if(diff == 0) {
		out("EQUAL");
	    } else if(diff > 0) {
		out("GREATER");
	    } else {
		out("LESS");
	    }
	} else {
	    if(a.length() > b.length()) out("GREATER");
	    else out("LESS");
	}
	    
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	a = sc.next();
	b = sc.next();
    }

    void out()
    {
	
    }
    
    void out(int ans)
    {
	System.out.println(ans);
    }
    
    void out(String ans)
    {
	System.out.println(ans);
    }
}


Measured memory_bytes: 22740
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;
int arrived[1010][1010];

int main()
{
   int H, W;
   cin >> H >> W;
   int Ch, Cw, Dh, Dw;
   cin >> Ch >> Cw >> Dh >> Dw;
   Ch--;
   Cw--;
   Dh--;
   Dw--;
   vector<string> S(H);
   for (int i = 0; i < H; i++)
   {
      cin >> S[i];
   }
   for (int i = 0; i < 1010; i++)
   {
      for (int j = 0; j < 1010; j++)
      {
         arrived[i][j] = INT_MAX / 2;
      }
   }
   priority_queue<pair<int, pair<int, int>>> pq;
   pq.push(make_pair(0, make_pair(Ch, Cw)));
   arrived[Ch][Cw] = 0;
   int dx[] = {1, 0, -1, 0};
   int dy[] = {0, 1, 0, -1};
   while (!pq.empty())
   {
      pair<int, pair<int, int>> t = pq.top();
      pq.pop();
      //cout << t.first << " " << t.second.first << " " << t.second.second << endl;
      if (t.second.first == Dh && t.second.second == Dw)
      {
         cout << -t.first << endl;
         return 0;
      }
      for (int i = 0; i < 4; i++)
      {
         int nx = t.second.first + dx[i];
         int ny = t.second.second + dy[i];
         if (0 <= nx && nx < H && 0 <= ny && ny < W && S[nx][ny] != '#')
         {
            if (arrived[nx][ny] > -t.first)
            {
               arrived[nx][ny] = -t.first;
               pq.push(make_pair(t.first, make_pair(nx, ny)));
            }
         }
      }
      for (int a = -2; a <= 2; a++)
      {
         for (int b = -2; b <= 2; b++)
         {
            int nx = t.second.first + a;
            int ny = t.second.second + b;
            if (0 <= nx && nx < H && 0 <= ny && ny < W && S[nx][ny] != '#')
            {
               if (arrived[nx][ny] > -t.first + 1)
               {
                  arrived[nx][ny] = -t.first + 1;
                  pq.push(make_pair(t.first - 1, make_pair(nx, ny)));
               }
            }
         }
      }
   }
   cout << -1 << endl;
   return 0;
}


Measured memory_bytes: 9584
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n").map(Number);
var N=arr.shift();
var A=[];
var L=[];
for(var i=0;i<N;i++)A.push(arr.shift());
L[0] = A[0]
var length = 1;
for(var i=1;i<N;i++){
   if (L[length-1] < A[i])L[length++] = A[i];
   else {
      for(var j=0;j<length;j++){
         if(L[j]>=A[i]){L[j]=A[i];break;}
      }
   }
}
console.log(length);

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

if A%2 == 1 or B%2 == 1 or C%2 == 1:
    print(0)
elif A == B and B == C:
    print(-1)
else:
    ans = 0
    flag = True
    a,b,c = A,B,C
    while flag:
        a_old, b_old, c_old = a,b,c
        a = b_old//2 + c_old//2
        b = c_old//2 + a_old//2
        c = a_old//2 + b_old//2
        ans += 1
        if a%2 == 1 or b%2 == 1 or c%2 == 1:
            flag = False

    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;
using ll = long long;

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

// https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n, 0); 
  rep(i, n) cin >> a[i];

  ll ans = 1e15;
  rep (bit, (1 << n)) {
    if (bitset<32>(bit).count() != k) continue;

    ll cost = 0;
    ll maxH = a[0] + 1;
    rep (i, n) {
      if (bit & (1 << i)) {
        // 一番目のビルはコストがかからないからスキップ
        if (i == 0) continue;
        if (a[i] < maxH) {
          cost += (maxH - a[i]);
          ++maxH;
        } else {
          maxH = a[i] + 1;
        }
      } else {
        maxH = max(maxH, a[i] + 1);
      }
    }
    ans = min(ans, cost);
  }
  cout << ans << endl;
  return 0;
}

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

x_dif = t_list[0][1]
y_dif = t_list[0][2]
t_dif = t_list[0][0]
if x_dif + y_dif <= t_dif and (x_dif+y_dif)%2 == t_dif%2:
    pass
else:
    print('No')
    exit()
for i in range(n-1):
    x_dif = abs(t_list[i+1][1]-t_list[i][1])
    y_dif = abs(t_list[i+1][2]-t_list[i][2])
    t_dif = t_list[i+1][0]-t_list[i][0]
    # print(i, x_dif, y_dif, t_dif)
    if x_dif + y_dif <= t_dif and (x_dif+y_dif)%2 == t_dif%2:
        pass
    else:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 27188
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;

const ll logx=30;
const ll N=4e5+5;
const ll M=3e5+5;
const ll mod=1e9+7;
const ll INF=1e18+5;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int main()
{
  ll a,b;
  priority_queue<ll> pq;
  cin>>a>>b;
  ll cnt=0,sum=0;
  pq.push(a);
  pq.push(b);
  while(cnt<2)
  {
    ll cur=pq.top();
    sum+=cur;
    pq.pop();
    cur--;
    pq.push(cur);
    cnt++;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
    	int n,m;cin>>n>>m;
    	int votes[n];
    	int sum = 0;
    	for(int i=0; i<n; i++)
    	{
    		cin>>votes[i];
    		sum = sum + votes[i];
    	}
    	int count = 0;
        float check = (sum * 1.0)/(4.0*m);
    	for( int i=0;i<n;i++)
    	{
    		if( votes[i] >= check)
    			count++;
    	}
    	if(count >= m)
    		cout<<"Yes";
    	else
    		cout<<"No";
    }

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    s, p = input().split()
# pを数値に
    p = int(p)
# i,s,pの並びでlistを入れる
    a.append([i+1, s, p])

# 点数の高い順に並べる
a.sort(key=lambda x:x[2], reverse=True)
# レストラン名の辞書順に並べる
a.sort(key=lambda x:x[1])
# それぞれの市について、辞書順に点数の高い順に並べる
for i in range(n):
    print(a[i][0])

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

vector<int> list;

bool input(){
  int n;
  cin>>n;
  if(n==0)return false;
  list.resize(n);
  for(int i=0;i<n;i++){
    cin>>list[i];
  }
  return true;
}

void print(){
  for(int i=0;i<list.size();i++){
    cout<<list[i];
    i++;
    if(i<list.size()&&list[i-1]==list[i]-1){
      while(list[i-1]==list[i]-1)i++;
      i--;
      cout<<"-"<<list[i];
    }else{
      i--;
    }
    if(i!=list.size()-1)cout<<" ";
  }
  cout<<endl;
}

int main(){
  while(input())print();
}

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

int main() {
    int64_t A,B;
    cin >> A >> B;
    
    int64_t num;
    int64_t ans = 0;
    if ( A % 2 == 0 ){
        if ( B % 2 == 0 ){
            num = B - A;
            ans = num/2;
            ans = ans%2;
            ans = ans^B;
        } else {
            num = B - A + 1;
            ans = num/2;
            ans = ans%2;
        }
    } else {
        if ( B % 2 == 0 ){
            num = B - A - 1;
            ans = num/2;
            ans = ans%2;
            ans = ans^A;
            ans = ans^B;
        } else {
            num = B - A;
            ans = num/2;
            ans = ans%2;
            ans = ans^A;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cctype>
#include<utility>

using namespace std;

int main()
{
    long long  n,a=0,i;
    scanf("%lld",&n);
    long long  p[n];
    for(i=0; i<n; i++)
    {
        scanf("%lld",&p[i]);
        p[i]-=i+1;
    }
    sort(p,p+n);
    i=1;
    while(n-i>=1)
    {
        a+=(p[n-1]-p[i-1]);
        n--;
        i++;
    }
    printf("%lld\n",a);
    return 0;
}


Measured memory_bytes: 1792
/*
I just got lost in thought. It was unfamiliar territory.
- Steven Wright
*/

#include <algorithm>
#include <bitset>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <vector>
//#include <boost/math/common_factor.hpp>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 1000000000;
const int MAX = 100005;
const int MAX1 = 2007;
const int MAX2 = 4007;
const int LEN = 21;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1234567891;
//g++ -std=c++11 your_file.cpp -o your_program

int arr[MAX];

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

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}


int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ifstream in("");
    ofstream out("");
    int n, x;
    cin >> n >> x;
    FOR(i, 1, n + 1) {
        int tmp;
        cin >> tmp;
        arr[i] = tmp;
    }
    arr[0] = x;
    sort(arr, arr + n + 1);
    int res;
    REP(i, n){
        if (i == 0) res = abs(arr[1] - arr[0]);
        else res = gcd(abs(arr[i] - arr[i + 1]), res);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
  int a,b,c;
  cin >>a>>b>>c;
  if(a>=b && b>=c){ cout<<a-c<<endl;return 0;}
  if(a>=c && c>=b){ cout<<a-b<<endl;return 0;}
  if(b>=c && c>=a) {cout<<b-a<<endl;return 0;}
  if(b>=a && a>=c) {cout<<b-c<<endl;return 0;}
  if(c>=a && a>=b) {cout<<c-b<<endl;return 0;}
  if(c>=b && b>=a) {cout<<c-a<<endl;return 0;}
  return 0;
}

Measured memory_bytes: 256
// doot diddly donger cuckerino Hahahahahah


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vi = vector<int>;

template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template <typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template <typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

class APluralForm {
public:

  void solve(std::istream& cin, std::ostream& cout) {
    string s;
    cin >> s;
    if(s.back() == 's') {
      s += "es";
    }else{
      s += "s";
    }
    cout << s << endl;
    
  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	APluralForm solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6;
int d()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
long long lld()
{
    long long ret;
    scanf("%lld", &ret);
    return ret;
}
bool cmp(pair<int, int> s, pair<int, int> f)
{
    if (f.first > s.first)
        return true;
    else if (f.first == f.second && f.second < s.second)
        return true;
    else
        return false;
}
long long arr[N],n;
bool IsCover(long long d){
    long long lastcover=-1,used=0;
    for(int i=0;i<n;i++){
        if(arr[i]>lastcover){
        lastcover=arr[i]+(2*d);
        used++;
        }

    }
    return used<=3;
}
long long PS(){
    long long hi=1e5,lo=0,mid;
    while(hi-lo > 0){
        mid=(lo+hi)/2;
        if(IsCover(mid))hi=mid;
        else lo=mid+1;
    }
    return lo;
}
int main(){
     int m=d();
     printf("%d\n",(24-m)+24);

}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

public class Main{
  public static OutputStream out=new BufferedOutputStream(System.out);
  static Scanner sc=new Scanner(System.in);
  static long mod=1000000007l;
  static int INF=1000000;

  //nl-->neew line; //l-->line;  //arp-->array print;  //arpnl-->array print new line
  public static void nl(Object o) throws IOException{out.write((o+"\n").getBytes()); }
  public static void l(Object o) throws IOException{out.write((o+"").getBytes());}
  public static void arp(int[] o) throws IOException{for(int i=0;i<o.length;i++) out.write((o[i]+" ").getBytes()); out.write(("\n").getBytes());}
  public static void arpnl(int[] o) throws IOException{for(int i=0;i<o.length;i++) out.write((o[i]+"\n").getBytes());}
  public static void scanl(long[] a,int n) {for(int i=0;i<n;i++) a[i]=sc.nextLong();}
  public static void scani(int[] a,int n) {for(int i=0;i<n;i++) a[i]=sc.nextInt();}
  public static void scan2D(int[][] a,int n,int m) {for(int i=0;i<n;i++) for(int j=0;j<m;j++) a[i][j]=sc.nextInt();}
  //
  static long cnt;
  static TreeSet<Integer> ans;
  static int n,m;
  static boolean[][] dp,vis;
  static HashMap<Pair,Boolean> arrl;
  static Stack<Integer> stk;
  static Queue<Integer> queue;
  static HashSet<Integer> mtrnode;
  static ArrayList<Integer> arrlans;


  public static void main(String[] args) throws IOException{
    long sttm=System.currentTimeMillis();
    long mod=1000000007l;

    int n=sc.nextInt();
    char[] c=sc.next().toCharArray();
    int cnt=0;
    for(int i=0,j=n-1;i<j;){
        if(c[j]=='R'){
            while(i<j && c[i]!='W'){
                i++;
            }
            if(c[i]=='W'){
                c[i]='R';
                c[j]='W';
                cnt++;
                i++;
                j--;
            }
        }
        else{
            j--;
        }
    }
    nl(cnt);

    out.flush();
  }

}

class Pair{
  int x,y;
  Pair(int x,int y){
    this.x=x;
    this.y=y;
  }
}


Measured memory_bytes: 43264
from collections import deque
n,q=map(int,input().split())
edge=[[] for i in range(n+1)]
for i in range(n-1):
  a,b=map(int,input().split())
  edge[a].append(b)
  edge[b].append(a)

x_list=[0]*(n+1)
for i in range(q):
  p,x1=map(int,input().split())
  x_list[p]+=x1

def bfs(x,x_list):
  qu=deque([])
  qu.append(0)
  qu.append(x)
  node_number=1
  while qu:
    pre=qu.popleft()
    node_number = qu.popleft()
    nodes = edge[node_number]
    for i in nodes:
      if pre != i:
        qu.append(node_number)
        qu.append(i)
        x_list[i]+=x_list[node_number]
      else:continue
  return x_list
answer=bfs(1,x_list)[1:]
print(*answer)

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

int main() {
  double a, t, n, d = 334, r = -1;
  cin >> n >> t >> a;
  for(int i = 0; i < n; i++){
    double h, k, l;
    cin >> h;
    k = t - h * 6 / 1000;
    l = k - a;
    if(l < 0)
      l *= -1;
    if(l < d){
      d = l;
      r = i + 1;
    }
  } 
  cout << r << endl; 
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

Vi v[200001];
bool in(int y,int x)
{
	return (*lower_bound(ALL(v[y]),x))==x;
}
int main(){
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	while(k--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[y].pb(x);
	}
	fup(i,1,m,1)
	{
		sort(ALL(v[i]));
		v[i].pb(n+1);
	}
	int ans=INF;
	int x=1,y=1,t=0;
	while(1)
	{
		ans=min(ans,(*upper_bound(ALL(v[y]),x))-1);
		if(!t)
		{
			if(!in(y,x+1))x++;
			else break;
		}
		else
		{
			if(y<m && !in(y+1,x))y++;
		}
		t^=1;
	}
	printf("%d",ans);
}

Measured memory_bytes: 11392
package main

import (
	"fmt"
)

func main() {
	var a,b,c,d,e,k int
	fmt.Scan(&a,&b,&c,&d,&e,&k)

	if e - a > k {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}
}

Measured memory_bytes: 512
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

typedef pair<ll, ll> P;

int main() {
  int n, m; in(n),in(m);
  vector<P> A(n),B(m);
  loop(i,0,n) in(A[i].first),in(A[i].second);
  loop(i,0,m) in(B[i].first),in(B[i].second);
  loop(i,0,n) {
    ll x = A[i].first, y = A[i].second;
    int k = -1;
    ll min_ = 100000000000000000;
    loop(j,0,m) {
      ll x_ = B[j].first, y_ = B[j].second;
      ll d = abs(x-x_) + abs(y-y_);
      if (min_ > d) {
        min_ = d;
        k = j;
      }
    }
    print(k+1);
  }
  
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int n;
    cin >> n;
    V<int> x(n);
    rep(i,n) cin >> x[i];
    int ans = inf;
    Rep(i,100) {
        int tmp = 0;
        rep(j,n) tmp += (x[j]-i) * (x[j]-i);
        chmin(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

int ans[111];

int calc(int x, int n) {
	int l = 0;
	for (; l <= x; l++) {
		if (ans[x-l] != -1) break;
	}
	if (l == x+1) l = n;
	int r = 0;
	for (; r+x < n; r++) {
		if (ans[r+x] != -1) break;
	}
	if (r+x == n) r = n;
	return min(l, r);
}

int main() {
	int N, M;
	while (cin >> N >> M) {
		if (N == 0 && M == 0) break;
		memset(ans, -1, sizeof(ans));
		for (int t = 0; t < M; t++) {
			char c;
			cin >> c;
			if (c == 'A') {
				for (int i = 0; i < N; i++) {
					if (ans[i] == -1) {
						ans[i] = 0;
						break;
					}
				}
			}
			if (c == 'B') {
				bool done = false;
				for (int i = N-1; i >= 0; i--) if (ans[i] == -1) {
					if (ans[i+1] != 0) {
						if (i == 0 || ans[i-1] != 0) {
							done = true;
							ans[i] = 1;
							break;
						}
					}
				}
				if (!done) {
					for (int i = 0; i < N; i++) {
						if (ans[i] == -1) {
							ans[i] = 1;
							break;
						}
					}
				}
			}
			if (c == 'C') {
				if (t == 0) {
					ans[N/2] = 2;
				} else {
					for (int i = 0; i < N; i++) {
						if (ans[i] != -1) {
							if (i+1 < N && ans[i+1] == -1) {
								ans[i+1] = 2;
								break;
							} else if (i > 0 && ans[i-1] == -1) {
								ans[i-1] = 2;
								break;
							}
						}
					}
				}
			}
			if (c == 'D') {
				if (t == 0) {
					ans[0] = 3;
				} else {
					int index = 0, maxi = 0;
					for (int i = 0; i < N; i++) if (ans[i] == -1) {
						int tmp = calc(i, N);
						if (tmp > maxi) {
							maxi = tmp;
							index = i;
						}
					}
					ans[index] = 3;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			if (ans[i] == 0) cout << 'A';
			else if (ans[i] == 1) cout << 'B';
			else if (ans[i] == 2) cout << 'C';
			else if (ans[i] == 3) cout << 'D';
			else cout << '#';
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 1e5 + 10;
lli dp[N];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	lli n, w;
	cin >> n >> w;
	for(int i = 1; i <= n; i++) {
		lli ww, vv;
		cin >> ww >> vv;
		for(int j = w-ww; j >= 0; j--)
			if(dp[j] != -1)
				dp[j+ww] = max(dp[j+ww], dp[j] + vv);
	}
	lli ans = 0;
	for(int i = 0; i <= w; i++)
		ans = max(ans, dp[i]);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
#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>;

const int INF=1001001001;
int dp[1005][5000];

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>a(m),b(m),c(m);
    rep(i,m){
        cin>>a[i]>>b[i];
        rep(j,b[i]){
            int x; cin>>x;
            x--;
            c[i]|=(1<<x);
        }
    }
    rep(i,1005)rep(j,5000)dp[i][j]=INF;
    dp[0][0]=0;
    for(int i=0; i<m; ++i){
        for(int j=0; j<(1<<n); ++j){
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            dp[i+1][j|c[i]]=min(dp[i+1][j|c[i]],dp[i][j]+a[i]);
        }
    }
    if(dp[m][(1<<n)-1]==INF)cout<<-1<<endl;
    else cout<<dp[m][(1<<n)-1]<<endl;
}

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

int n;
int preorder[40], inorder[40];

void reconstruct(int fp, int lp, int fi, int li)
{
    int root;
    rep(i, n)
    {
        if (preorder[fp] == inorder[i])
            root = i;
    }
    if (root != fi)
    {
        reconstruct(fp + 1, fp + (root - fi) + 1, fi, root);
        cout << " ";
    }
    if (root != li - 1)
    {
        reconstruct(fp + (root - fi) + 1, lp, root + 1, li);
        cout << " ";
    }
    cout << inorder[root];
}

int main()
{
    cin >> n;
    rep(i, n) cin >> preorder[i];
    rep(i, n) cin >> inorder[i];
    reconstruct(0, n, 0, n);
    cout << endl;
    return 0;
}


Measured memory_bytes: 3108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C {
    class Program {
        static void Main(string[] args) {
            var N = int.Parse( Console.ReadLine() );
            var C = new int[ N -1 ];
            var S = new int[ N -1 ];
            var F = new int[ N -1 ];
            var DurationFrom = new int[ N ];
            for ( var i = 0; i != N - 1; ++i ) {
                var buffer = Console.ReadLine().Split();
                C[ i ] = int.Parse( buffer[ 0 ] );
                S[ i ] = int.Parse( buffer[ 1 ] );
                F[ i ] = int.Parse( buffer[ 2 ] );
                DurationFrom[ i ] = S[ i ] + C[ i ];

                for ( var StartFrom = 0; StartFrom != i; ++StartFrom ) {
                    var TimeDeparture = S[ i ];
                    if ( DurationFrom[ StartFrom ] > S[ i ] ) {
                        for ( ; TimeDeparture < DurationFrom[ StartFrom ]; TimeDeparture += F[ i ] ) ;
                    }
                    DurationFrom[ StartFrom ] = TimeDeparture + C[ i ];
                }
            }
            foreach ( var t in DurationFrom ) Console.WriteLine( t );
        }
    }
}


Measured memory_bytes: 13140
a, b, c = map(int, input().split())

x1 = a*c - b
print(x1)
x2 = a*x1 - b
print(x2)
x3 = a*x2 - b
print(x3)
x4 = a*x3 - b
print(x4)
x5 = a*x4 - b
print(x5)
x6 = a*x5 - b
print(x6)
x7 = a*x6 - b
print(x7)
x8 = a*x7 - b
print(x8)
x9 = a*x8 - b
print(x9)
x10 = a*x9 - b
print(x10)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int cnt[99];
string s;
bool f(int i,int sum,bool h)
{
	if(sum==14)return true;
	while(cnt[i]==0)i++;
	if(!h&&cnt[i]>=2)
	{
		cnt[i]-=2;
		if(f(i,sum+2,1))
		{
			cnt[i]+=2;
			return true;
		}
		cnt[i]+=2;
	}
	if(cnt[i]>=3)
	{
		cnt[i]-=3;
		if(f(i,sum+3,h))
		{
			cnt[i]+=3;
			return true;
		}
		cnt[i]+=3;
	}
	if(cnt[i]&&cnt[i+1]&&cnt[i+2])
	{
		cnt[i]--;
		cnt[i+1]--;
		cnt[i+2]--;
		if(f(i,sum+3,h))
		{
			cnt[i]++;
			cnt[i+1]++;
			cnt[i+2]++;
			return true;
		}
		cnt[i]++;
		cnt[i+1]++;
		cnt[i+2]++;
	}
	return false;
}
main()
{
	while(cin>>s)
	{
		for(int i=0;i<9;i++)cnt[i]=0;
		for(int i=0;i<s.size();i++)cnt[s[i]-'1']++;
		int a=0;
		for(int i=0;i<9;i++)
		{
			if(cnt[i]==4)continue;
			cnt[i]++;
			if(f(0,0,0))cout<<(a++?" ":"")<<i+1;
			cnt[i]--;
		}
		if(!a)cout<<0;
		cout<<endl;
	}
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

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

    vector<ll> t(n);
    rep(i, n) cin >> t[i];

    ll L = 0, ans = 0;
    rep(i, n-1){
        if(t[i]+T < t[i+1]){
            ans += (t[i] - L + T);
            L = t[i+1];
        }
    }
    ans += (t[n-1] - L + T);

    cout << ans << endl;
}

Measured memory_bytes: 1792
import sys
from collections import deque

input = sys.stdin.readline

n = int(input())
que = deque()

for _ in range(n):
    command = input().split()
    if command[0] == 'insert':
        que.appendleft(command[1])
    elif command[0] == 'delete':
        if command[1] in que:
            que.remove(command[1])
    elif command[0] == 'deleteFirst':
        que.popleft()
    else:
        que.pop()

print(' '.join(map(str, que)))


Measured memory_bytes: 69728
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            //var c = Console.ReadLine();
            //var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            //var P = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray()


            if (N % 1000 != 0)
            {
                Console.WriteLine(1000 - (N % 1000));
            }
            else{
                Console.WriteLine(0);
            }
            


        }
    }

}


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

int main () {
    string s;
    cin >> s;
    ll size = s.size();
    vector<ll> si(size);
    rep(i, size) {
        si.at(i) = s.at(i) - '0';
    }
    ll ans = 0; //答え
    for (ll i = 0; i < (1 << size - 1); i++) { //1をsize-1シフトさせる(1*2 ^(size - 1))
        ll temp = si.at(0);   //足していく
        for (ll x = 0; x < size - 1; x++) {
            if (i & (1 << x)) {
                ans += temp;
                temp = 0;
                temp += si.at(x+1); //これを一番最後に置く。今あるtempを保存してから新しいのを足す。
            }
            else {
                temp *= 10; //10倍して足すのがわからなかった。
                temp += si.at(x+1);
            }
        }
        ans += temp;
    }
    cout << ans << endl;
}   

Measured memory_bytes: 256
#include <iostream>

using namespace std;
string ans="",str;
int main(){
    cin >> str;
    ans=str[0];
    int idx=1,to=str.length();
    for(int i=0;i<to-1;i++){
        cin >> str;
        ans += str[idx++];
    }
    cout << ans << endl;
    return 0;
}


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

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

// code starts
int main()
{
  int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
  vector<ll> p(a);
  vector<ll> q(b);
  vector<ll> r(c);
  int i;
  rep(i,a)cin>>p[i];
  rep(i,b)cin>>q[i];
  rep(i,c)cin>>r[i];
  sort(all(p));
  reverse(all(p));
  sort(all(q));
  reverse(all(q));
  sort(all(r));
  reverse(all(r));
  priority_queue<ll,vector<ll>,greater<ll>> pq;
  rep(i,x)pq.push(p[i]);
  rep(i,y)pq.push(q[i]);
  int ind=0;
  while(ind<c)
  {
    ll s=pq.top();
    if(s<r[ind])
    {
      pq.pop();
      pq.push(r[ind]);
      ind++;
    }
    else break;
  }
  ll ans=0;
  while(!pq.empty())
  {
    ll now=pq.top();
    pq.pop();
    ans+=now;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#pragma region DEBUG
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#pragma endregion DEBUG
#define MOD 1000000007
#define MAX 500005
#define endl "\n"
lli arr[MAX]; 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    lli t;
    t =1 ;
    while(t--){
        lli n;
        cin>>n;
        lli maxm = -1;
        lli ans = 0;
        for(lli i = 0; i<n; i++){
            lli temp;
            cin>>temp;
            if(temp > maxm)
                maxm = temp;
            else{
                ans += maxm - temp;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3652
#!usr/bim/python
#! -*- coding: utf-8 -*-
import math

nyu = raw_input()
nyu = int(nyu)

h = 0
n = 0
w = 0

if nyu % 2 == 0:
    h = nyu
    n = nyu
    w = nyu / 2

elif nyu % 4 == 1:
    h = nyu / 4.0
    h = math.ceil(h)
    h = int(h)
    i = 0
    status = 0
    while 1:
        x = nyu*h
        y = 4*i+3
        for j in range(y/2):
            if j == 0:
                if x % y == 0:
                    n = x*2/y
                    w = x*2/y
                    status = 1
                    break
            else:
                if x % (j*(y-j)) == 0:
                    n = x/(y-j)
                    w = x/j
                    status = 1
                    break
        if status == 1:
            break
        else:
            i += 1
            h += 1

else:
    h = nyu / 4.0
    h = math.ceil(h)
    h = int(h)
    n = nyu*h*2
    w = nyu*h*2

print h,n,w


Measured memory_bytes: 2696
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;

int main() {
	int X, N;
	int pi[110];
	int i;
	int z;
	int min = 1000;

	cin >> X >> N;
	for (i = 1; i <=N; i++) {
		cin >> pi[i];
	}
	bool a[300]{};

	for (i = 1; i <= N; i++) {
		a[pi[i]+120] = 1;
	}
	for (i = 0; i <= 290; i++) {
		if (a[i] == 0) {
			z = abs(X-(i-120));
		}
		if (z <= min) {
			min = z;
		}
	}
	for (i = -120; i <= 130; i++) {
		if ((a[i+120] == 0) && (min == abs(X-i))) {
			cout << i  << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3608
/* Author : Pranav Deshmukh
            PICT,Pune
   Stay Focused!
*/

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

#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int             long long
#define float           double
#define ms(s, n) 		memset(s, n, sizeof(s))
#define dip(type,var)   type var; cin>>var;
#define dipi(x)         int x; cin>>x;
#define dipi2(x,y)      int x,y; cin>>x>>y;
#define w(x)            int x; cin>>x; while(x--)
#define mka(type,arr,n) type *arr=new type[n];
#define fo(i,n)         for(int i=0;i<n;i++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define pi              3.141592653589793238
#define endl            "\n"
#define f               first
#define s               second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >

void sync() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void timeTaken() {
	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
}

int32_t main() {
	sync();
	dipi(n);
	mka(int, arr, n);
	fo(i, n) {
		cin >> arr[i];
	}
	int max_till_now = arr[0];
	int total_stool_height = 0;
	for (int i = 1; i < n; i++) {
		if (max_till_now > arr[i]) {
			total_stool_height += max_till_now - arr[i];
		}
		else {
			max_till_now  = arr[i];
		}
	}
	cout << total_stool_height << endl;

	return 0;
}


Measured memory_bytes: 5156
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(),(x).end()
inline cpp_int between(cpp_int n, cpp_int x) {
  if(n >= 0)
    return (n/x)+1;
  else
    return 0;
}

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

  REP(i, 1009) {
    if(floor(i*0.08) == a && floor(i*0.1) == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

int a[2009], b[2009];
long long d[2009][2009], md = 1000000007;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= m; i++)
		cin >> b[i];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			if (a[i] == b[j]) d[i][j] = (d[i - 1][j] + d[i][j - 1] + 1) % md;
			else d[i][j] = (d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1] + 2 * md) % md;
		}
	cout << (d[n][m] + 1) % md << '\n';
	return 0;
}	

Measured memory_bytes: 31616