akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	static int cnt=0;
	public static void Merge(int a[],int start,int end){
		if (start>=end) return;
		int center=(start+end)/2;
		Merge(a,start,center);
		Merge(a,center+1,end);
		int n1=center-start+1;
		int n2=end-center;
		int[] L=new int[n1];
		int[] R=new int[n2];
		for (int i=0;i<n1;i++){L[i]=a[start+i];}
		for (int i=0;i<n2;i++){R[i]=a[center+1+i];}
		int i=0; int j=0;
		for (int k=start;k<=end;k++){
			cnt++;
			if (i==n1) a[k]=R[j++];
			else if (j==n2) a[k]=L[i++];
			else if (L[i]<=R[j]) a[k]=L[i++];
			else a[k]=R[j++];
		}
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		StringBuilder output = new StringBuilder();
	    int n = in.nextInt();
	    int[] A = new int[n];
	    for (int i = 0; i<n; i++) {
	      A[i] = in.nextInt();
	    }
		Merge(A,0,n-1);
		for (int i=0;i<n;i++){
			 output.append(A[i]);
		     if (i != n - 1) output.append(" ");
		}
		System.out.println(output.toString());
		System.out.println(cnt);
	}
}

Measured memory_bytes: 178652
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;
int main()
{
	int y, m, d;
    char i, j;
    cin >> y >> i >> m >> j >> d;
    if(m<=4) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

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

L=[[{0}for i in range(0,101)]for q in range(0,101)]
cnt=0

for inp in range(n):
    x,y,h=map(int,input().split())
    if h != 0:
        cnt+=1
        for i in range(0,101):
            for q in range(0,101):
                L[i][q].add(h+abs(x-i)+abs(y-q))
    else:
        L[x][y].add(-1)

if cnt==1:
    for i in range(101):
        for q in range(101):
            if L[i][q]=={0,1}:
                print(str(i)+" "+str(q)+" "+"1")
                break
else:  
    for i in range(101):
        for q in range(101):
            if len(L[i][q])==2 and max(L[i][q])>0:
                print(str(i)+" "+str(q)+" "+str(max(L[i][q])))
                

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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    vector<int>adj[100005];
    vector<int>h(100005);
    vector<int>connect(100005);
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n,m;
        cin>>n>>m;
        for(int i=0;i<n;i++)
            cin>>h[i];
        for(int i=0;i<m;i++){
            int a,b;
            cin>>a>>b;
            a--;
            b--;
            adj[a].push_back(b);
            connect[a]++;
            connect[b]++;
        }
        int total=0;
        vector<int>ans(n);
        for(int i=0;i<n;i++){
            for(int j=0;j<adj[i].size();j++){
                if(h[i]>h[adj[i][j]])
                    ans[i]++;
                else if(h[i]<h[adj[i][j]])
                    ans[adj[i][j]]++;
            }
        }
        for(int i=0;i<n;i++){
            if(ans[i]==connect[i] || (connect[i]==0 && ans[i]==0))
                total++;
        }
        cout<<total;
        return 0;
    }


Measured memory_bytes: 8724
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    long long int now=100;
    long long int X;
    cin>>X;
    for(int i=0;;i++){
        if(now>=X){
            cout<<i<<endl;
            return 0;
        }
        now=now+now/100;
 
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define mp make_pair
int main()
{
	ll n,k;
	fastio;	
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll dp[n]={0};
	for(ll i=n-2;i>=0;i--)
	{
		ll mini=LONG_LONG_MAX;
		for(ll j=i+1;j<n && j<=i+k ;j++)
		{
			mini=min(mini,abs(a[j]-a[i])+dp[j]);		
		}
		dp[i]=mini;
	}
	cout<<dp[0];
}


Measured memory_bytes: 1792
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j,k;
            cin>>n>>k;
            int ar[n+1],ans=0;
            for(i=1;i<=n;++i)
                cin>>ar[i];
            sort(ar+1,ar+n+1);
            for(i=1;i<=k;++i)
                ans=ans+ar[i];
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define s second
#define pb push_back
//#define mp make_pair

int n, a[101010], k, dist[101010], x, y;
vi tree[101010];
vector<pi> adj[101010], v;
bool vis[101010];
priority_queue<pi> q;

void djikstra(int s){

dist[s]=0;

q.push({0, s});

while(!q.empty()){
    int v, u;
    tie(v,u)=q.top();
    q.pop();
    if(vis[u])continue;
    vis[u]=true;

    for(auto t: adj[u]){
        int b, w;
        tie(b,w)=t;

        if(dist[b]>=dist[u]+w){
            dist[b]= dist[u]+w;
            //cout << dist[b] << endl;
            if(a[b])dist[b]=a[b];
            q.push({-dist[b], b});
        }
    }
}

}


int main(){
rep(i, 0, 101010)dist[i]=inf;

cin >> n;
rep(i, 1, n-1){
cin >> x >> y;
v.pb({x,y});
adj[x].pb({y,1});
adj[y].pb({x,1});
tree[x].pb(y);
tree[y].pb(x);
}

cin >> k;
rep(i, 1, k){

cin >> x >> y;
a[x]=y;
dist[x]=y;
adj[0].pb({x, y});

}

djikstra(0);

rep(i, 0, n){
if(!a[i])a[i]=dist[i];
}

for(auto t: v){
    int u, v;
    tie(u, v)=t;
    if(abs(a[u]-a[v])!=1)return 0*printf("No");
}
cout << "Yes"<< endl;
rep(i, 1, n){
cout << a[i] << endl;
}


return 0;}


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	ll n;
	cin >> n;
	ll a = 0; // /4
	ll b = 0; // /2
	ll c = 0; // else
	for (int i = 0; i < n; i++) {
		ll tmp;
		cin >> tmp;
		if (tmp%4==0) {
			a++;
		} else if (tmp%2==0) {
			b++;
		} else {
			c++;
		}
	}
//	cout << a << " " << b << " " << c << "\n";
	bool cc = false;
	bool bb = false;
	bool aa = true;
	for (int i = 0; i < n; i++) {
		if (c>0&&aa==true) {
			aa = false;
			bb = false;
			cc = true;
			c--;
			continue;
		} else if (b>0&&cc!=true) {
			aa = false;
			cc = false;
			bb = true;
			b--;
			continue;
		} else if (a>0){
			aa = true;
			cc = false;
			bb = false;
			a--;
			continue;
		}
//		cout << a << b << c << "\n";
		cout << "No" << "\n";
		return 0;
	}
//	cout << a << b << c << "\n";

	if (a < 0 || b < 0 || c < 0) {
		cout << "No" << "\n";
		return 0;
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>

#define rep(i, s, n) for(int (i) = (s); (i) < (n); ++(i))
#define print(x) cout << (x) << endl 
#define min2(a, b) ((a) < (b)) ? (a) : (b)
#define max2(a, b) ((a) > (b)) ? (a) : (b)

using namespace std;

int main(){
    int K, S, sum = 0;
    cin >> K >> S;
    rep(x, 0, min2(S + 1, K + 1)){
        rep(y, 0, min2(S + 1 - x, K + 1)){
            if(0 <= S - x - y && S - x - y <= K) sum++;
        }
    }
    print(sum);
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

alias Ele = Tuple!(long, "val", int, "idx");

void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(long[]);

    int[][long] asc;
    auto bh = new BinaryHeap!(Array!Ele, "a.val < b.val")();

    auto cp = new int[][](n, 0);

    foreach (i ; 0 .. n) {
        asc[a[i]] ~= i;
        bh.insert(Ele(a[i], i));
    }

    auto used = new bool[](n);
    int ans;

    while (!bh.empty) {

        auto e = bh.front;
        bh.removeFront();

        debug {
            writeln(e);
            writeln(asc);
        }

        if (used[e.idx]) {
            continue;
        }

        int d = bitlen(e.val);
        long msk = (1L<<d) - 1;
        long pr = ((~e.val) & msk) + 1;

        if (!(pr in asc)) {
            continue;
        }

        while (!asc[pr].empty && used[asc[pr].front]) {
            asc[pr].popFront();
        }

        while (!asc[pr].empty && used[asc[pr].back]) {
            asc[pr].popBack();
        }

        if (asc[pr].empty) {
            continue;
        }
        if (asc[pr].front != e.idx) {
            used[e.idx] = true;
            used[asc[pr].front] = true;
            asc[pr].popFront();
            ans++;
            continue;
        }
        if (asc[pr].back != e.idx) {
            used[e.idx] = true;
            used[asc[pr].back] = true;
            asc[pr].popBack();
            ans++;
            continue;
        }

    }

    debug {
        writeln(asc);
    }

    writeln(ans);
}

int bitlen(long x) {
    return x > 0 ? bitlen(x>>1) + 1 : 0;
}

















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 36976
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

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

using namespace std;

int main(){


ll int N;
cin >> N;

vector<ll int> d(N);
rep(i,N){
	cin >> d[i];
}

ll int wa = 0;
rep(i,N){
	for(ll int j=i+1;j<N;j++){
		wa += d[i]*d[j];
	}
}
cout << wa;











	return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 5;
int main() {
	int n, k;
	cin >> n >> k;
	vector <int> h(n);
	vector <int> dp(n, inf);
	for(int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	dp[0] = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j <= i + k && j < n; ++j) {
			dp[j] = min (dp[j], dp[i] + abs (h[i] - h[j]));
		}
	}
	cout << dp[n-1] << endl;
}



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

int main() {
	string a, b;
	int i=0,n,flag=1;
	cin >> a >> b;
	n = a.size();
	for (i = 0; i < n; i++) {
		if (a[i] != b[n - 1 - i]) {
		flag = 0;
		break;
		}
	}
	if (flag)cout << "YES";
	else cout << "NO";
	cout << endl;
	return 0;
}

			

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

int main()
{
  int W, H;
  while (cin >> H >> W) {
    if ((W | H) == 0)
      break;

    vector<string> tile(H);
    for (int i = 0; i < H; ++i)
      cin >> tile[i];

    int x = 0, y = 0;
    bool loop = false;
    vector<vector<int> > visited(H, vector<int>(W, 0));
    while (tile[y][x] != '.') {
      if (visited[y][x]) {
	loop = true;
	break;
      }

      visited[y][x] = 1;
      if (tile[y][x] == '>')
	++x;
      else if (tile[y][x] == '<')
	--x;
      else if (tile[y][x] == 'v')
	++y;
      else if (tile[y][x] == '^')
	--y;
    }

    if (loop)
      cout << "LOOP" << endl;
    else
      cout << x << " " << y << endl;
  }
  return 0;
}

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

#define int long long 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define N 100005
int dp[N];
int h[N];
int n,k;

int solve(){
    for(int i=1;i<=n;i++) dp[i]=LONG_MAX;
    dp[1]=0;
    //dp[2]=abs(h[1]-h[2]);
    for(int i=2;i<=n;i++){
        for(int j=i-1;j>=1 &&(i-j)<=k ;j--){
            //if(j<=i){
                dp[i]=min(dp[i],abs(h[i]-h[j])+dp[j]);
            //}
        }
    }
    return dp[n];

}
int32_t main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>h[i];
    cout<<solve();


}

Measured memory_bytes: 1792
N, K, Q = map(int, input().split())

scores = [0] * N
for _ in range(Q):
    answerer = int(input())
    answerer -= 1
    scores[answerer] += 1

ans = ["Yes" if K - (Q - scores[i]) > 0 else "No" for i in range(N)]
for val in ans:
    print(val)

Measured memory_bytes: 5460
n = int(input())
a = list(map(int,input().split()))
l=[]
j=0
ans = sum(a)
for i in range(n):
    if a[i] <0:
        a[i] *=-1
        j +=1
b = sum(a)
if j%2 == 0:
    print(b)
else:
    for i in range(n):
        ans=max(ans,b-2*a[i])
    print(ans)

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

// TIPS: ceilを使うときはdouble
int main() {
    ll n;
    cin >> n;
    ll a=1, b=1;
    for(ll i=0; i<n; i++){
        int tt, aa;
        cin >> tt >> aa;
        ll tmp = max((a+tt-1)/tt, (b+aa-1)/aa);
        a = tt*tmp;
        b = aa*tmp;
    }

    cout << a+b << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    int ans = 0;
    if(n % 2 == 1) {
        int ami = a[(n - 1) / 2];
        int bmi = b[(n - 1) / 2];
        ans = (bmi - ami + 1);
    } else {
        int ami = (a[(n - 1) / 2] + a[n / 2]);
        int bmi = (b[(n - 1) / 2] + b[n / 2]);
        ans = bmi - ami + 1;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

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

using ll = long long;
using P = pair<int,int>;

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

ll digit(ll n) {
    ll res = 0;
    while(n != 0) {
        res += n % 10;
        n /= 10;
    }
    return res;
}

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

    int ans = INF;
    for (int i = 1; i <= n / 2; ++i) {
        int cnt = digit(i) + digit(n - i);
        ans = min(ans, cnt);
    }

    cout << ans << "\n";

    return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second


int main(){
    ll n;
    cin >> n;
    P pos[n];
    rep(i,0,n) cin >> pos[i].fs >> pos[i].sc;
    
    map<P,ll> m;
    ll cnt = 0;
    rep(i,0,n){
        rep(j,0,n){
            if(i == j) continue;
            ll dx = pos[i].fs - pos[j].fs;
            ll dy = pos[i].sc - pos[j].sc;
            if(m.count(P(dx,dy)) == 0){
                m[P(dx,dy)] = 1;
                cnt = max(1LL,cnt);
            }
            else{
                m[P(dx,dy)]++;
                cnt = max(m[P(dx,dy)],cnt);
            }
        }
    }

    cout << n - cnt << endl;

    return 0;
}


Measured memory_bytes: 3760
#include <iostream>

using namespace std;
int main()
{
    int K, S;
    cin >> K >> S;

    int cnt = 0;
    for (int i = 0; i <= K; i++)
    {
        for (int j = 0; j <= K; j++)
        {
            if(S-(i+j)<=K && S-(i+j) >= 0){
                cnt++;
            }
        }
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int n,m;
struct graph{
    int f = 0;
    int x;
    vector <int> e;
    vector <int> w;
};
vector <struct graph> g;
int l,r,d;

bool dfs(int i){
    int j;
    int s = g[i].e.size();
        for(int k=0;k<s;k++){
            j = g[i].e[k];
            if(g[j].f == 1){
                if(g[j].x - g[i].x == g[i].w[k]){
                    continue;
                }else{
                    return false;
                }
            }

            if(g[j].f == 0){
                g[j].x = g[i].x + g[i].w[k];
                g[j].f = 1;
                if(!dfs(j)) return false;
            }                
        }
    return true;
}

int main(void){
    cin >> n >> m;
    g.resize(n+1);

    for(int i=1;i<=m;i++){
            cin >> l >> r >> d;
            g[l].e.push_back(r);
            g[l].w.push_back(d);
            g[r].e.push_back(l);
            g[r].w.push_back(-d);
    }

    for(int i=1;i<=n;i++){
        if(g[i].f == 0){g[i].x = 0; g[i].f = 1;}
        if(!dfs(i)){cout << "No"; return 0;}
    }

    cout << "Yes";
    return 0;
}

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

div_AandB = list(set(make_divisors(A))&set(make_divisors(B)))

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

all_set = set()
for div in div_AandB:
    all_set_next = all_set | set(prime_factorize(div))
    all_set = all_set_next
print(len(list(all_set))+1)


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
typedef pair<ll, ll> P;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e14;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}


int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a >= k) {
        cout << k << endl;
        ret();
    }
    if (a + b >= k) {
        cout << a << endl;
        ret();
    }
    k -= a;
    k -= b;
    cout << a - k << endl;
}





Measured memory_bytes: 3624
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

void Main() {
  int n, k;
  cin >> n >> k;
  int ans = 1;
  n /= k;
  while (n) {
    ans++;
    n /= k;
  }
  cout << ans << endl;
}

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


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

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

// [ _UnionFind ]
// Union-Find木 /* union by size */
// 宣言は UnionFind uf(N); のようにする
// find(x) : xの根を求める
// same(x, y) : xとyが同じ集合に属するかどうか
// size(x) : xの属する集合の要素数
// size() : 集合がいくつあるか
// unite(x, y) : xとyの属する集合を併合する
struct UnionFind {
private:
	vector<int> uf;
	size_t sz;

public:
	UnionFind(size_t Size) {
		uf.assign(Size, -1);
		sz = Size;
	}

	int find(int x) { return (uf[x] < 0) ? x : uf[x] = find(uf[x]); }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -uf[find(x)]; }
	int size() { return sz; }

	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) { return; }
		--sz;

		if (uf[y] < uf[x]) { swap(x, y); }
		uf[x] += uf[y];
		uf[y] = x;
	}
};

int main() {
	const int sz = 1e5;
	int N;
	cin >> N;
	vector<int> x(N), y(N);
	vector<vector<int>> vx(sz), vy(sz);
	map<P, int> mp;
	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i];
		--x[i];
		--y[i];
		vx[x[i]].push_back(y[i]);
		vy[y[i]].push_back(x[i]);
		mp[P(x[i], y[i])] = i;
	}

	UnionFind uf(N);
	for (int i = 0; i < sz; ++i) {
		if (vx[i].size() < 2) { continue; }
		int idx = mp[P(i, vx[i][0])];
		for (int j = 1; j < vx[i].size(); ++j) {
			uf.unite(idx, mp[P(i, vx[i][j])]);
		}
	}
	for (int i = 0; i < sz; ++i) {
		if (vy[i].size() < 2) { continue; }
		int idx = mp[P(vy[i][0], i)];
		for (int j = 1; j < vy[i].size(); ++j) {
			uf.unite(idx, mp[P(vy[i][j], i)]);
		}
	}

	map<int, vector<P>> mp2;
	for (int i = 0; i < N; ++i) {
		P p = P(x[i], y[i]);
		mp2[uf.find(mp[p])].push_back(p);
	}

	ll sum = 0;
	for (auto it = mp2.begin(); it != mp2.end(); ++it) {
		set<int> X, Y;
		for (auto p : it->second) {
			X.insert(p.first);
			Y.insert(p.second);
		}
		sum += ((ll)X.size() * (ll)Y.size());
	}
	cout << sum - N << endl;

	return 0;
}


Measured memory_bytes: 20984
#include<stdio.h>

int main(){
    int n, q;
    long int sum=0, count[100001]={0}, p;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%ld", &p);
        count[p]++;
        sum = sum + p;
    }
    scanf("%d", &q);
    int b[100001], c[100001];
    for(int i=0; i<q; i++){
        scanf("%d%d", &b[i], &c[i]);
        sum = sum + (c[i]-b[i])*count[b[i]];
        printf("%ld\n", sum);
        count[c[i]] = count[c[i]] + count[b[i]];
        count[b[i]] = 0;
    }
}





Measured memory_bytes: 3284
##Just for prctice
ans1=1000
ans2=1000
for i in range(2):
    ans1=min(ans1, int(input()))
for i in range(2):
    ans2=min(ans2, int(input()))

print(ans1+ans2)


"""
600
300
220
420

520


555
555
400
200

755

549
817
715
603

1152
"""




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

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

int main() {
  int n, t;
  cin >> n >> t;
  vector<int> a(t+1);

  rep(i,n) {
    int l, r;
    cin >> l >> r;
    a[l]++; a[r]--;
  }
  rep(i,t) a[i+1] += a[i];
  int ans = 0;
  rep(i,t+1) ans = max(ans, a[i]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3120
"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	lines = lines.map(function(str){return str.split(" ").map(Number);});
	var nml = lines[0];
	var a = lines.slice(1, 1+nml[0]);
	var b = lines.slice(1+nml[0]);
	var c = [];
	for(var i=0;i<nml[0];i++){
		c.push([]);
		for(var j=0;j<nml[2];j++){
			var d = 0;
			for(var k=0;k<nml[1];k++) d += a[i][k] * b[k][j];
			c[i].push(d);
		}
	}
	console.log(c.map(function(r){return r.join(" ");}).join("\n"));
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= i+1;
	}
	SORT(a);
	LL b = a[n/2];
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		ans += abs(a[i] - b);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d; 
    cin>>a>>b>>c>>d;
	ll x=c-a;
	ll y=d-b;
	cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return sums.back();
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void build() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};


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

    CumulativeSum cs(n);
    rep(i, n) cs.set(i, as[i]);
    cs.build();

    map<ll, ll> mp;
    rep(i, n) mp[cs.getSum(i)]++;

    ll ans = 0;
    rep(i, n) {
        ll target = as[i];
        ll now = mp[cs.getSum(i) - target];
        ans += now;

        mp[cs.getSum(i)]--;

    }
    cout << ans << endl;

}


Measured memory_bytes: 20296
S = input()
T = input()

ls = len(S)
lt = len(T)
ret = 'UNRESTORABLE'
for i in range(ls-lt+1):
    judge = True
    for t in range(lt):
        if S[i+t] != T[t] and S[i+t] != "?":
            judge = False
            break
    if judge:
        ret = S[:i] + T + S[i+lt:]
ret = ret.replace("?", "a")
print(ret)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <string>
#include <time.h>


using namespace std;

int main(void) {


	int a = 0, b = 0;
	int s=0;
	cin >> a >> b;

	s = a;
	if (a > b) s--;

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int h1, h2, m1, m2, k;
int main() {
	scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
	m1 += h1 * 60;
	m2 += h2 * 60;
	printf("%d\n", m2 - m1 - k);
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

ll f(ll w, ll h){
  if(h==0) return -w;
  return f(h,w%h) + 2*(w/h)*h;
}

int main(){
  ll n, x;
  cin >> n >> x;

  cout << n + f(x,n-x) << endl;
}


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

a=1
min = 10**10
while a*a <= N:
    if N % a == 0:
        b = N//a
        if max(len(str(a)),len(str(b))) < min:
            min = max(len(str(a)), len(str(b)))
    a += 1
print(min)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const static int INF = 1 << 30;

struct edge {
  int to, cost;
};
vector< edge > Graph[1000];
int N, C[1000];


int rec(int idx, int prev) {
  if(C[idx] > 0) return(INF);
  int ret = 0;
  for(int i = 0; i < Graph[idx].size(); i++) {
    edge& e = Graph[idx][i];
    if(e.to == prev) continue;
    ret += min(rec(e.to, idx), e.cost);
  }
  return(ret);
}


int main()
{
  cin >> N;
  for(int i = 1; i < N; i++) {
    cin >> C[i];
  }
  for(int i = 0; i < N - 1; i++) {
    int u, v, p;
    cin >> u >> v >> p;
    Graph[u].push_back((edge){v, p});
    Graph[v].push_back((edge){u, p});
  }
  cout << rec(0, -1) << endl;
}

Measured memory_bytes: 1276
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int H, W,i,j,cnt=0;
	char map[50][51];
	cin >> H>>W;
	for (i = 0; i < H; i++)
	{
		for (j = 0; j < W; j++)
		{
			cin >> map[i][j];
		}
	}
	for (i = 0; i < H; i++)
	{
		for (j = 0; j < W; j++)
		{
			if (map[i][j] == '#' && map[i - 1][j] != '#' && map[i][j - 1] != '#' && map[i + 1][j] != '#' && map[i][j + 1] != '#')cnt++;
		}
	}
	if (cnt == 0)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;
const double EPS=1e-8;

int main(){
	string s;
	cin>>s;
	ll cnt_alphabet[26];
	for(ll i1=0;i1<26;i1++){
		cnt_alphabet[i1]=0;
	}
	for(ll i1=0;i1<4;i1++){
		cnt_alphabet[s[i1]-'A']++;
	}
	bool ans=true;
	for(ll i1=0;i1<26;i1++){
		if(!(cnt_alphabet[i1]==0 || cnt_alphabet[i1]==2)){
			ans=false;
		}
	}
	if(ans){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int count =0;
        for (int i = 1; i <=N ; i++) {
            if(String.valueOf(i).length()%2==1){
                count++;
            }
        }
        System.out.println(count);
    }
}


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

int main(){
    int n,m;
    while(cin >> n >> m &&n!=0){
        vector<int> a(n);
        vector<int> b(n);
        rep(i,m){
            int s;
            cin >> s;
            int k;
            cin >> k;
            rep(j,k){
                int c;
                cin >> c;
                c--;
                if(k==1){
                    b[c] += s;
                }else{
                    a[c] += s;
                }
            }
        }
        vector<pair<int,int> > A,B;
        rep(i,n){
            A.push_back(make_pair(a[i]+b[i],i));
            B.push_back(make_pair(b[i],i));
        }
        sort(B.begin(),B.end());
        sort(A.rbegin(),A.rend());
        int res = 0;
        rep(i,2){
            rep(j,2){
                if(A[i].second!=B[j].second){
                    res = max(res,A[i].first-B[j].first);
                }
            }
        }
        cout << res+1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3320
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    for(;;)
    {
        cin>>a>>b;
        if(a==0&&b==0)
            break;
        if(a>b)
            swap(a,b);
        printf("%d %d\n",a,b);
    }
    return 0;
}


Measured memory_bytes: 3144
def sky(a, b):
    if a > b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a

n = int(input())
if n == 2:
    a, b = sorted(list(map(int, input().split())))
    s = sky(a, b)

else:
    a, b, c = sorted(list(map(int, input().split())))
    s = sky(a, b)
    s = sky(s, c)

i = 1
table = []
while i * i <= s:
    if s%i == 0:
        table.append(i)
        table.append(s//i)
    i += 1
table = sorted(list(set(table)))
for k in table:
    print(k)


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

int main() {
  string S,T;
  cin >> S >> T;
  
  
  if(S.size() != T.size()-1){
    cout << "No" << endl;
  }
  
  
  else if(S.size() == T.size()-1){
    
    int count = 0;
    for(int i = 0 ; i<S.size() ; i++){
      if(S.at(i) == T.at(i)){
        count++;  
      }
    }
    
    if(count == S.size()){
      cout << "Yes" << endl;
    }
    else if(count != S.size()){
      cout << "No" << endl;
    }
    
  }
      
  
}

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

int main(){
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    int same = 0;
    for (int i = 1; i <= N; i++) {
        bool check = true;
        for (int j = 0; j < i; j++) {
            if (s[N-i+j] != t[j]) check = false;
        }
        if (check) same = i;
    }
    cout << 2*N-same << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    string s;
    cin >> s;

    bool ok = (s[2] == s[3] && s[4] == s[5]);
    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
  int v;
  int n;
}cand;

int c_cand(const void *a,const void *b){
  return (*(cand *)b).n-(*(cand *)a).n;
}
int main(){
  int i,j,k,n,m;
  cand c[100];
  do{
    scanf("%d %d",&n,&m);
    if(!n&&!m) break;
    for(i=0;i<m;i++){
      c[i].v=i+1;
      c[i].n=0;
    }
    for(i=0;i<n;i++){
      for(j=0;j<m-1;j++){
	scanf("%d ",&k);
	c[j].n+=k;
      }
      scanf("%d",&k);
      c[j].n+=k;
    }
    qsort(c,m,sizeof(cand),c_cand);
    for(i=0;i<m-1;i++) printf("%d ",c[i].v);
    printf("%d\n",c[i].v);
  }while(1);
  return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))
MOD = 10**9+7

def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n,k,p=MOD):
    ans = 1
    k = min(k,n-k)
    for i in range(k):
        ans = ans * (n-i) * inv[i+1] % p
    return ans

N, K = inpl()
inv = [0]*(N+1)
for n in range(1,N+1):
    inv[n] = inv_mod(n)

for i in range(1,min(K+1,N-K+2)):
    print((comb_mod(K-1,i-1)*comb_mod(N-K+1,i)) % MOD)
for i in range(N-K+2,K+1):
    print(0)

Measured memory_bytes: 48856
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;

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

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



int main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll E = lcm(C,D);
	//cout << E << endl;
    ll ans = (B - A + 1) - ((B/C + B/D) - ((A-1)/C + (A-1)/D - (A-1)/E)) + B/E;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main() {
  int a, b;

  scanf("%d %d", &a, &b);

  if (a==1) {
    a = 14;
  }
  if(b == 1){
    b = 14;
  }
  if(a>b){
    printf("Alice");
  } else if(a == b){
    printf("Draw");
  }
  else {
    printf("Bob");
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,x,t;
  cin >> n >> x >> t;
  
  int tak = 0;
  
  for(int i=1;i<=1000000;i++){
    tak = x*i;
    if(tak>=n){
      cout << t*i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3656
// Created by  Ambesh kumar
#include "bits/stdc++.h"

//I already compile this file in my computer system to save the time
//if get the compiler error then you should change this header to
// #include "bits/stdc++.h"  ---> #include <bits/stdc++.h>

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0, lim - 1);
	return uid(rang);
}
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=================================================================================================================================//

vi g[N];
int a[N];

void solve() {
	int i, j, n, m;

	cin >> n;

	// ll arr[n];

	// fo(i, n)
	// cin >> arr[i];

	if (n == 0)
		cout << "1" << '\n' ;
	else if (n == 1)
		cout << "0" << '\n' ;





}







int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());

	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}







Measured memory_bytes: 10648
#include <iostream>
#include <string>
#include <numeric>
#include <algorithm>

#include <cctype>

using namespace std;
using ulli = unsigned long long int;
using uchar = unsigned char;

int main(void){
	string s;
	cin >> s;
	
	cout << *(s.begin()) << (s.size() - 2) << *(s.end() - 1) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
char s[110][110];
long long p[110][2];
long long ans[5],sum=9223372036854775800,n,k;
void check()
{
	long long temp=0,nx=p[ans[1]][0],mx=p[ans[1]][0];
	long long ny=p[ans[1]][1],my=p[ans[1]][1];
	for (int i=1;i<=min(4ll,k);i++)
	{
		nx=max(nx,p[ans[i]][0]);
		ny=max(ny,p[ans[i]][1]);
		mx=min(mx,p[ans[i]][0]);
		my=min(my,p[ans[i]][1]);
	}
	for (int i=1;i<=n;i++)
		if (p[i][0]<=nx && p[i][0]>=mx && p[i][1]<=ny && p[i][1]>=my)
			temp++;
	if (temp>=k)
	{
		sum=min(sum,(nx-mx)*(ny-my));
	}
}
void dfs(int now)
{
	if (now==min(4ll,k))
		check();
	else
	{
		for (int i=1;i<=n;i++)
		{
			int flag=1;
			for (int j=1;j<=now;j++)
				if (ans[j]==i)
				{
					flag=0;
					break;
				}
			if (flag)
			{
				ans[now+1]=i;
				dfs(now+1);
			}
		}
	}
}
main()
{
	scanf("%lld%lld",&n,&k);
	if (k==1)
	{
		puts("0");
		return 0;
	}
	for (int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&p[i][0],&p[i][1]);
	}
	dfs(0);
	printf("%lld\n",sum);
}

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

#define si(v) v.size()
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (n); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b; cin >> a >> b;
  cout << (a + b) % 24 << endl;
  
  return (0);
}

Measured memory_bytes: 3632
using System;

class Program
{
    static void Main()
    {
        var a = Console.ReadLine().Split(' ');
        var person = new int[int.Parse(a[0])];
        var ret = new string[int.Parse(a[0])];

        for (var i = 0; i < int.Parse(a[2]); i++)
        {
            person[int.Parse(Console.ReadLine()) - 1] ++;
        }

        for (var i = 0; i < int.Parse(a[0]); i++)
        {
            if ((int.Parse(a[1]) + person[i] - int.Parse(a[2])) > 0)
            {
                ret[i] = "Yes";
            }
            else
            {
                ret[i] = "No";
            }

        }
        foreach (var item in ret)
        {
            Console.WriteLine(item);
        }
    }
}


Measured memory_bytes: 18524
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

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

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

int main()
{
    ll A, B;
    cin >> A >> B;

    cout << lcm(A, B) << endl;
    return 0;
}

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def sosu(x):
    arr = factorization(x)
    if len(arr) == 1 and arr[0][0] == x:
        return True
    else:
        return False

def solve(X: int):
    ans = 100003
    for i in range(X, 10**5 + 1):
        #if i % 2 == 0 and X != 2:
        #    continue
        if sosu(i):
            ans = i
            break

    print(ans)

# Generated by 1.1.6 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
    solve(X)

if __name__ == '__main__':
    main()


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


bool ok[2] = {false};

int main() {
    string s;
    cin >> s;
    li xx = atoi(s.substr(0, 2).c_str());
    li yy = atoi(s.substr(2, 2).c_str());
    ok[0] = (xx <= 12 && xx > 0);
    ok[1] = (yy <= 12 && yy > 0);

    if (!ok[0]) {
        if (!ok[1]) {
            puts("NA");
        } else {
            puts("YYMM");
        }
    } else if (!ok[1]) {
        puts("MMYY");
    } else {
        puts("AMBIGUOUS");
    }

    return 0;
}

Measured memory_bytes: 256