akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  ll ans=a[0];
  rep(i,n) {
    ans=__gcd(ans,a[i]);
  }
  pr(ans);
}

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


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   int n;
   cin>>n;
   unordered_map<int, int> um;
   ll sum=0;
   rep(i, n){
      int a;
      cin>>a;
      sum+=a;
      um[a]+=1;
   }
   int q;
   cin>>q;
   rep(k, q){
      int b, c;
      cin>>b>>c;
      sum=sum-(ll)(b-c)*um[b];
      um[c]+=um[b];
      um.erase(b);
      cout << sum << endl;
   }
   return 0;
}


Measured memory_bytes: 6636
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

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

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

    ll n,k;cin>>n>>k;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    auto result=unique(a.begin(),a.end());
    a.erase(result,a.end());
    n=a.size();
    if(n==1){
        if(a[0]!=k) cout<<"IMPOSSIBLE"<<endl;
        else cout<<"POSSIBLE"<<endl;
        return 0;
    }
    if(k>a[n-1]){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    ll g=a[1]-a[0];
    for(int i=2;i<n;i++){
        if(a[i]-a[i-1]==0) continue;
        g=gcd(g,a[i]-a[i-1]);
    }
    for(int i=0;i<n;i++){
        if(a[i]<k) continue;
        if((a[i]-k)%g==0){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    int n, k; cin >> n >> k;
    string S; cin >> S;
    int cnt = 1, ans = 0;
    loop (n - 1, i) {
        if (S[i] != S[i + 1]) cnt++;
        else ans++;
    }
    loop (k, i) {
        if (cnt <= 1) continue;
        if (cnt == 2) {
            ans += 1;
            cnt = 1;
        } else {
            ans += 2;
            cnt -= 2;
        }
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=1<<18|2,mod=998244353;
ll a[N],f[N];
ll ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
void FWT(ll *a,int n){
	For(i,0,n-1){
		For(j,0,(1<<n)-1)if(j>>i&1){
			ll x=a[j-(1<<i)],y=a[j]; //cout<<j<<" "<<a[j]<<" "<<x<<" "<<y<<endl;
			a[j-(1<<i)]=(x+y)%mod; a[j]=(x-y)%mod;
		}
	}
}
int main(){
	int n=read(); ll sum=0;
	For(i,0,(1<<n)-1)a[i]=read();
	For(i,0,(1<<n)-1)sum=(sum+a[i])%mod;
	sum=ksm(sum,mod-2); 
	For(i,0,(1<<n)-1)a[i]=a[i]*sum%mod;
	FWT(a,n);
	For(i,0,(1<<n)-1){
		if(i==0)f[i]=1; 
		else f[i]=ksm(a[i]-1,mod-2); 
	}
	FWT(f,n);
	For(i,0,(1<<n)-1){
		writeln(((f[i]-f[0])%mod+mod)%mod);
	}
}

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

/*int main(){
    int N;
    cin >> N;
    vector <int> a(N);
    for(int i=0;i<N;i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int A=0,B=0;
    for(int i=0;i<N;i++){
        if(i%2==0) A+=a.at(i);
        else B+=a.at(i);
    }
    cout << (1+7/3)*3 <<endl;
    return 0;
}*/

int main(){
    bool flag =false;
    bool flag2 =false;
    vector<vector<int>> c(3,vector<int>(3));
    rep(i,0,3) rep(j,0,3) cin >> c.at(i).at(j);
    vector<int> b(3);
    rep(i,0,3) b.at(i)=c.at(0).at(i); //a_0を０とする
    if(c.at(1).at(0)-b.at(0)==c.at(1).at(1)-b.at(1)&&c.at(1).at(1)-b.at(1)==c.at(1).at(2)-b.at(2)){
        flag=true;
    }
    if(c.at(2).at(0)-b.at(0)==c.at(2).at(1)-b.at(1)&&c.at(2).at(1)-b.at(1)==c.at(2).at(2)-b.at(2)){
        flag2=true;
    }
    if(flag==true&&flag2==true) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long n, res;

int main()
{
	long l, r;

	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		cin >> l >> r;

		res += r - l + 1;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.format;

void main()
{
	auto D = readln.chomp.to!int;
	switch(D)
	{
		case 22:
			writeln("Christmas Eve Eve Eve");
			break;
		case 23:
			writeln("Christmas Eve Eve");
			break;
		case 24:
			writeln("Christmas Eve");
			break;
		case 25:
			writeln("Christmas");
			break;
		default:
	}
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
      val Array(w, h, x, y, r, _*) = StdIn.readLine().split(" ").map(_.toInt)
      if(x - r >= 0 && x + r <= w && y - r >=0 && y + r <= h) println("Yes")
      else println("No")
  }
}

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

int main()
{
    int d, g;
    cin >> d >> g;
    vector<int> p(d), c(d);
    for (int i = 0; i < d; i++)
    {
        cin >> p[i] >> c[i];
    }
    int ans = 1000;
    for (int bit = 0; bit < (1 << d); bit++)
    {
        int count = 0;
        int point = 0;
        for (int i = 0; i < d; i++)
        {
            if (bit & (1 << i))
            {
                count += p[i];
                point += 100 * (i + 1) * p[i] + c[i];
            }
        }
        if (point < g)
        {
            for (int i = d - 1; i >= 0; i--)
            {
                bool flag = false;
                if (!(bit & (1 << i)))
                {
                    for (int j = 0; j < p[i]; j++)
                    {
                        count++;
                        point += 100 * (i + 1);
                        if (point >= g)
                        {
                            flag = true;
                            break;
                        }
                    }
                }
                if (flag)
                {
                    break;
                }
            }
        }
        if (point >= g) {
            ans = min(ans, count);
        }
    }
    cout << ans << endl;
}

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

vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for (ll i = 2; i*i < n; i++) {
        if (n%i) continue;
        res.emplace_back(i, 0);
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}

int main() {
    ll n;
    cin >> n;
    auto a = factorize(n);
    ll ans = 0;
    for (auto x : a) {
        ll e = 1;
        while(x.second - e >= 0) {
            x.second -= e;
            e++;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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


long long int gcd(long long int a, long long int b){
    long long int c, tmp;
    while(1){
        c = a%b;
        if(c==0) break;
        a=b;
        b=c;
    }
    return b;
}

int main(void){
    long long int n, xx, i, ans;
    scanf("%lld %lld", &n, &xx);
    long long int x[n], y[n];
    for(i=0; i<n; i++){
        scanf("%lld", &x[i]);
    }
    for(i=0; i<n; i++){
        y[i] = llabs(xx-x[i]);
    }
    ans = y[0];
    for(i=0; i<n; i++){
        ans = gcd(ans, y[i]);
    }
    printf("%lld", ans);
    /*   for(i=0; i<n; i++){
        printf("%lld ", y[i]);
    }*/
}


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

int main(){
	long long a1,a2,b1,b2;
	cin>>a1>>b1>>a2>>b2;
	int round=1;
	while(1){
		if(round%2==1)	a2-=b1;
		else a1-=b2;
		if(a1<=0){
			cout<<"No";
			break;
		}
		if(a2<=0){
			cout<<"Yes";
			break;
		}
		round++;
	}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

long long n,k,x[55],y[55],X1,Y1,X2,Y2,t,s=2000000000ll*2000000000ll+5ll;


int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        cin >> x[i] >> y[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int l=1;l<=n;l++){
                for(int r=1;r<=n;r++){
                    X1=min(x[i],x[j]); X2=max(x[i],x[j]);
                    Y1=min(y[l],y[r]); Y2=max(y[l],y[r]);
                    t=0;
                    for(int h=1;h<=n;h++){
                        if(x[h]>=X1 && x[h]<=X2 && y[h]>=Y1 && y[h]<=Y2) t++;
                    }
                    //cout << (x2-x1)*(y2-y1) << ' ' << t << '\n';
                    if(t>=k) s=min(s,(X2-X1)*(Y2-Y1));
                }
            }
        }
    }
    cout << s;
}


Measured memory_bytes: 384
N = int(input())
H = list(map(int, input().split()))

result = "Yes"


for i in range(1, N)[::-1]:
    if H[i - 1] <= H[i]:
        continue
    elif H[i - 1] - H[i] == 1:
        H[i - 1] -= 1
    else:
        result = "No"

print(result)

Measured memory_bytes: 14224
a, b = input().split()

if a == 'H' and b == 'H':
    result = 'H'
    
if a == 'D' and b == 'H':
    result = 'D'
    
if a == 'D' and b == 'D':
    result = 'H'
    
if a == 'H' and b == 'D':
    result = 'D'
    
print(result)

Measured memory_bytes: 8968
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
int main()
{
    int n,flag=0;
    while(scanf("%d",&n)==1)
    {
        flag=0;
        for(int i=0;i<=n/4;i++)
        {
            for(int j=0;j<=n/7;j++)
            {
                if((i*4+j*7)==n)
                {
                    flag=1;
                    break;
                }
            }
        }
        if(flag)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}
/*
4 4
..##
..##
####
####
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
             
            using namespace std;
            using ull = unsigned long long;
             
            const int MAX_N = 400;
            const ull MAX_VAL = numeric_limits<ull>::max();
            ull costs[MAX_N + 1][MAX_N + 1];
            ull sums[MAX_N + 1][MAX_N + 1];
            ull inp[MAX_N + 1];
             
            int main() {
            	ios_base::sync_with_stdio(false);
            	int N; cin >> N;
            	for (int i = 0; i <= MAX_N; i++) {
            		for (int j = 0; j <= MAX_N; j++) {
            			costs[i][j] = MAX_VAL;
            		}
            	}
            	for (int i = 1; i <= N; i++) {
            		cin >> inp[i];
            		costs[i][i] = 0;
            	}
             
            	for (int i = 1; i <= N; i++) {
            		sums[i][i] = inp[i];
            		for (int j = i + 1; j <= N; j++) {
            			sums[i][j] = inp[j] + sums[i][j - 1];
            		}
            	}
            	
            	for (int L = 1; L <= N; L++) {
            		for (int start = 1; start + L <= N; start++) {
            			for (int div = 0; div + 1 <= L; div++) {
            				costs[start][start + L] = min(costs[start][start + L], costs[start][start + div] + costs[start + div + 1][start + L]);
            			}
                      	costs[start][start + L] +=  sums[start][start + L];
            		}
            	}
            	cout << costs[1][N] << endl;
            	return 0;
            }

Measured memory_bytes: 2816
//Projection
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

static const double ESP = 1e-10;

bool equals(double a, double b) { return fabs(a - b) < ESP; }

class Point {
public:
    double x, y;

    explicit Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (const Point &p) const { return Point(x + p.x, y + p.y); }
    Point operator - (const Point &p) const { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(a * x, a * y); }
    Point operator / (double a) { return Point(a / x, a / y); }

    double norm() { return x * x + y * y; }
    double abs() { return sqrt(norm()); }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x - p.x) < ESP && fabs(y - p.y) < ESP;
    }
};

typedef Point Vector;

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

bool isParallel(Vector v1, Vector v2) {
    return equals(cross(v1, v2), 0.0);
}

bool isOrthogonal(Vector v1, Vector v2) {
    return equals(dot(v1, v2), 0.0);
}

int main() {
    int q;
    double x, y, x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2 >> q;
    Point p1 = Point(x1, y1), p2 = Point(x2, y2);
    Vector v1, v2;
    v1 = p2 - p1;
    for(int i = 0; i < q; i++) {
        cin >> x >> y;
        Point p = Point(x, y);
        Vector v2 = p - p1;
        Point x = Point();
        x = p1 + (v1 * (dot(v1, v2) / v1.norm()));
        cout << setprecision(15) << x.x << " " << x.y << endl;
    }
}


Measured memory_bytes: 3288
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
prev_A = None
for a in A:
    ans += B[a - 1]
    if prev_A == a - 1:
        ans += C[prev_A - 1]
    prev_A = a
print(ans)

Measured memory_bytes: 3064
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 1000000000
#define ldb long double
#define pb push_back
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define gi(x) scanf("%lf",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define gc(a) scanf("%s",a+1)
#define rep(p,n,i) for(RE ll i=p;i<=n;++i)
#define go(x) for(ll i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE ll i=n;i>=p;--i)
#define pii pair<ll,ll>
#define mk make_pair
#define RE register
#define P 1000000007
#define mod 998244353
#define S second 
#define F first
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define ull unsigned long long
#define ui unsigned
#define zz p<<1
#define yy p<<1|1
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
    register ll x=0,f=1;register char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
    return x*f;
}
const ll MAXN=252;
ll n,m,S,cnt,len;
ll w[MAXN],vis[MAXN],c[MAXN],ans[MAXN],b[52][MAXN*10];
ll lin[MAXN],ver[MAXN],nex[MAXN],e[MAXN],e1[MAXN];
struct wy
{
	ll x,v,s;
	ll friend operator < (wy a,wy b){return a.v>b.v;}
};
inline void add(ll x,ll y,ll z,ll z1)
{
	ver[++len]=y;
	nex[len]=lin[x];
	lin[x]=len;
	e[len]=z;
	e1[len]=z1;
}
priority_queue<wy>q;
inline void dij()
{
	q.push((wy){1,0,min(2518ll,S)});
	vis[1]=1;
	while(q.size())
	{
		wy cc=q.top();
		q.pop();
		if(!vis[cc.x])vis[cc.x]=cc.v,--cnt;
		if(b[cc.x][cc.s])continue;
		b[cc.x][cc.s]=1;
		if(!cnt)return;
		if(cc.s>=2500);
		else q.push((wy){cc.x,cc.v+w[cc.x],min(cc.s+c[cc.x],2518ll)});
		go(cc.x)
		{
			if(cc.s>=e1[i])q.push((wy){tn,cc.v+e[i],cc.s-e1[i]});
		}
	}
}
signed main()
{
	//freopen("1.in","r",stdin);
	get(n);get(m);get(S);cnt=n-1;
	rep(1,m,i)
	{
		ll get(x),get(y),get(z1),get(z);
		add(x,y,z,z1);add(y,x,z,z1);
	}
	rep(1,n,i)get(c[i]),get(w[i]);
	dij();
	rep(2,n,i)putl(vis[i]);
	return 0;
}


Measured memory_bytes: 16408
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
    auto n = readLong();
    long[] a;
    foreach(i; iota(n)) {
        a ~= readLong();
    }
    auto b = sort(a.dup);
    foreach(ref ai; a) {
        ai = b.lowerBound(ai).length();
    }
    long ans;
    foreach(i, ai; a) {
        ans += abs(ai-i) % 2;
    }
    writeln(ans/2);
}



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

public class Main {

	static Scanner scanner;

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

        int N=gi();
        int D=gi();
        int X=gi();
        int[] A=new int[N];
        int c=X;
        for (int i=0; i<N;i++) {
        	A[i]=gi();
        	c+=Math.floorDiv(D-1, A[i])+1;
        }


	    System.out.println(c);

//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35764
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() (int, int) {
	n, m := scanInt(sc), scanInt(sc)
	return n, m
}

func resolve(n, m int) int {
	return abs((n - 2) * (m - 2))
}
func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

int main(){
    vector<int>A,B;
    for(int i=0;i<2;i++){
        int a;
        cin >> a;
        A.push_back(a);
    }
    for(int i=0;i<2;i++){
        int b;
        cin >> b;
        B.push_back(b);
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    cout << A.at(0) + B.at(0) << '\n';
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second  
#define endl '\n'
#define pb push_back
#define t_case ll tt; cin>>tt; while (tt--)
#define all(v) v.begin(),v.end()
#define ub(a,x) upper_bound(all(a),x)-a.begin()
#define lb(a,x) lower_bound(all(a),x)-a.begin()
#define fr(a,b,c) for (ll a=b;a<c;a++)
#define take(xx,n) for (int i=0;i<n;i++) cin>>xx[i];
#define take1(xx,n) for (int i=1;i<=n;i++) cin>>xx[i];
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
const auto inf=LLONG_MAX; 

int main() 
{
	fastio
	//t_case
	{
		ll sum=0,f=0,ans=0,n,m=0,z=0,mx=inf,mn=-inf,q,x,t ;
		cin>>n>>x>>t;
		ll val=ceil((ld)n/(ld)x);
		cout<<val*t<<endl;
	}
	return 0;
}

Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
#include<cassert>
#include<functional>

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	typedef long long ll;
	
	int n;
	int expensive = 0;
	int expensive_index;
	int sum;
	std::cin >> n;
	std::vector<int> p(n);
	for (int i = 0; i < n; i++){
		std::cin >> p[i];
		if (p[i] > expensive){
			expensive = std::max(expensive, p[i]);
			expensive_index = i;
		}
	}
	for (int i = 0; i < n; i++){
		if (i != expensive_index){
			sum += p[i];
		}
		else{
			sum += p[i] / 2;
		}
	}

	std::cout << sum << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int C,*S,*T;
int main(void)
{
	int n,q,i,j,right,left,mid;
	cin >> n;
	S = new int[n];
	for(i=0;i<n;i++){
		cin >> S[i];
	}
	cin >> q;
	T = new int[q];
	for(i=0;i<q;i++){
		cin >> T[i];
	}

	for(i=0;i<q;i++){
		left = 0;
		right = n;
		while(left < right){
			mid = (left+right)/2;
			if(T[i] == S[mid]){
				C++;
				break;
			}
			else if(T[i] < S[mid])
				right = mid;
			else
				left = mid + 1;
		}
	}
	cout << C << endl;
	return 0;
}

Measured memory_bytes: 1764
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
using namespace std;
namespace mine
{
	typedef long long ll;
	#define double long double
	const int INF=0x3f3f3f3f;
	const ll LLINF=0x3f3f3f3f3f3f3f3fll;
	ll qread()
	{
		ll ans=0;char c=getchar();int f=1;
		while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) {num=-num;putchar('-');}
		if(num>9) write(num/10);
		putchar('0'+num%10);
	}
	void writeln(int num){write(num);puts("");}
	#define FR first
	#define SE second
	#define MP make_pair
	#define pr pair<int,int>
	#define PB push_back
	inline void chmax(ll &x,const ll y) {x=x>y?x:y;}
	inline void chmin(ll &x,const ll y) {x=x<y?x:y;}


	const int MAX_N=1e3+10;
	bool v[MAX_N][MAX_N];
	void main()
	{
		int n;scanf("%d",&n);
		if(n&1) for(int i=1;i<=n/2;i++) v[i][n-i]=1;
		else for(int i=1;i<=n/2;i++) v[i][n+1-i]=1;
		printf("%d\n",n*(n-1)/2-(n/2) );
		for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) if(!v[i][j]) printf("%d %d\n",i,j);
	}
};
int main()
{
	srand(time(0));
	mine::main();
}


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

int main() {
	int n,k,tmp;
	cin >> n >> k;

	int cnt = 0;
	REP(i,n) {
		cin >> tmp;
		if (tmp >= k) {
			cnt++;
		}
	}
	cout << cnt << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int ans = 0;
char m[100][100] = { 0 };
bool sirusi[100][100] = { 0 };
 
void kukaku(int h, int w, int y, int x, char c, int cnt)
{
    if (y < 0 || y >= h || x < 0 || x >= w || sirusi[y][x] || m[y][x] != c) {
        return;
    }
 
    if (cnt == 0) {
        ++ans;
    }
 
    sirusi[y][x] = true;
 
    kukaku(h, w, y + 1, x, c, cnt + 1);
    kukaku(h, w, y - 1, x, c, cnt + 1);
    kukaku(h, w, y, x + 1, c, cnt + 1);
    kukaku(h, w, y, x - 1, c, cnt + 1);
}
 
int main(void)
{
    int h, w;
    while (1) {
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }
        ans = 0;

        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
            	m[i][j] = '\0';
            	sirusi[i][j] = false;
            }
        }

        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cin >> m[i][j];
            }
        }
 
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                kukaku(h, w, i, j, m[i][j], 0);
            }
        }
 
        cout << ans << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
#define rep(p,q) for(int i = p;i < q;i++)

int main(void) {
	int a = (int)'z' + 1;
	char al;
	string str;
	string ans;
	long int num = 0;
	cin >> str >> num;
	rep(0, str.length() - 1) {
		al = str[i];
	    if (a - (int)al <= num && al != 'a') {
			num -= a - (int)al;
			al = 'a';
		} 
		ans += al;
	}
	al = str[str.length() - 1];
	num %= 26;
	if (a - (int)al > num ) {
		al = (char)((int)al + num);
	}
	else {
		num -= a - (int)al;
		al = (char)((int)'a' + num );
	}
	ans += al;
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e8;

const int N_MAX = 101;
int C[N_MAX][N_MAX] = {};

struct Edge{
    int from;
    int to;
    int cost;
    Edge(int from, int to, int cost): from(from), to(to), cost(cost) {}

    string ToString(){
        return to_string(from) + " " + to_string(to) + " " + to_string(cost);
    }
};

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

    // input
    ll N, M;
    cin >> N >> M;

    FOR(i, 0, N_MAX){
        FOR(j, 0, N_MAX){
            if(i==j){
                C[i][j] = 0;
            }else{
                C[i][j] = inf;
            }
        }
    }

    vector<Edge> edgeList;

    FOR(i, 0, M){
        int a, b, c;
        cin >> a >> b >> c;

        C[a][b] = c;
        C[b][a] = c;

        auto edge = Edge(a, b, c);
        edgeList.push_back(edge);
    }

    FOR(i, 1, N+1){ // 経由点
        FOR(j, 1, N+1){ // 始点
            FOR(k, 1, N+1){ // 終点
                // j -> i -> k
                C[j][k] = min(C[j][k], C[j][i] + C[i][k]);
            }
        }
    }

    ll count = 0;
    for(auto edge : edgeList){
        if(edge.cost != C[edge.from][edge.to]){
            count++;
        }
    }

    p(count);

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#define N 1001

int lcs(char*,char*);
int max(int,int);
int main(){
  char s1[N],s2[N];
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",s1+1,s2+1);
    printf("%d\n",lcs(s1,s2));
  }
  return 0;
}

int lcs(char* x,char* y){
  int C[N+1][N+1],i,j,m,n,maxl=0;
  m=strlen(x+1);
  n=strlen(y+1);
  x[0]=' ';
  y[0]=' ';
  
  for(i=0;i<=m;i++)C[i][0]=0;
  for(j=1;j<=n;j++)C[0][j]=0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i]==y[j]) C[i][j]=C[i-1][j-1]+1;
      else C[i][j]=max(C[i-1][j],C[i][j-1]);
      maxl=max(maxl,C[i][j]);
    }
  }

  return maxl;
}
int max(int a,int b){
  if(a>b)return a;
  else return b;
}


Measured memory_bytes: 5620
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(X: int, Y: int):
    if (4*X-Y)%2 == 1:
        print(NO)
        exit()
    if (Y-2*X)%2 == 1:
        print(NO)
        exit()
    if 4*X-Y < 0:
        print(NO)
        exit()
    if Y-2*X < 0:
        print(NO)
        exit()

    print(YES)

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


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

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

using namespace std;

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

  int sum=0,maxp=0;
  
  rep(i,n){
    int t;cin>>t;
    sum+=t;
    maxp=max(maxp, t);
  }

  cout<<sum-maxp/2;

  return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000009
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 200010
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
 
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
 
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}


char s[20];
int main(){
    int n,t,i,j,m,k;
    scanf("%s",s);
    rep(i,0,4)printf("%c",s[i]);putchar(' ');
    rep(i,4,12)printf("%c",s[i]);puts("");
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll a,b,c;
	cin >> a >> b >> c;
	cout << min({a,b,c}) << " " << max({a,b,c}) << endl;
	return 0;
}


Measured memory_bytes: 3108
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, M;
	in >> N >> M;
	std::vector<LL>A(N), B(N);
	rep(i, N) in >> A[i] >> B[i];

	std::vector<std::pair<LL, LL>>store;
	rep(i, N) store.push_back(std::make_pair(A[i], B[i]));
	std::sort(store.begin(), store.end());

	LL sum = 0, ans = 0;
	rep(i, N)
	{
		if (sum == M) break;
		LL want = M - sum;
		LL can = std::min(want, store[i].second);
		ans += store[i].first*can;
		sum += can;
	}

	out << ans << std::endl;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	long long times;
	cin>>times;
	long long cnt=1,dif=1;
	long long sum=0;
		if(s.size()==1){
		printf("%lld\n",times/2);
		return 0;
	}
	for(int i=1;i<s.size();i++){
		while(s[i]==s[i-1]){
			if(i>=s.size())
				break;
			i++;
			cnt++;	
		}
		sum+=cnt/2;
		cnt=1;
		if(i<s.size()) dif++;
	}
	//cout<<dif<<endl;
	if(dif==1){
		printf("%lld\n",(s.size()*times)/2);
	}
	else if(s[0]==s[s.size()-1]){
		int cnt1=1,cnt2=1;
		int i=1;
		while(s[i]==s[i-1]){
			i++;
			cnt1++;
		}
		i=s.size()-1;
		while(s[i]==s[i-1]){
			i--;
			cnt2++;
		}
		//cout<<cnt1<<" "<<cnt2<<" ";
		sum=(sum-cnt1/2-cnt2/2)*times+cnt1/2+cnt2/2+(cnt1+cnt2)/2*(times-1);
		printf("%lld\n",sum);	
	}
	else printf("%lld\n",sum*times);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a > b && a > c){
    if(b > c){
      printf("%d %d %d\n",c,b,a);
      }
      else{
        printf("%d %d %d\n",b,c,a);
      }
  }
  else if(b > a && b > c){
          if(a > c){
            printf("%d %d %d\n",c,a,b);
          }
          else{
              printf("%d %d %d\n",a,c,b);
        }
  }
  else if(c > a && c > b){
        if(a > b){
          printf("%d %d %d\n",b,a,c);
        }
        else{
          printf("%d %d %d\n",a,b,c);
        }

  }

  return 0;
}



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

int main(){
    ll n,ans,k;
    cin >> n;
    ans=0;

    if(n%2==0){
        n/=2;
    while(n>=5){
        n/=5;
        ans+=n;
    }
    }
    else{
        ans=0;
    }

    
    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 256
#S = input()
N,K,Q = map(int,input().split())
A_list = [int(input()) for i in range(Q)]
#X_list = list(map(int,input().split()))
#X2_list = [list(map(int,input().split())) for i in range(N)]
ans = [K - Q] * N
for i in range(Q):
    ans[A_list[i] -1] +=1
for a in ans:
    if a > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 10472
import itertools
n = int(input())
p = input().split()
q = input().split()

n_str = ''
for i in range(n):
    n_str += str(i+1)

n_list = []
for order in itertools.permutations(n_str):
    int_str = int(''.join(order))
    n_list.append(int_str)

print(abs(n_list.index(int(''.join(p)))-n_list.index(int(''.join(q)))))

Measured memory_bytes: 4760
#include <iostream>
#include <array>
#include <vector>

using namespace std;

int main() {
    int player_num, point, round;
    cin >> player_num >> point >> round;
    
    vector<int> player_list(player_num, point-round);

    for(int i = 0; i < round; ++i) {
        int winner;
        cin >> winner;
        ++player_list.at(winner-1);
    }

    for(int player : player_list) {
        string result = (player > 0) ? "Yes" : "No";
        cout << result << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  ll K, N;
  cin >> K >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  vector<ll> DeltaMigi(N);
  vector<ll> ANSMigi(N);
  ll ans = 20000000;
  rep(i, N)
  {
    cin >> A.at(i);
    ANSMigi.at(i) = K;
  }
  //支点を0に揃える
  rep(i, N)
  {
    B.at(i) = A.at(i) - A.at(0);
  }
  //差分の計算
  rep(i, N - 1)
  {
    DeltaMigi.at(i) = B.at(i + 1) - B.at(i);
  }
  DeltaMigi.at(N - 1) = K - B.at(N - 1);

  //各支点から出発した場合の距離
  ANSMigi.at(0) -= DeltaMigi.at(N - 1);
  for (int i = 1; i < N; i++)
  {
    ANSMigi.at(i) -= DeltaMigi.at(i - 1);
  }
  rep(i, N)
  {
    ans = min(ans, ANSMigi.at(i));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
  int main(){
      lint n,m;
      lint ans=0;
      cin>>n>>m;
      vector<vector<lint>> g(m);
      rep(i,n){
          lint a;
          cin>>a;
        g[a%m].push_back(a);
      }
      repp(i,1,(m+1)/2){
          lint dif=0;
          lint comp=0;
          lint count=1;
          if(g[i].size()<g[m-i].size()){
              ans+=g[i].size();
              dif=g[m-i].size()-g[i].size();
              sort(all(g[m-i]));
              rep(j,g[m-i].size()-1){
                  if(g[m-i][j]==g[m-i][j+1])count++;
                  else{
                      comp+=count/2;
                      count=1;
                  }
              }
              comp+=count/2;
          }else if(g[i].size()>g[m-i].size()){
              ans+=g[m-i].size();
              dif=g[i].size()-g[m-i].size();
              sort(all(g[i]));
              rep(j,g[i].size()-1){
                  if(g[i][j]==g[i][j+1])count++;
                  else{
                      comp+=count/2;
                      count=1;
                  }
              }
              comp+=count/2;
          }else{
              ans+=g[i].size();
          }
          dif/=2;
          ans+=min(comp,dif);
      }
      if(m%2==0)ans+=g[m/2].size()/2;
      ans+=g[0].size()/2;
      cout<<ans;
  }
  
     


Measured memory_bytes: 5760
import java.util.*;
public class Main{
  	public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int M = keyboard.nextInt();
				
		int[][]drink = new int[N][2];
		for(int i=0; i<N; i++){
			for(int j=0; j<2; j++){
				drink[i][j] = keyboard.nextInt();
			}
		}
		Arrays.sort(drink, (l,r) -> {return l[0]-r[0];});
		
		int buy = M;
		long money = 0;
		for(int k=0; k<N; k++) {
			buy -= drink[k][1];
			if(buy > 0) {
				money += (long)drink[k][0]*drink[k][1];	
			}else{
				money += (long)drink[k][0]*(drink[k][1]+buy);
				break;
			}
		}
		
		System.out.println(money);
		keyboard.close();	
	}
}


Measured memory_bytes: 91328
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1,n,a,b,m,K;
    cin>>n>>K;
    vector<ll> ar(n+1,0),dp(n+1,1e10);
    for(ll i=1;i<=n;i++)
        cin>>ar[i];
    /*
    State
    dp[i]: Denotes the minimum cost to reach the ith Stone
    Recurrence
    dp[i]=min(dp[i-1]+|ar[i]-ar[i-1]|,dp[i-2]+|ar[i]-ar[i-2]|,....dp[i-k]+|ar[i]-ar[i-k]|) 
    */
    dp[1]=0;
    for(ll i=2;i<=n;i++){
        for(ll k=1;k<=min(K,i-1);k++){
            dp[i]=min(dp[i],dp[i-k]+abs(ar[i-k]-ar[i]));
        }
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

string C[36], Cb[36];

void BubbleSort(int N) {
  for(int i = 0; i < N; i++) {
    for(int j = N - 1; j > i; j--) {
      if(C[j][1] < C[j - 1][1]) {
        string swap = C[j];
        C[j] = C[j - 1];
        C[j - 1] = swap;
      }
    }
  }
}

void SelectionSort(int N) {
  for(int i = 0; i < N; i++) {
    int minj = i;
    for(int j = i; j < N; j++) {
      if(C[j][1] < C[minj][1]) {
        minj = j;
      }
    }
    string swap = C[i];
    C[i] = C[minj];
    C[minj] = swap;
  }
}

bool IsStable(int N) {
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      for(int k = 0; k < N; k++) {
        for(int l = k + 1; l < N; l++) {
          if(C[i][1] == C[j][1] && C[i] == Cb[l] && C[j] == Cb[k]) {
            return false;
          }
        }
      }
    }
  }

  return true;
}

int main() {
  int N;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> C[i];
    Cb[i] = C[i];
  }

  BubbleSort(N);

  for(int i = 0; i < N; i++) {
    if(i == N - 1) {
      cout << C[i] << endl;
    } else {
      cout << C[i] << " ";
    }
  }

  if(IsStable(N)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not Stable" << endl;
  }

  for(int i = 0; i < N; i++) {
    C[i] = Cb[i];
  }

  SelectionSort(N);

  for(int i = 0; i < N; i++) {
    if(i == N - 1) {
      cout << C[i] << endl;
    } else {
      cout << C[i] << " ";
    }
  }

  if(IsStable(N)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  return 0;
}


Measured memory_bytes: 3148
ls = raw_input().split()
l=[0,0,0,0]
l[0]=int(ls[0])
l[1]=int(ls[1])
l[2]=int(ls[2])
l[3]=int(ls[3])
ax=l[1]-l[3]
ay=l[2]-l[0]

x3=str(ax+l[2])
y3=str(ay+l[3])
x4=str(ax+l[0])
y4=str(ay+l[1])
ans=x3+" "+y3+" "+x4+" "+y4
print ans


Measured memory_bytes: 2568
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string alph="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
string s;
int n;
cin>>n>>s;

for(int k=0;k<s.size();k++){
   int t=s[k]-'A';
   for(int i=1;i<=n;i++){
    t++;
    if(t>=26)
        t=0;
   }
   cout<<char('A'+t);
}
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[10000005];
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    ll n;
    cin>>n;
    for(ll i=2;i<=10000000;i++)
    {
        for(ll j=i;j<=10000000;j+=i)
        {
            dp[j]++;
        }
    }
    for(ll i=1;i<=10000000;i++)
    {
        dp[i]++;
    }
    ll sum = 0;
    for(ll i=1;i<=n;i++)
    {
        sum+= i*dp[i];
    }
    cout<<sum<<"\n";
}


Measured memory_bytes: 81716
using System;
using System.Linq;

class Prog
{
  public static void Main()
  {
    var iptO = Console.ReadLine(); 
    var iptE = Console.ReadLine();  
    var output = "";
    for(var i = 0; i < iptO.Length-1; i++)
    {
      output+=iptO[i];
      output+=(iptE[i]);
    }
    if (iptO.Length==iptE.Length)
    {
      output+=(iptO[iptO.Length-1]);
      output+=(iptE[iptE.Length-1]);
    }
    else
    {
      output+=(iptO[iptO.Length-1]);
    }
    Console.WriteLine(output);
  }
}


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

using namespace std;

//#define FILE_IO

typedef long long LL;

int N;
LL a[100005], b[100005];
LL ans;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
        scanf("%lld%lld", &a[i], &b[i]);

    for(int i = N; i >= 1; i--)
    {
        LL press = (b[i] - ( (a[i] + ans) % b[i] )) % b[i];
        ans += press;
    }

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

    return 0;
}


Measured memory_bytes: 1792