akhauriyash/Code-Regression huggingface dataset:
import java.io.*;


class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){

			String str = br.readLine();
			String p;
			String strArr[] = str.split(" ");
			double a = Double.parseDouble(strArr[0]);
			double b = Double.parseDouble(strArr[2]);
			

			p = strArr[1];
			int i=0;
			double ans;
			
			if("?".equals(p)){
				break;
			}
			else if("+".equals(p)){
				ans = a+b;
				System.out.println((int)ans);
			}
			else if("-".equals(p)){
				ans = a-b;
				System.out.println((int)ans);
			}
			else if("*".equals(p)){
				ans = a*b;
				System.out.println((int)ans);
			}
			else if("/".equals(p)){
				ans = a/b;
				System.out.println((int)ans);
			}
			
			/*switch(p){
				case "+":
					ans = a+b;
					System.out.println((int)ans);
					break;
				case "-":
					ans = a-b;
					System.out.println((int)ans);
					break;
				case "*":
					ans = a*b;
					System.out.println((int)ans);
					break;
				case "/":
					ans = a/b;
					System.out.println((int)ans);
					break;
				case "?":
					i=4;
					break;
				default:
					break;
			}
			if(i==4)
				break;
				*/

			}



		}
	}

Measured memory_bytes: 16932
require 'prime'
ans=1
a,b=gets.split.map &:to_i
aa=a.prime_division << [Float::INFINITY]
bb=b.prime_division << [Float::INFINITY]
la=aa.size
lb=bb.size
ea,eb=aa.each,bb.each
pa=ea.next
pb=eb.next
(la+lb).times do
  break if pa[0]==Float::INFINITY&&pb[0]==Float::INFINITY
  if pa[0]==pb[0]
    ans*=pa[0]**[pa[1],pb[1]].max
    pa=ea.next
    pb=eb.next
  elsif pa[0] > pb[0]
    ans*=pb[0]**pb[1]
    pb=eb.next
  else
    ans*=pa[0]**pa[1]
    pa=ea.next
  end
end
p ans


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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ii> llii;

const int Maxn = 52;
const int Maxc = 5005;
const ll Inf = 4000000000000000000ll;

int n, m, s;
int U[Maxc], V[Maxc], A[Maxc], B[Maxc];
vector <ii> neigh[Maxn];
int C[Maxn], D[Maxn];
ll dist[Maxn][Maxc];
priority_queue <llii> Q;

int main()
{
    scanf("%d %d %d", &n, &m, &s);
    for (int i = 0; i < m; i++) {
        scanf("%d %d %d %d", &U[i], &V[i], &A[i], &B[i]);
        neigh[U[i]].push_back(ii(V[i], i));
        neigh[V[i]].push_back(ii(U[i], i));
    }
    for (int i = 1; i <= n; i++)
        scanf("%d %d", &C[i], &D[i]);
    fill((ll*)dist, (ll*)dist + Maxn * Maxc, Inf);
    dist[1][min(s, Maxc - 1)] = 0;
    Q.push(llii(0, ii(1, min(s, Maxc - 1))));
    while (!Q.empty()) {
        ii v = Q.top().second;
        ll d = -Q.top().first; Q.pop();
        if (dist[v.first][v.second] != d) continue;
        ii u = ii(v.first, min(v.second + C[v.first], Maxc - 1));
        ll cand = d + D[v.first];
        if (cand < dist[u.first][u.second]) {
            dist[u.first][u.second] = cand;
            Q.push(llii(-dist[u.first][u.second], u));
        }
        for (int i = 0; i < neigh[v.first].size(); i++) {
            u.first = neigh[v.first][i].first;
            int ind = neigh[v.first][i].second;
            if (v.second >= A[ind]) {
                u.second = v.second - A[ind];
                cand = d + B[ind];
                if (cand < dist[u.first][u.second]) {
                    dist[u.first][u.second] = cand;
                    Q.push(llii(-dist[u.first][u.second], u));
                }
            }
        }
    }
    for (int i = 2; i <= n; i++) {
        ll res = dist[i][0];
        for (int j = 1; j < Maxc; j++)
            res = min(res, dist[i][j]);
        printf("%lld\n", res);
    }
    return 0;
}


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

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

  vector<int> h(n+1);
  rep(i,n) cin >> h[i+1];

  vector<int> dp(n+1,0);

  for(int i = 1; i <= n; i++){
    if(i==1){
      dp[i] = 0;
      continue;
    }
    if(i==2){
      dp[i] = abs(h[i] - h[i - 1]);
      continue;
    }
    int cost1 = dp[i-1] + abs(h[i] - h[i-1]);
    int cost2 = dp[i-2] + abs(h[i] - h[i-2]);
    dp[i] = min(cost1,cost2);
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 4056
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


// Modint
struct Mint {
	static const ll mod = 998244353;
	ll val;

	Mint() { val = 0; }
	Mint(ll a) { val = a; verify_value(); }

	void verify_value() {
		if (val >= mod) val %= mod;
		if (val < 0) val %= mod, val += mod;
	}

	Mint pow(ll p) const {
		Mint cur = Mint(val), ret = 1;
		while (p > 0) {
			if (p & 1) ret *= cur;
			cur *= cur;
			p >>= 1LL;
		}
		return ret;
	}
	Mint inv() const {
		if (val == 0) cerr << "WARNING: inv() is called with 0." << endl;
		return pow(mod - 2);
	}

	Mint operator+() const { return *this; }
	Mint operator-() const { return Mint(mod - val); }

	Mint operator+=(const Mint &a) {
		val += a.val;
		if (val >= mod) val -= mod;
		return Mint(val);
	}
	Mint operator*=(const Mint &a) {
		val *= a.val;
		if (val >= mod) val %= mod;
		return Mint(val);
	}
	Mint operator-=(const Mint &a) { return *this += -a; }
	Mint operator/=(const Mint &a) { return *this *= a.inv(); }

	Mint operator++() { return *this += Mint(1); }
	Mint operator--() { return *this -= Mint(1); }
	Mint operator++(int) {
		Mint ret = *this;
		++(*this);
		return ret;
	}
	Mint operator--(int) {
		Mint ret = *this;
		--(*this);
		return ret;
	}

	operator ll() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
	ll ret = a.val + b.val;
	if (ret >= Mint::mod) ret -= Mint::mod;
	return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
	ll ret = a.val * b.val;
	if (ret >= Mint::mod) ret %= Mint::mod;
	return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

ostream &operator<<(ostream &out, const Mint &a) { return out << a.val; }
istream &operator>>(istream &in, Mint &a) {
	in >> a.val;
	a.verify_value();
	return in;
}

Mint pow(Mint a, ll b) {
	return a.pow(b);
}


// Combinatorics
constexpr int MAX_N = 2000003;
Mint fact[MAX_N], inv[MAX_N];

void init_fact() {
	fact[0] = inv[0] = 1;
	for (ll i = 1; i < MAX_N; i++) {
		fact[i] = fact[i - 1] * Mint(i);
		inv[i] = fact[i].inv();
	}
}

// aCb
Mint C(int a, int b) {
	if (a < b) return 0;
	Mint res = fact[a];
	res *= inv[b];
	res *= inv[a - b];
	return res;
}

// aPb
Mint P(int a, int b) {
	if (a < b) return 0;
	return fact[a] * inv[a - b];
}

// aHb
Mint H(int a, int b) {
	if (b == 0) return 1;
	return C(a + b - 1, b);
}


int main() {
	int n, s; cin >> n >> s;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<Mint> cnt(n*s + 2);
	cnt[0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = s; j >= 0; j--) {
			Mint cf = 1;
			if (j == 0) cf *= i + 1;
			if (j + a[i] == s) cf *= n - i;
			cnt[j + a[i]] += cf*cnt[j];
		}
	}
	cout << cnt[s] << endl;
	return 0;
}


Measured memory_bytes: 101760
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2424>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll check(ll N){
    ll ret = -1;
    ll base = 10;
    for(;;base*=10){
        if(N%base == N) break;
        ret = max(ret,(N/base)*(N%base));
    }
    return ret;
}
ll solve(){
    ll res = 0;
    ll N; cin >> N;
    map<ll,bool> mp;
    while(true){
        if(N%10 == N) break;
        if(mp[N]){ res = -1; break; }
        N = check(N);
        res++;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int Q; cin >> Q;
    while(Q--){
        cout << solve() << endl;
    }
    return 0;
}



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

int x,y;
int main() {
    cin>>x>>y;
    if(((x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12) && (y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12)) || (((x==4) || (x==6) || (x==9) || (x==11)) && ((y==4) || (y==6) || (y==9) || (y==11)) || ((x==2) && (y==2)))) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1) {
		if (b == 1) cout << "Draw" << endl;
		else cout << "Alice" << endl;
	}
	else {
		if (b == 1) cout << "Bob" << endl;
		else if (b == a) cout << "Draw" << endl;
		else if (b < a) cout << "Alice" << endl;
		else cout << "Bob" << endl;
	}
}

Measured memory_bytes: 256
/**
 *    Author:  Oak_limy
 *    Created: 2020-09-13 21:01:59
**/
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <bits/stdc++.h>
#include <cwctype>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define up upper_bound
using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
       if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
    char c = getchar(); int w = 1; int x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
inline ll readll() {
    char c = getchar(); ll w = 1; ll x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
void fl(string name){
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
          dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
const ll mod=1e9+7;
int main(){
    ll n;
    cin>>n;
    cout<<(((powmod(10,n,mod)-powmod(9,n,mod)+mod)%mod+powmod(8,n,mod))-powmod(9,n,mod+mod)+mod)%mod<<endl;
    return 0;
}
/* stuff to remember
    * int overflow, array bounds
    * special cases (n=1? n=0?)
    * do something instead of nothing and stay organized
    * USE STATIC ARRAYS
    * DEFINING ARRAYS BEFORE main()
    * DO NOT DEFINE ARRAYS IN main()
    * USE INT INSTEAD OF LL,NOTICE THE MLE
*/

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    int cnt = 0;
    rep(i,s.size())if(s[i]=='x')cnt++;
    if(cnt>7)cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
	int N,M;
		cin >> N;
	M=N;
	int S=0;
	while(M!=0){
		S+=M%10;
		M/=10;
	}
	if(N%S)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        ll n,m,k;
        cin>>n>>m>>k;
        vector <ll> a(n+1);
        a[0]=0ll;
        for(int i=1;i<=n;i++){
            cin>>a[i];
            a[i]+=a[i-1];
        }
        ll b[m+1];b[0]=0ll;
        for(int i=1;i<=m;i++){
            cin>>b[i];
            b[i]+=b[i-1];
        }
        ll ans=0ll;
        for(int i=0;i<=m;i++){
            if(b[i]<=k){
                auto it=upper_bound(a.begin(),a.end(),k-b[i]);
                ll val=it-a.begin();
                ans=max(ans,i+val-1);
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}

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

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    string s[10];
    for(int i = 0; i < h; i++){
        cin >> s[i];
    }
    int ans = 0;
    for(int i = 0; i < (1<<(h+w)); i++){//2^(h+w)通り探索
        int cnt = 0;
        for(int j = 0; j < h; j++){
            //cout << j << endl;
            for(int l = 0; l < w; l++){
                if(s[j][l] == '#' && ((i&(1<<j)) == 0) && ((i&(1<<(l+h))) == 0)){
                    cnt++;//塗られてないかつ黒のとこがあったらカウント
                    //cout << cnt << ' ' << j << ' ' << l << endl;
                }
            }
        }
        if(cnt == k) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  string s,t;
  cin >> s >> t;
  if(s.length()==t.length())rep(i,s.length())cout << s[i] << t[i];
  else {
    rep(i,s.length()-1)cout << s[i] << t[i];
    cout << s[s.length()-1];
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
	long long a,b,k,l;
	cin>>a>>b>>k;
  	l = k;
  	k -= a;
  	if(k > 0){
      	a = 0;
      	if(b-k < 0){
          	b = 0;
        }else{
        	b -= k;
        }
    } else {
    	a -= l;
    }
	cout<<a<<" "<<b;
}


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

int main( int argc, char *argv[] )
{
int A;
int B;
int C;
int D;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;
	if( A * B < C * D )
		cout << C * D << endl;
	else
		cout << A * B << endl;

	return 0;
}




Measured memory_bytes: 256
/*
        |___________________________Arshit Mangukiya_____________________________|
        |_______________________________DA-IICT__________________________________|
        |_____________________________201801173__________________________________|
*/
        /*______________________WRITE  YOUR  CODE  HERE_________________________*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef vector<pll> vpl;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
#define F(i,a,n) for(ll i=a;i<n;i++)
#define MOD 1000000007
#define MAX 200007
#define LM LLONG_MAX
#define sz size()
#define p(x) 		cout<< x << " ";
#define pe(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
const int N=1e5+5;
    	/*	bool fun(pair<int,int>a , pair<int,int>b)
			{
				if(a.ff == b.ff)	return a.ss < b.ss;
				else			return a.ff < b.ff;
			}*/
 /*void bfs(ll x)
 {
 	queue<ll> q;
	q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
            	l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/


void solve()
{
	ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
    {
      cout<<k<<endl;
      return ;
    }
    if(k<=(a+b))
    {
      cout<<a<<endl;
      return ;
    }
    cout<<a-(k-a-b);
}
int32_t main(){
	mr_ad_0501;
//	fun();
	ll t=1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long one, zero, minus_one;
    int k, amount = 0;
    cin >> one >> zero >> minus_one >> k;
    if(one >= k){
        amount = k;
    }else if(one+zero >= k){
        amount = one;
    }else{
        amount = one - (k-(one+zero));
    }
    cout << amount << endl;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

bool compare(pair<int, int> &a, pair<int, int> &b) {
    if (a.first != b.first) {
        return a.first > b.first;
    } else {
        return a.second > b.second;
    }
}

void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    unordered_map<int, int> m;
    REP(i, N) {
        if (m.count(A[i])) {
            m[A[i]]++;
        } else {
            m[A[i]] = 1;
        }
    }
    vector<pair<int, int>> vec;
    for (auto item : m) {
        vec.push_back(make_pair(item.first, item.second));
    }
    sort(vec.begin(), vec.end(), compare);
   
    /*
    REP(i, vec.size()) {
        print(vec[i].first << " " << vec[i].second);
    }
    */
    ll ans = 1;
    int cnt = 0;
    REP(i, vec.size()) {
        if (vec[i].second >= 2) {
            ans *= vec[i].first;
            cnt++;
            if (cnt == 2) break;
            if (vec[i].second >= 4) {
                ans *= vec[i].first;
                cnt++;
            }
        }
        if (cnt == 2) break;
    }
    if (cnt < 2) {
        print(0);
    } else {
        print(ans);
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 6308
def Z(S):
    res = [0]*len(S)
    res[0] = len(S)
    i = 1
    j = 0
    while i < len(S):
        while i+j < len(S) and S[j] == S[i+j]:
            j += 1
        res[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < len(S) and k+res[k] < j:
            res[i+k] = res[k]
            k += 1
        i += k
        j -= k
    return res

N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
S = [0]*N
T = [0]*N
for i in range(N):
    S[i] = a[i]^a[(i+1)%N]
    T[i] = b[i]^b[(i+1)%N]
s = 0
t = 0
for i in range(N):
    s += S[i]
    t += T[-i-1]
    if s==t:
        break

ans = []
z = Z(S)
for j in range(N):
    if z[j]==N-j:
        ans.append([(j+i+1)%N,a[0]^b[(-j-i-1)%N]])
ans.sort()
if s!=t:
    ans = []
for s in ans:
    print(*s)


Measured memory_bytes: 128080
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

int main() {
  int N;
  std::vector<int> A;
  std::cin >> N;
  for (int i = 0; i < N; i++)
    A.push_back(0);

  for (int i = 0; i < N; i++) {
    int people;
    std::cin >> people;
    A.at(people - 1) = i + 1;
  }
  for (int n : A)
    std::cout << n << " ";
  return 0;
}


Measured memory_bytes: 1272
#include<stdio.h>

int main(void)
{
    int r, d, xx;
    int i;

    //入力
    scanf("%d %d %d", &r, &d, &xx);

    long int x[11];
    x[0] = xx;

    for(i=0; i<10; i++)
    {
        x[i+1] = r * x[i] - d;
        printf("%ld\n", x[i+1]);
    }

    return 0;
}


Measured memory_bytes: 128
// In the name of God
#include <bits/stdc++.h>

using namespace std;
#define Size(x) ((int)(x).size())
#define pb push_back
#define LD_OUT setprecision(12) << fixed
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int INF = 1e9 + 10;
const int MN = 850;

pii q[MN*MN];
bool mk[MN][MN];
int l , r , R , C;
string s[MN];
int n , m , k;
int dist[MN][MN];

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

bool valid(int tr,int tc){
	if(tr < 0 || tc < 0 || tr >= n || tc >= m) return false;
	return true;
}

void bfs()
{
	for(int i=0;i<MN;++i) fill(dist[i] , dist[i] + MN , INF);
	mk[R][C] = true , dist[R][C] = 0;
	q[r++] = {R , C};
	while(l < r){
		pii v = q[l++];
		for(int d=0;d<4;++d){
			int tr = v.first + dx[d] , tc = v.second + dy[d];
			if(valid(tr , tc) && s[tr][tc] != '#'&& !mk[tr][tc]){
				mk[tr][tc] = true;
				dist[tr][tc] = dist[v.first][v.second]+1;
				q[r++] = {tr , tc};
			}
		}
	}	
}

int F(int a){
	return (a+k-1)/k;
}

int main()
{
	ios_base :: sync_with_stdio(false) ,cin.tie(0) , cout.tie(0);
	cin >> n >> m >> k;
	for(int i=0;i<n;++i) cin >> s[i];
	for(int i=0;i<n;++i)
		for(int j=0;j<m;++j)
			if(s[i][j] == 'S')
				R = i , C = j;
	int Ans = INF;
	bfs();
	for(int i=0;i<n;++i)
		for(int j=0;j<m;++j) if(dist[i][j] <= k){
			int V = min(min(i , n-1-i) , min(j , m-1-j)); 
			Ans = min(Ans , 1 + F(V));
		}
	cout << Ans << '\n';
	return 0;
}


Measured memory_bytes: 9344
map="abcdefghijklmnopqrstuvwxyz"
count=[0 for i in range(len(map))]

lines=[]

try:
    while True:
        line=input()
        if line=="":
            break
        
        if len(line)==0:
            break
        else:
            lines+=line

except EOFError:
    pass
            
for i in range(len(map)):
    for j in range(len(lines)):
        if map[i]==lines[j].lower():
            count[i]+=1
    print("{} :".format(map[i]),count[i])


Measured memory_bytes: 5572
#include <stdio.h>

int rorl(int alp){
  if (alp=='q'
      ||alp=='w'
      ||alp=='e'
      ||alp=='r'
      ||alp=='t'
      ||alp=='a'
      ||alp=='s'
      ||alp=='d'
      ||alp=='f'
      ||alp=='g'
      ||alp=='z'
      ||alp=='x'
      ||alp=='c'
      ||alp=='v'
      ||alp=='b')
    return 0;
  if (alp=='y'
      ||alp=='u'
      ||alp=='i'
      ||alp=='o'
      ||alp=='p'
      ||alp=='h'
      ||alp=='j'
      ||alp=='k'
      ||alp=='l'
      ||alp=='n'
      ||alp=='m')
    return 1;
}

int main(void){

  for(;;){

    int alp,state;
    
    alp = getchar();
    state = rorl(alp);
    
    if(alp=='#')break;
    
    int change=0;
    
    while((alp=getchar())!='\n'){
      
      if(rorl(alp) ==0 && state==1){
        change++;
        state=0;
      }
      
      if(rorl(alp) ==1 && state==0){
        change++;
        state=1;
      }
      
    }
    
    printf("%d\n",change);
  }
  return 0;
}

Measured memory_bytes: 524
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"strings"
)

const (
	TooLarge = math.MaxInt64
	TooSmall = math.MinInt64
)

func main() {
	scanner := makeWordScanner()
	var n, a, b int64

	n = eGetInt64(scanner)
	a = eGetInt64(scanner)
	b = eGetInt64(scanner)
	x := n / (a + b)
	y := n % (a + b)
	if y >= a {
		fmt.Println((a * x) + a)
	} else {
		fmt.Println((a * x) + y)
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	if n == 0 {
		return 1
	}
	if n == 1 {
		return a
	}
	if n%2 == 1 {
		return pow((a*a), n/2) * a
	}
	return pow((a * a), n/2)
}
func powMod(a, n, mod int) int {
	if n == 0 {
		return 1 % mod
	}
	if n == 1 {
		return a % mod
	}
	if n%2 == 1 {
		return powMod((a*a)%mod, n/2, mod) * a % mod
	}
	return powMod((a*a)%mod, n/2, mod)
}

func factoricalMod(n, count, mod int) int {
	if count == 1 {
		return n % mod
	}
	return (n % mod) * (factoricalMod(n-1, count-1, mod)) % mod
}

func combinationMod(n, a, mod int) int {
	x := factoricalMod(n, a, mod)
	y := factoricalMod(a, a, mod)
	y = powMod(y, mod-2, mod)
	return ((x % mod) * (y % mod)) % mod
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> w(N);
    for(int i = 0;i < N;i++){
        cin >> w[i];
    }

    int S1 = accumulate(w.begin(),w.end(),0);
    int S2 = 0;
    int ans = abs(S1 - S2);
    for(int i = 0;i < N;i++){
        S1 -= w[i];
        S2 += w[i];
        assign_min(ans,abs(S1-S2));
    }

    cout << ans << endl;
}

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> s(h+2,vector<char>(w+2));
  for(int i=0;i<w+2;i++){
    s.at(0).at(i)+='.';
    s.at(h+1).at(i)+='.';
  }
  for(int i=1;i<h+1;i++){
    s.at(i).at(0)='.';
    for(int j=1;j<w+1;j++){
      cin >> s.at(i).at(j);
    }
    s.at(i).at(w+1)='.';
  }
  
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      
      if(s.at(i).at(j)!='#'){
        char k='0';
        for(int x=-1;x<=1;x++){
          for(int y=-1;y<=1;y++){
            if(s.at(i+x).at(j+y)=='#'){
              k++;
            }
          }
        }
        s.at(i).at(j)=k;
      }
      
    }
  }
  
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      cout << s.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stack>
using namespace std;
const int maxn=100+10;
int n;
int a[maxn];

void select_sort(int a[],int n)
{
    int swap_cnt=0;
    int minh;
    for(int i=0;i<n;i++)
    {
        minh=i;
        for(int j=i;j<n;j++)
        {
            if(a[j]<a[minh]) minh=j;
        }
        if(i!=minh)
        {
            swap(a[minh],a[i]);
            swap_cnt++;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(i) printf(" ");
        printf("%d",a[i]);
    }
    printf("\n%d\n",swap_cnt);
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    select_sort(a,n);

    return 0;
}

Measured memory_bytes: 3208
#include<stdio.h>

int main(){
  int a = 0, b = 0, i, x;
  for(i = 0;i < 4;i++){
    scanf("%d", &x);
    a+=x;
  }
  for(i = 0;i < 4;i++){
    scanf("%d", &x);
    b+=x;
  }
  if(a > b)printf("%d\n", a);
  else printf("%d\n", b);
  return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n;
		int w = 0, k = 0;
		int[] topW, topK;
		topW = new int[3];
		topK = new int[3];
		
		for(int i = 0; i < 10; i++){
			n = scan.nextInt();
			if(n > topW[0]){
				topW[2] = topW[1];
				topW[1] = topW[0];
				topW[0] = n;
			}else if(n > topW[1]){
				topW[2] = topW[1];
				topW[1] = n;
			}else if(n >topW[2]){
				topW[2] = n;
			}
		}
		for(int i = 0; i < 3; i++){
			w += topW[i];
		}
		
		for(int i = 0; i < 10; i++){
			n = scan.nextInt();
			if(n > topK[0]){
				topK[2] = topK[1];
				topK[1] = topK[0];
				topK[0] = n;
			}else if(n > topK[1]){
				topK[2] = topK[1];
				topK[1] = n;
			}else if(n >topK[2]){
				topK[2] = n;
			}
		}
		for(int i = 0; i < 3; i++){
			k += topK[i];
		}
		
		System.out.println(w + " " + k);
	}
}

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



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

using namespace std;
string a,b;

int main(){
  cin >> a >> b;
  REP(i,a.size()){
    if(a==b){
      cout << "Yes" << endl;
      return 0;
    }
    a = a.substr(a.size()-1,1) + a.substr(0,a.size()-1);
    //cout << a << endl;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(3 * n);
    for (size_t i = 0; i < 3 * n; i++)
    {
        cin >> a[i];
    }
    ll ans = 0;
    sort(a.begin(), a.end());
    for (size_t i = 0; i < n; i++)
    {
        ans += a[n + 2 * i];
        /* code */
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int x = Integer.parseInt(tmpArray[0]);
		int y = Integer.parseInt(tmpArray[1]);
		
		
		while (x != y){
			//System.out.println(x + " " + y);
			if(y > x){
				int tmp = y;
				y = x;
				x = tmp;
			}
			if(x%y == 0){
				x = y;
				break;
			}
			x = x%y;
		}		
		
		System.out.println(x);
	}

}

Measured memory_bytes: 24416
/**-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*                                                               *-*
*-*                  Bismillahir Rahmanir Rahim                   *-*
*-*                                                               *-*
*-*                  Author: Ahsan Habib (comrade)                *-*
*-*                    Metropolitan University                    *-*
*-*                         Language: C++                         *-*
*-*                                                               *-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**/
#include<bits/stdc++.h>
#include<istream>
#include<cstdio>
#define pii          pair<ll,ll >
#include<string>
#define In freopen("ahsan.txt","r",stdin);
#define ll long long
#define ff first
#define ss second
#define NO cout<<"NO"<<endl
#define m1 cout<<"-1"<<endl
#define No cout<<"No"<<endl
#define cinarr0(n) for(int i = 0;i<n;i++)cin>>a[i],mp[a[i]]++;
#define cinarr1(n) for(int i = 1;i<=n;i++)cin>>a[i];
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define pb push_back
#define sorta(a) sort(a,a+n)
#define sortv(v)  sort(v.begin,v.end())
#define bug(a) cerr << #a << " : " << a << endl
#define all(v) (v.begin(), v.end())
#define   sz(x)       x.size()
#define fill(x, y) memset(x, y, sizeof(x))
const int mx = 1e6+5;
using namespace std;
ll a[200010],m,ans,i,t,k,ev=0,od=0,tt=0,n,cas = 1;
vector<int>vec[mx];
vector<pii>v;
bool ok = true;
int arr[100000];
int dp[6000];
int main()
{
   //In;
    ios::sync_with_stdio(false);
    cin.tie(0);



    string s;
    cin>>s;
    ll sum = 0;
    for(auto it : s)
    {
        sum+= it - '0';
    }
    if(sum%9==0)Yes;
    else No;



}


Measured memory_bytes: 27204
#include<iostream>
#include<cmath>

typedef long long ll;

using namespace std;

int main(){
    ll N; cin >> N;
    
    ll res=N-1;

    for(ll i=sqrt(N); i>1; i--){
        if(N%i==0){
            res = (N/i - 1) + (i - 1); 
            break;
        }
    }
    

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

struct Edge {
  int to, cost;

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

void bfs(std::vector<std::vector<Edge> >& g, long long d[], int k) {
  std::fill(d, d + 100000, (long long)(1e15));

  d[k] = 0;

  std::priority_queue<std::pair<long long, int> > que; // cost, vertex
  que.push({0, k});

  while (!que.empty()) {
    auto p = que.top();
    que.pop();

    for (auto nextv : g[p.second]) {
      if (d[nextv.to] <= p.first + nextv.cost) {
	continue;
      }

      d[nextv.to] = p.first + nextv.cost;
      que.push({d[nextv.to], nextv.to}); 
    }
  }

}

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

  int N, Q, K;
  long long d[100001];
  std::vector<std::vector<Edge> > g;

  cin >> N;
  g.resize(N);

  for (int i = 0; i < N - 1; ++i) {
    int a, b, c;
    cin >> a >> b >> c, a--, b--;

    g[a].push_back({b, c});
    g[b].push_back({a, c});
  }

  cin >> Q >> K, K--;

  bfs(g, d, K);

  for (int i = 0; i < Q; ++i) {
    int x, y;
    cin >> x >> y, x--, y--;

    cout << d[x] + d[y] << endl;
  }

  return 0;
}


Measured memory_bytes: 9460
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	l := len(s)
	a1 := make([]int, l)
	for i := 0; i < l; i++ {
		if i%2 == 0 {
			a1[i] = 1
		} else {
			a1[i] = 0
		}
	}
	a0 := make([]int, l)
	for i := 0; i < l; i++ {
		if i%2 == 0 {
			a0[i] = 0
		} else {
			a0[i] = 1
		}
	}
	cnt1 := 0
	cnt0 := 0
	for i := 0; i < l; i++ {
		p, _ := strconv.Atoi(string(s[i]))
		if a1[i] != p {
			cnt1++
		}
		if a0[i] != p {
			cnt0++
		}
	}
	if cnt1 > cnt0 {
		fmt.Println(cnt0)
		return
	} else {
		fmt.Println(cnt1)
		return
	}
}


Measured memory_bytes: 3328
N,M=map(int,input().split())
lr=[list(map(int,input().split()))for _ in range(M)]

count=[0]+[0]*N+[0]
for l,r in lr:
    count[l]+=1
    count[r+1]-=1

i=1
while i<N+2:
    count[i]=count[i]+count[i-1]
    i+=1

print(sum(c==M for c in count))

Measured memory_bytes: 31284
#include<iostream>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
vector<string> s;
long long int n,a,b,c,ans,d,e;
string s1,s2,s3;
cin >>n>>a>>b;
c=a+b;
if(c==0)cout<<"0"<<endl;
else {
  d=n/c;
if(n%c>=a)e=a;
  else e=n%c;
  cout<<d*a+e<<endl;
  }
return 0;
} 

Measured memory_bytes: 256
l = input().split()

a = int(l[0])
b = int(l[1])
c = int(l[2])

if a > b:
    w = a
    a = b
    b = w
if b > c:
    w = b
    b = c
    c = w
if a > b:
    w = a
    a = b
    b = w
print(a,b,c)


Measured memory_bytes: 5596
n = int(input())
A = list(map(int, input().split()))

import fractions
#import math
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
    #return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
    #return reduce(math.gcd, numbers)

g = gcd_list(A)
print(g)


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

#define rep(i,f,n) for (long long (i) =(f);(i)<(n);(i)++)
typedef  long long ll;

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<ll>a(n),b(n);
    rep(i,0,n){
        cin>>a[i];
        b[i]=a[i];
    }
    int q;
    cin>>q;
    vector<int>x(q),y(q);
    rep(i,0,q){
        cin>>x[i]>>y[i];
    }
    sort(b.begin(),b.end());
    int ans=0,cnt=0;
    ll w;
    rep(i,0,n){
        if(a[i]==b[i])cnt++;
    }
    for(ans=0;ans<=q;ans++){
/*rep(i,0,n){
            cout<<a[i]<<" "<<b[i]<<endl;
        }
        cout <<cnt<<endl<<endl;*/
        if(cnt==n)break;
        if(ans==q){
            ans=-1;
            break;
        }
        if(a[x[ans]-1]==b[x[ans]-1])cnt--;
        if(a[y[ans]-1]==b[y[ans]-1])cnt--;
    
        swap(a[x[ans]-1],a[y[ans]-1]);
        if(a[x[ans]-1]==b[x[ans]-1])cnt++;
        if(a[y[ans]-1]==b[y[ans]-1])cnt++;
        if(ans==q){
            ans=-1;
            break;
        }



        
    }
    cout <<ans<<endl;


    return 0;
}



Measured memory_bytes: 9968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using Tuple = tuple<int, int, int>;


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

    ll ans = 0;
    rep(i, n) {
        ll now = 1;
        for(ll j=1; now < d; j++) {
            now = a[i] * j;
            ans += 1;
        }
        if(d == 1) ans += 1;
    }
    cout << x + ans << endl;
}


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

int main(){
    char A[12], B[12], C[12];
    scanf("%s %s %s", A, B, C);

    if(A[strlen(A) - 1] == B [0] && B[strlen(B) - 1] == C [0]){
        printf("YES\n");
    } else{
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 1664
def solve():
    N = int(input())
    T, A = map(int, input().split())
    H = map(int, input().split())
    ans = float('inf')
    ans_i = 0
    for i, v in enumerate(H):
        tmp = abs(A - (T - 0.006 * v))
        if ans > tmp:
            ans_i = i
            ans = tmp
    print(ans_i+1)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
import java.util.*;

public class Main{
  static int[] ans;
  static Map<Integer, Integer> map;
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    String[] T = sc.nextLine().split(" ");
    
    int ans = 0;
    for(int i = 0; i < N; i++){
      int a = Integer.parseInt(S[i]);
      int b = Integer.parseInt(T[i]);
      
      if(a-b > 0){
        ans += a-b;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
#include<iostream>
using namespace std;
const long long mod = 1000000007;
long long ksm(long long x,long long y)
{
	long long ans=1%mod;
	x=x%mod;
	while(y)
	{
		if(y%2==1)
		{
			ans=ans*x%mod;
		}
		y/=2;
		x=x*x%mod;
	}
	return ans;
}
int main()
{
	long long n;
	cin>>n;
	cout<<((ksm(10,n)-2*ksm(9,n)+ksm(8,n))%mod+mod)%mod;
}

Measured memory_bytes: 3636
/*

Author: @karngyan
Team: BlundersPride

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
//MIT OCW DP PROBLEM
const ll N = 3010;
ll a[N];
ll dp[N][N];

ll go(ll i , ll j)
{
	if(i == j)
		return a[i];
	if(i+1 == j)
		return max(a[i] , a[j]);

	ll &ans = dp[i][j];
	if(ans != -1)
		return ans;

	ans = max( a[i] + min(go(i+2 , j) , go(i+1 , j-1)) , a[j] + min(go(i+1 , j-1) , go(i , j-2)));
	return ans;
}

signed main()
{
	fast;
	memset( dp , -1 , sizeof dp );
////////////////////////////////////////////////////////////////////////////////////////////
		
	ll n;
	cin >> n;
	ll tot = 0;
	rep(i,0,n)
		cin >> a[i] , tot+=a[i];

	cout<<go(0 , n-1) - (tot - go(0 , n-1))<<endl;

////////////////////////////////////////////////////////////////////////////////////////////
	
	return 0;
}


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

int main(){
    string s; cin >> s;
    if(s == "AAA" || s == "BBB") cout << "No" << endl;
    else cout << "Yes"  << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
	int x = 0, y = 0, s = 0;


	while (cin >> x >> y >> s)
	{
		int A = 0, B = 0, stemp = 0, stemp2 = 0, stemp3 = 0;

		if (x == 0 && y == 0 && s == 0)
		{
			break;
		}

		for (int i = 1; i < s; i++)
		{
			for (int j = 1; j < s; j++)
			{
				stemp = (i * (x + 100)) / 100 + (j * (x + 100)) / 100;

				if (stemp == s)
				{
					stemp2 = (i * (y + 100)) / 100 + (j * (y + 100)) / 100;
					
					if (stemp2 > stemp3)
					{
						stemp3 = stemp2;
					}
				}
			}
		}

		printf("%d\n", stemp3);
	}
	
	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<int> c(n);
  for (int i = 1; i < n; i++) {
    int m;
    cin >> m;
    c[m-1]++;
  }

  for (int i = 0; i < n; i++) {
    cout << c[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3976
//include---------------------------------------------------------------------------
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cctype>
#include<vector>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<bitset>
#include<map>
#include<algorithm>
#include<memory>

//using namespace-------------------------------------------------------------------
using namespace std;

//define,const----------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < n; i++)
const int INF = 1 << 25;
#define MAX_N 100

//global----------------------------------------------------------------------------
int numbar_A, numbar_B;
int a, b;

//function--------------------------------------------------------------------------
int main(){
	scanf("%d %d", &numbar_A, &numbar_B);
	if(numbar_A < numbar_B)
		swap(numbar_A, numbar_B);
	a = numbar_A;
	b = numbar_B;
	while(a % b != 0){
		a = a % b;
		swap(a, b);
	}
	printf("%d\n", b);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define Rep(i, s, n) for (ll i = (ll)s; i < (ll)n; i++)
typedef long long ll;

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

    int n;
    string s, res = "No";
    cin >> n >> s;
    if (n % 2 == 0) {
        if (s.substr(0,n/2) == s.substr(n/2, n/2)) res = "Yes";
    }
    cout << res << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a,b,k;
    cin>>a>>b>>k;
    a-=k;
    if(a+b<0)cout<<"0 0"<<endl;
    else if(a<0) cout<<"0 "<<b+a<<endl;
    else cout<<a<<" "<<b<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>

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

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

int main() {
  int a,b;
  cin >> a >> b;
  if (max(a,b) <= 8) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    vector<int> ans(N);
    rep(i, N) ans[a[i]-1] = i+1;
    rep(i, N-1) cout << ans[i] << ' ';
    cout << ans[N-1] << endl;


	return 0;
}



Measured memory_bytes: 1664