akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;
int x[20][20],y[20][20],a[20],check[20];
int main(){
    int n,ans = 0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        rep(j,a[i]){
            cin>>x[i][j]>>y[i][j];
        }
    }
    rep(i,pow(2,n)){
        rep(j,n)check[j] = -1;
        int cnt = 0;
        bool flag = true;
        rep(j,n){
            if(i & (1 << j))check[j] = 1;
            else check[j] = 0;
        }
        rep(j,n){
            if(i & (1 << j)){
                rep(k,a[j]){
                    if(check[x[j][k]-1] == -1){
                        check[x[j][k]-1] = y[j][k];
                    }
                    else{
                        if(check[x[j][k]-1] != y[j][k]){
                            flag = false;
                            break;
                        }
                    }
                }
                if(!flag)break;
            }
        }
        rep(j,n)if(check[j] == 1)cnt++;
        if(flag)ans = max(ans,cnt);
    }
    cout<<ans<<endl;

    
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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



int main(void) {
	
	while (1) {
		int a, l;
		bool flag = true;
		
		int dp[21] = {};

		cin >> a >> l;
		if (l == 0) {
			break;
		}
		dp[0] = a;
		FOR(i, 1, 20) {
			int now = 0;
			int large = 0, small = 0;
			int tmp;
			int count[10] = {};
			int point[10] = {};
			tmp = dp[i - 1];
			while (tmp != 0) {
				count[tmp % 10]++;
				point[tmp % 10]++;
				tmp /= 10;
				now++;
			}
			count[0] += l - now;
			point[0] += l - now;
			FOR(t, 0, 9) {
				while (count[t] != 0) {
					small *= 10;
					small += t;
					count[t]--;
				}
			}
			RFOR(t, 9, 0) {
				while (point[t] != 0) {
					large *= 10;
					large += t;
					point[t]--;
				}
			}
			dp[i] = large - small;
		}
		FOR(i, 1, 20) {
			FOR(t, 0, i - 1) {
				if (dp[i] == dp[t]) {
					cout << t << " " << dp[i] << " " << i-t << endl;
					flag = false;
					break;
				}
			}
			if (!flag) {
				break;
			}
		}
	}
	
}


Measured memory_bytes: 3008
import java.util.Arrays;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] d = new int[n];
    for (int i = 0; i < n; i++) {
      d[i] = sc.nextInt();
    }
    sc.close();

    if (n % 2 == 1) {
      System.out.println(0);
    } else {
      Arrays.sort(d);
      int min = d[d.length / 2 - 1];
      int max = d[d.length / 2];
      System.out.println(max - min);
    }
  }
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

    vector<vector<int>> vc(n, vector<int> (d));
    REP(i, n) {
        REP(j, d) {
            cin >> vc[i][j];
        }
    }

    int cnt = 0;

    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {
            int sum = 0;
            REP(s, d) {
                sum += (vc[i][s] - vc[j][s]) * (vc[i][s] - vc[j][s]);
            }
            REP(t, 40*40*d) {
                if (sum == t*t)
                    cnt++;
            }
        }
    }

    cout << cnt << endl;
}


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

int main() {
  double D, T, S;
  cin >> D >> T >> S;
  double result = D / S;
  if (result > T) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


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

using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;


int32_t main() {
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    
    double n;
    in(n);
    n*=2;
    n*=3.14159265358979323846;
    printf("%.14f", n);
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;

ll N;
ll A[3],B[3];

int main(){
    cin >> N;
    for(int i=0;i<3;i++) cin >> A[i];
    for(int i=0;i<3;i++) cin >> B[i];
    if(A[0]<=B[0] && A[1]<=B[1] && A[2]<=B[2]){
        ll ans = 0;
        for(ll i=0;i<=N;i++){
            if(i%A[0]!=0) continue;
            for(ll j=0;i+j<=N;j++){
                if(j%A[1]!=0) continue;
                ll now = i/A[0]*B[0]+j/A[1]*B[1];
                ll h = N-i-j;
                now += h/A[2]*B[2]+h%A[2];
                ans = max(ans,now);
            }
        }
        cout << ans << endl;
        return 0;
    }
    if(A[0]>=B[0] && A[1]>=B[1] && A[2]>=B[2]){
        ll ans = 0;
        for(ll i=0;i<=N;i++){
            if(i%B[0]!=0) continue;
            for(ll j=0;i+j<=N;j++){
                if(j%B[1]!=0) continue;
                ll now = i/B[0]*A[0]+j/B[1]*A[1];
                ll h = N-i-j;
                now += h/B[2]*A[2]+h%B[2];
                ans = max(ans,now);
            }
        }
        cout << ans << endl;
        return 0;
    }
    vector<int> v[2];
    for(int i=0;i<3;i++){
        if(A[i]<=B[i]) v[0].push_back(i);
        else v[1].push_back(i);
    }
    if(v[0].size()==2){
        ll ans = 0;
        int id1 = v[0][0],id2 = v[0][1];
        for(ll i=0;i<=N;i++){
            if(i%A[id1]!=0) continue;
            for(ll j=0;i+j<=N;j++){
                if(j%A[id2]!=0) continue;
                ll have = i/A[id1]*B[id1]+j/A[id2]*B[id2]+N-(i+j);//Bにいるときのどんぐりの数
                ans = max(ans,have/B[v[1][0]]*A[v[1][0]]+have%B[v[1][0]]);
            }
        }
        cout << ans << endl;
        return 0;
    }else{
        ll ans = 0;
        ll have = N/A[v[0][0]]*B[v[0][0]]+N%A[v[0][0]];
        int id1 = v[1][0],id2 = v[1][1];
        for(ll i=0;i<=have;i++){
            if(i%B[id1]!=0) continue;
            ll now = i/B[id1]*A[id1];
            ll h = have-i;
            now += h/B[id2]*A[id2]+h%B[id2];
            ans = max(ans,now);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 384
#include <cstdio>
#include <deque>
struct dot{
    int x,y,step;
};
std::deque<dot> q;//开双端队列
int h,w,ch,cw,dh,dw;
char s[1003][1003];
bool vis[1003][1003];
const int dx[]={-1,0,1,0},dy[]={0,1,0,-1};//方向数组
int main(){
    scanf("%d%d%d%d%d%d",&h,&w,&ch,&cw,&dh,&dw);
    for(int i=1;i<=h;i++) scanf("%s",s[i]+1);
    //采取上面的方式读入可以防止不必要的字符被读入
    q.push_back((dot){ch,cw,0});//第一次前面后面入队都行
    while(!q.empty()){
        dot t=q.front();q.pop_front();
        if(t.x==dh&&t.y==dw){
            printf("%d\n",t.step);
            return 0;
        }
        vis[t.x][t.y]=1;
        //使用A方式移动：
        for(int i=0;i<4;i++){
            int tx=t.x+dx[i],ty=t.y+dy[i];
            if(tx>=1&&tx<=h&&ty>=1&&ty<=w&&!vis[tx][ty]&&s[tx][ty]=='.')
                q.push_front((dot){tx,ty,t.step});//插入队列前面
        }
        //使用魔法移动：
        for(int tx=t.x-2;tx<=t.x+2;tx++)
            for(int ty=t.y-2;ty<=t.y+2;ty++)
                if(tx>=1&&tx<=h&&ty>=1&&ty<=w&&!vis[tx][ty]&&s[tx][ty]=='.'){
                    if(t.x==tx&&t.y==ty) continue;
                    q.push_back((dot){tx,ty,t.step+1});//插入队列后面
                }
    }
    puts("-1");
    return 0;
}


Measured memory_bytes: 11972
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
#define mod 1000000007
#define inf 2147483647
int main(){
	int n,m;
	cin>>n>>m;
	vector<int> ver[n+1];//隣接リスト
	int visit[n+1];
	rep(i,n+1)visit[i]=0;
	visit[1]=1;
	int front[n+1];
	init(front,n+1);
	int a,b;
	rep(i,m){
		cin>>a>>b;
		ver[a].push_back(b);
		ver[b].push_back(a);
	}
	int visit_num=1,obj;
	queue<int> q;
	q.push(1);
	while(q.size()){
		obj=q.front();
		q.pop();
		for(int& i:ver[obj]){
			if(!visit[i]){
				q.push(i);
				front[i]=obj;
				visit[i]=1;
				visit_num++;
			}
		}
	}
	if(visit_num!=n){
		cout<<"No";
		return 0;
	}
	cout <<"Yes"<<"\n";
	rep(i,n-1)cout<<front[i+2]<<"\n";
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  int k = 0;
  for (int i = 0; i < 4; i++) {
    if (S.at(i) == '+') {
      k++;
    }
    else {
      k--;
    }
  }
  cout << k << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void)
{
    int h, w, i, j;

    scanf("%d %d", &h, &w);

    while ((h!=0) || (w!=0)) {
        for (i=0; i<h; i++) {
            for (j=0; j<w; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
        scanf("%d %d", &h, &w);
    }

    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];

    ll cnt = 0;
    rep(i, N - 1){
        rep(j, N - 1){
            if(A[j]>A[j + 1]){
                swap(A[j], A[j + 1]);
                cnt++;
            }
        }
    }

    rep(i, N) cout << A[i] << (i == N - 1 ? '\n' : ' ');
    cout << cnt << endl;
}


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

long long MOD = 1000000000 + 7;

long long fctm(long long x) {
  long long result = 1;
  for (long long i = 1; i <= x; i++) {
    result = result * i % MOD;
  }
  return result;
}

long long powm(long long x, long long p) {
  if (p == 0) return 1;
  long long tmp = x * x % MOD;
  if (p % 2 == 0) {
    return powm(tmp, p/2);
  } else {
    return x * powm(tmp, (p-1)/2) % MOD;
  }
}

long long finvm(long long x) {
  long long result = 1;
  for (long long i = 1; i <= x; i++) {
    result = result * powm(i, MOD-2) % MOD;
  }
  return result;
}

int main() {
  long long X, Y;
  cin >> X >> Y;
  if ((2*Y-X) % 3 != 0 || (2*X-Y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  long long p = (2*Y-X)/3, q = (2*X-Y)/3;
  if (p < 0 || q < 0) {
    cout << 0 << endl;
    return 0;
  }
  long long res = (fctm(p+q)*finvm(p) % MOD) * finvm(q) % MOD;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    red = []
    for _ in range(N):
        a, b = map(int, input().split())
        red.append((a, b))
    red_fin = set()
    blue = []
    for _ in range(N):
        c, d = map(int, input().split())
        blue.append((c, d))
    blue.sort()

    """
    解説pdfの通り、x方向に見た上で青い点に対応する赤い点の最適な物を貪欲に選べば良い。
    これが最適であることの証明は、非最適なペアリングを上述のペアリングに「「１組」」繋ぎ直しても
    ペアの個数が減らないことを見れば良い。
    （x+yが小さい順に見ればいけるかなと想定したのが外れルート。。。）
    """

    ans = 0
    for c, d in blue:
        cand = (-1, -1)
        for a, b in red:
            if a < c and b < d and cand[1] < b and (a, b) not in red_fin:
                cand = (a, b)
        if cand == (-1, -1): continue
        ans += 1
        red_fin.add(cand)
    print(ans)





if __name__ == "__main__":
    main()


Measured memory_bytes: 67980
#include <iostream>
#include<string>
#include<list>
#include<algorithm>
#include<cstdio>
using namespace std;


int main(){
    
    int n,t;
    cin>>n;
    list<int> V;
    string com;
    for(int i=0;i<n;i++){
        
        cin>>com;
        
        if(com[0]=='i'){
            cin>>t;
            V.push_front(t);
            
        }else if(com[6]=='F'){
                V.pop_front();
                //deleteLast
        }else if(com[6]=='L'){
                V.pop_back();
        }else if(com[0]=='d'){
                cin>>t;
                for(list<int>::iterator it = V.begin();it!=V.end();it++){
                    if(*it==t){
                        V.erase(it);
                        break;
                    }
                }
            }
    }
    int i=0;

    for(list<int>::iterator it = V.begin();it != V.end();it++){
       if(i++) cout<<' ';
        printf("%d",*it);
        }
        
    
    printf("\n");




return 0;
}



Measured memory_bytes: 34504
#include <stdio.h>

int main(){
  int a[5];
  int sumA,sumB,i=0;
  while(i<4){
  	scanf("%d",&a[i]);
    i++;
  }
  sumA = a[0]+a[1];
  sumB = a[2]+a[3];
  
  if(sumA > sumB) printf("Left\n");
  else if(sumA < sumB) printf("Right\n");
  else printf("Balanced");
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var A = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        WriteLine((A.Sum() >= 22) ? "bust" : "win");
    }
}


Measured memory_bytes: 28200
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int lo;
typedef pair< int,int > PII;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
 
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
 
lo n,m,b[li],a[li],k,flag,t,deg[li];
lo cev;
string s;
vector<lo> v;

void bolenbul(lo n){
	for(lo i=1;i*i<=n;i++){
		if(n%i==0 && i!=n/i){
			deg[i]++;
			deg[n/i]++;
		}
		if(n%i==0 && i==n/i){
			deg[i]++;
		}
	}
}

int main(void){
	scanf("%lld",&n);
	FOR{
		scanf("%lld",&a[i]);
	}
	for(lo i=n;i>=1;i--){
		b[i]=deg[i]%2;
		if(b[i]==a[i])continue;
		v.pb(i);
		bolenbul(i);
	}
	sort(v.begin(),v.end());
	printf("%lld\n",(lo)v.size());
	for(lo i=0;i<(lo)v.size();i++){
		printf("%lld ",v[i]);
	}
	return 0;
}


Measured memory_bytes: 11764
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int k = int.Parse(input[1]);
        int ans = k;
        int i;
        for (i = 1; i <= n - 1; i++) ans = ans * (k - 1);
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 2776
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int N,K;
    cin >> N >> K;
    int x[N];
    for(int i=0; i<N; i++) cin >> x[i];
    int ans=1e9;
    int j=K-1;
    for(int i=0; i<=N-K; i++){
        //左端、右端ともに正
        if(x[i]>=0 && x[j]>=0){
            ans = min(ans,x[j]);
        }
        //左端が負、右端が正
        if(x[i]<=0 && x[j]>=0){
            int xi=abs(x[i]),xj=x[j];
            if(xj < xi){
                swap(xj,xi);
            }
            ans = min(ans, xi*2+xj);
        }
        //左端、右端ともに負
        if(x[i]<=0 && x[j]<=0){
            ans = min(ans,abs(x[i]));
        }
        j++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int n;
  int d[100000];
  
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> d[i];
  
  sort(d, d+n);
  
  if (n % 2)
    cout << 0 << endl;
  else
    cout << d[n/2] - d[n/2-1] << endl;

  return 0;
}


Measured memory_bytes: 640
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int sum = 0;
    rep(i, n){
        sum += a[i];
    }

    vector<int> div;
    for(int i = 1; i * i <= sum; i++){
        if(sum % i){
            continue;
        }
        div.push_back(i);
        if(i * i != sum){
            div.push_back(sum / i);
        }
    }

    sort(ALL(div), greater<int>());
    rep(i, SZ(div)){
        vector<P> x(n);
        rep(j, n){
            int y = a[j] % div[i];
            x[j] = {y, div[i] - y};
        }
        sort(ALL(x));
        vector<int> f(n + 1), b(n + 1);
        rep(j, n) f[j+1] = f[j] + x[j].first;
        for(int j = n - 1; j >= 0; j--){
            b[j] = b[j+1] + x[j].second;
        }

        for(int j = 1; j < n; j++){
            if(f[j] > k || b[j] > k){
                continue;
            }
            if(max(f[j], b[j]) > k){
                continue;
            }
            cout << div[i] << endl;
            return 0;
        }
    }

    return 0;
}


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int x; cin>>x;
	if(x==7 or x==5 or x==3) cout<<"YES";
	else cout<<"NO";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long long ll;
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; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  
  int k;
  cin >> k;
  if(k<=9){
    cout << k << endl;
    return 0;
  }
  else{
    vector<ll>vec;
    deque<ll>deq;
    rep(i,9){
      vec.push_back(i+1);
      deq.push_back(i+1);
    }
    while(vec.size()<3*k){
      ll t=deq.front();
      deq.pop_front();
      ll c=t%10;
      ll u,v;
      if(t%10==0){
        u=t*10+1;
        deq.push_back(t*10+c);
        vec.push_back(t*10+c);
        deq.push_back(u);
        vec.push_back(u);
      }
      else if(t%10==9){
        v=t*10+8;
        deq.push_back(t*10+c);
        vec.push_back(t*10+c);
        deq.push_back(v);
        vec.push_back(v);
      }
      else{
        
        u=t*10+c+1;
        v=t*10+c-1;
        deq.push_back(t*10+c);
        vec.push_back(t*10+c);
        deq.push_back(u);
        vec.push_back(u);
        deq.push_back(v);
        vec.push_back(v);
      }
    }
    
    sort(vec.begin(),vec.end());
    cout << vec[k-1] << endl;
  }
}


Measured memory_bytes: 7664
#include<iostream>
using namespace std;
int main(){
    int x,y;
    int i = 1;
    
    while (1){
        cin >>x >>y;
        if ((x == 0) && (y == 0)) break;
        
        if (x > y){
            cout<< y <<" "<< x <<endl;
        } else {
            cout<< x <<" "<< y <<endl;
        }
        
        i++;
    }
    return 0;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15

/* Debug Begins */ 
# define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(bool f) { if(f) return "True"; else return "False";}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
/***************************************************************/


signed main()
{
    ios_base::sync_with_stdio(0);
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {   
        int n;
        cin >> n;
        vector<int>a(n);
        rep(i,0,n) cin >> a[i];
        map<int,int> cnt;
        int cur = 0;
        rep(i,0,n){
            cnt[a[i]]++;
            cur += a[i];
        }
        int q;
        cin >> q;
        while(q--){
            int b,c;
            cin >> b >> c;
            int ct = cnt[b];
            cnt[b] = 0;
            cnt[c] += ct;
            cur += ct*c - ct*b;
            cout << cur << endl;
        }
    }
}

Measured memory_bytes: 9912
A=input()
L=A.split()

N=int(L[0])
M=int(L[1])

x=1
for n in range(N-1,N+1):
  x*=n
x /= 2
  
y=1
for m in range(M-1,M+1):
  y*=m
y /= 2

print(int(x+y))

Measured memory_bytes: 3064
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from functools import reduce, lru_cache
import collections, heapq, itertools, bisect
import math, fractions
import sys, copy

sys.setrecursionlimit(1000000)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline().rstrip())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

class ModInt:
    def __init__(self, x, MOD=1000000007): self.x, self.MOD = x % MOD, MOD
    def __str__(self): return str(self.x)
    def __add__(self, other): return ModInt(self.x + other.x) if isinstance(other, ModInt) else ModInt(self.x + other)
    def __sub__(self, other): return ModInt(self.x - other.x) if isinstance(other, ModInt) else ModInt(self.x - other)
    def __mul__(self, other): return ModInt(self.x * other.x) if isinstance(other, ModInt) else ModInt(self.x * other)
    def __truediv__(self, other): return ModInt(self.x * other.inverse()) if isinstance(other, ModInt) else ModInt(self.x * pow(other, self.MOD - 2, self.MOD))
    def __pow__(self, other): return ModInt(pow(self.x, other.x, self.MOD)) if isinstance(other, ModInt) else ModInt(pow(self.x, other, self.MOD))
    def __rsub__(self, other): return ModInt(other.x - self.x) if isinstance(other, ModInt) else ModInt(other - self.x)
    def __rtruediv__(self, other): return ModInt(other.x * other.inverse()) if isinstance(other, ModInt) else ModInt(other * pow(self.x, self.MOD - 2, self.MOD))
    def __rpow__(self, other): return ModInt(pow(other.x, self.x, self.MOD)) if isinstance(other, ModInt) else ModInt(pow(other, self.x, self.MOD))
    __repr__, __radd__, __rmul__ = __str__, __add__, __mul__
    def inverse(self): return pow(self.x, self.MOD - 2, self.MOD)

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    L = S()

    dp1 = [ModInt(0) for _ in  range(len(L) + 1)]
    dp2 = [ModInt(0) for _ in  range(len(L) + 1)]
    dp1[0] = ModInt(1)

    for i, bit in enumerate(L):
        if bit == "0":
            dp1[i+1] = dp1[i]
            dp2[i+1] = 3 * dp2[i]
        else:
            dp1[i+1] = 2 * dp1[i]
            dp2[i+1] = 3 * dp2[i] + dp1[i]
    
    print(dp1[-1] + dp2[-1])



if __name__ == '__main__':
    main()

Measured memory_bytes: 108572
#include <iostream>

#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstring>
#include <algorithm>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : vec) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

const int MAX { 1000010 };
const ll oo { 2000000010 };
const int MOD { 1000000007 };

ll as[MAX];

void precomp()
{
}

ll solve(ll N)
{
    for (int i = 0; i < N; ++i)
        as[i] -= (i + 1);

    sort(as, as + N);

    auto b = as[N/2];

    ll ans = 0;

    for (int i = 0; i < N; ++i)
        ans += labs(as[i] - b);

    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    precomp();

    ll N;
    cin >> N;

    for (int i = 0; i < N; ++i)
        cin >> as[i];

    solve(N);

    return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl '\n'
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
  	string s;
    cin>>s;
    s[3]='8';
    cout<<s<<endl;
    
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{

    lli n;
    cin>>n;
    lli a[n + 1];
    vector<pair<lli, lli> > v;
    for(int i = 1; i <= n; i ++) {
        cin>>a[i];
        v.push_back({a[i], i });
    }

    multiset<lli> s({0, 0, n + 1, n + 1});

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    lli ans = 0;
    for(int i = 0; i < n; i ++) {
        lli num = v[i].ff;
        lli id = v[i].ss;
        auto it = s.lower_bound(id);
        lli R1 = *it;
        it ++;
        lli R2 = *it;
        it --;
        it --;
        lli L1 = *it;
        it --;
        lli L2 = *it;
        if(R1 < R2) {
            ans += num * (R2 - R1) * (id - L1);
        }
        if(L2 < L1) {
            ans += num * (L1 - L2) * (R1 - id);
        }
        s.insert(id);
    }

    cout<<ans;
    cout<<"\n";
    return ;
}

/*
*/

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

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


Measured memory_bytes: 7280
L, R = map(int, input().split())
mod = 2019

if R - L >= 2019:
    print(0)
    exit()

L %= 2019
R %= 2019

ans = 2019
for i in range(min(L, R), max(L, R)+1):
    for j in range(i+1, max(L, R)+1):
        ans = min(ans, (i*j)%mod)

print(ans)


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define INF  (int)1e9
#define LINF (long long)1e18

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

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

    int N;
    std::cin >> N;

    vector<int> P(N);
    REP(i, N) {
        std::cin >> P[i];
    }

    int ans = 0;
    for(int i = 1; i < N - 1; i++) {
        int max_val = max({P[i - 1], P[i], P[i + 1]});
        int min_val = min({P[i - 1], P[i], P[i + 1]});
        if(P[i] != max_val && P[i] != min_val) {
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    vector<int> a(100, 0);
    for (int i = 0; i < 3; ++i)
    {
        int x;
        cin >> x;
        ++a[x - 1];
    }
    int odp = 0;
    for (int i = 0; i < 100; ++i)
        if (a[i] != 0)
            ++odp;
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
#include <stdio.h>
using namespace std;
 
int main()
{
    int n,x,t;
    cin >> n >> x >> t;
    /*
    int a[n];
    std::vector<int> v;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        a[i] = tmp;
    }
    */

    int ans = n/x * t;
    if(n%x != 0) ans+=t;
    cout << ans << endl;
    //cout << a << endl;
    //cout << "Yes" << endl;
    //printf("%d\n", n);
 
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,n+1){
        rep(j,m+1){
            if((n-i)*j+(m-j)*i==k){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli n;
  cin >> n;
  vector <lli> a(n);
  lli x;
  fore (i,0,n){
    cin >> x;
    a[i] = x;
  }
  vector <lli> b(n);
  b[0] = 0;
  b[1] = abs(a[0] - a[1]) + b[0];
  fore (i,2,n){
    if ((abs(a[i - 1] - a[i]) + b[i - 1]) < (abs(a[i - 2] - a[i]) + b[i - 2])){
      b[i] = abs(a[i - 1] - a[i]) + b[i - 1];
    }
    else{
      b[i] = abs(a[i - 2] - a[i]) + b[i - 2];
    }
  }
  cout << b[n - 1] << ENDL;
  return 0;
}
// Hola, si estás viendo esto te notifico que te detuviste a leer mi código.

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

long long min2(long long a, long long b) {
	if (a < b)
		return a;
	else
		return b;
}

int main()
{
	long long n, k;
	cin >> n >> k;
	long long x;
	x = min2(n % k, abs((n % k) - k));
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        byte[] data = r.readLine().getBytes();
        for(int i = 0; i < data.length; i++){
            if(data[i] >= 65 && data[i] <= 90) System.out.print((char)(data[i] + 32));
            else if(data[i] >= 97 && data[i] <=122) System.out.print((char)(data[i] - 32));
            else System.out.print((char)(data[i]));
        }
        System.out.println();
    }
}



Measured memory_bytes: 25200
/***
 ** " Love the life you live. Live the life you love. "
 **     -- Bob Marley
***/

/**
  *  Author: dhruv_gheewala
  *  Problem: __________
  *  Date:   19.04.2020
  *  Time:   17:33:51
**/

#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;

    #define p(str) 7
    #define o(str) 42
    #define fundri 108
    #define debug(...) 1729
#endif

#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;

const bool testcases = 0;
#define ff first
#define ss second
#define endl '\n'
#define all(s) s.begin(), s.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr)

// if vector isn't soted then it will remove consecutive same elements
#define make_unique(vec) vec.erase(unique(all(vec)), vec.end())
#define test int TC = 1;if(testcases)cin >> TC;for(int tc = 1 ; tc <= TC ; tc++)
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})

int seed;mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX){return uniform_int_distribution<int>(l,r)(rng);}

template<typename T>bool isPrime(T n){for(T i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}
template<typename T, typename U>inline istream& operator >>(istream& in, pair<T, U> &a){in >> a.ff >> a.ss;return in;}
template<typename T>inline istream& operator >>(istream& in, vector<T> &a){for(auto &x : a)in >> x;return in;}

int32_t main()
{
    #ifdef DHRUV_GHEEWALA
        std::chrono::time_point<std::chrono::high_resolution_clock> start_time, end_time;
        start_time = std::chrono::high_resolution_clock::now();

        freopen("INPUT.txt","r",stdin);
        freopen("OUTPUT.txt","w",stdout);
        freopen("DEBUG.txt","w",stderr);
    #endif

    fast;
    int r;
    test
    {
        cin >> r;
    	cout << 6.28318530717958623200 * r << endl;
        fundri;
    }

    #ifdef DHRUV_GHEEWALA
        end_time = std::chrono::high_resolution_clock::now();
        int elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count();
        cerr << endl << endl;
        cerr << "Elapsed Time: " << elapsed_time << " ms" << endl;
    #endif

    return 0;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
struct edge{int to;ll cost;};
typedef pair<ll,int> P;
const ll INF=100000000000LL;
const ll MOD=1000000007LL;
const ll MAX=100010;
vector<edge> G[100010];
ll d[100010];
int n;
void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P> >que;
    fill(d,d+n+1,INF);
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top();
        que.pop();
        int v=p.second;
        if(d[v]<p.first){
            continue;
        }
        for(int i=0;i<(int)G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}
int main(){
	int m,r;
	cin>>n>>m>>r;
	for(int i=0;i<m;i++){
		int a,b;ll c;
		cin>>a>>b>>c;
		G[a].pb({b,c});
	}
	dijkstra(r);
	for(int i=0;i<n;i++){
        if(d[i]==INF){
            cout<<"INF"<<endl;
            continue;
        }
		cout<<d[i]<<endl;
	}
	return 0;
}



Measured memory_bytes: 19464
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define MOD 1e9 + 7
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
#define all(x) (x).begin(), (x).end()

void Main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a >= k)
    {
        cout << k << endl;
    }
    else if (a + b >= k)
    {
        cout << a << endl;
    }
    else
    {
        int tmp = k - a - b;
        cout << a - tmp << endl;
    }

    return;
}

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


Measured memory_bytes: 3700
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():

    # N = int(input())
    # a = [int(input()) for _ in range(N)]
    S = str(input())[:-1]
    T = str(input())[:-1]
    ans = 0
    for i in range(len(S)):
        if (S[i] == T[i]):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <stdio.h>
#include <iostream>
#include <string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int a;
    cin >> a;

    cout << (a + a*a + a*a*a) << endl;

    return 0;
}

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

typedef long long ll;

const ll MOD = (1e+9) + 7;

ll memo[10]; // have none continuous 1 
ll dp[101][8];

void dfs(string s)
{
  if(s.size() > 8) return;

  bool f = false;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '1'){
      if(f) return;
      f = true;
    }else{
      f = false;
    }
  }

  memo[s.size()]++;

  dfs(s + '0');
  dfs(s + '1');
}

int main()
{
  dfs("");
    // for(int i = 0; i < 10; ++i) printf("%d ", memo[i]); printf("\n");
  int h, w, k;
  cin >> h >> w >> k;

  dp[0][0] = 1;

  ll t;
  for(int i = 1; i <= h; i++){
    for(int j = 0; j < w; j++){
      if(j > 0){
        t = memo[max(0, w-1-(j+1))];
        t *= memo[max(0, j-2)];
        t %= MOD;
        dp[i][j] = dp[i-1][j-1] * t % MOD;
      }

      if(j < w-1){
        t = memo[max(0, j-1)];
        t *= memo[max(0, w-1-(j+2))];
        t %= MOD;
        dp[i][j] += dp[i-1][j+1] * t % MOD;
        dp[i][j] %= MOD;
      }

      t = memo[max(0, j-1)];
      t *= memo[max(0, w-1-(j+1))];
      t %= MOD;
      dp[i][j] += dp[i-1][j] * t % MOD;
      dp[i][j] %= MOD;
    }
  }

  cout << dp[h][k-1] << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  
  int K; cin>>K;
  int ans;

  map<ll,ll> mp;
  ll temp = 7;
  ll count = 1;
  while(1){
    ll amari = temp%K;
    if(amari==0){
      ans = count; break;
    }else if(mp[amari]==0){
      ++mp[amari];
      ++count;
      temp = (10*temp%K)+7;
    }else{
      ans = -1;
      break;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 66116
#include <iostream>

using namespace std;

int main()
{
	int old;
	int v, n;

	cin >> n;
	cin >> old;
	cout << old;
	for (int i = 1; i < n; i++) {
		cin >> v;
		if (v != old) {
			cout << " " << v;
		}
		old = v;
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <set>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<ll> pos(N,0);
    for(int i=0; i<N; i++){
        int x;
        cin >> x;
        x--;
        pos[x]=i;
    }

    set<int> s;
    s.insert(-1);
    s.insert(N);
    ll ans=0;
    for(int i=0; i<N; i++){
        ll p=pos[N-i-1];
        s.insert(pos[N-i-1]);
        if(i>0){
            ll a,b,c,d;
            a=b=MOD;
            c=d=0;
            auto it=s.find(p);
            b=*(--it);
            if(it!=s.begin()){
                a=*(--it);
            }
            it=s.find(pos[N-i-1]);
            c=*(++it);
            ++it;
            if(it!=s.end()){
                d=*it;
            }
            ans+=max(0LL,(b-a)*(c-p)*(N-i))+max(0LL,(p-b)*(d-c)*(N-i));
            //cout << N-i << endl;
            //cout << a << ' ' << b << ' ' << p << ' ' << c << ' ' << d << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<P, int> PP;
//const int MAX=;
//const long double INF=;


int main(){
	int L;
	cin>>L;
	vi v;
	int tmp=L;
	while(tmp>0){
		v.push_back(tmp);
		tmp/=2;
	}
	reverse(v.begin(), v.end());
	int N=sz(v);
	vector<PP> ans;
	rep1(i,N-1){
		PP pp1=make_pair(make_pair(i,i+1), 0);
		ans.push_back(pp1);
		PP pp2=make_pair(make_pair(i,i+1), v[i-1]);
		ans.push_back(pp2);
		if(v[i-1]*2!=v[i]){
			PP pp3=make_pair(make_pair(1,i+1), v[i]-1);
			ans.push_back(pp3);
		}
	}
	int M=sz(ans);
	cout<<N<<" "<<M<<endl;
	rep(i,M){
		PP pp=ans[i];
		P p=pp.first;
		cout<<p.first<<" "<<p.second<<" "<<pp.second<<endl;
	}
}

Measured memory_bytes: 256