akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;

void read (int&a) {
	a = 0; char k = getchar(); int f = 1;
	for(;!isdigit(k); k = getchar()) if (k == '-') f = -1;
	for(; isdigit(k); k = getchar()) a = a * 10 + k - '0';
	a *= f;
}

const int N = 190;
int n, m;
int dp[N][N][N][17], a[N][N], sum[N][N];
char s[N][N];

int main ()
{
	read (n), read (m);
	for (int i = 1; i <= n; ++i) scanf ("%s", s[i] + 1);
	for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) a[i][j] = s[i][j] == '#';
	// for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j];
	for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) sum[i][j] = sum[i][j - 1] + a[i][j];
	memset (dp, -1, sizeof dp);
	for (int i = n; i >= 1; --i) {
		for (int j = 1; j <= m; ++j) {
			for (int k = j; k <= m; ++k) {
				int tsum = sum[i][k] - sum[i][j - 1];
				if (i == n) {
					if (tsum == 0 || tsum == k - j + 1) dp[i][j][k][0] = n;
					else dp[i][j][k][0] = -1;
				}
				else {
					if (tsum != 0 && tsum != k - j + 1) continue;
					if (dp[i + 1][j][k][0] > -1 && a[i][j] == a[i + 1][j]) dp[i][j][k][0] = dp[i + 1][j][k][0];
					else dp[i][j][k][0] = i;
				}
			}
		}
	}
	// debug ("%d\n", dp[2][1][3][0]);
	for (int i = n; i >= 1; --i) {//枚举行
		for (int len = 1; len <= m; ++len) {//枚举长度
			for (int l = 1; l <= m; ++l) {//枚举左端点
				if (l + len - 1 > m) break;
				int r = l + len - 1;
				for (int k = 1; k <= 16; ++k) {
						//dp[i][l][r][k]
					if (dp[i][l][r][k - 1] == n) { dp[i][l][r][k] = n; continue; }
					dp[i][l][r][k] = dp[ dp[i][l][r][k - 1] + 1 ][l][r][k - 1];//横着切开
					int L = l, R = r - 1, mid;
					while (L < R) {
						mid = (L + R) >> 1;
						dp[i][l][r][k] = max (dp[i][l][r][k], min (dp[i][l][mid][k - 1], dp[i][mid + 1][r][k - 1]));
						if (dp[i][l][mid][k - 1] < dp[i][mid + 1][r][k - 1]) R = mid - 1;
						else L = mid + 1;
					}
					mid = (L + R) >> 1;
					dp[i][l][r][k] = max (dp[i][l][r][k], min (dp[i][l][mid][k - 1], dp[i][mid + 1][r][k - 1]));
				}
			}
		}
	}
	for (int i = 0; i <= 16; ++i) if (dp[1][1][m][i] == n) {
		printf ("%d\n", i);
		return 0;
	}
	return 0;
}


Measured memory_bytes: 456064
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        Deque dq = new Deque();
        int q = Integer.parseInt(sc.next());
        for (int i = 1; i <= q; i++) {
            int query = Integer.parseInt(sc.next());
            switch (query) {
                case 0 : 
                    int a = Integer.parseInt(sc.next());
                    int x = Integer.parseInt(sc.next());
                    if (a == 0)
                        dq.pushHead(x);
                    else
                        dq.pushTail(x);
                    break;
                case 1 :
                    int p = Integer.parseInt(sc.next());
                    pw.println(dq.ar[dq.head+p+1]);
                    break;
                case 2 :
                    int d = Integer.parseInt(sc.next());
                    if (d == 0)
                        dq.popHead();
                    else
                        dq.popTail();
                    break;
                default:
                    break;
            }
        }
        pw.flush();
    }
}

class Deque {
    int[] ar;
    int head = 500000;
    int tail = 500001;
    Deque() {
        ar = new int[1000000];
    }
    void pushHead(int x) {
        this.ar[head] = x;
        this.head--; 
    }
    void pushTail(int x) {
        this.ar[tail] = x;
        this.tail++;
    }
    void popHead() {
        this.head++;
    }
    void popTail() {
        this.tail--;
    }
}


Measured memory_bytes: 181096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=1e9+7;
#define endl '\n'
#define SIGMA 128
const ld PI=3.14159265358979;
#define fr(i,n) for(i=1;i<=n;i++)
#define rep(i,k,n) for(i=k;i<=n;i++)
#define w(x) int x;cin>>x;while(x--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ps(x,y) cout<<fixed<<setprecision(y)<<x<<endl
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define vvl vector<vll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define mset multiset
#define uset unordered_set
#define umap unordered_map
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll binpow(ll x, ll y, ll p){  ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  { if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}  
ll gcd(ll a, ll b){ if (b == 0) return a; return gcd(b, a % b); } 
bool parity(ll x,ll y){ bool f = ((x ^ y) < 0);return !f;}

ll dp[103][100003];
int main()
{
    IOS

    ll n,k,i;
    cin>>n>>k;
    vi a(n+1);
    fr(i,n)
        cin>>a[i];

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

    for(int i=1;i<=n;i++)
    {
        vll pref(k+1);
        pref[0]=dp[i-1][0];
        for(int j=1;j<=k;j++)
        {
            pref[j]=pref[j-1]+dp[i-1][j];
            pref[j]%=mod;
        }
        for(int j=0;j<=k;j++)
        {
            int r=j;
            int l=max(0,j-a[i]);
            ll val;
            if(l==0)
                val=pref[r];
            else
                val=pref[r]-pref[l-1];
            dp[i][j]=(val+mod)%mod;
        }
    }
    cout<<dp[n][k]<<endl;

    return 0;  
}



Measured memory_bytes: 82384
#include<cstdio>
#include<algorithm>
#include<stack>
#include<utility>
using namespace std;
int cnt,h,w,dp[2000][2000],f[2000][2000]={},ans=0,l[2000][2000],r[2000][2000];
char s[2000][2010];
int main(){
    stack<pair<int,int> > st;
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++){
        scanf("%s",s[i]);
    }
    for(int i=1;i<h;i++){
        for(int j=1;j<w;j++){
            cnt=0;
            if(s[i][j]=='#'){
                cnt++;
            }
            if(s[i][j-1]=='#'){
                cnt++;
            }
            if(s[i-1][j]=='#'){
                cnt++;
            }
            if(s[i-1][j-1]=='#'){
                cnt++;
            }
            if(cnt%2){
                f[i][j]=1;
            }
        }
    }
    for(int i=0;i<h;i++){
        dp[i][0]=i+1;
    }
    for(int i=0;i<w;i++){
        dp[0][i]=1;
    }
    for(int i=1;i<h;i++){
        for(int j=1;j<w;j++){
            if(f[i][j]){
                dp[i][j]=1;
            }
            else{
                dp[i][j]=dp[i-1][j]+1;
            }
        }
    }
    ans=max(h,w);
    for(int i=0;i<h;i++){
        l[i][0]=0;
        r[i][w-1]=w-1;
        while(!st.empty()){
            st.pop();
        }
        st.push(make_pair(0,dp[i][0]));
        for(int j=1;j<w;j++){
            while(!st.empty()&&st.top().second>=dp[i][j]){
                st.pop();
            }
            if(st.empty()){
                l[i][j]=0;
            }
            else{
                l[i][j]=st.top().first;
            }
            st.push(make_pair(j,dp[i][j]));
        }
        while(!st.empty()){
            st.pop();
        }
        st.push(make_pair(w-1,dp[i][w-1]));
        for(int j=w-2;j>=0;j--){
            while(!st.empty()&&st.top().second>=dp[i][j]){
                st.pop();
            }
            if(st.empty()){
                r[i][j]=w-1;
            }
            else{
                r[i][j]=st.top().first-1;
            }
            st.push(make_pair(j,dp[i][j]));
        }
        for(int j=0;j<w;j++){
            ans=max(ans,dp[i][j]*(r[i][j]-l[i][j]+1));
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 66688
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void sublime(){ 
    #ifndef ONLINE_JUDGE 
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
      }
vector<ll>ans;
template<typename T>
class graph
  {
    public:
    map<T, vector<T>>g;
    void addedge( T u, T v, bool bidir=true)
    {
        g[u].push_back(v);
        if(bidir)
        {
            g[v].push_back(u);
        }
    }
   void countconnected(T src)
   {
    map<T, bool>visited;
    int count=0;
    for(auto i : g)
    {  T node= i.first;
        if(!visited[node])
        {
            count++;
            bfs(node, visited);
        }
    }
    //cout<<"Total connected component "<<count<<'\n';
   }
   void bfs(T src, map<T, bool> &visited)
   {
     queue<T>q;
     q.push(src);
     visited[src]=true;
     ll aa=0;
     while(!q.empty())
     { 
        T node=q.front();
        aa++;
        q.pop();
        for(auto nbr: g[node])
        {
          if(!visited[nbr])
            { 
             q.push(nbr);
             visited[nbr]=true;
            }
        }
     }
     ans.push_back(aa);
   }
};

int main()
{   
   // sublime();
    graph<ll>g;
    ll n,m;
    cin>>n>>m;
    
    int flag=0;
    ll start;
    while(m--)
    {
        ll a,b;
        cin>>a>>b;
        if(flag==0)
        { 
            start=a;
            flag=1;
        }
        g.addedge(a,b);

    }
    g.countconnected(start);
    ans.push_back(1);
    sort(ans.begin(), ans.end());
    ll sum=0;
    for(ll i=0; i<ans.size(); i++)
    {
        ans[i]-=sum;
        sum+=ans[i];
    }
    cout<<sum;
    return 0;
}

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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define print(a) cout<<a<<endl;
#define end cout<<endl;
#define elif else if

int a,b,c,i,j,k,n,m,x,y,z;
str s,t;
vector<signed> v;

signed main(){
  
  double t,x;
  cin>>t>>x;
  double ans=t/x;
  printf("%.5f\n",ans);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <string.h>
#include <cmath>
using namespace std;

const int INF = 1e+9;
typedef pair<int, int> P;

int main() {
	int d, n, m;
	while(cin >> d && d){
		int s, k, ans = 0;
		vector<int> shops;
		cin >> n >> m;
		for(int i = 0; i < n - 1; ++i){
			scanf("%d", &s);
			shops.push_back(s);
		}
		shops.push_back(INF);
		sort(shops.begin(), shops.end());
		for(int i = 0; i < m; ++i){
			scanf("%d", &k);
			auto it = lower_bound(shops.begin(), shops.end(), k) - shops.begin();
			if(it == n - 1)
				ans += min(abs(d - k), abs(k - shops[n - 2]));
			else if(it == 0)
				ans += min(k, abs(shops[0] - k));
			else
				ans += min(abs(shops[it]  - k), abs(k - shops[it - 1]));
		}
		cout << ans << endl;
	}  
	return 0;
}

Measured memory_bytes: 1776
//q005.cpp
//Sat Sep 19 16:30:44 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

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

	int ans = 0;
	ans += min(x,y)*min(a+b,2*c);
	if (x>y){
		ans += (x-y)*min(a,2*c);
	}else if (x<y){
		ans += (y-x)*min(b,2*c);
	}
	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3540
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
    public void exec() throws IOException {
        InputUtil input = new InputUtil();
        PrintWriter out = new PrintWriter(System.out);
        while(true) {
            int H = input.nextInt();
            int W = input.nextInt();
            if(H==0 && W==0) break;
            for(int y=0; y<H; y++) {
            	char[] cbuf = new char[W];
            	Arrays.fill(cbuf, '#');
            	out.println(cbuf);
            }
            out.println("");
        }
        out.flush();
        input.close();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }

}
 
/**
 * --------------------------------------------------
 * Input Utility
 * --------------------------------------------------
 */
class InputUtil {
    //Static Fields
    private static final int BUFSIZ = 2100005;
     
    //Fields
    protected InputStream in;
    private char[] buf = null;
    private int ptr = 0;
    private int max = -1;
    private BufferedReader br = null;
     
    //Constructors
    public InputUtil() {this(System.in,BUFSIZ);}
    public InputUtil(int bufsiz) {this(System.in,bufsiz);}
    public InputUtil(InputStream in) {this(in,BUFSIZ);}
    public InputUtil(InputStream in, int bufsiz) {
        initBuf(bufsiz);
        initIn(in);
    }
     
    //Methods
    //Initializer
    protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));}
    protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
     
    //String Input Reader/Parser
    private void readBuf() throws IOException {
        if(ptr >= max && br.ready()) {
            max = br.read(buf);
            ptr = 0;
        }
    }
     
    public BufferedReader getReader() {return br;}
     
    //Number Input Reader/Parser
    private boolean isNum(char b) {return '0' <= b && b <= '9'; }
    private boolean isMinus(char b) {return b=='-'; }
    private void next() throws IOException {ptr++; readBuf();}
 
 
    public int nextInt() throws IOException {return nextInt(new int[1])[0];}
    public int[] nextInt(int[] result) throws IOException {
        readBuf();
        for(int i=0; i<result.length; i++) {
            int sign = 1;
            int res = 0;
            char c;
            while (!isNum(c=buf[ptr]) && !isMinus(c)) 
                next();
            if (isMinus(buf[ptr])) {
                sign = -1;
                next();
            }
            while (isNum(c=buf[ptr])) {
                res *= 10;
                res += c - '0' ;
                next();
            }
            next();
            result[i] = sign * res;
        }
        return result;
    }
     
    //Close 
    public void close() throws IOException {
        if(!this.in.equals(System.in)) 
            this.in.close();
    }
 
}

Measured memory_bytes: 28556
#include <iostream>
#include <cstring>
using namespace std;
#define INF 1000000000000

long long dp[2010][2010];
long long a[2010];


int main(){
	int N;long long hog,res;
	bool fla;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	if(N==1){
		cout<<a[0]<<endl;
		return 0;
	}
	dp[0][N-1]=a[N-1];
	for(int i=1;i<N;i++){
		dp[i][N-1]=a[i-1];
	}
	fla=false;
	for(int i=N-2;i>=1;i--){
		if(fla){
			dp[0][i]=max(dp[0][i+1]+a[i],dp[N-1][i+1]+a[N-1]);
			for(int j=1;j<N;j++){
				dp[j][i]=max(dp[j][i+1]+a[(j+i)%N],dp[j-1][i+1]+a[j-1]);
			}
		}
		else{
			hog=-INF;
			if(a[0]<a[i]){
				hog=dp[0][i+1];
			}
			if(a[N-1]>a[i-1]){
				hog=max(hog,dp[N-1][i+1]);
			}
			dp[0][i]=hog;
			for(int j=1;j<N;j++){
				hog=-INF;
				if(a[j]<a[(i+j)%N]){
					hog=dp[j][i+1];
				}
				if(a[j-1]>a[(i+j-1)%N]){
					hog=max(hog,dp[j-1][i+1]);
				}
				dp[j][i]=hog;
			}
		}
		fla=!fla;
	}
	res=-INF;
	/*
	for(int i=0;i<N;i++){
		for(int j=1;j<N;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}
	*/
	if(fla){
		for(int i=0;i<N;i++){
			res=max(res,dp[i][1]+a[i]);
		}
	}
	else{
		for(int i=0;i<N;i++){
			res=max(res,dp[i][1]);
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 32588
#include <stdio.h>

int main(void){
  int x, a, b;
  scanf("%d", &x);
  scanf("%d", &a);
  scanf("%d", &b);
  x -= a;
  while(x >= 0) x -= b;
  x += b;
  printf("%d\n", x);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    string s; cin >> s;
    int n = s.size();
    int K; cin >> K;

    ll dp[110][2][4] = {};
    dp[0][0][0] = 1;
    
    rep(i, n) rep(j, 2) rep(k, K+1){
        int lim = j? 9:s[i]-'0';
        rep(d, lim+1) {
            if(d != 0 && k == K) continue;
            dp[i+1][j || d<lim][d==0? k:k+1] += dp[i][j][k];
        }
    }

    ll ans = 0;
    rep(j, 2) ans += dp[n][j][K];
    cout << ans << endl;
    

    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  ll h; cin >> h;
  function<ll(ll)> calc = [&](ll n) {
    return n == 1 ? 1LL : calc(n / 2) * 2 + 1;
  };
  cout << calc(h) << '\n';
  return 0;
}


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

int main(){
  int a, b, p, r;
  double f;

  cin >> a >> b;

  p = a/b;
  r = a%b;
  f = (double)a/b;

  printf("%d %d %lf\n", p,r,f);

  return 0;

}


Measured memory_bytes: 3216
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <iomanip>
using namespace std;
long Nchoose2(long n){
    return n*(n-1)/2;
}
int main(){
    char s;
   cin >> s;

   if (isupper(s))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }

   return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 1e5 + 7;
struct Node {
	int num;
	int multi;
}node[maxn];
bool cmp(Node lhd, Node rhd) {
	return lhd.num < rhd.num;
}
int main()
{
	int n;
	long long k;
	while(~scanf("%d%lld", &n, &k)) {
		for (int i = 0;i < n; ++i) {
			scanf("%d%d", &node[i].num, &node[i].multi);
		}
		sort(node, node + n, cmp);
		int cur = 0;
		while(true) {
			k -= node[cur].multi;
			if (k <= 0) {
				break;
			}
			cur++;
		} 
		printf("%d\n", node[cur].num);
	}
	
	return 0;
}

Measured memory_bytes: 896
X , N = map(int, input().split())
p = list(map(int,input().split()))
ans = []
if N == 0:
    print(X)
elif X not in  p:
    print(X)
else:
    p = sorted(p)
    p2 = [abs(i-X) for i in p]

    for i in range(p[p2.index(min(p2))],102):
        if i not in p:
            ans.append(i)
            break
    for i in range(p[p2.index(min(p2))], -100, -1):
        if i not in p:
            ans.append(i)
            break
    
    ans = sorted(ans)
    ans2 = [abs(i-X) for i in ans]
    print(ans[ans2.index(min(ans2))])


Measured memory_bytes: 9224
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

int X, Y;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

class State
{
public:
	int tx, ty, kx, ky;
	int time;

	State(int tx, int ty, int kx, int ky, int time) : tx(tx), ty(ty), kx(kx), ky(ky), time(time) {}
};

bool oor(int x, int y)
{
	return x<0 || x>=X || y<0 || y>=Y;
}

int main()
{
	while (cin >> X >> Y, X||Y)
	{
		int itx, ity, ikx, iky;
		cin >> itx >> ity >> ikx >> iky;

		bool map[Y][X];
		for (int y=0; y<Y; y++)
		for (int x=0; x<X; x++)
			cin >> map[y][x];

		queue<State> q;
		q.push(State(itx-1, ity-1, ikx-1, iky-1, 0));
		bool v[Y][X][Y][X];
		memset(v, 0, sizeof(v));
		bool f = 0;

		while (!q.empty())
		{
			State t = q.front(); q.pop();
			if (v[t.ty][t.tx][t.ky][t.kx]) continue;
			if (t.time >= 100)
			{
				break;
			}

			if (t.tx==t.kx && t.ty==t.ky)
			{
				cout << t.time << endl;
				f = 1;
				break;
			}
			v[t.ty][t.tx][t.ky][t.kx] = 1;

			for (int i=0; i<4; i++)
			{
				State next = State(t.tx+dx[i], t.ty+dy[i], t.kx+dx[(i+2)%4], t.ky+dy[(i+2)%4], t.time+1);
				if (oor(next.tx, next.ty) && oor(next.kx, next.ky)) continue;
				if (oor(next.tx, next.ty) || map[next.ty][next.tx])
				{
					next.tx = t.tx;
					next.ty = t.ty;
				}

				if (oor(next.kx, next.ky) || map[next.ky][next.kx])
				{
					next.kx = t.kx;
					next.ky = t.ky;
				}
				
				if (v[next.ty][next.tx][next.ky][next.kx]) continue;

				q.push(next);
			}
		}

		if (!f)
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 7504
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 2002, INF = 1e9 * 1e9 + 10, MOD = 1e9 + 7;

ll grid[2002][2002], pref[2002][2002], dl1[2002][2002], dl2[2002][2002];

int main()
{
    fastInp;
    
    ll n, m, q;
    cin >> n >> m >> q;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            pref[i + 1][j + 1] = pref[i][j + 1] + pref[i + 1][j] - pref[i][j];
            dl1[i + 1][j + 1] = dl1[i + 1][j] + dl1[i][j + 1] - dl1[i][j];
            dl2[i + 1][j + 1] = dl2[i + 1][j] + dl2[i][j + 1] - dl2[i][j];
            char ch;
            cin >> ch;
            grid[i][j] = (ch - '0');
            if (grid[i][j]) {
                pref[i + 1][j + 1]++;
                if (i > 0 && grid[i - 1][j]) dl1[i + 1][j + 1]++;
                if (j > 0 && grid[i][j - 1]) dl2[i + 1][j + 1]++; 
            }
        }
    }

    while (q--) {
        ll x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;

        ll vl = (dl1[x2][y2] - dl1[x1][y2] - dl1[x2][y1 - 1] + dl1[x1][y1 - 1]) + (dl2[x2][y2] - dl2[x1 - 1][y2] - dl2[x2][y1] + dl2[x1 - 1][y1]);
        cout << (pref[x2][y2] - pref[x1 - 1][y2] - pref[x2][y1 - 1] + pref[x1 - 1][y1 - 1]) - (vl) << "\n";
    }

    return 0;
}

Measured memory_bytes: 128812
#include <iostream>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;

const long long mod = 1000000007;

long long mod_pow(long long x,long long n){
    if(n == 0) return 1;
    long long res = mod_pow(x * x % mod, n / 2);
    if(n % 2) res = res * x % mod;
    return res;
}

int main(){
    long long m, n;
    cin >> m >> n;
    cout << mod_pow(m, n) % mod << endl;
}

Measured memory_bytes: 3092
import sys

def sum_bincount(n):
    l = 0
    r = n
    res = [0] * (41)
    if n < 0:
        return res
    for i in range(40, -1, -1):
        stand = n >> i & 1
        res[i] += 2 ** i * l
        if stand:
            r -= 2 ** i
            res[i] += r + 1
        l = (l << 1) + (stand & 1)
    return res

a, b = map(int, sys.stdin.readline().split())

def main():
    s_a_bin = sum_bincount(a-1)
    s_b_bin = sum_bincount(b)
    res = 0
    for i in range(40, -1, -1):
        res += 2 ** i * ((s_a_bin[i] % 2) ^ (s_b_bin[i] % 2))
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

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

using namespace std;

using ll = long long;

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

void dfs(const auto& graph, int v, vector<bool> is_visit, int& cnt) {
    is_visit[v] = true;
    bool ok = true;
    for (bool b : is_visit) ok &= b;
    if (ok) {
        ++cnt;
        return;
    }
    for (auto u : graph[v]) {
        if (is_visit[u]) continue;
        dfs(graph, u, is_visit, cnt);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector<bool> is_visit(N, false);
    int ans = 0;
    dfs(graph, 0, is_visit, ans);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n;
    int p[4][3][10] = {0};
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        int b, f, r, v;
        scanf("%d %d %d %d", &b, &f, &r, &v);
        p[b - 1][f - 1][r - 1] += v;

    }

    for (int b = 0; b < 4; b++)
    {
        for (int f = 0; f < 3; f++)
        {
            for (int r = 0; r < 10; r++)
            {
                printf(" %d", p[b][f][r]);
            }
            printf("\n");
        }
        if (b != 3)
        {
            printf("####################\n");
        }   
    }
    return 0;
}


Measured memory_bytes: 2108
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using ll = long long;

using namespace std;

ll mod=1e9+7;


int main() {
	int n,m;
	cin>>n>>m;
	vector<pair<int,int>>island(m,pair<int,int>(n-1,0));
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		island[i].second=a;
		island[i].first=b;
	}
	int tmp=-1;
	int ans=0;
	sort(island.begin(),island.end());
	for(int i=0;i<m;i++){
		if(tmp>island[i].second){
			continue;
		}
		tmp=island[i].first;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


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



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//
//-----class-----//
class UnionFind{
    public:
        vector<ll> par; //parents
        vector<ll> siz; // sizes of set
        vector<ll> rank; // rank of each element 
    UnionFind(ll n): par(n), siz(n, 1LL), rank(n){
        LREP(i, 0, n) par[i] = i;
    }
    //initialization
    /*
    void init(ll n){
        par.assign(n);
        siz.assign(n, 1LL);
        rank.assign(n);
        LREP(i, 0, n) par[i] = i;
    }
    */

    // find the root of x
    ll find(ll x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    //Unite two set including x or y
    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(rank[x] < rank[y]){
            par[x] = y;
            siz[y] += siz[x];
        }else{
            par[y] = x;
            siz[x] += siz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    //Do x and y belong to the same set?
    bool issame(ll x, ll y){
        return find(x) == find(y);
    }

};

int N;
string S;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    cin >> S;
    char tmp = S[0];
    int ans = 1;
    REP(i, 1, N){
        if(S[i] != tmp){
            ++ans;
            tmp = S[i];
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
 
using namespace std;
 
int main(){
  string S,T;
  cin >> S;
  cin >> T;
  
  int times = 0;
  for(int i=0;i<S.size();i++){
    if(S[i] != T[i]){times ++;}
  }
  
  cout << times << endl;
  
}

Measured memory_bytes: 3912
#include <stdio.h>
 
main(void)
{
    int a,n,i;
     
    long long int min=1000000 , max=-1000000 , sum=0;
    a=0;
     
    scanf("%d",&n);
     
    for(a=1;a<=n;a++){
        scanf("%d",&i);
        if(i<min) min=i;
        if(i>max) max=i;
        sum+=i;
    }
    printf("%d %d %lld\n",min,max,sum);
     
    return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	if(abs(x-a)<abs(x-b))puts("A");
	else puts("B");
}


Measured memory_bytes: 256
x = int(input())

if x <= 6:
    print(1)
else:
    ans = (x//11)*2
    if x%11 == 0:
        print(int((x/11)*2))
    elif (x//11)*11 +6 >= x:
        print(ans+1)
    else:
        print(ans+2)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
using namespace std;

int main() {
    int h,w;
    
    while (cin >> h >> w && h!=0 && w!=0){
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (j%2 == 0 && i%2 != 0) cout << ".";
                else if (j%2 != 0 && i%2 == 0) cout << ".";
                else cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3108
import math
[a, b, h, m] = list(map(int, input().rstrip().split()))
hour_angle = 0.5 * (h * 60 + m)
minute_angle = 6 * m

angle = abs(hour_angle - minute_angle)
angle = min([360 - angle, angle])
angle = angle * math.pi / 180

ans = a ** 2 + b ** 2 - 2 * a * b * math.cos(angle)
print(math.sqrt(ans))

Measured memory_bytes: 9512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define int ll
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

const int Size=2017;
char board[Size][Size];
bool can[Size][Size];
int x[Size],r[Size],l[Size];
int ans;
void Calc(int w){
	stack<int> s;
	REP(i,w){
		while(!s.empty())
			if(x[s.top()]>x[i]){
				r[s.top()]=i;
				s.pop();
			}else
				break;
		l[i]=s.empty()?-1:s.top();
		s.push(i);
	}
	while(!s.empty()){
		r[s.top()]=w;
		s.pop();
	}
	REP(i,w)
		ans=max(ans,(r[i]-l[i])*(x[i]+1));
}

signed main(){
	int h=read(),w=read();
	REP(i,h)scanf("%s",board[i]);
	REP(i,h-1)REP(j,w-1)
		can[i][j]=(board[i][j]^board[i+1][j+1])==(board[i+1][j]^board[i][j+1]);
	h--,w--;
	REP(i,h){
		REP(j,w)
			if(can[i][j])x[j]++;
			else x[j]=0;
		Calc(w);
	}
	ans=max({ans,h+1,w+1});
	cout<<ans<<endl;
}
	

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

int main()
{
	map<int,int>mp;
	int n,sum=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		mp[x]++;
	}
	for(map<int,int>::iterator t=mp.begin();t!=mp.end();t++)
	{
		if((*t).second>=(*t).first)
			sum+=(*t).second-(*t).first;
		else
			sum+=(*t).second;
	}
	cout<<sum;

	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    int n;
    cin >> n;
    cout << n + n*n + n*n*n << endl;
}

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

int main()
{
	int n, l;
	cin >> n >> l;
	auto a = vector<string>(n);
	for(auto& b : a){
		cin >> b;
	}
	sort(a.begin(), a.end());
	for(auto b : a){
		cout << b;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 764
s = input()
t = input()

dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]

# 数え上げ
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        else:
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

# 経路復元
ans = ""
i, j = len(s), len(t)

while i > 0 and j > 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        ans = s[i - 1] + ans
        i -= 1
        j -= 1

print(ans)

Measured memory_bytes: 112732
N = int(input())
string = str(input())
string =list(string)
index = 0 
i = 0
res = []
# print(string[index])
while index<len(string):
	res.append(string[index])
	# print(res[-1])
	while index<len(string) and res[-1]==string[index]:
		index+=1
	i+=1
print(len(res))



Measured memory_bytes: 49648
#include <stdio.h>
#include <stdlib.h>
#define NMAX 2000000
#define AMAX 10000
int n=AMAX;
void CountingSort(unsigned short *,unsigned short *,int);
int main(){
  int i;
  unsigned short *A;
  unsigned short *B;
  int k;


  scanf("%d",&k);

  A=malloc(sizeof(short)*k+1);
  B=malloc(sizeof(short)*k+1);

  for(i=0;i<k;i++){
    scanf("%hu",&A[i+1]);
  }
  //  printf("ok1\n");
  CountingSort(A,B,k);
  return 0;
}

void CountingSort(unsigned short *A,unsigned short *B,int k){
  int i,j;
  int C[AMAX+1];
  //printf("ok2\n");
  for(i=0;i<=AMAX;i++){
    C[i]=0;
  }
  //printf("ok3\n");
  for(j=0;j<k;j++){
    C[A[j+1]]++;
  }
  //printf("ok4\n");
  for(i=1;i<=AMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  //printf("ok5\n");
  for(j=1;j<=k;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  //printf("ok6\n");
  for(i=1;i<=k;i++){
    if(i>1)
      printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
}



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

using namespace std;
typedef long long ll;

bool solve(string S){
    for(int i=0;i<3;i++){
        if(S[i] == S[i+1]) return true;
    }
    return false;
}

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

    vector<pair<ll, ll> > spairs(N);
    for(int i=0;i<N;i++){
        ll A, B;
        cin >> A >> B;
        spairs[i] = make_pair(B, A);
    }

    sort(spairs.begin(), spairs.end());
    ll curtime = 0;
    for(auto spair : spairs) {
        ll deadline = spair.first;
        ll time = spair.second;
        curtime += time;
        if(curtime > deadline){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 3328
n,m = map(int,input().split())
cnt = [[0,0] for i in range(n)]
for i in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if cnt[p-1][1] >0:
        continue
    if s =='AC':
        cnt[p-1][1] += 1
    else:
        cnt[p-1][0] += 1

ok = 0
no  = 0

for i in range(n):
    if cnt[i][1] > 0:
        ok += 1
        no += cnt[i][0]
print(ok,no)


Measured memory_bytes: 13172
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);


ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}

ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}

void dfs(ll x,ll y,ll ans[],VLL ad[],ll cnt[],ll t)
{
    ans[x]=t;
    REP(i,0,ad[x].size())
    {
        if(ad[x][i]!=y)
        {
            dfs(ad[x][i],x,ans,ad,cnt,t+cnt[ad[x][i]]);
        }
    }
    return;
}

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

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

    ll n,q;
    cin>>n>>q;
    VLL ad[n];
    REP(i,0,n-1)
    {
        ll t1,t2;
        cin>>t1>>t2;
        ad[t1-1].PB(t2-1);
        ad[t2-1].PB(t1-1);
    }
    ll cnt[n]={};
    REP(i,0,q)
    {
        ll t1,t2;
        cin>>t1>>t2;
        cnt[t1-1]+=t2;
    }
    ll ans[n];
    dfs(0,-1,ans,ad,cnt,cnt[0]);
    REP(i,0,n)
    {
        cout<<ans[i]<<' ';
    }

    return 0;
}


Measured memory_bytes: 32128
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(lint i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint X;
  cin>>X;
  FOR(A,-2000,2000)FOR(B,-2000,2000){
    if(A*A*A*A*A-B*B*B*B*B==X){
      cout<<A<<" "<<B<<endl;
      return 0;
    }
  }
  return 1;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string S, T;
    cin >> S >> T;
    int size = S.size();
    REP(i, size) {
        bool ok = true;
        REP(j, size) {
            if (S[(i + j) % size] != T[j]) {
                ok = false;
                break;
            }
        } 
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        } 
    } 

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
X = [int(x) for x in input().split()]

INF = (100 ** 2) * 100

minD = INF

for xi in range(1, 101):
    D = 0
    for n in range(N):
        D += (xi-X[n])**2
    if D < minD:
        minD = D

print(minD)

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

using namespace std;
using namespace __gnu_pbds; // namespace for pb_ds

/* short forms */
#define Accelerate                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mt make_tuple
#define cld(x, y) (((x) / (y)) + ((x) % (y) != 0)) //integer ceil division
#define tc(tt) \
    int tt;    \
    cin >> tt; \
    for (int _tt = 0; _tt < tt; _tt++) // testcase
#define all(cont) (cont).begin(), (cont).end()
#define sz(cont) (int)(cont).size()
#define endl '\n'
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl //print with precision
#define dbg(x) cerr << #x << "is" << (x) << endl
#define leadzero(a) __builtin_clz(a)      // count leading zeroes
#define trailzero(a) __builtin_ctz(a)     // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)

/* constants */
const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-9;

/* typedefs */
typedef pair<int,int> pii;
typedef priority_queue<int, vector<int>, greater<int> > min_heap;
typedef priority_queue<int, vector<int> > max_heap;
typedef tree<int,null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> 
    indexed_set; // integer set with indexing / pb_ds

/* main program */


int main() {
    Accelerate;
    int a,b;
    cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys 

def A():
  n = int(sys.stdin.readline().rstrip())
  charge = (n+999)//1000 * 1000 - n
  print(charge)
  pass


def B():
  pass


def C():
  pass


def D():
  pass


def E():
  pass


def F():
  pass

if __name__ == "__main__":
  A() 
  B()
  C()
  D()
  E()
  F()

Measured memory_bytes: 9044
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<decltype(x)::value_type>())
#define RSORT2(x, T) sort(ALL(x), greater<T>())
#define REVERSE(x) reverce(ALL(x))
#define ACM(x, y) accumulate(ALL(x), y)

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

// デバッグ用
#define PUT_LIST(x, y) std::copy(ALL(x), ostream_iterator<decltype(x)::value_type>(cout, y))

const int kMod = 1e9 + 7;

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

	int l;

	cin >> l;

	long double hen = (long double)l / 3;

	cout << fixed << setprecision(10) << hen * hen * hen;

	return 0;
}


Measured memory_bytes: 256
i,j,N,p,P,t[36],c[36],T[36],C[36];
B(){
    for(i=0;i<N;i++)
    for(j=N-1;j>0;j--)
        if(t[j-1]>t[j]){
            t[j]^=t[j-1]^=t[j]^=t[j-1];
            c[j]^=c[j-1]^=c[j]^=c[j-1];
        }
}
S(){
    for(i=0;i<N;i++){
        for(j=p=i;j<N;j++)if(T[j]<T[p])p=j;
        P=T[p];T[p]=T[i];T[i]=P;
        P=C[p];C[p]=C[i];C[i]=P;
    }
}
main(){
    for(scanf("%d",&N);i<N;scanf(" %c%d",&c[i],&t[i]),T[i]=t[i],C[i]=c[i],i++);
    B();S();
    for(i=0;i<N;printf("%c%d%s",c[i],t[i],i==N-1?"\nStable\n":" "),i++);
    for(i=0;i<N;printf("%c%d%s",C[i],T[i],i==N-1?"\n":" "),i++);
    for(i=p=0;i<N;i++)if(c[i]==C[i]&&t[i]==T[i])p++;
    puts(p==N?"Stable":"Not stable");
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int q = sc.nextInt();
		TreeSet<Long> sSet = new TreeSet<>();
		TreeSet<Long> tSet = new TreeSet<>();
		for (int i = 0; i < a; i++) {
			sSet.add(sc.nextLong());
		}
		for (int i = 0; i < b; i++) {
			tSet.add(sc.nextLong());
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
			long x = sc.nextLong();
			Long sLeft = sSet.floor(x);
			long sleft;
			if (sLeft == null) {
				sleft = Integer.MIN_VALUE;
			} else {
				sleft = sLeft;
			}
			Long tLeft = tSet.floor(x);
			long tleft;
			if (tLeft == null) {
				tleft = Integer.MIN_VALUE;
			} else {
				tleft = tLeft;
			}
			Long sRight = sSet.ceiling(x);
			long sright;
			if (sRight == null) {
				sright = Integer.MAX_VALUE;
			} else {
				sright = sRight;
			}
			Long tRight = tSet.ceiling(x);
			long tright;
			if (tRight == null) {
				tright = Integer.MAX_VALUE;
			} else {
				tright = tRight;
			}
			long x1 = x - Math.min(sleft, tleft);
			if (sLeft == null || tLeft == null) {
				x1 = Long.MAX_VALUE;
			}
			long x2 = Math.max(sright, tright) - x;
			if (sRight == null || tRight == null) {
				x2 = Long.MAX_VALUE;
			}
			long x3 = Math.min(sright - x, x - tleft) + sright - tleft;
			if (sRight == null || tLeft == null) {
				x3 = Long.MAX_VALUE;
			}
			long x4 = Math.min(tright - x, x - sleft) + tright - sleft;
			if (tRight == null || sLeft == null) {
				x4 = Long.MAX_VALUE;
			}
			sb.append(Math.min(Math.min(x1, x2), Math.min(x3, x4))).append("\n");
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 113044
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int inf = 1e17;
const int mod = 1000000007;
typedef pair<int, int> P;
typedef pair<int, P> PP;
int cnt[200006];
int n;

void disp(vector<int>V){
	rep(i,V.size()){
		if(cnt[V[i]]){
			V[i]+=n;
			}
		cnt[V[i]]++;	
		}
		
	rep(i,V.size()-1)cout<<V[i]<<' '<<V[i+1]<<endl;	
}

signed main(){
	cin>>n;
	rep(i,20){
		if(n==(1<<i)){
			puts("No");return 0;
			}
		}
	puts("Yes");
	vector<int>V;
	
	for(int i=3;i<= n;i+=4){
		rep(k,2){
		rep(j,4){
			if(i-3+j)V.push_back(i-3+j);
			}
		}
	}
	
	if(n%4==0){
	//	assert(0);
		V.clear();
		int k1,k2;
		rep(i,20){
			if(n&(1<<i)){
				k1=1<<i;
				k2=n-k1;
				break;
				}
			}
			
			rep(j,2)rep(i,4)V.push_back(k1+3-i);
			rep(j,2)rep(i,4)V.push_back(k2+i);
			
			for(int i=0;i<n;i+=4){
					if(i!=k1&&i!=k2){
					rep(j,2){
						rep(k,4){
							if(i+k)V.push_back(i+k);
							}
						}
					}
				}
			disp(V);
			cout<<n<<' '<<k1+n<<endl;
			cout<<n+n<<' '<<k2<<endl;	
		}
	else if(n%4==1){
		disp(V);
		int k=n/4*4;
		cout<<1<<' '<<k<<endl;
		cout<<k<<' '<<k+1<<endl;
		cout<<1<<' '<<n+k+1<<endl;
		cout<<n+k<<' '<<n+k+1<<endl;
		}
	else if(n%4==2){
		disp(V);
		int k=n/4*4;
		cout<<1<<' '<<k<<endl;
		cout<<k<<' '<<k+1<<endl;
		cout<<1<<' '<<k+n+1<<endl;
		cout<<k+n+1<<' '<<k+2<<endl;
		cout<<k+n+1<<' '<<k+n<<endl;
		cout<<2<<' '<<k+n+2<<endl;
		}		
	else{
		disp(V);
		}	
}


Measured memory_bytes: 7536
#include<iostream>
using namespace std;
int gcd(int ,int);
int main(){
  int x,y,a;
  cin>>x>>y;
  a=gcd(x,y);
  cout<<a<<endl;
  return 0;
}
  
int gcd(int x,int y){
  while(1)
    if(x>y){
      x%=y;
      if(x==0) return y;
    }
    else{
      y%=x;
      if(y==0) return x;
    }
}


Measured memory_bytes: 3096