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

class UnionFind {
private:
	vector< int > data;
	
public:
	UnionFind(int n) : data(n, -1) {}
	
	void unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (data[y] < data[x]) swap(x, y);
		if (x != y) { data[x] += data[y]; data[y] = x; }
	}
	
	bool sameSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
};

int N, M;
vector< vector< int > > aList;

vector< int > getDegOrder() {
	vector< int > deg(N, 0);
	for (int v=0; v<N; ++v) deg[v] = (int)aList[v].size();
	
	using pii = pair< int, int >;
	set< pii > que;
	for (int v=0; v<N; ++v) que.insert(pii(-deg[v], v));
	
	vector< int > ret;
	while (!que.empty()) {
		int v = que.begin()->second; que.erase(que.begin());	
		if (deg[v] < 0) continue;
		ret.push_back(v); deg[v] = -1;
		for (int u : aList[v]) {
			if (deg[u] < 0) continue;
			que.erase(pii(-deg[u], u));	--deg[u];
			que.insert(pii(-deg[u], u));
		}
	}
	return ret;
}

vector< int > constructCliques(const vector< int >& vertex_order) {
	vector< int > mark(N, 0);
	
	UnionFind uf(N);
	for (int v : vertex_order) {
		mark[v] = 1;
		int g = -1;
		for (int u : aList[v]) {
			if (mark[u] == 0) continue;
			int r = uf.root(u);
			if (g != r) g = (g == -1 ? r : -2);
		}
		if (g >= 0) uf.unionSet(g, v);
		if (g == -2) mark[v] = -1;
	}
	
	vector< int > ret;
	for (int v=0; v<N; ++v) {
		if (mark[uf.root(v)] == -1) continue;
		mark[uf.root(v)] = -1;
		ret.push_back(uf.size(v));
	}
	return ret;
}

int main() {
	cin >> N >> M;
	aList.assign(N, vector< int >());
	for (int i=0; i<M; ++i) {
		int u, v; cin >> u >> v; --u; --v;
		aList[u].push_back(v);
		aList[v].push_back(u);
	}
	
	vector< int > deg_order = getDegOrder();
	reverse(deg_order.begin(), deg_order.end());
	vector< int > cliqueSize = constructCliques(deg_order);
	
	using lint = long long int;
	lint ans = 1, MOD = (lint)1e9 + 9;
	for (int x : cliqueSize) ans = (ans * x) % MOD;
	cout << cliqueSize.size() << endl << ans << endl;
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t;
	cin >> t;
	if(t>=30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
        	int y = scan.nextInt();
        	int m = scan.nextInt();
        	int d = scan.nextInt();
        	if(y > 1989){
        		System.out.println("heisei " + (y - 1988) + " " + m + " " + d);
        	}else if(y > 1926){
        		if(y == 1989){
        			if(32*m + d > 39){
        				System.out.println("heisei 1 " + m + " " + d);
        			}else{
        				System.out.println("showa 64 " + m + " " + d);
        			}
        		}else{
        			System.out.println("showa " + (y - 1925) + " " + m + " " + d);
        		}
        	}else if(y > 1912){
        		if(y == 1926){
        			if(32*m + d > 408){
        				System.out.println("showa 1 " + m + " " + d);
        			}else{
        				System.out.println("taisho 15 " + m + " " + d);
        			}
        		}else{
        			System.out.println("taisho " + (y - 1911) + " " + m + " " + d);
        		}
        	}else if(y > 1868){
        		if(y == 1912){
        			if(32*m + d > 253){
        				System.out.println("taisho 1 " + m + " " + d);
        			}else{
        				System.out.println("meiji 45 " + m + " " + d);
        			}
        		}else{
        			System.out.println("meiji " + (y - 1867) + " " + m + " " + d);
        		}
        	}else{
        		if(y == 1868){
        			if(32*m + d > 295){
        				System.out.println("meiji 1 " + m + " " + d);
        			}else{
        				System.out.println("pre-meiji");
        			}
        		}else{
        			System.out.println("pre-meiji");
        		}
        	}
        }
    }
}

Measured memory_bytes: 17196
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
            string[] s0 = Console.ReadLine().Split(' ');
    		int n = int.Parse(s0[0]);
            int m = int.Parse(s0[1]);
            int[] arr = new int[n];
            for (int i=0; i<m; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                arr[int.Parse(s[0]) - 1]++;
                arr[int.Parse(s[1]) - 1]++;
            }
            
            bool ans = true;
            foreach (int i in arr)
            {
                if (i%2 == 1)
                {
                    ans = false;
                    break;
                }
            }
            if (ans) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 17196
#include <stdio.h>

int main(void) {
    int a,b,c;
    int cnt=0;
    scanf("%d %d %d", &a, &b, &c);
    for (int i=a; i<=b; i++) {
        if (c%i == 0) {
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 2732
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

const int MOD = 1000000007;

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	vector<int> x(N + 1), y(N + 1), z(N + 1);
	ll ans = 1;
	for (int i = 0; i < N; i++) {
		int cnt = 0;
		x[i + 1] = x[i];
		y[i + 1] = y[i];
		z[i + 1] = z[i];
		if (x[i] == A[i]) {
			x[i + 1]++;
			cnt++;
			if (y[i] == A[i]) cnt++;
			if (z[i] == A[i]) cnt++;
		}
		else if (y[i] == A[i]) {
			y[i + 1]++;
			cnt++;
			if (z[i] == A[i]) cnt++;
		}
		else if (z[i] == A[i]) {
			z[i + 1]++;
			cnt++;
		}
		ans *= cnt;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(void) {
	int hei[10];
	
	for (int i = 0; i < 10; i++) {
		cin >> hei[i];
	}
	sort(hei, hei + 10);

	for (int i = 9; i > 6; i--) {
		cout << hei[i] << endl;
	}
}

Measured memory_bytes: 3104
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
typedef long long int lli;

using namespace std;

int main() {
   
   char S;
   cin >> S;
   if (isupper(S))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void){
	int n; cin >> n;
	ll ans = 1;
	reps(i, 1, n + 1){
		(ans *= i) %= MOD;
		// printf("%lld\n", ans);
	}
	printf("%lld\n", ans);
	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;

int main(){
  ll n;
  string s;
  cin >> n >> s;

  vector<ll> lw(n, 0); // ]
  lw[0] = s[0] == '.';
  rep(i, n-1) lw[i+1] = lw[i] + ((s[i+1] == '.')? 1:0);
  
  vector<ll> rb(n, 0); // [
  rb[n-1] = s[n-1] == '#';
  rep(i, n-1) rb[n-1-i-1] = rb[n-1-i] + ((s[n-1-i-1] == '#')? 1:0);

  ll minn = 1e9;
  rep(i, n) minn = min(minn, i-lw[i] + (n-i)-rb[i]);  

  cout << minn << endl;

  return 0;
}



Measured memory_bytes: 3732
str = input()

ans = False
if str[0] == str[1] and str[2] == str[3]:
    ans = True
elif str[0] == str[2] and str[1] == str[3]:
    ans = True
elif str[0] == str[3] and str[1] == str[2]:
    ans = True

if str[0] == str[1] and str[0] == str[2]:
    ans = False
    
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
using namespace std;
typedef long long unsigned int llui_t;
typedef long long int lli_t;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

/* inputs */
llui_t N;

int main() {
    cin >> N;

    vector<vector<lli_t>> F(N, vector<lli_t>(10));
    vector<vector<lli_t>> P(N, vector<lli_t>(10));

	for(llui_t i=0; i<N; i++) {
        for(llui_t j=0; j<10; j++) {
            cin >> F[i][j];
        }
    }

	for(llui_t i=0; i<N; i++) {
        for(llui_t j=0; j<11; j++) {
            cin >> P[i][j];
        }
    }

    lli_t ans = -1e11;
    for(unsigned i=1; i<pow(2,10); i++) {
        lli_t p = 0;
        for(int k=0; k<N; k++) {
            int n = 0;
            for(int j=0; j<10; j++) {
                n += (i>>j & F[k][j]);
            }
            p += P[k][n];
        }
        ans = max(p, ans);
    }
    cout << ans << endl;

}


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

int A, B, C;

int main() {
  cin >> A >> B >> C;
  if(A == B && B == C && A % 2 == 0) cout << -1 << endl;
  else {
    int res = 0;
    while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
      int a = A / 2, b = B / 2, c = C / 2;
      A = b + c, B = c + a, C = a + b;
      ++res;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
int a,b,c;
int main(void){
    cin>>a>>b>>c;   
    cout<<max(a,max(b,c))-min(a,min(b,c))<<endl;
}


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

int main() {
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(a+1==c)cout<<1<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 3620
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

INF = 100000000

def main():
    N, L = map(int, input().split())
    apples = [i for i in range(L, L + N)]
    sum_ = sum(apples)
    without_self_sum = [sum_ - apples[i] for i in range(N)]
    abs_minimum = INF
    ans = 0
    for i in range(N):
        if abs(sum_ - without_self_sum[i]) < abs_minimum:
            abs_minimum = abs(sum_ - without_self_sum[i])
            ans = without_self_sum[i]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 12436
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;
 
int main(){
    ll n,x;
    cin >> n >> x;
    cout << 3*(n-__gcd(n,x)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e18;
const int mod = 1e9 + 7;

signed main() {
    vector<bool > prime(1e5 + 200, true);
    for (int i = 2; i < 1e5 + 100; i++) {
        if (!prime[i]) continue;
        for (int j = 2 * i; j < 1e5 + 100; j += i) {
            prime[j] = false;
        }
    }
    int X;
    cin >> X;
    int ans = -1;
    for (int i = X; i < 1e5 + 100; i++) {
        if (prime[i]) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
ll const mod=998244353;
const ll MAX=200000;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////
template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};
map<int,P>mp;
int main(){
    int h,w,d;
    cin>>h>>w>>d;
    vvi a(h,vi(w));
    rep(i,h)rep(j,w){
        cin>>a[i][j];
        mp[a[i][j]-1]=P(i,j);
    }
    int q;
    cin>>q;
    vi ans;
    UnionFind<int> uf(h*w);
    rep(i,q){
        int l,r;
        cin>>l>>r;
        l--,r--;
        
        int L=l;
        while(l<=r){
            if(uf.issame(l,r)){
                ans.push_back(uf.diff(l,r)+uf.diff(L,l));
                break;
            }
            P now=mp[l];
            P next =mp[l+d];
            int df=abs(next.fs-now.fs)+abs(next.sc-now.sc);
            uf.merge(l,l+d,df);
            l+=d;    
        }
        
    }
    rep(i,q){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 8700
import java.io.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
class Main{
    public static void main(String[] a){
        int first = 0;
        int last = 0;
        Scanner scan = new Scanner(System.in);
        while (scan.hasNext()){
        first = scan.nextInt();
        
        int num = 1;
        
        if(first < 0){
        num = 0;}
        else if(first == 1){
        num = 0;
         System.out.println(num);
        } else if (first == 2){
        num = 1;
         System.out.println(num);
        } else if (first == 3){
        num = 2;
         System.out.println(num);
        }else{
        
        for(int i=3; i< first+1; i+=2){
        boolean prime = true;
        for(int div = 3; div <= Math.sqrt(i); div+=2){
        if(i%div == 0){
        prime = false;
        break;
        }
     }
     if(prime== true){
     num = num + 1;
     }
  }
  System.out.println(num);
        
        }
        
      }
      
    }
     
}

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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    vector<ll>a(n+1),b(m+1);

    rep(i,n){
        ll A;
        cin>>A;

        a[i+1]=a[i]+A;
    }

    ll amax=upper_bound(a.begin(),a.end(),k)-a.begin()-1;

    rep(i,m){
        ll B;
        cin>>B;

        b[i+1]=b[i]+B;
    }

    ll ans=0;

    rep(i,amax+1){
        ll bmax=upper_bound(b.begin(),b.end(),k-a[i])-b.begin()-1;

        ans=max(ans,i+bmax);
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 6432
void main()
{
    string s = readln.chomp;

    long n = s.countUntil('C');
    long m = -1;
    if (n != -1)
    {
        m = s[n+1..$].countUntil('F');
    }

    writeln(m != -1 ? "Yes" : "No");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
/*
This code By @1353055672(Ligen)
[Warning]You're not excepted to understand this code!
RP++
*/
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#define ll long long
#define ull unsigned long long
#define mn 1000020
#define FOR(a,b,c) for (int a=b;a<=c;a++)
#define FORD(a,b,c) for (int a=b;a>=c;a--)
using namespace std;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while (c<'0'||c>'9'){
        if (c=='-')f=-1;
        c=getchar();
    }
    while (c>='0'&&c<='9'){
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
int Max(int a,int b){return (a>b)?a:b;}
int Min(int a,int b){return (a<b)?a:b;}

int main(){
	int n=read();
	FOR(i,0,n/4)if(n-i*4>=0&&(n-i*4)%7==0){printf("Yes\n");return 0;}
	printf("No\n");
	return 0;
}

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

using ll = long long;

const long long mod = 1e9 + 7;

ll ext_gcd(ll a, ll b, ll& x, ll& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  ll g = ext_gcd(b, a % b, y, x);
  y -= (a / b) * x;
  return g;
}

ll mod_inv(ll a, ll mod) {
  ll x, y;
  ext_gcd(a, mod, x, y);
  return (x % mod + mod) % mod;
}

ll fact(ll n, ll mod) {
  ll res = 1;
  for (ll i = 2; i <= n; ++i) res = (res * i) % mod;
  return res;
}

ll comb(ll n, ll r) {
  ll numerator = fact(n, mod);
  ll denominator = (fact(r, mod) * fact(n - r, mod)) % mod;
  return (numerator * mod_inv(denominator, mod)) % mod;
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll X, Y;
  cin >> X >> Y;
  ll ans = 0;
  ll a, b;
  a = 2 * X - Y;
  b = 2 * Y - X;
  if (a % 3 == 0 && b % 3 == 0 && a >= 0 && b >= 0) ans = comb(a / 3 + b / 3, a / 3);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;
/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int main(){
  int N;cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A[i];
  int res = 0;
  for(int i=0;i<N;i++){
    while(i+1 < N && A[i] == A[i+1]) ++i;
    
    //up
    if(i+1 < N && A[i] < A[i+1]) {
       while (i+1 < N && A[i] <= A[i+1]) ++i;
    }
    // down
    else if (i+1 < N && A[i] > A[i+1]) {
       while (i+1 < N && A[i] >= A[i+1]) ++i;
    }
    ++res;
  }
  std::cout << res << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

int n, a, b;

int main() {
	scanf("%d%d%d", &n, &a, &b);
	printf("%lld\n", max(1ll * b * n - b + a - 1ll * a * n + a - b + 1, 0ll));
	return 0;
}

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


int main(){
    string s;
    cin >> s;
    
    if(s.at(0) != s.at(1) && s.at(1) != s.at(2) && s.at(2) != s.at(3)){
        cout << "Good" << endl;
    }
    else{
        cout << "Bad" << endl;
    }
}


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

int main() {
	int n;
	cin >> n;
	vector<double>v(n);
  for(int i=0;i<n;i++) cin >> v.at(i);
  sort(v.begin(),v.end());
  for(int i=0;i<n-1;i++) v.at(i+1)=(v.at(i)+v.at(i+1))/2;
  cout << v.at(n-1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef pair<pair<int, int>, int > P;

bool cmp (P a, P b )
{
	if (a.first.first != b.first.first )
		return a.first.first < b.first.first;

	if (a.first.second != b.first.second )
		return a.first.second < b.first.second;

	return a.second < b.second;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.B", "r", stdin );
	int n, m;

	while (cin >> n >> m && n && m ){
		vector <int> a (n, 0 );
		int maxa = 0;
		for (int i = 0; i < n; i++){
			cin >> a[i];
//			maxa = max (maxa, a[i] );
		} // end for
//		while (maxa > m ){
//			m *= 10;
//		} // end while
		vector <P> rank (n );
		for (int i = 0; i < n; i++ ){
			rank[i].first.first = m/a[i]*a[i];
			rank[i].first.second = a[i];
			rank[i].second = i+1;
		} // end for
		sort (ALL(rank ), cmp );

		if (rank[0].first.first  == rank[1].first.first 
		 && rank[0].first.second == rank[1].first.second ){
			cout << n << endl;
		}else{
			cout << rank[0].second << endl;
		} // end if
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>

using namespace std;

bool judge(vector<int>& xi, vector<int>& xj) {
  int d = 0;
  for(size_t i=0;i<xi.size();++i) {
    d += (xi[i]-xj[i])*(xi[i]-xj[i]);
  }
  // max of d: 40**2 * 10 = 16000 < 127*127
  for(int x=1;x<127;++x) {
    if (x*x==d) return true;
  }
  return false;
}

int main(int argc, char const *argv[])
{
  int n,d; cin >> n >> d;
  vector<vector<int> > x(n, vector<int>(d,0));
  for(int i=0;i<n;++i) {
    for(int j=0;j<d;++j) {
      cin >> x[i][j];
    }
  }
  int c=0;
  for(int i=0;i<n;++i) {
    for(int j=i+1;j<n;++j) {
      if(judge(x[i], x[j])) ++c;
    }
  }
  cout << c << endl;
  return 0;
}


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

int main() {
  long long A, B, N;

  cin >> A >> B >> N;

  long long x = min(B-1, N);
  long long f = floor(A*x/B)-floor(x/B);

  cout << f << endl;

  return 0;
}


Measured memory_bytes: 3596
<?php

fscanf(STDIN, "%d %d %d %d", $a, $b, $c, $d);

$arr1 = [$a, $b];
$arr2 = [$c, $d];

$result = [];

for($i=0; $i<2; $i++) {
    for($j=0; $j<2; $j++) {
        array_push($result, $arr1[$i]*$arr2[$j]);
    }
}

echo max($result) . PHP_EOL;

Measured memory_bytes: 16200
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstdio>
using namespace std;

#define int long long
#define INF 1e18

signed main() {
    int n; cin >> n;
    int a, b; cin >> a >> b;
    int sum = 0;
    for(int i = 1;  i <= n; i++) {
        string s = to_string(i);
        int tmp = 0;
        for(int i = 0; i < s.size(); i++) {
            tmp += s[i] - '0';
        }
        if(a <= tmp && tmp <= b) {
            sum += i;
        }
    }
    cout << sum << endl;
}


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

int main() {
    int N;
    cin >> N;
    int cnt = 0;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    rep(i, N - 1) {
        if (p[i] != i + 1) {
            cnt += 1;
        }
    }
    cnt <= 2 ? puts("YES") : puts("NO");
    return 0;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll n,k,m;
    cin >> n >> k >> m;
    ll q = n/k;
    if(n%k)q++;
    cout << q * m << nl;    
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 3604
unittest
{
	assert( [ "A B" ].parse.expand.solve == "<" );
	assert( [ "E C" ].parse.expand.solve == ">" );
	assert( [ "F F" ].parse.expand.solve == "=" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto xy = input.front.split.to!( string[] );
	return tuple( xy[ 0 ], xy[ 1 ] );
}

auto solve( string x, string y )
{
	if( x < y ) return "<";
	if( y < x ) return ">";
	return "=";
}


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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt(); int m = sc.nextInt(); int k = sc.nextInt();
        initFac(n * m);
        long choose = nck(n * m - 2, k - 2);
        long first = m * ((long) m * (m - 1)) / 2;
        first %= mod;
        first = (first - (((long)m - 1) * m * (2 * m - 1)) / 6);
        if (first < 0) first += mod;
        first = (first * ((long) n * n)) % mod;
        long second = n * ((long) n * (n - 1)) / 2;
        second %= mod;
        second = (second - (((long)n - 1) * n * (2 * n - 1)) / 6);
        if (second < 0) second += mod;
        second = (second * ((long) m * m)) % mod;
        long res = (choose * ((first + second) % mod)) % mod;
        res %= mod;
        if (res < 0) res += mod;
        out.println(res);
        out.close();
    }

    static long[] fac;
    static long mod = (long) 1e9 + 7;

    static void initFac(long n) {
        fac = new long[(int)n + 1];
        fac[0] = 1;
        for (int i = 1; i <= n; i++) {
            fac[i] = (fac[i - 1]  * i) % mod;
        }
    }
    
    static long nck(int n, int k) {
        if (n < k)
            return 0;
        long den = inv((int) (fac[k] * fac[n - k] % mod));
        return fac[n] * den % mod;
    }

    static long pow(long b, long e) {
        long ans = 1;
        while (e > 0) {
            if (e % 2 == 1)
                ans = ans * b % mod;
            e >>= 1;
            b = b * b % mod;
        }
        return ans;
    }

    static long inv(long x) {
        return pow(x, mod - 2);
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 34416
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)

int main(){
    int x,y;
    
    while(1){
        cin>>x>>y;
        if(x==0&&y==0) break;
        if(x<=y){  
            cout<<x<<" "<<y<<endl;
        }else{
            cout<<y<<" "<<x<<endl;
        }
    }
}


Measured memory_bytes: 2988
x = list(map(int, input().split()))
A = x[0]
B = x[1]
C = x[2]
K = x[3]
ans = 0
if K >= A:
    ans += A * 1
    K += - A
else:
    ans += K * 1
    K += - A
    
if K <= 0:
    print(ans)
    exit()
else:
    if K >= B:
        ans += B * 0
        K += - B
    else:
        ans += K * 0
        K += - B

if K <= 0:
    print(ans)
    exit()
else:
    if K >= C:
        ans += C * -1
        K += K - C
    else:
        ans += K * -1
        K += K - C
    print(ans)

Measured memory_bytes: 9228
n = int(input())
a = list(map(int, input().split()))

count = 0
contin = True
while contin:
    for i in range(len(a)):
        if a[i] % 2 == 0:
            a[i] = a[i] / 2
        else:
            contin=False
            break
    count += 1
print(count - 1)

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    char s[4];
	cin >> s;
    sort(s,s+4);
    if((s[0]==s[1])&&(s[2]==s[3])&&(s[1]!=s[2])){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
	return 0;
}

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

typedef pair<int,int> pii;
typedef vector<int> vec;
typedef unordered_map<int,int> hash;
#define long long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define F first
#define S second
#define pb push_back
// #define mp make_pair
#define fill(a,v) memset(a,v,sizeof(a))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define INF 0x3f3f3f3f//infinity for integers
#define JJ ios_base::sync_with_stdio(0); cin.tie(0)//input fast
#define MOD 1000000007


int main()
{
	JJ;
	long h,w,m; cin>>h>>w>>m;
	long x,y;
	map<long,long>row;
	map<long,long>col;
	map<pair<long,long>,long> mp;
	// memset(arr,0,sizeof(arr));
	FOR(i,0,m){
		cin>>x>>y;
		row[x]++;
		col[y]++;
		mp[{x,y}]=1;
	}
	long mxr=0,mxr_freq=0,mxc=0,mxc_freq=0;
	for(auto i=row.begin();i!=row.end();i++){
		if(i->second>=mxr_freq){
			mxr_freq=i->second;
			mxr=i->first;
		}
	}
	for(auto i=col.begin();i!=col.end();i++){
		if(i->second>=mxc_freq){
			mxc_freq=i->second;
			mxc=i->first;
		}
	}
	// checking all columns in row with max freq
	long col_bombs=0,row_bombs=0;
	// int c=0,r=0;
	FOR(j,1,w+1){
		if(col[j]+mxr_freq-mp[{mxr,j}]>=col_bombs){
			// c=j;
			col_bombs=col[j]+mxr_freq-mp[{mxr,j}];
		}
	}
	// checking all rows in col with max freq
	FOR(i,1,h+1){
		if(row[i]+mxc_freq-mp[{i,mxc}]>=row_bombs){
			// r=i;
			row_bombs=row[i]+mxc_freq-mp[{i,mxc}];
		}
	}
	long ans=max(row_bombs,col_bombs);
	cout<<ans<<endl;
	


	return 0;
}


Measured memory_bytes: 97428
using System;
using System.Numerics;
using System.Text;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        Console.WriteLine(Parse(sc.Next()) * Parse(sc.Next()));
    }

    public BigInteger Parse(string s)
    {
        BigInteger result = 0;
        StringBuilder sb = new StringBuilder();
        int minus = s[0] == '-' ? 1 : 0;

        for (int i = minus; i < s.Length; i++)
        {
            sb.Append(s[i]);
            if ((i + 1) % 18 == minus)
            {
                result *= (long) 1e18;
                result += long.Parse(sb.ToString());
                sb = new StringBuilder();
            }
        }

        result *= (long) Math.Pow(10, sb.Length);
        result += long.Parse(sb.ToString());
        return minus == 1 ? -result : result;
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


Measured memory_bytes: 18196
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

void solve(){
    int N;
    cin >> N;
    vector<ll> cnt(101010);
    ll sum = 0;
    REP(i,N){
        int A;
        cin >> A;
        cnt[A]++;
        sum += A;
    }
    int Q;
    cin >> Q;
    REP(i,Q){
        int B, C;
        cin >> B >> C;
        ll tmp_cnt = cnt[B];
        ll tmp_sum = tmp_cnt * B;
        cnt[B] = 0;
        cnt[C] += tmp_cnt;
        sum -= tmp_sum;
        sum += tmp_cnt * C;
        cout << sum << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 3988
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;



int main() {
	int X;
	cin >> X;
	int Y = X % 500;
	cout << (X / 500) * 1000 + ((X % 500) / 5) * 5;
}

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

const int N = 100000;

bool binary_search(int key, int n, int A[]) {
  int l, r, mid;
  
  l = 0;
  r = n;
  mid = (l + r) / 2;

  while (l < r) {
    if (A[mid] > key) r = mid;
    else if (A[mid] < key) l = mid + 1;
    else return 1;
    mid = (l + r) / 2;
  }
      
  return 0;
}

int main() {
  int i, n, q, t, cnt;
  int A[N];

  cin >> n;
  for (i = 0; i < n; i++) cin >> A[i];
  cin >> q;
  cnt = 0;
  for (i = 0; i < q; i++) {
    cin >> t;
    cnt += binary_search(t, n, A);
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3464
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int a, b, c;
    cin >> a >>  b >> c;
    vector<int> just;
    just.pb(a) ;
    just.pb(b);
    just.pb(c);

    sort(just.begin(), just.end());
    if (just[1] == c) {
        cout << "Yes";

    }

    else {
        cout << "No";
    }

}

Measured memory_bytes: 256
from collections import Counter
from fractions import gcd

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if __name__ == "__main__":
    A, B = list(map(int, input().split()))
    x = gcd(A, B)
    print(len(Counter(prime_factorize(x)).keys())+1)


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

int GCD(int a, int b){

    int mod = a%b;
    if(mod == 0) return b;
    else{
        return GCD(b, mod);
    }
}

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

    if(a < b) swap(a, b);
    cout << GCD(a,b) << endl;

    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
#define PI 3.14159265

// DEBUG TEMPLATE
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
  *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
  
// DEBUG TEMPLATE ENDS

#define MOD 1000000007
int power(int x,int y,int mod = MOD) 
{ 
  int ret = 1;
  x = x % mod;
  while (y){
    if(y&1) ret = (ret*x)%mod;
    y = y>>1;
    x = (x*x)%mod;
    } 
    return ret%mod; 
}


void solve()
{ 
  char x;
  cin>>x;
  if (x>='A' && x<='Z') cout<<'A';
  else cout<<'a';
}


/*
  
*/
signed main(){
  int t = 1;
  // cin>>t;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (int test=1;test<=t;test++){
    // debug() << imie(test);
    solve();
  }
}
// Check MOD values plox :(


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;



int main()
{
    string a,b,c;
    cin >> a >> b >> c;
    cout << (char)('A' + (a[0] - 'a')) << (char)('A' + (b[0] - 'a')) << (char)('A' + (c[0] - 'a')) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T>
T inf = numeric_limits<T>::max();

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

  ll K, N;
  cin >> K >> N;
  vector<ll> A(N+2);
  repr(i, N+1, 1) {
    cin >> A[i];
  }

  A[0] = A[N] - K;
  A[N+1] = A[1] + K;

  ll ans = inf<int>;
  for (int i = 1; i < N+1; ++i) {
    chmin(ans, K - max(abs(A[i] - A[i-1]), abs(A[i+1] - A[i])));
  }

  cout << ans << endl;
}


Measured memory_bytes: 4760
#include <iostream>
#include <fstream>
#include <queue>
using namespace std;
struct node
{
    int no,di;
};
struct cmp
{
    bool operator()(node unu,node doi)
    {
        return unu.di>doi.di;
    }
};
priority_queue<node,vector<node>,cmp> pq;
int d[100005],E[100005];
int k,i,j,dist,nod;
int main()
{
    cin>>k;
    for(i=0;i<k;i++)
        d[i]=(1<<30);
    for(i=1;i<=min(9,k);i++)
        {
            d[(i%k)]=i;
            pq.push({i%k,i});
        }
    while((!pq.empty())&&pq.top().no!=0)
    {
        nod=pq.top().no;dist=pq.top().di;
        pq.pop();
        if(!E[nod])
        {
            E[nod]=1;
            for(i=0;i<10;i++)
              if(dist+i<d[(10*nod+i)%k])
            {
                d[(10*nod+i)%k]=dist+i;
                pq.push({(10*nod+i)%k,dist+i});
            }
        }
    }
    cout<<d[0];
    return 0;
}


Measured memory_bytes: 4212
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 

int main()
{ 
    int h,w;
    cin>>h>>w;
    int c[h][w];
    int a[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            c[i][j]=a[i][j]=0;
        }
    }
    int ans=0;
    for(int i=0;i<h;i++){
        string s;
        cin>>s;
        for(int j=0;j<w;j++){
            if(s[j]=='#'){c[i][j]=1;}
            else{c[i][j]=0;}
        }
    }
    for(int i=0;i<h;i++){
        int cnt=0;
         for(int j=0;j<w;j++){
             if(c[i][j]==1){a[i][j]=cnt;cnt=0;}
             else{cnt++;}
         }
         for(int j=w-1;j>=0;j--){
             if(c[i][j]==1){cnt=a[i][j];a[i][j]=0;}
             else{a[i][j]=cnt;}
         }
    }
    for(int j=0;j<w;j++){
        int cnt=0;
         for(int i=0;i<h;i++){
             if(c[i][j]==1){a[i][j]=cnt;cnt=0;}
             else{cnt++;}
         }
         for(int i=h-1;i>=0;i--){
             if(c[i][j]==1){cnt=a[i][j];a[i][j]=0;}
             else{
                 a[i][j]=cnt+a[i][j]-1;
                 if(a[i][j]>ans){ans=a[i][j];}
             }
         }
    }
    /*for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<a[i][j];
        }
        cout<<endl;
    }*/
    cout<<ans<<endl;
    return 0;
}

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


int getNumber()
{
	int input;
	scanf("%d", &input);
	return input;
}

void getString(char* input)
{
	scanf("%s", input);
}

typedef struct LinkElement
{
	int key;
	struct LinkElement* pre;
	struct LinkElement* next;
} LE, *PLE;

void display(PLE head, PLE tail)
{
	PLE p = head->next;
	while (p->next != tail)
	{
		printf("%d ", p->key);
		p = p->next;
	}
	printf("%d\n", p->key);
}

int main(void)
{
	int n;
	PLE head, tail;
	head = (PLE) malloc(sizeof(LE));
	tail = (PLE) malloc(sizeof(LE));
	head->key = 0;
	head->pre = NULL;
	head->next = tail;
	tail->key = 0;
	tail->pre = head;
	tail->next = NULL;
	char command[20];

	n = getNumber();
	int i, x;
	PLE p;
	for (i = 0; i < n; i++)
	{
		getString(command);
		if (command[0] == 'i')
		{
			// insert n;
			x = getNumber();
			p = (PLE) malloc(sizeof(LE));
			p->key = x;
			p->next = head->next;
			p->pre = head;
			p->next->pre = p;
			head->next = p;
		}
		else if(command[6] == 'F')
		{
			p = head->next;
			p->next->pre = p->pre;
			p->pre->next = p->next;
			free(p);
		}
		else if(command[6] == 'L')
		{
			p = tail->pre;
			p->pre->next = p->next;
			p->next->pre = p->pre;
			free(p);
		}
		else
		{
			x = getNumber();
			for (p = head->next; p->key != x && p != tail; p = p->next);
			if (p != tail)
			{
				p->pre->next = p->next;
				p->next->pre = p->pre;
				free(p);
			}
		}
	}

	display(head, tail);

	return 0;
}


Measured memory_bytes: 33012
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

string dfs(LL N){
    if(!N) return "";
    return (abs(N)%2?dfs((N<0?N/(-2)+1:N/(-2)))+"1":dfs(N/(-2))+"0");
}

int main(){
    LL N;
    cin >> N;
    cout << (N?dfs(N):"0") << endl;
    return 0;
}

Measured memory_bytes: 256