akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int h,a;cin>>h>>a;
    int c =0;
    while(h>0){
        c++;
        h-=a;
    }
     cout<<c<<endl;
}

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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const ll llinf = LLONG_MAX;
const ull ullinf = ULLONG_MAX;

int n;
ll m;
string s;
ll a[100011];
ll b[100011];
map<int, vector<ll> > mp;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;
#endif
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  for (int i = 1; i < n; i++) {
    a[i] += a[i - 1];
  }
  for (int i = 0; i < n; i++) {
    mp[a[i] % m].push_back(a[i]);
  }
  ll res = 0;
  ll pre = 0;
  for (int i = 0; i < n; i++) {
    res += mp[pre % m].size();
    //cout << mp[pre % m].size() << endl;
    //cout << "erase:" << *mp[a[i] % m].begin() << endl; 
    mp[a[i] % m].erase(mp[a[i] % m].begin());
    pre = a[i];
    
  }
  cout << res << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}


Measured memory_bytes: 9088
fn main() {
    let (n, q): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut uf = UnionFind::new(n);
    for _ in 0..q {
        let (com, x, y) = (read::<usize>(), read(), read());
        if com == 0 {
            uf.union(x, y);
        } else {
            if uf.same(x, y) {
                println!("{}", 1);
            } else {
                println!("{}", 0);
            }
        }
    }
}

//
/*
中身はi64だけど外はusizeにしてみる
*/

// ============
#[derive(Debug)]
struct UnionFind {
    // size= 親なら負のサイズ、子なら親
    // number= 集合の数
    table: Vec<i64>,
    number: usize,
}
impl UnionFind {
    fn new(n: usize) -> Self {
        let table = vec![-1; n];
        UnionFind {
            table: table,
            number: n,
        }
    }
}
impl UnionFind {
    fn root(&mut self, x: usize) -> usize {
        let par = self.table[x];
        if par < 0 {
            x
        } else {
            let tmp = self.root(par as usize);
            self.table[x] = tmp as i64;
            tmp
        }
    }
    fn same(&mut self, a: usize, b: usize) -> bool {
        self.root(a) == self.root(b)
    }

    fn union(&mut self, a: usize, b: usize) -> () {
        let a_root = self.root(a);
        let b_root = self.root(b);

        if a_root == b_root {
            return ();
        }
        // 負なので小さい法が大きい. 大きい方につける
        if self.table[a_root] > self.table[b_root] {
            self.table[b_root] += self.table[a_root];
            self.table[a_root] = b_root as i64;
        } else {
            self.table[a_root] += self.table[b_root];
            self.table[b_root] = a_root as i64;
        }
        self.number -= 1;
    }
    // 親のサイズを返す
    fn size(&mut self, x: usize) -> usize {
        let ri = self.root(x);
        -self.table[ri] as usize
    }
    fn count(&self) -> usize {
        self.number
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { 1, -1, 0, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, 0, 1, -1 , 1,  1, -1, -1 };
static const char Move[] = { 'E', 'W', 'N', 'S' };

int N, sum_tree[ 101 ][ 101 ], tree_mp[ 101 ][ 101 ], X, Y, ans = 0, W, H;

int main() {
	while ( ~scanf( "%d", &N ) && N ) {
		scanf( "%d %d", &W, &H );
		for ( int i = 0; i < N; i++ ) {
			scanf( "%d %d", &X, &Y );
			tree_mp[ Y ][ X ]++;
		}
		for ( int i = 1; i <= H; i++ ) {
			for ( int j = 1; j <= W; j++ ) {
				sum_tree[ i ][ j ] = sum_tree[ i - 1 ][ j ] + sum_tree[ i ][ j - 1 ] - sum_tree[ i - 1 ][ j - 1 ] + tree_mp[ i ][ j ];
			}
		}
		scanf( "%d %d", &X, &Y );
		for ( int i = Y; i <= H; i++ ) {
			for ( int j = X; j <= W; j++ ) {
				ans = max( ans, sum_tree[ i ][ j ] - sum_tree[ i - Y ][ j ] - sum_tree[ i ][ j - X ] + sum_tree[ i - Y ][ j - X ] );
			}
		}
		printf( "%d\n", ans );
		ans = 0;
		memset( tree_mp, 0, sizeof( tree_mp ) );
		memset( sum_tree, 0, sizeof( sum_tree ) );
	}
	return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)


int main() {
    string gen;
    while (cin >> gen && gen != "#") {
        int a, b, c; cin >> a >> b >> c;
        //?
        if (a > 31 || (a == 31 && b >= 5)) {
            out("?" << " " << a - 30 << " " << b << " " << c);
        } else {
            out("HEISEI " << a << " " << b << " " << c);
        }
    }
}



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

int main(){
  int A, B;
  int N = 0;
  cin >> A >> B;
  for(int i = 0; i < B - A + 1; i++){
    int s = A;
    int a, b, d, e;
    int x;
    s += i;
    a = s % 10;
    b = s % 100 / 10;
    d = s % 10000 / 1000;
    e = s / 10000;
    if (a == e && b == d){
     N ++;
    }
  }
  cout << N << endl;
}

Measured memory_bytes: 256
import sys
a=int(input())
for i in range(151):
  b=i**5-a
  c=abs(b)
  j=0
  while j**5<=c:
    if j**5==c:
      if b>=0:
        print(i,j)
        sys.exit()
      else:
        print(i,-j)
        sys.exit()
    j+=1
      
    

Measured memory_bytes: 63792
#include <iostream>

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using namespace std;

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int N;

    cin >> N;
    cout << N * N * N << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    string s; cin >> s;
    vector<ll> ss(26, 0);
    rep(i, s.length()){
        ss[s[i] - 'a']++;
    }
    string st = s;
    if(s.length() < 26){
        char v = ' ';
        rep(i, ss.size()) if(ss[i]==0){ v = i + 'a'; break;}
        cout << s << v << endl;
    }else{
        vector<ll> tmp;
        for(ll i = s.length()-1; i >= 0; --i){
            if(i == s.length()){
                tmp.push_back(s[i]);
                continue;
            }
            if(s[i] > s[i+1]){
                tmp.push_back(s[i]);
            }else{
                tmp.push_back(s[i]);
                sort(tmp.begin(), tmp.end());
                auto it = find(tmp.begin(), tmp.end(), s[i]);
                s[i] = *(++it);
                s.erase(s.begin()+i+1, s.end());
                break;
            }

        }
        if(s == st) cout << -1 << endl;
        else cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 256
class union_find:

    def __init__(self, n):
        self.n = n
        self.par = [-1] * n

    def root(self, x):
        if self.par[x] < 0:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return

        if self.par[x] > self.par[y]:
            x, y = y, x

        self.par[x] += self.par[y]
        self.par[y] = x
        return

    def sizeof(self, x):
        return -par[root(x)]

n, m = map(int, input().split())
p = list(map(int, input().split()))

uf = union_find(n)

for i in range(m):
    x, y = map(int, input().split())
    uf.unite(x-1, y-1)

cnt = 0
for i in range(len(p)):
    if uf.same(i, p[i]-1):
        cnt += 1

print(cnt)

Measured memory_bytes: 13812
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int n;
    int s = 0;

    scanf ( "%d", &n );
    if ( !n ) break ;

    for ( i = 1; i * i <= n; ++i )
    {
      if ( i * i == n && !( n % i ) )
      {
        s += i;
      }
      else if ( !( n % i ) )
      {
        s += i + ( n / i );
      }
    }
    s -= n;

    if ( n > s )
    {
      puts ( "deficient number" );
    }
    else if ( n < s )
    {
      puts ( "abundant number" );
    }
    else
    {
      puts ( "perfect number" );
    }
  }

  return ( 0 );
}

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

const int Val=256;

long long int square(long long int val){return val*val;}

int main(){
  int n,m;
  while(cin>>n>>m,n){
    vector<int> c(m);
    for(int i=0;i<m;i++) cin>>c[i];
    vector<int> x(n);
    for(int i=0;i<n;i++) cin>>x[i];
    vector<vector<long long int>> dp(n+1,vector<long long int>(Val,(long long int)(1e13)));
    dp[0][128]=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<Val;j++){
	//renew dp[i+1][j]
	for(int k=0;k<m;k++){
	  if(0<=j-c[k] && j-c[k]<Val) {dp[i+1][j]=min(dp[i+1][j],dp[i][j-c[k]]+square(x[i]-j));}
	  if(j==0){
	    for(int r=0;r<=-c[k];r++){
	      dp[i+1][j]=min(dp[i+1][j],dp[i][r]+square(x[i]-j));
	    }

	  }
	  if(j==Val-1){
	    for(int r=Val-1;r>=Val-1-c[k];r--){
	      dp[i+1][j]=min(dp[i+1][j],dp[i][r]+square(x[i]-j));
	    }
	  }
	}
      }
    }
    cout<<*min_element(dp[n].begin(),dp[n].end())<<endl;

  }
  
  return 0;
}

Measured memory_bytes: 43764
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int n;
bool used[500001];
int cmp[500001];
vector<int> g[500001], gr[500001];
vector<int> vs;

void dfs(int x){
	used[x]=1;
	for(auto y:g[x]){
		if(!used[y]) dfs(y);
	}
	vs.push_back(x);
}
 
void rdfs(int v, int k){
	used[v]=1;
	cmp[v]=k;
	for(auto y:gr[v]){
		if(!used[y]) rdfs(y, k);
	}
}
int scc(){
	fill(used, used+n, 0);
	vs.clear();
	for(int i=0; i<n; i++){
		if(!used[i]) dfs(i);
	}
	fill(used, used+n, 0);
	int k=0;
	for(int i=vs.size()-1; i>=0; i--){
		if(!used[vs[i]]) rdfs(vs[i], k++);
	}
	return k;
}
int dp[500010];
int solve(int x){
    if(dp[x]>=0) return dp[x];
    int ret=0;
    for(auto y:g[x]){
        ret=max(ret, solve(y)+1);
    }
    return dp[x]=ret;
}
int main()
{
    string s, t; cin>>s>>t;
    n=s.size();
  int m=t.size();
    string s0=s;
    while(s0.size()<t.size()+s.size()) s0+=s;
    ll bs[2000020];
    bs[0]=0;
    ll b=67;
    ll bp=1;
    for(int i=0; i<s0.size(); i++){
        bs[i+1]=(bs[i]+bp*s0[i])%MOD;
        bp=bp*b%MOD;
    }
    bp=1;
    ll bt=0;
    for(int i=0; i<m; i++){
        (bt+=bp*t[i])%=MOD;
        bp=bp*b%MOD;
    }
    bp=1;
    int nx[500010];
    for(int i=0; i<n; i++){
        if((bs[i+m]-bs[i]+MOD)%MOD==bt*bp%MOD){
            if(i==(i+m)%n){
            cout<<-1<<endl;
            return 0;
          }
            g[i].push_back((i+m)%n);
            gr[(i+m)%n].push_back(i);
          //cout<<i<<" "<<(i+m)%n<<endl;
        }
        bp=bp*b%MOD;
    }
    int k=scc();
    if(k<n){
        cout<<-1<<endl;
        return 0;
    }
    fill(dp, dp+n, -1);
    int ans=0;
    for(int i=0; i<n; i++){
        ans=max(ans, solve(i));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 98608
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;
    
    map<ll, ll> mp;
    rep(i, n) {
        ll a;
        cin >> a;
        mp[a]++;
    }

    ll ans = 0;
    for(auto p : mp) {
        if(p.second%2 == 1) {
            ans++;
        }
    }

    out(ans);
    re0;
}

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

int main() {
  int n,t = 0;
  cin >> n;
  vector<pair<int,int>>data(n);
  for(int i = 0;i < n;i++){
    int a,b;
    cin >> a >> b;
    data[i].first = b;
    data[i].second = a;
  }
  sort(data.begin(),data.end());
  for(int i = 0;i < n;i++){
    t += data[i].second;
    if(data[i].first < t){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,m,q,a[100],b[100],c[100],d[100],ans=0;
vector <int> v;

void dfs(int pos,int x)
{
	if(pos==n)
	{
		int res=0;
		rep(i,q) if(v[b[i]]-v[a[i]]==c[i]) res+=d[i];
		ans=max(ans,res);
		return;
	}
	for(int i=x;i<=m;i++)
	{
		v.pb(i);
		dfs(pos+1,i);
		v.pop_back();
	}
}

int main()
{
	cin>>n>>m>>q;
	rep(i,q)
	{
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		a[i]--;
		b[i]--;
	}
	dfs(0,1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3584
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

const int MAX = 1000000;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N),cnt(MAX+1);
    rep(i,N) {
        cin >> A[i];
        cnt[A[i]]++;
    }

    vector<int> check(MAX+1,1);
    for (int i = 1; i <= MAX; i++) {
        if (cnt[i]) {
            if (cnt[i] >= 2) check[i] = 0;
            for (int j = 2; j*i <= MAX; j++) {
                check[j*i] = 0;
            }
        }
    }

    int ans = 0;
    rep(i,N) ans += check[A[i]];

    cout << ans <<ln;
}

Measured memory_bytes: 11860
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	ll a,b;
};


ll calc(ll x,ll y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}


Info func(ll H,ll W){

	ll num;
	if(H >= W){
		num = calc(H,W);
	}else{
		num = calc(W,H);
	}

	if(num == 1){

		ll S = H*W;

		Info ret;
		if(H%2 == 0 || W%2 == 0){
			ret.a = 1;
			ret.b = 1;
		}else{
			ret.a = (S)/2+1;
			ret.b = (S)/2;
		}
		return ret;
	}else{
		return func(H/num,W/num);
	}
}


int main(){

	int T;
	scanf("%d",&T);

	ll H,W;

	Info ret;

	for(int loop = 0; loop < T; loop++){

		scanf("%lld %lld",&H,&W);
		ret = func(H,W);
		printf("%lld %lld\n",ret.a,ret.b);
	}

	return 0;
}



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

class Main {
	public static void main(String[] $) {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		boolean ans=false;
		int[][] D=new int[N][2];
		for (int i=0;i<N;++i) {
			D[i][0]=sc.nextInt();
			D[i][1]=sc.nextInt();
		}
		for (int i=0;i+2<N;++i) {
			ans|=D[i][0]==D[i][1]&&D[i+1][0]==D[i+1][1]&&D[i+2][0]==D[i+2][1];
		}
		System.out.println(ans?"Yes":"No");
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}


Measured memory_bytes: 35948
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
d = gets.chomp.to_i
c = gets.chomp.split.map(&:to_i)
s = []
d.times do
  s.push gets.chomp.split.map(&:to_i)
end

lasts = Array.new(26, 0)
d.times do |i|
  minusmax = 0
  minusmaxi = 0
  26.times do |j|
    minusscore = c[j] * (i + 1 - lasts[j])
    if minusmax < minusscore
      minusmax = minusscore
      minusmaxi = j
    end
  end

  getscore = s[i].max
  minusmax *= 26

  if getscore < minusmax
    type = minusmaxi
  else
    type = s[i].index(getscore)
  end
  lasts[type] = i + 1
  puts type + 1
end



Measured memory_bytes: 14624
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	map<string, int> m;
	
	string str;
	cin >> str;
	
	int K;
	cin >> K;
	
	for(int i = 1; i <= K; i++){
		for(int j = 0; j < str.size() - i + 1; j++){
			m[str.substr(j, i)] = 1;
		}
	}
	
	map<string, int>::iterator ite;
	
	int cnt = 0;
	
	for(ite = m.begin(); ite != m.end(); ite++){
		cnt++;
		if(cnt == K){
			cout << ite -> first << endl;
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 1920
#include <cstdio>
#include <cctype>
#include <cassert>
#include <string>

int parse(const std::string& s, size_t& i) {
  if (s[i] == '*') {
    ++i;
    return 0;
  }

  assert(s[i] == '(');
  ++i;
  int res = 0;
  while (s[i] != ')') {
    if (s[i] == '*') {
      res = 1;
      ++i;
    } else {
      int tmp = parse(s, i);
      if (tmp) res += ++tmp;
    }
  }
  assert(s[i] == ')');
  ++i;
  return res;
}

int main() {
  char buf[128];
  scanf("%s", buf);
  std::string s = buf;
  size_t i = 0;

  while (i != s.length()) {
    int res = parse(s, i);
    if (res) return !printf("%d\n", res);
  }
  puts("0");
}



Measured memory_bytes: 2840
import java.util.Scanner;

public class Main {
    static public void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        scan.close();

        if (n < 1000) {
            System.out.println("ABC");
        } else {
            System.out.println("ABD");
        }
    }
}


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

int main() {
  int M, D, M_, D_;

  cin >> M;
  cin >> D;
  cin >> M_;
  cin >> D_;
  
  if(M != M_ && D != D_ -1){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int w, h, n;
    cin >> w >> h >> n;
    int lx, ly, rx, ry;
    lx = 0, ly = 0, rx = w, ry = h;
    for (int i = 0; i < n; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        switch (a) {
            case 1:
                lx = max(lx, x);
                break;
            case 2:
                rx = min(rx, x);
                break;
            case 3:
                ly = max(ly, y);
                break;
            case 4:
                ry = min(ry, y);
                break;
        }
    }
    if (lx < rx && ly < ry) {
        cout << (rx-lx) * (ry-ly) << endl;
    }
    else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  vvl d = vv(n, 2, 0, ll), c = vv(m, 2, 0, ll);
  re(i, n) std::cin >> d[i][0] >> d[i][1];
  re(i, m) std::cin >> c[i][0] >> c[i][1];

  re(i, n){
    ll dis = 10000000000, idx = -1;
    re(j, m){
      if(dis>abs(d[i][0]-c[j][0])+abs(d[i][1]-c[j][1])) {
        dis = abs(d[i][0]-c[j][0])+abs(d[i][1]-c[j][1]);
        idx=j;
      }
    }
    std::cout << idx+1 << '\n';
  }
}


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

int main() {
    long n, min, max, sum = 0, i;
    cin >> n;
    long a[n];
    
    for( i = 0; i < n; i++ ) {
        cin >> a[i];
        if( i == 0 ) {
            min = a[i];
            max = a[i];
        }
        if( a[i] < min ) {
            min = a[i];
        }else if( a[i] > max ) {
            max = a[i];
        }
        sum += a[i];
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3164
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int num;
    while(1){
        int a_score=0;
        int b_score=0;
        scanf( "%d", &num );
        if(num==0)break;
        for(int i=0;i<num;i++){
            int a_card,b_card;
            scanf("%d %d",&a_card,&b_card);
            if(a_card>b_card){a_score+=a_card+b_card;}
            else if(a_card==b_card){a_score+=a_card;b_score+=b_card;}
            else b_score+=a_card+b_card;
        } 
        cout<<a_score<<" "<<b_score<<endl;
    }
    
}

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

using namespace std;
int a[100005];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	long long ans=0;
	for(int i=0;i<n;i++){
		if(a[i]==0)continue;
		if(a[i]%2!=0){
			if(a[i+1]>0){
				a[i]--,a[i+1]--,ans++;
			}
		}
	}
	for(int i=0;i<n;i++)ans+=a[i]/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
    #define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
    #define rep(i,n) REP(i,0,n)
    typedef long long ll;
    using namespace std;
     
    ll x;
    int main(){
      cin>>x;
      if(x>=1200){
        cout<<"ARC"<<endl;
      }else{
        cout<<"ABC"<<endl;
      }
     
     
    }

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N;
ll a[100010];
bool f;
int main() {
    cin>>N;
    REP(i,0,N){
        cin>>a[i];
    }
    REP(i,0,N){
        if(a[i]%2){
            f=true;
        }
    }
    if(f) p("first");
    else p("second");
    return 0;
}


Measured memory_bytes: 1024
//CODE FESTIVAL 2017 qual C
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main(ll argc, char* argv[]) {
	string s;
	cin >> s;
	string excludeX;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i]!='x')
		{
			excludeX += s[i];
		}
	}
	for (int i = 0; i < excludeX.size()/2; i++)
	{
		if (excludeX[i]!=excludeX[excludeX.size()-i-1])
		{
			cout << -1 << endl;
			return 0;
		}
	}
	ll leftSide = 0;
	ll rightSide = s.size()-1;
	ll answer = 0;
	while (leftSide<rightSide)
	{
		if (s[leftSide]==s[rightSide])
		{
			leftSide++;
			rightSide--;
		}
		else
		{
			answer++;
			if (s[leftSide] == 'x')
			{
				leftSide++;
			}
			else
			{
				rightSide--;
			}
		}
	}


	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n = ini()
ans = True
prevt = 0
prevx = 0
prevy = 0
for _ in range(n):
    t, x, y = inm()
    totalt = t - prevt
    totald = abs(x - prevx) + abs(y - prevy)
    if totald > totalt or (totald % 2) != (totalt % 2):
        ans = False
        break
    prevt = t
    prevx = x
    prevy = y
print("Yes" if ans else "No")

Measured memory_bytes: 9048
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int N_MAX=90001;
int main()
{
  int h,w,d,q,l,r,t,i,j;
  int a[N_MAX],b[N_MAX],c[N_MAX];
  cin >> h >> w >> d;
  for(i=0;i<h;i++)
    for(j=0;j<w;j++){
      cin >> t;
      a[t]=i;
      b[t]=j;
    }
  fill(c,c+d+1,0);
  for(i=d+1;i<=h*w;i++)
    c[i]=c[i-d]+abs(a[i]-a[i-d])+abs(b[i]-b[i-d]);
  cin >> q;
  for(i=0;i<q;i++){
    cin >> l >> r;
    cout << c[r]-c[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 4656
#include <iostream>
#include <algorithm>
#include <array>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;
int amin(int* array, int length) {
	int ret=INF;
	rep(i, 0, length)
		ret = min(ret, array[i]);
	return ret;
}

int main() {
	int a[6];
	rep(i, 0, 6)
		cin >> a[i];
	int x, y;
	x = amin(a, 4);
	y = amin(a + 4, 2);
	int sum = 0;
	rep(i, 0, 6)
		sum += a[i];
	cout << sum - x - y << endl;
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin >> s >> t;
    
    string result = "No";
    if(s == t.substr(0,s.size())) {
        result = "Yes";
    }
    
    cout << result << "\n";
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
using namespace std;
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repb(i,r,l) for(int i=r;i>l;i--)
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator

void solve() {
    ve<int> mp(26, 0);
    string s;
    cin>>s;
    for(char i:s) {
        mp[i-'a']++;
        if(mp[i-'a']>1) {
            cout<<"no\n";
            return;
        }
    }
    cout<<"yes\n";
}

int main() {
    solve();
    return 0;
}

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

using ll = long long;

constexpr int mod = 1e9 + 7;

int main() {
    int n; cin >> n;
    vector<vector<int>> g(n);
    for(int i = 0; i < n - 1; ++i) {
        int x, y; cin >> x >> y;
        g[x - 1].push_back(y - 1);
        g[y - 1].push_back(x - 1);
    }

    // 1: black
    vector<vector<ll>> dp(n, vector<ll>(2));
    function<void(int, int)> solve = [&] (int v, int p) {
        dp[v][0] = dp[v][1] = 1;
        for(auto to : g[v]) {
            if(to == p) continue;
            solve(to, v);
            (dp[v][0] *= (dp[to][1] + dp[to][0])) %= mod;
            (dp[v][1] *= dp[to][0]) %= mod;
        }
    };
    solve(0, -1);

    cout << (dp[0][0] + dp[0][1]) % mod << endl;
}


Measured memory_bytes: 19584
#include <stdio.h>
int main(void){
int a[3];
int b,c,d;
for(d = 0;d < 3;d++){
scanf("%d",&a[d]);
}
for(b=0;b<2;b++){
for(c=b+1;c<=2;c++){
if(a[b]>a[c]){
d = a[b];
a[b] = a[c];
a[c] = d;
}
}
}
printf("%d %d %d\n",a[0],a[1],a[2]);
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(int i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1<<30;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
ll jou(ll n, ll x){
  ll res = 1;
  while(n){
    if(n & 1) res = res*x % mo;
    x = x*x % mo;
    n >>= 1;
  }
  return res;
}
int main(){
  int n;  cin >> n;
  vector<int> v(n), a(n,0);
  int ma = 0;
  rep(i,0,n){
    cin >> v[i];
    a[v[i]]++;
    ma = max(ma, v[i]);
  }
  ll ans = 1;
  rep(i,0,ma){
    if(!a[i] || !a[i+1]||a[0]!=1||v[0]!=0){
      cout << 0 << endl;
      return 0;
    }
    ans *= jou(a[i+1], a[i]);
    ans %= mo;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    string S;
    cin >> S;

    int idx = 1, ans = 1;
    string prev = S.substr(0, 1);
    while(idx < S.length()) {
        string cur = S.substr(idx++, 1);
        while(idx < S.length() && prev == cur) {
            cur.append(S.substr(idx++, 1));
        }
        // idx += len;
        if(prev != cur)
            ans++;
        prev = cur;
    }

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

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

int main(){
  int N;
  cin >> N;
  char a[4]={'P','W','G','Y'};
  int num[4]={};
  for(int i=0;i<N;i++){
    char d;
    cin >> d;
    for(int j=0;j<4;j++){
    	if(d==a[j])
          num[j]++;
    }
  }
  if(num[3]>0)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}

Measured memory_bytes: 256
N = int(input())
A_list = []
A_list.append(list(map(int, input().split())))
A_list.append(list(map(int, input().split())))


candy_max_count = 0
for switch_path_index in range(N):
    candy_count = sum(A_list[0][0:switch_path_index + 1]) + sum(A_list[1][switch_path_index:N])
    candy_max_count = max(candy_max_count, candy_count)

print(candy_max_count)

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

using namespace std;

int main()
{
    int N;
    int A,B,C,D;
    vector<pair<int,int> > P;
    vector<int> R;

    cin >> N;

    P.push_back({1000000000,-1});
    R.resize(N+1);

    for(int i=1; i<=N; ++i) P.push_back({0,i});

    for(int i=0; i<N*(N-1)/2; ++i) {
        cin >> A >> B >> C >> D;
        if(C==D) {
            ++P[A].first;
            ++P[B].first;
        } else if(C>D) {
            P[A].first+=3;
        } else {
            P[B].first+=3;
        }
    }

    sort(P.rbegin(),P.rend());

    int rnk=1;

    R[P[1].second]=1;

    for(int i=2; i<=N; ++i) {
        if(P[i-1].first!=P[i].first) rnk=i;
        R[P[i].second]=rnk;
    }

    for(int i=1; i<=N; ++i) {
        cout << R[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>


using namespace std;

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

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=200005;

int segsiz;
int mn[MAXN*4];

int Query(int pos,int L=1,int R=segsiz,int id=1)
{
    if(L==R)
        return mn[id];
    int ret=mn[id],mid=(L+R)/2;
    if(pos<=mid)
        return min(ret,Query(pos,L,mid,id*2));
    return min(ret,Query(pos,mid+1,R,id*2+1));
}
void Insert(int l,int r,int v,int L=1,int R=segsiz,int id=1)
{
    if(l>r)
        return;
    if(l<=L&&R<=r)
    {
        mn[id]=min(mn[id],v);
        return;
    }
    int mid=(L+R)/2;
    if(l<=mid)
        Insert(l,r,v,L,mid,id*2);
    if(mid<r)
        Insert(l,r,v,mid+1,R,id*2+1);
}

int N,M,K,A[MAXN],B[MAXN];
int sumA[MAXN];
int L[MAXN],R[MAXN];
int val[MAXN];
long long dp[MAXN];

int main()
{
    scanf("%d%d",&N,&K);
    long long sum=0;
    for(int i=1;i<=N;i++)
    {
        scanf("%d%d",&A[i],&B[i]);
        if(B[i]==1&&2*A[i]>K)
        {
            puts("-1");
            return 0;
        }
        sum+=A[i];
        sumA[i]=(sumA[i-1]+A[i])%K;
    }
    for(int i=1;i<=N;i++)
    {
        if(B[i]==1)
        {
            L[i]=2*(K-sumA[i-1])%K;
            R[i]=2*(K-sumA[i])%K;
        }
        else
            L[i]=0,R[i]=K-1;
    }
    for(int i=1;i<=N;i++)
        val[i*2-1]=L[i],val[i*2]=R[i];
    sort(val+1,val+2*N+1);
    M=unique(val+1,val+2*N+1)-val-1;
    for(int i=1;i<=N;i++)
    {
        L[i]=lower_bound(val+1,val+M+1,L[i])-val;
        R[i]=lower_bound(val+1,val+M+1,R[i])-val;
    }
    segsiz=M;
    memset(mn,0x3F,sizeof mn);
    for(int i=N;i>=1;i--)
    {
        int j=Query(L[i]);
        if(j==0x3F3F3F3F)
            dp[i]=0;
        else
            dp[i]=dp[j]+(val[L[j]]-val[L[i]]+K)%K;
        if(L[i]<=R[i])
        {
            Insert(1,L[i]-1,i);
            Insert(R[i]+1,M,i);
        }
        else
            Insert(R[i]+1,L[i]-1,i);
    }
    long long ans=0x3F3F3F3F3F3F3F3FLL;
    for(int i=1;i<=M;i++)
    {
        int j=Query(i);
        if(j==0x3F3F3F3F)
            ans=0;
        else
            ans=min(ans,1LL*(val[L[j]]-val[i]+K)%K+dp[j]);
    }
    ans=ans+2LL*sum;
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 8704
n,m,k = map(int, input().split())

g = [[] for i in range(n+1)]
f = [0]*(n+1)
b = []
for i in range(m):
  u, v = map(int, input().split())
  g[u].append(v)
  g[v].append(u)
  f[u] += 1
  f[v] += 1
for i in range(k):
  b.append(map(int, input().split()))
count = 0
renketu_list = [-1]*(n+1)
renketu_size = [0]
stack = []
for i in range(1, n+1):
  if renketu_list[i] == -1:
    count += 1
    renketu_list[i] = count
    renketu_size.append(1)
    while len(g[i]) > 0:
      stack.append(g[i].pop())
    while len(stack) > 0:
      v=stack.pop()
      if renketu_list[v] == -1:
        renketu_list[v] = count
        renketu_size[count] += 1
        while len(g[v])>0:
          stack.append(g[v].pop())

s = [0] * (n+1)
for i in range(1, n+1):
  s[i] += renketu_size[renketu_list[i]] - f[i] - 1
  
for i in range(k):
  u, v = b[i]
  if renketu_list[u] == renketu_list[v]:
    s[u] -= 1
    s[v] -= 1

print(" ".join(list(map(str, s[1:]))))
  


Measured memory_bytes: 69892
#include<stack>
#include<cstdio>
using namespace std;
const int N = 4005;
int ans[N];

inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

bool query(int x, int y)
{
	printf("? %d %d\n", x, y);
	fflush(stdout);
	char s[3]; scanf("%s", s);
	return s[0] == 'Y';
}

int main()
{
	int a = read(), b = read();
	if (a <= b) return puts("Impossible"), 0;
	
	stack<int> Stack;
	for (int i = 0; i < a + b; ++i)
	{
		if (Stack.empty()) Stack.push(i);
		else
		{
			if (query(Stack.top(), i)) Stack.push(i);
				else Stack.pop();
		}
	}
	
	for (int i = 0; i < a + b; ++i) if (query(Stack.top(), i)) ans[i] = 1;
	printf("! ");
	for (int i = 0; i < a + b; ++i) printf("%d", ans[i]);
	return 0;
}


Measured memory_bytes: 724
#include<stdio.h>
int main(){
 int r, g ,b, n, s = 0;
 scanf("%d %d %d %d", &r, &g, &b, &n);
 for(int i = 0; i <= n; i += r)
  for(int j = i; j <= n; j += g)
   if((n - j) % b == 0) s++;
 printf("%d", s);
}

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

int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a+b) cout<<min(k,a);
	else cout<<a-(k-a-b);	
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll N;
    cin>>N;
    vi A(N);
    REP(i,N)cin>>A[i];
    sort(A.begin(),A.end(),greater<ll>());
    ll a=0,b=0,prev=-1;
    REP(i,N){
        if(prev==A[i]){
            if(a<=0)a=A[i];
            else{
                b=A[i];
                break;
            }
            prev=-1;
        }else{
            prev=A[i];
        }
    }
    cout<<a*b<<endl;
    return 0;
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e6 + 100;
int T;
int n, m;

struct graph {
    int head[N], nxt[N << 1], to[N << 1], w[N << 1], sz;

    void init() { memset(head, 0, sizeof(head)), sz = 0; }

    graph() { init(); }

    void push(int a, int b, int c) {
        nxt[++sz] = head[a], to[sz] = b, w[sz] = c, head[a] = sz;
    }

    int &operator[](const int a) { return to[a]; }
} g;

int vis[N];

void dfs(int u) {
    vis[u] = 1;
    for (int i = g.head[u]; i; i = g.nxt[i]) {
        if (!vis[g[i]])dfs(g[i]);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int a, b;
        cin >> a >> b;
        g.push(a, b, 0);
        g.push(b, a, 0);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
            dfs(i);
            ans++;
        }
    }
    cout << ans-1;
    return 0;
}

Measured memory_bytes: 11008
#include <stdio.h>

#define MAX 100
#define INF 100100

#define WHITE 0
#define GRAY 1
#define BLACK 2

int M[MAX][MAX];
int n;

void dijkstra() {
  int u, min;
  int d[MAX], color[MAX];
  int i;

  for (i = 0; i < n; i++) {
    d[i] = INF;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;

  while (1) {
    min = INF;
    u = -1;
    for (i = 0; i < n; i++) {
      if (min > d[i] && color[i] != BLACK) {
        u = i;
        min = d[i];
      }
    }

    if (u == -1) break;
    color[u] = BLACK;
    for (i = 0; i < n; i++) {
      if (color[i] != BLACK && M[u][i] != INF) {
        if (d[i] > d[u] + M[u][i]) {
          d[i] = d[u] + M[u][i];
          color[i] = GRAY;
        }
      }
    }
  }

  for (i = 0; i < n; i++) {
    printf("%d %d\n", i, (d[i] == INF) ? -1 : d[i]);
  }
}

int main() {
  int i, j;
  int u, k, v, c;

  scanf("%d", &n);


  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      M[i][j] = INF;
    }
  }

  for (i = 0; i < n; i++) {
    scanf("%d %d", &u, &k);

    for (j = 0; j < k; j++) {
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}



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

int main() {
  char S;
  cin >> S;
  if (S == 'a' or S == 'i' or S == 'u' or S == 'e' or S == 'o' ){
    cout << "vowel"<<endl;
  }else{
    cout << "consonant" <<endl;
  }
}


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

int main() {

    string s; cin >> s;

    string ans = "";
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0) ans += s[i];
    }

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define drep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define MAGICLINE ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define se second
#define fs first
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, pair<int, int> > PII;
typedef priority_queue<PII,
                       vector<PII>,
                       greater<PII> > dijQ;

int main(){
    int n; cin >> n;
    int a1 = 0, b1 = 0, c1 = 0;
    rep(i, 0, n){
        int a2, b2, c2; cin >> a2 >> b2 >> c2;
        a2 += max(b1, c1);
        b2 += max(a1, c1);
        c2 += max(a1, b1);
        a1 = a2; b1 = b2; c1 = c2;
    }
    cout << max(a1, max(b1, c1)) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  int n, m;
  cin >> n >> m;
  if(n == m) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <string>
using namespace std;

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  int tf=0;
  int k = n;
  while(tf==0 && k>0){
    if(s[k-1] == '.') tf++;
    else k--;
  }
  int b[k+1];
  int w[k+1];
  b[k] = 0;
  w[k] = 0;
  int sa[k+1];
  int num_max=0;
  int num = k;
  for(int i=k-1; i>=0; i--){
    if(s[i] == '.'){
      w[i] = w[i+1]+1;
      b[i] = b[i+1];
    }
    else{
      w[i] = w[i+1];
      b[i] = b[i+1]+1;
    }
    sa[i] = b[i] - w[i];
    if(num_max < sa[i]){
      num_max = sa[i];
      num = i;
    }
  }
  cout << min(b[0]-b[num], w[0]-w[num]) + w[num] << endl;
  return 0;
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP(i, n) for(int i = 0; i < n; i++)
#define DUMP(range) do{for(auto& x:range){cout<<x<<' ';}cout<<endl;}while(0)

int N;
Int tot[51], pat[51];

Int eat(int n, Int x)
{
    Int ans = 0;
    if (x >= tot[n]) return pat[n];
    // B
    if (x == 0) return ans;
    x--;
    // L(n-1)
    if (x < tot[n-1]) return ans + eat(n-1, x);
    x -= tot[n-1];
    ans += pat[n-1];
    // P
    if (x == 0) return ans;
    x -= 1;
    ans += 1;
    // L(n-1)
    return ans + eat(n-1, x);
}

int main()
{
    Int X; cin >> N >> X;
    tot[0] = pat[0] = 1;
    for (int i = 1; i <= 50; i++) {
        tot[i] = 3 + 2 * tot[i-1];
        pat[i] = 1 + 2 * pat[i-1];
    }
    cout << eat(N, X) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 100000
#define MAX_M 100000
const int MAX = 100100;
const int MOD = 1000000007;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecbvecb vector<vector<bool>>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL<<60;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int main() {
  string a,b,ans="";
  cin>>a>>b;
  a=" "+a;
  b=" "+b;
  int dp[3300][3300],pre[3300][3300];
  for(int i=1;i<=a.size();i++){
    for(int j=1;j<=b.size();j++){
      if(a[i]==b[j]){
        dp[i][j]=dp[i-1][j-1]+1;
        pre[i][j]=1;
      }
      else{
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        if(dp[i-1][j]>dp[i][j-1]){
          pre[i][j]=2;
        }
        else{
          pre[i][j]=3;
        }
      }
    }
  }
  int si=a.size()-1,ti=b.size()-1;
  while(si>=1&&ti>=1){
    if(pre[si][ti]==1){
      ans+=a[si];
      si--,ti--;
    }
    else if(pre[si][ti]==2){
      si--;
    }
    else {
      ti--;
    }
  }
  reverse(all(ans));
  cout<<ans<<endl;
}


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

int main(){
    int X, A, B;
    cin >> X >> A >> B;
    int x = B - A;
    if(x <= 0){
        cout << "delicious" << endl;
    }else if(0 < x && x <= X){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
    return 0;
}

Measured memory_bytes: 256