akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
	char a[3];
	scanf("%s",a);
	if(a[0]=='S'&&a[1]=='A')
	printf("1\n");
	if(a[0]=='F')
	printf("2\n");
	if(a[0]=='T'&&a[1]=='H')
	printf("3\n");
	if(a[0]=='W')
	printf("4\n");
	if(a[0]=='T'&&a[1]=='U')
	printf("5\n");
	if(a[0]=='M')
	printf("6\n");
	if(a[0]=='S'&&a[1]=='U')
	printf("7\n");
	return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max({a*c,a*d,b*c,b*d}) << "\n";
    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		for (int i = 0; i < s.length; i++) {
			s[i] = (char)((s[i] - 'A' + n) % 26 + 'A');
		}
		System.out.println(String.valueOf(s));
		sc.close();
	}
}

Measured memory_bytes: 23380
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s="ESWN";
	int n,m;
	ll t;
	while(cin>>n>>m>>t,n+m+t){
		vs in(n);
		rep(i,n)cin>>in[i];
		int x,y,now;
		rep(i,n)rep(j,m)rep(k,4)
			if(in[i][j]==s[k])x=i,y=j,now=k;
		ll memo[101][101][4]={0};
		bool h=false;
		while(t--){
			if(!h&&memo[x][y][now]){
				h=true;
				t%=memo[x][y][now]-t;
			}
			memo[x][y][now]=t;
			int nx=x+dx[now];
			int ny=y+dy[now];
			if(nx<0||ny<0||nx>=n||ny>=m||in[nx][ny]=='#')(now+=1)%=4,t++;
			else x=nx,y=ny;
		}
		cout<<x+1<<" "<<y+1<<" "<<s[now]<<endl;
	}
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double PI = acos(-1.0);

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string en = "abcdefghijklmnopqrstuvwxyz";
	int count[26] = {};
	string s;
	while(getline(cin, s)) {
		transform(s.begin(), s.end(), s.begin(), ::tolower);
		REP(i, s.size()) count[s[i] - 'a']++;
	}
	
	REP(i, 26) {
		cout << en[i] << " : " << count[i] << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <numeric>
typedef long long int ll;
using namespace std;
int main(){
	int H,W,D,a,b,num;
	ll Q;
	cin>>H>>W>>D;
	vector<int> h(H*W+1,0);
	vector<int> w(H*W+1,0);
	vector<int> count(H*W+1,0);
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin>>a;
			h[a]=i;
			w[a]=j;
		}
	}
	for(int i=0;i<=H*W+1;i++){
		if(i>=D+1){
			count[i]=count[i-D]+abs(h[i]-h[i-D])+abs(w[i]-w[i-D]);
		}else{
			count[i]=0;
		}
	}
		
	cin>>Q;
	for(int k=0;k<Q;k++){
		cin>> a>>b;
		if(a==b){
			cout<<0<<endl;
		}else{
			cout <<count[b]-count[a]<<endl;
		}
	}
}

Measured memory_bytes: 2176
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;


bool is_even(const string& s) {
    if (s.size() % 2 != 0) {
        return false;
    }
    int ss = s.size() / 2;
    return s.substr(0, ss) == s.substr(ss, ss);
}

int main() {
    string s;
    cin >> s;
    for (int i = s.size() - 1; i >= 0; --i) {
        if (is_even(s.substr(0, i))) {
            cout << i << endl;
            return 0;
        }
    }
}


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

using namespace std;

#define int long long

const int MOD = (int)(1e9+ 7);

template<int mod>
struct ModInt{
    int x;
    ModInt():x(0){}
    ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
    ModInt &operator+=(const ModInt &p){
        if((x+=p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p){
        if((x+=mod-p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p){
        x=(int)(1LL*x*p.x%mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p){
        *this*=p.inverse();
        return *this;
    }
    ModInt &operator^=(long long p){
        ModInt res = 1;
        for (; p; p >>= 1) {
            if (p & 1) res *= *this;
            *this *= *this;
        }
        return *this = res;
    }
    ModInt operator-()const{return ModInt(-x);}
    ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
    ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
    ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
    ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
    ModInt operator^(long long p)const{return ModInt(*this)^=p;}
    bool operator==(const ModInt &p)const{return x==p.x;}
    bool operator!=(const ModInt &p)const{return x!=p.x;}
    explicit operator int() const { return x; }                           // added by QCFium
    ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
    ModInt inverse()const{
        int a=x,b=mod,u=1,v=0,t;
        while(b>0){
            t=a/b;
            a-=t*b;
            std::swap(a,b);
            u-=t*v;
            std::swap(u,v);
        }
        return ModInt(u);
    }
    friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
        return os<<p.x;
    }
    friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
        long long x;
        is>>x;
        a=ModInt<mod>(x);
        return (is);
    }
};
typedef ModInt<MOD> mint;
 
struct MComb {
    std::vector<mint> fact;
    std::vector<mint> inversed;
    MComb(int n) { // O(n+log(mod))
        fact = std::vector<mint>(n+1,1);
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*mint(i);
        inversed = std::vector<mint>(n+1);
        inversed[n] = fact[n] ^ (MOD-2);
        for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*mint(i+1);
    }
    mint ncr(int n, int r) {
        return (fact[n] * inversed[r] * inversed[n-r]);
    }
    mint npr(int n, int r) {
        return (fact[n] * inversed[n-r]);
    }
    mint nhr(int n, int r) {
        assert(n+r-1 < (int)fact.size());
        return ncr(n+r-1, r);
    }
};
 
mint ncr(int n, int r) {
    mint res = 1;
    for (int i = n - r + 1; i <= n; i++) res *= i;
    for (int i = 1; i <= r; i++) res /= i;
    return res;
}

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

    mint res = (mint(2) ^ n) - 1 - ncr(n, a) - ncr(n, b);

    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def SS(): return input()


S = SS()

key = 'keyence'
n = 0
j = 0
for l in range(-1, len(S)):
    for r in range(l, len(S)):
        n = 0
        j = 0
        # print(l, r)
        for i in range(len(S)):
            if l <= i <= r:
                continue
            # print(i, n)
            if n == len(key):
                j = 1
                break
            if S[i] == key[n]:
                n += 1
            else:
                break
        else:
            if n == len(key) and j == 0:
                print('YES')
                exit()

print('NO')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;



void solve(){

    ll k;
    cin >> k;

    ll a,b;
    cin >> a >> b;

    bool b_=false;

    for(ll i=a; i<=b; i++){
        if(i%k==0) b_=true;
    }

    if(b_) cout << "OK" << endl;
    else cout << "NG" << endl;

}

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


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	/*
	2
	10 11
	11 12
	2
	N 2
	E 1
	3
	0 15
	5 10
	5 15
	5
	W 10
	S 10
	N 20
	E 10
	S 10
	2
	10 11
	11 12
	2
	N 2
	E 1
	2
	10 11
	11 12
	2
	N 2
	E 1
	0
	 * */
	/*
	3
	0 15
	5 10
	5 15
	5
	W 10
	S 10
	N 20
	E 10
	S 10
	
	 */

	public static int num = 0;

	public static int robotX;
	public static int robotY;

	public static boolean endFlag = false;

	public static boolean[][] area = new boolean[21][21];
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws NumberFormatException, IOException {
		while (true) {
			inputStone();
			if (endFlag) {
				break;
			}

			robotWalk();

			if (countStone()) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
			clearStone();
		}

	}

	public static void walkOne() {
		area[robotX][robotY] = false;
	}

	public static void robotWalk() throws IOException {
		robotX = 10;
		robotY = 10;

		walkOne();

		//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		num = Integer.parseInt(br.readLine());

		for (int j = 0; j < num; j++) {
			String str[] = br.readLine().split(" ");

			if (str[0].equals("N")) {
				for (int i = 0; i < Integer.parseInt(str[1]); i++) {
					robotY++;
					walkOne();
				}
			} //if

			if (str[0].equals("S")) {
				for (int i = 0; i < Integer.parseInt(str[1]); i++) {
					robotY--;
					walkOne();
				}
			} //if

			if (str[0].equals("E")) {
				for (int i = 0; i < Integer.parseInt(str[1]); i++) {
					robotX++;
					walkOne();
				}
			} //if

			if (str[0].equals("W")) {
				for (int i = 0; i < Integer.parseInt(str[1]); i++) {
					robotX--;
					walkOne();
				}
			} //if
		}
	}

	public static void inputStone() throws NumberFormatException, IOException {
		//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		num = Integer.parseInt(br.readLine());
		if (num == 0) {
			endFlag = true;
			return;
		}

		for (int i = 0; i < num; i++) {
			String str[] = br.readLine().split(" ");
			area[Integer.parseInt(str[0])][Integer.parseInt(str[1])] = true;
		}

	}

	//配列areaに一つでもtrueがあるとfalse
	public static boolean countStone() {

		for (int i = 0; i < 21; i++) {
			for (int j = 0; j < 21; j++) {
				if (area[i][j]) {
					return false;
				}
			}
		}

		return true;
	}

	public static void clearStone() {
		for (int i = 0; i < 21; i++) {
			for (int j = 0; j < 21; j++) {
				area[i][j] = false;
			}
		}
	}
}



Measured memory_bytes: 28792
//A - Station and Bus
//#include <iostream>
//#include <cstdio>
//#include <algorithm>
//#include <cstring>
//using namespace std;
//string s;
//int cnt;
//int main() {
//	cin >> s;
//	if (s[0] == 'A') cnt++;
//	if (s[1] == 'A') cnt++;
//	if (s[2] == 'A') cnt++;
//	if (cnt == 0 || cnt == 3) {
//		puts("No");
//	} else {
//		puts("Yes");
//	}
//	return 0;
//}
//B - Count Balls
//#include <iostream>
//#include <cstdio>
//#include <algorithm>
//#include <cstring>
//using namespace std;
//long long n, a, b;
//int main() {
//	cin >> n >> a >> b;
//	cout << n / (a + b) * a + min(a, n % (a + b));
//	return 0;
//}
//C - Tax Increase
//#include <iostream>
//#include <cstdio>
//#include <algorithm>
//#include <cstring>
//using namespace std;
//int a, b;
//int main() {
//	cin >> a >> b;
//	for (int i = b * 10; i < b * 10 + 10; i++) {
//		if ((int)(i * 0.08) == a) {
//			cout << i << endl;
//			return 0;
//		}
//	}
//	cout << -1 << endl;
//	return 0;
//}
//D - String Formation
//#include <iostream>
//#include <cstdio>
//#include <algorithm>
//#include <cstring>
//#include <deque>
//using namespace std;
//deque<char> s;
//string tmp;
//bool tag;//0:正序，1:倒序 
//int q;
//int main() {
//	cin >> tmp;
//	for (int i = 0; i < (int)tmp.length(); i++) {
//		s.push_back(tmp[i]);
//	}
//	cin >> q;
//	while (q--) {
//		int t;
//		cin >> t;
//		if (t == 1) {
//			tag = !tag;
//		} else {
//			int f;
//			char c;
//			cin >> f >> c;
//			if (tag == 0) {
//				if (f == 1) s.push_front(c);
//				else s.push_back(c);
//			} else {
//				if (f == 2) s.push_front(c);
//				else s.push_back(c);
//			}
//		}
//	}
//	if (tag == 0) {
//		while (!s.empty()) {
//			cout << s.front();
//			s.pop_front();
//		} cout << endl;
//	} else {
//		while (!s.empty()) {
//			cout << s.back();
//			s.pop_back();
//		} cout << endl;
//	}
//	return 0;
//}
//E - Divisible Substring
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
long long n, p;
string s;
long long h[200010];
bool ASUKA[10010];
long long sum[10010], ans, x = 1, tmp;
int main() {
	cin >> n >> p;
	cin >> s;
	s = " " + s;
	if (p == 2 || p == 5) {
		for (long long i = 1; i <= n; i++) {
			if ((s[i] - '0') % p == 0) {
				ans += i;
			}
		}
		cout << ans << endl;
	} else {
		for (long long i = n; i >= 1; i--) {
			tmp = (tmp + (s[i] - '0') * x % p) % p;
			x = (x * 10) % p;
			sum[tmp]++;
		}
		for (long long i = 0; i < p; i++) {
			ans += sum[i] * (sum[i] - 1) / 2;
		}
		cout << ans + sum[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 772
n = int(input())
a = list(map(int, input().split()))
law = 10 ** 9 + 7

bitsum = [0 for _ in range(60)]
for x in a:
    for i in range(60):
        bitsum[i] += bool(x & (1 << i))

ans = 0
for x in a:
    for i in range(60):
        k = bitsum[i]
        if (x & (1 << i)):
            k = n - k
        ans += k << i
    ans %= law
if ans % 2 == 0:
    print(ans // 2)
else:
    print((ans + law) // 2)

Measured memory_bytes: 122808
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <deque>
#include <map>
using namespace std;
int main() {
	int n, ans = 0;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s.substr(i, 3) == "ABC") {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int N;
  scanf("%d", &N);
  int array[N], i, x=1, count=0;
  for(i=0; i<N; i++){
    scanf("%d", &array[i]);
  }
  for(i=0; i<N-1; i++){
    if(array[i] == array[i+1]){
      x++;
      if(i == N-2){
        count = count + (x/2);
      }
    }else{
      count = count + (x/2);
      x = 1;
    }
  }
  printf("%d", count);
  return 0;
}


Measured memory_bytes: 128
n=int(input())

count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for x in range(n):
    b,f,r,v=map(int,input().split())
    count[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f' {count[i][j][k]}',end='')
        print()
    if i < 3:
        print('#'*20)



Measured memory_bytes: 5636
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
int main(){
  ll i,j,N=50,K;
  cin>>K;
  cout<<N<<endl;
  ll x=K/N,y=K%N;
  vec ans(N);
  rep(i,N){
    ans[i]=i+x;
  }
  rep(i,y){
    ans[i]+=N+1;
    rep(j,N){
      ans[j]--;
    }
  }
  output(ans);
  return 0;
}


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

using namespace std;

const int MaxN = 503;

long long a[MaxN][MaxN];

vector <int> p1;
vector <int> p2;

long long lcm(long long a, long long b)
{
    return a / __gcd(a, b) * b;
}

bool isPrime(int x)
{
    if(x == 1)
        return false;
    for(int i = 2; i * i <= x; ++i)
        if(x % i == 0)
            return false;
    return true;
}

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

void build(int x, int y)
{
    for(int i = 0; i < 4; ++i)
    {
        int xx = x + dx[i];
        int yy = y + dy[i];

        if(xx >= 0 && xx < MaxN && yy >= 0 && yy < MaxN)
            a[x][y] = lcm(a[x][y], a[xx][yy]);
    }

    ++a[x][y];

    assert(a[x][y] <= 1e15 && a[x][y] > 0);
}

void check()
{
    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
        {
            for(int d = 0; d < 4; ++d)
            {
                int x = i + dx[d];
                int y = j + dy[d];

                if(x >= 0 && x < MaxN && y >= 0 && y < MaxN)
                {
                    long long k1 = min(a[i][j], a[x][y]);
                    long long k2 = max(a[i][j], a[x][y]);

                    assert(k2 % k1 == 1);
                }
            }
        }
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
    mt19937 rnd(clock());

    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
            a[i][j] = 1;

    for(int i = 2; i <= 20000; ++i)
        if(isPrime(i))
        {
            if(p1.size() <= MaxN)
                p1.push_back(i);
            else
                p2.push_back(i);
        }

//    shuffle(p1.begin(), p1.end(), rnd);
//    shuffle(p2.begin(), p2.end(), rnd);

    for(int i = 0; i < MaxN; i += 2)
        for(int j = 0; j + i < MaxN; ++j)
            a[i + j][j] *= p1[i];

    for(int j = 2; j < MaxN; j += 2)
        for(int i = 0; i + j < MaxN; ++i)
            a[i][j + i] *= p1[j - 1];


    for(int i = 0; i < MaxN; i += 2)
        for(int j = 0; j < MaxN && i - j >= 0; ++j)
            a[i - j][j] *= p2[i];

    for(int j = 2; j < MaxN; j += 2)
        for(int i = 0; j + i < MaxN; ++i)
            a[MaxN - 1 - i][j + i] *= p2[j - 1];

    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
            if((i + j) & 1)
                build(i, j);

    check();

    int n;
    cin >> n;

    assert(n <= MaxN);

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

    return 0;
}


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


int main(void) {
    using namespace std;

    long n;
    cin >> n;
    string s;
    cin >> s;

    vector<long> l(n);
    l[0] = 0;
    for(int i=0; i<n-1; i++)
        l[i+1] = l[i] + (s[i] == 'W');

    vector<long> r(n);
    r[n-1] = 0;
    for(int i=n-1; i>0; i--)
        r[i-1] = r[i] + (s[i] == 'E');

    long res = 1e9;
    for(int i=0; i<n; i++)
        res = min(res, l[i]+r[i]);

    cout << res << endl;
}


Measured memory_bytes: 5380
x, n = map(int, input().split())

if n == 0:
  print(x)
  exit()
  
p = list(map(int, input().split()))

ans = 100000
for i in range(102):
    if not i in p:
        if abs(i - x) < abs(ans - x):
            ans = i
            
print(ans)

Measured memory_bytes: 9188
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	string s; cin >> s;
	if (s == "zyxwvutsrqponmlkjihgfedcba")
	{
		cout << -1 << endl;
		return 0;
	}
	vector<bool> alp(26, false);
	if (s.size() == 26)
	{
		int pos = 24;
		while (s[pos] > s[pos + 1])--pos;
		rep(i, pos + 1)alp[s[i] - 'a'] = true;
		for(int i = s[pos]-'a'; i < 26; ++i)if (!alp[i])
		{
			s = s.substr(0, pos);
			s.push_back(i + 'a');
			break;
		}
		cout << s << endl;
	}
	else
	{
		for (char x : s)alp[x - 'a'] = true;
		rep(i, 26)if (!alp[i])
		{
			s.push_back(i + 'a');
			break;
		}
		cout << s << endl;
	}
}

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

const int N = 55;

const int mod = 1e9+7;

int n;
int A;
int a[N];
long long mem[N][N][N*N];

long long go(int idx , int lft , int sum){
    if(idx == n+1){
        return sum == 0 && lft == 0;
    }
    long long &ret = mem[idx][lft][sum];
    if(~ret)
        return ret;
    ret = 0;
    if(a[idx] <= sum && lft)
        ret += go(idx + 1 , lft - 1 , sum - a[idx]);
    ret += go(idx + 1 , lft , sum);
    return ret;
}

int main(){
    scanf("%d%d" , &n , &A);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &a[i]);
    }
    memset(mem , -1 , sizeof mem);
    long long ans = 0;
    for(int len = 1; len <= n; len++){
        ans += go(1 , len , A*len);
    }
    printf("%lld\n" , ans);
}

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

#define ED return 0;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) long(pow(x,y))
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ax, ay, bx, by;
    cin >> ax >> ay >> bx >> by;
    cout << bx-(by-ay) << " " << by+(bx-ax) << " " << bx-(by-ay)-(bx-ax) << " " << by+(bx-ax)+(ay-by) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath> 
#include <string>
#include<bits/stdc++.h>
using Int = long long;
using namespace std;

Int ans=0,n;

void dfs(Int x, Int a, Int b, Int c){
    if(x>n) return;
    if(a&&b&&c) ans++;
    dfs(x*10+3, 1, b, c);
    dfs(x*10+5, a, 1, c);
    dfs(x*10+7, a, b, 1);

}

signed main(){
    cin >> n;
    dfs(0,0,0,0);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
#include <map>
#include <list>
#include <set>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
#define pb push_back
#define mp make_pair


int h, w, n;
map<ii, int> cnt;
int ans[10]={0};
int main()
{
  scanf("%d %d %d", &h, &w, &n);
  for (int i = 0; i < n; ++i)
    {
      int a, b;
      scanf("%d %d", &a, &b);
      for (int i = -2; i <= 0; ++i)
	for (int j = -2; j <= 0; ++j)
	  {
	    int x = a+i;
	    int y = b+j;
	    if (x >= 1 && x <= h-2 && y >= 1 && y <= w-2)
	      {
		cnt[mp(x, y)] += 1;
	      }
	  }
    }
  ll tot =1ll*(h-2)*(w-2);
  for (map<ii, int>::iterator it = cnt.begin(); it != cnt.end(); ++it)
    {
      ans[it->second] += 1;
    }
  for (int i = 1; i <= 9; ++i)
    tot -= ans[i];
  printf("%lld\n", tot);
  for (int i = 1; i <= 9; ++i)
    printf("%d\n", ans[i]);
      
}


Measured memory_bytes: 56576
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();

            int diff1 = Math.abs(a - b);
            int diff2 = Math.abs(b - c);
            int diff3 = Math.abs(c - a);
            int max = Math.max(Math.max(diff1, diff2), diff3);
            int ans = diff1 + diff2 + diff3 - max;
            System.out.println(ans);

        }
    }

}


Measured memory_bytes: 23252
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	/* 入力 */
	int n = scan.nextInt();
	String s = scan.next();

	int ans = 0;
	int max = 0;
	for(int i = 0; i < n; i++){
	    if(s.charAt(i) == 'I'){
		ans++;
	    }else{
		ans--;
	    }
	    if(max < ans){
		max = ans;
	    }
	}

	System.out.println(max);
    }
}


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

signed main(){
  int N,M;
  cin>>N>>M;
  std::vector<int> a(M),b(M),c(M),dp(N,-1e18),kk(N,0);
  for(int i=0;i<M;i++)cin>>a[i]>>b[i]>>c[i];
  int out=0;
  queue<int> que;
  que.push(1);
  dp[0]=0;
  while(que.size()&&out==0){
    int p=que.front();
    que.pop();
    for(int i=0;i<M;i++){
      if(a[i]==p){
        if(dp[b[i]-1]<dp[a[i]-1]+c[i]){
          dp[b[i]-1]=dp[a[i]-1]+c[i];
          kk[b[i]-1]=kk[a[i]-1]+1;
          if(kk[b[i]-1]>4000)out++;
          que.push(b[i]);
        }
      }
    }
    if(kk[N-1]>2000)break;
  }
  if(kk[N-1]>2000)cout<<"inf"<<endl;
  else cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 896
H, W, M = map(int, input().split())

rows = [0] * H
cols = [0] * W
s = set()
for _ in range(M):
    h, w = map(lambda x: int(x) - 1,input().split())
    rows[h] += 1
    cols[w] += 1
    s.add((h, w))

max_rows = max(rows)
max_cols = max(cols)

max_rows_indexes = [i for i in range(H) if rows[i] == max_rows]
max_cols_indexes = [i for i in range(W) if cols[i] == max_cols]

duplicate = True
if M >= len(max_rows_indexes) * len(max_cols_indexes):
    for h in max_rows_indexes:
        for w in max_cols_indexes:
            if (h, w) not in s:
                duplicate = False
                break
        if not duplicate:
            break
else:
    duplicate = False

if duplicate:
    print(max_rows + max_cols - 1)
else:
    print(max_rows + max_cols)


Measured memory_bytes: 83556
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define endl        	"\n"
#define int         	long long int  
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define pll         	pair<ll,ll>
#define vec     		vector<ll>
#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

ll mod_pow(ll a,ll b)
{
    ll res = 1;
    while(b)
    {
        if(b&1) res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a)
{
	return mod_pow(a,mod-2);
}

void solve()
{
	int n,k;
	
	cin>>n>>k;
	
	ll dp[k+5];
	
	fill(dp,0);
	
	for(int i=k;i>=1;i--)
	{
		dp[i] = mod_pow(k/i,n);
		
		for(int j=2*i;j<=k;j+=i)
		{
			dp[i] = (dp[i] - dp[j] + mod) % mod;
		}
	}
	
	int ans = 0;
	
	for(int i=1;i<=k;i++)
	{
		ans = (ans + (dp[i]*i)%mod)%mod;
	}
	
	cout<<ans;
}

signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 4320
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int, int);
int main()
{
    int i, q;

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &A[i]);
    q = partition(0, n - 1);

    for (i = 0; i < n; i++)
    {
        if (i)
            printf(" ");
        if (i == q)
            printf("[");
        printf("%d", A[i]);
        if (i == q)
            printf("]");
    }
    printf("\n");
    return 0;
}
int partition(int a, int b)
{
    int x, i, j, t;
    x = A[b];
    i = a - 1;
    for (j = a; j < b; j++)
    {
        if (A[j] <= x)
        {
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i + 1];
    A[i + 1] = A[b];
    A[b] = t;
    return i + 1;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define ll long long int
#define mod 10000007
#define pb push_back
#define ru(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define mp make_pair
#define inp(a,n) ru(i,n){cin>>a[i];}
using namespace std;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

ll po(ll a,ll b,ll m)
{	a%=m;
	ll res=1;
	while(b>0)
	{if(b&1)
	res=(res*a)%m;
	a=(a*a)%m;
	b>>=1;}
	return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
	ll a,b,k;
	cin>>a>>b>>k;
	ll d=a;
	a-=k;
	k-=d;
	if(k>0)
	b-=k;
	if(a<0)
	a=0;
	if(b<0)
	b=0;
	cout<<a<<" "<<b<<"\n";	
	}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define MOD 1000000007
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	int N,a;
	int A[100000]={};
	cin>>N;
	for(int i=N-1;i>=0;i-=2){
		//printf("%d\n",i);
		A[i]+=2;
	}
	if(N%2)
		A[0]--;
	for(int i=0;i<N;i++){
		cin>>a;
		A[a]--;
	}
	bool flag=0;
	for(int i=0;i<100000;i++)
		if(A[i])
			flag=1;
	if(flag)
		cout<<"0"<<endl;
	else{
		long long ans=1;
		int pow=N/2;
		for(int i=0;i<pow;i++)
			ans=2*ans%MOD;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

char oc[] = "01235789";

void oct(int a){
  if(a == 0)return;
  oct(a / 8);
  putchar(oc[a % 8]);
}

int main(){
  int a;
  while(scanf("%d", &a)){
    if(a == 0)return 0;
    oct(a);
    puts("");
  }  
}

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

int main(){
  int s,w; cin >> s >> w;
  if(s > w) {
    cout << "safe" << endl;
  }
  else {
    cout << "unsafe" << endl;
  }
}



Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, K;
set<int> S;

int main() {
  INCANT;
  cin >> N >> K;
  int d, a;
  rep(i, K) {
    cin >> d;
    rep(i, d) {
      cin >> a;
      S.insert(a);
    }
  }
  cout << N-S.size() << "\n";
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
 
  string s,t;cin>>s>>t;
  int q;cin>>q;
  vector<ll> S,T;
  S.push_back(0);
  T.push_back(0);
  rep(i,s.size()){
    if(s[i] == 'A'){
      S.push_back((S.back() + 1) % 3);
    }else{
      S.push_back((S.back() + 2) % 3);
    }
  }
  rep(i,t.size()){
    if(t[i] == 'A'){
      T.push_back((T.back() + 1) % 3);
    }else{
      T.push_back((T.back() + 2) % 3);
    }
  }
  rep(_t,q){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    if((S[b] - S[a-1] + 3) % 3 == (T[d] - T[c-1] + 3) % 3){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2884
x = gets.to_i
n_3 = x / 3
n_5 = x / 5
n_15 = x / 15
def ary_sum(a)
  (a * n * (n + 1)) / 2
end
s = (x * (x + 1)) / 2
s_3 = (3 * n_3 * (n_3 + 1)) / 2
s_5 = (5 * n_5 * (n_5 + 1)) / 2
s_15 = (15 * n_15 * (n_15 + 1)) / 2
p s + s_15 - s_3 - s_5

Measured memory_bytes: 14376
#include <stdio.h>

int main(void){
  int x, y, z, temp;
  scanf("%d %d %d",&x,&y,&z);
  temp = x;
  x = y;
  y = temp;
  temp = x;
  x =z;
  z = temp;
  printf("%d %d %d",x,y,z);
  return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 105;
int x[maxn];
int n;
int cal(int p)
{
    int sum = 0;
    for (int i = 0; i < n; ++i)
        sum += (x[i] - p) * (x[i] - p);
    return sum;
}
int main(void)
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &x[i]);
    int l = 0, r = 105;
    while (l < r)
    {
        int m = (l + r) >> 1;
        int rm = (m + r) >> 1;
        if (cal(m) > cal(rm))
            l = m;
        else
            r = rm;
    }
    printf("%d\n", cal(l + 1));
    return 0;
}

Measured memory_bytes: 256
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

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

s = sorted(p)
ok = False
if s == p:
    ok = True
for i in range(len(p)):
    for j in range(i + 1, len(p)):
        q = p[:]
        q[i], q[j] = q[j], q[i]
        if q == s:
            ok = True
print('YES' if ok else 'NO')



Measured memory_bytes: 38768
# B - Two Arrays
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sum_a=sum(a)
sum_b=sum(b)

a_cnt,b_cnt=0,0

for aa,bb in zip(a,b):
    if aa>bb:
        a_cnt+=aa-bb
    elif aa<bb:
        b_cnt+=(bb-aa)//2

print('Yes') if a_cnt<=b_cnt else print('No')

Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
using namespace std;


int main(){
    long long n, k, ans = 0;
    cin >> n >> k;
    vector<long long> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    vector<long long> p(n + 1);
    for(int i = 0; i < n; ++i)
        p[i + 1] = (p[i] + a[i] - 1) % k;
    map<long long, long long> m;
    for(int i = 0; i <= n; ++i) {
      if(i - k >= 0) m[p[i - k]]--;
      ans += m[p[i]];
      m[p[i]]++;
    }
    cout << ans;
}


Measured memory_bytes: 15872
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	while (N) {
		int num[100000];
		for (int i = 0; i < N; i++)cin >> num[i];
		sort(num, num + N);
		int ret = 10000000;
		for (int i = 1; i < N; i++)ret = min(ret, num[i] - num[i - 1]);
		cout << ret << endl;
		cin >> N;
	}
	return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	map<string, int> M;
	int q;
	cin >> q;
	int query, x;
	string key;
	map<string, int>::iterator itr;

	for (int i = 0; i < q; i++) {
		cin >> query >> key;
		if (query == 0) {
			cin >> x;
			itr = M.find(key);

			if (itr == M.end())
				M.insert(make_pair(key, x));
			else
				M[key] = x;
		}
		else {
			cout << M[key] << endl;
		}	
	}
}


Measured memory_bytes: 27748
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout << max(a*b,c*d) <<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);

    int N;
    cin >> N;
    long long ans = 1;
    for(int i=1; i<=N; i++){
        ans *= i;
        ans %= 1000000007;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

import(
	"bufio"
	"strconv"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func check(a int, b int) int {
	return 1
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	data := [][]int{}
	sums := [][]int{}

	for i := 0; i < 2; i++ {
		tmp1 := make([]int, n+2)
		tmp2 := make([]int, n+2)
		tmp1[n-1] = -1
		tmp1[0] = 0
		tmp2[0] = 0
		for j := 1; j <= n; j++ {
			tmp1[j] = nextInt()
			if i == 0 {
				tmp2[j] = tmp2[j-1] + tmp1[j]
			} else if i == 1 {
				if sums[0][j] > tmp2[j-1] {
					tmp2[j] = sums[0][j] + tmp1[j]
				} else {
					tmp2[j] = tmp2[j-1] + tmp1[j]
				}
			}
		}
		data = append(data, tmp1)
		sums = append(sums, tmp2)
	}
	
	candy := 0

	if sums[0][n] > sums[1][n-1] {
		candy = sums[0][n] + data[1][n]
	} else {
		candy = sums[1][n-1] + data[1][n]
	}
	fmt.Println(candy)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {

    // 頂点数と辺数
    int n, m; cin >> n >> m;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int new_v : G[v]) {
            if (dist[new_v] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 new_v について距離情報を更新してキューに追加する
            dist[new_v] = dist[v] + 1;
            que.push(new_v);
        }
    }
	if (dist[n - 1] == 2) cout << "POSSIBLE" << endl;
	else  cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 16140
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  int a;
  cin>>a;
  cout<<a+(a*a)+(a*a*a)<<endl;
  return 0;
}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  ll a,b,k;
  cin >> a >> b >> k;
  if(a>k){
    cout << a-k << " " << b << endl;
  }
  else if(a+b<k){
    cout << "0 0" << endl;
  }
  else
    cout << "0 " << a+b-k << endl;
}

Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on
void main()
{
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t)(N));
    foreach (i; 0 .. cast(size_t)(N))
    {
        A[i] = input.front.to!long;
        input.popFront;
    }

    solve(N, A);
}

void solve(long N, long[] A)
{
    long ans;
    if (N == 1)
    {
        writeln(0);
        return;
    }
    foreach (i; 1 .. N)
    {
        long h = max(0, A[i - 1] - A[i]);
        A[i] += h;
        ans += h;
    }
    writeln(ans);
}


Measured memory_bytes: 18764
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

#define all(c) (c).begin(),(c).end()

using namespace std;

typedef pair<int,int> pii;

int main(void){

  int D;
  cin >> D;

  vector<pii>v;

  int n;
  cin >> n;

  string a;
  int p;

  for(int i=0;i<n;i++){
    cin >> a >> p;
    if(a=="D")v.push_back(pii(1,p));
  }


  cin >> n;

  for(int i=0;i<n;i++){
    cin >> a >> p;
    if(a=="DD")v.push_back(pii(2,p));
  }

  int dp[15];
  fill(dp,dp+15,0);


  for(int j=0;j<(int)v.size();j++){
      for(int i=D;i>=0;i--){
      dp[i+v[j].first]=max(dp[i+v[j].first],dp[i]+v[j].second);
    }
  }

  int ans=0;
  for(int i=0;i<=D;i++)ans=max(ans,dp[i]);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<list>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[200000]={0};
    for(int i(0);i<n;i++){
        cin>>a[i];
    }
    bool reverse(false);
    list<int>b;
    for(int i(0);i<n;i++){
        if(reverse){
            b.push_front(a[i]);
            reverse = false;
        }
        else{
            b.push_back(a[i]);
            reverse = true;
        }
    }
    if(reverse){
        list<int>c;
        list<int>::iterator itr;
        for(itr = b.begin();itr != b.end(); itr++){
            c.push_front(*itr);
        }
        for(itr = c.begin(); itr != c.end(); itr++){
            cout<< *itr <<" ";
        }
        cout<<endl;
    }
    else{
        list<int>::iterator itr;
        for(itr = b.begin();itr != b.end();itr++){
            cout<< *itr <<" ";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 15488