akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
using namespace std;

//***********************************************************************

// hash struct for unordered_map
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void solve()
{
    ll n;
    cin >> n;
    vector<ll> v(n);
    ll allxor=0;
    for(int i=0;i<n;i++)
    {
        cin >> v[i];
        allxor^=v[i];
    }
    for(int i=0;i<n;i++)
    {
        cout << (allxor^v[i]) << " ";
    }
    cout  << endl;
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

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

int main () {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  while (1) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int a[3];
int main() {
	cin >> a[0] >> a[1] >> a[2];
	int s = a[0] * 4 + a[1] * 2 + a[2];
	if (s % 2 == 0 && s < 6) { cout << "Close" << endl; }
	else { cout << "Open" << endl; }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
typedef long long ll;
typedef unsigned long long ull;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = (a); i < (ll) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define MOD 1000000007
int dp[100005], alturas[100005];

void solve(int n)
{
    dp[0]=0;
    dp[1]=abs(alturas[1]-alturas[0]);
    forr(i,2,n)
    {
        dp[i]=min(dp[i-1]+abs(alturas[i]-alturas[i-1]),dp[i-2]+abs(alturas[i]-alturas[i-2]));
    }
    cout << dp[n-1] << "\n";
}


int main() {
    FIN;
    int n;
    cin >> n;
    forn(i,n) cin >> alturas[i];
    solve(n);
    return 0;
}


Measured memory_bytes: 1024
//INCLUDE
//------------------------------------------
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------
int main(void){
  string S;cin>>S;
  bool flag=false;
  REP(i,S.size()-1){
    if(S[i]!=S[i+1])flag=true;
  }
  cout<<(flag?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

x, y = inm()


def solve():
    if 4 * x - y < 0:
        return False
    if (4 * x - y) % 2 == 1:
        return False

    a = (4 * x - y) // 2
    return x - a >= 0


print("Yes" if solve() else "No")


Measured memory_bytes: 9124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.ArrayList;

public class Main
{
	static ArrayList<ArrayList<Integer>> tr =new ArrayList<>() ;
	static long dp[] ,sl[] ,fct[] ,md =1000000007l ;	static int n ,sz[] ;
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 	
		int i ,j ,k ;	n =fr.nextInt() ;	sz =new int[n] ;	dp =new long[n] ;	sl =new long[n] ;	fct =new long[n] ;
		for (i =0 ; i<n ; ++i) {
			dp[i] =sz[i] =1 ;	tr.add (new ArrayList<>()) ;
		}
		fct[0] =1l ;
		for (i =1 ; i<n ; ++i) {
			j =fr.nextInt()-1 ;	k =fr.nextInt()-1 ;	tr.get(j).add(k) ;	tr.get(k).add(j) ;
			fct[i] =(i * fct[i-1])%md ;
		}
		dfs (0,-1) ;	sl[0] =dp[0] ;
		for (i =0 ; i<tr.get(0).size() ; ++i)	rer (tr.get(0).get(i) , 0) ;
		for (i =0 ; i<n ; ++i)	op.println(sl[i]) ;
		op.flush();	op.close();
	}
	static void rer (int nd , int p) {
		long nm ,dn ,dm ;	nm =dn =1l ;	dm =sl[p] ;
		dn =((dn*fct[n-1])%md * dp[nd])%md ;	nm =(nm * (fct[n-1-sz[nd]]*fct[sz[nd]])%md)%md ;
		dm =(dm*nm)%md ;	dn =pow (dn,md-2,md) ;	dm =(dm*dn)%md ;

		nm =dn =1l ;	nm =(nm*dm)%md ;	dm =dp[nd] ;
		dn =(dn*fct[sz[nd]-1])%md ;	nm =(nm*fct[n-1])%md ;	dn =(dn*fct[n-sz[nd]])%md ;
		dm =(dm*nm)%md ;	dn =pow (dn,md-2,md) ;	dm =(dm*dn)%md ;	sl[nd] =dm ;

		int j ,k ;
		for (j =0 ; j<tr.get(nd).size() ; ++j) {
			k =tr.get(nd).get(j) ;	if (k==p)	continue;	rer (k,nd) ;
		}
	}
	static void dfs (int nd , int p) {
		int i ,j ;	long nm =1l ,dm =1l ;
		for (i =0 ; i<tr.get(nd).size() ; ++i) {
			j =tr.get(nd).get(i) ;	if (j==p)	continue;
			dfs (j,nd) ;	sz[nd] += sz[j] ;	nm =(nm*dp[j])%md ;	dm =(dm*fct[sz[j]])%md ;
		}
		nm =(nm*fct[sz[nd]-1])%md ;	dm =pow (dm,md-2,md) ;	nm =(nm*dm)%md ;	dp[nd] =nm ;
	}
	static long pow (long b , long e , long md) {
		if (e==0l)	return 1l;
		if (e==1l)	return b;
		long dm =pow(b,e/2l,md) ;	dm *= dm ;	dm %= md ;
		if ((e&1l)==1l)	{	dm *= b ;	dm %= md ;	}
		return dm ;
	}		
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

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

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

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

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

Measured memory_bytes: 94124
/*  ex3_3
    B30095    */
#include <stdio.h>

int main(void){
    int num, base, numOfDigits = 0;
    scanf("%d %d", &num, &base);

    while(num != 0){
        num /= base;
        numOfDigits++;
    }

    printf("%d", numOfDigits);

    return 0;
}

Measured memory_bytes: 128
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize, k: usize,
        a: [i64; n],
    }

    let mut ans = std::i64::MAX;
    for i in 0..n - k + 1 {
        let l = a[i];
        let r = a[i + k - 1];
        let l_first = (0 - l).abs() + (l - r).abs();
        let r_first = (0 - r).abs() + (l - r).abs();
        ans = min(ans, min(l_first, r_first));
    }
    println!("{}", ans);
}


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

using namespace std;

const long long M = 1000000007;

long long h,w,a,b;

long long mod_pow(long long a, long long b)
{
  if (b == 0) return 1;
  long long ret = mod_pow(a, b/2);
  ret = ret * ret % M;
  if (b % 2 == 1) ret = ret * a % M;
  return ret;
}

long long comb(long long a, long long b)
{
  if (b > a - b) return comb(a, a - b);

  long long num = 1;
  long long denom = 1;

  for (long i = 1; i <= b; i++) {
    num = num * (a - i + 1) % M;
    denom = denom * i % M;
  }

  return num * mod_pow(denom, M-2) % M;
}


int main()
{
  cin >> h >> w >> a >> b;
  long long result = 0;
  long long fst = comb(h - a + b - 2, b - 1);
  long long snd = comb(a + w - b - 1, a);
  for (int i = h - a; i >= 1; i--) {
    result = (result + fst * snd % M) % M;
    fst = fst * (i - 1) % M;
    fst = fst * mod_pow(i + b - 2, M - 2) % M;
    snd = snd * (h - i + w - b) % M;
    snd = snd * mod_pow(h - i + 1, M - 2) % M;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e18;
const ll mod=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    bool odd=false;
    rep(i,n){
        cin >> a[i];
        if(a[i]%2==1) odd=true;
    }
    if(odd) cout << "first" << endl;
    else cout << "second" << endl;
    return 0;
}


Measured memory_bytes: 4048
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
int dp[200][200][200];
int zero[200] , one[200];
int N;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int d , t , s;
  cin >> d >> t >> s;
  if(t * s >= d){
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }

}

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

struct edge {int /*from**/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const long long INf = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll

int n,k;

int b(int i){
    return i+k;
}

int a(int i){
    return i*2;
}

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

Measured memory_bytes: 256
//#include <cmath>
//#include <ctime>
#include <cstdio>
//#include <cstdlib>
//#include <cstring>

#include <map>
//#include <set>
//#include <queue>
//#include <string>
//#include <vector>
//#include <sstream>
//#include <iostream>
#include <algorithm>
//#include <functional>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const int MAXN = 200005;
const int P = 1000000007;
const int INF = 1000000007;
const double eps = 1e-6;

inline int getint() {
    int r = 0; bool b = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') b = false; c = getchar(); }
    while (c >= '0' && c <= '9') { r = (r<<1)+(r<<3) + c - '0'; c = getchar(); }
    return b ? r : -r;
}

map<int, int> m;
int a[MAXN];
int n, ans;

int main() {
    n = getint();
    for (int i = 1; i <= n; ++i) {
        a[i] = getint();
        ++m[a[i]];
    }
    sort(a + 1, a + n + 1);
    const int MX = 1<<30;
    for (int i = n; i >= 1; --i) {
        if (m[a[i]] > 0) {
            --m[a[i]];
            bool found = false;
            for (int j = MX; j > a[i]; j >>= 1) {
                if (m[j - a[i]] > 0) {
                    found = true;
                    --m[j - a[i]];
                    break;
                }
            }
            if (!found) ++m[a[i]];
            else ++ans;
        }
    }
    printf("%d", ans);
}


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

int main(){

int n;
cin >> n;
ll mod=1000000007;
ll a=1,b=1,c=1,ans=0;
rep(i,n){
    a = (a*10)%mod;
    b = (b*8)%mod;
    c = (c*9)%mod;
}
c = (c*2)%mod;
ans = ((a+b)%mod - c + mod)%mod;
cout << ans << endl;

}

Measured memory_bytes: 3604
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll a[100005], b[100005], c[100005];

int isOK_a(ll index, ll key)
{
  if (a[index] >= key)
    return 1;
  else
    return 0;
}
int isOK_c(ll index, ll key)
{
  if (c[index] <= key)
    return 1;
  else
    return 0;
}

ll binary_search(ll key, ll n, ll aorc)
{
  // a -> aorc=1, c -> aorc=0
  ll ng = -1, ok = n;
  while (llabs(ok - ng) > 1)
  {
    ll mid = (ng + ok) / 2;
    if (aorc)
    {
      if (isOK_a(mid, key))
        ok = mid;
      else
        ng = mid;
    }
    else
    {
      if (isOK_c(mid, key))
        ok = mid;
      else
        ng = mid;
    }
  }
  return ok;
}

int main()
{
  ll n, ans = 0;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++)
    scanf("%lld", a + i);
  for (int i = 0; i < n; i++)
    scanf("%lld", b + i);
  for (int i = 0; i < n; i++)
    scanf("%lld", c + i);
  sortup(a, n);
  sortup(b, n);
  sortdown(c, n);
  for (int i = 0; i < n; i++)
    ans += binary_search(b[i], n, 1) * binary_search(b[i], n, 0);
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3324
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int a,p;
int main(){
	cin>>a>>p;
	cout<<(a*3+p)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

class UnionFind {
public:
    vector<int> par;
    vector<int> rnk;
    vector<int> sze;

    UnionFind(ll n): par(n), rnk(n, 0), sze(n, 1) {
        for (ll i = 0; i < n; ++i) par[i] = i;
    }

    void init(int n) {
        for (int i = 0; i < n; i++) {
            par.resize(n);
            rnk.assign(n, 0);
            sze.assign(n, 1);
        }
    }

    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return 0;
        if (rnk[x] < rnk[y]) {
            sze[y] = sze[x] + sze[y];
            par[x] = y;
        }
        else {
            sze[x] = sze[x] + sze[y];
            par[y] = x;
            if (rnk[x] == rnk[y]) rnk[x]++;
        }
        return 1;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    bool size(int x) {
        return sze[find(x)];
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    UnionFind uf = UnionFind(200000);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        x[i]--;  y[i]--;
        uf.unite(x[i], y[i] + 100000);
    }

    vector<Pll> v(200000, Pll(0, 0));
    for (int i = 0; i < 200000; i++) {
        if (i < 100000) v[uf.find(i)].first++;
        else v[uf.find(i)].second++;
    }

    ll ans = 0;
    bool f[200000] = {};
    for (int i = 0; i < 200000; i++) {
        if (v[i].first >= 2 && v[i].second >= 2) {
            ans += v[i].first * v[i].second;
            f[i] = 1;
        }
    }
    
    for (int i = 0; i < n; i++) {
        if (uf.same(x[i], y[i] + 100000) && f[uf.find(x[i])]) {
            ans--;
        }
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  string s; cin >> s;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  
  // ll ans = 0;
  bool ok = false;
  int i;
  for(i = 0; i <  s.size(); i++) {
    if(s[i] == 'C') {
      ok = true;
      break;
    }
  }
  if(ok) {
    ok = false;
    for( ; i < s.size(); i++) {
      if(s[i] == 'F') ok = true;
    }
  }
  // cout << ans << endl;
  cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l[i];
    ssort(l);
    int ans = 0;
    rep (i,n) repSE(j,i+1,n) repSE(k,j+1,n) {
        if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
        if (l[i] + l[j] <= l[k]) continue;
        ans ++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3564
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    A = list(map(int, input().split()))

    A.append(0)
    min_, max_ = A[0], A[0]
    money = 1000
    for i in range(N + 1):
        if A[i] < max_:
            d, m = divmod(money, min_)
            money = d * max_ + m
            min_, max_ = A[i], A[i]
            continue
        min_ = min(min_, A[i])
        max_ = max(max_, A[i])
    print(money)


main()


Measured memory_bytes: 8988
#include<stdio.h>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#define INF 1e11;
using namespace std;
typedef long long ll;
struct edge{ll to,cost;};
typedef pair<ll,ll> pii;
ll solve();
void dijkstra(ll a);
void binary(ll a,ll b);
vector <edge> vec[100010];
ll D[100100];
vector <ll> road;
ll Cost[100100] = {0};
ll ANS = INF;

int N,M,C;

int main()
{
    scanf("%d%d%d",&N,&M,&C);
    for(int i = 0; i < M; i++)
    {
        int A,B,L;
        scanf("%d%d%d",&A,&B,&L);
        edge test1,test2;
        test1.to = B;test1.cost = L;
        test2.to = A;test2.cost = L;
        vec[A].push_back(test1);
        vec[B].push_back(test2);
    }
    printf("%lld\n",solve());
    return 0;
}

ll solve()
{
    dijkstra(1);
    for(int i = 0 ; i < N; i++)
    {
        road.push_back(D[i + 1]);
    }
    sort(road.begin(),road.end());
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < vec[i + 1].size(); j++)
        {
            if(D[vec[i + 1][j].to] > D[i + 1] ||
              (D[vec[i + 1][j].to] == D[i + 1] && i + 1 < vec[i + 1][j].to))
            {
                binary(D[vec[i + 1][j].to],vec[i + 1][j].cost);
            }
        }
    }
    for(int i = N - 2; i >= 0; i--)
    {
        Cost[i] += Cost[i + 1];
    }
    for(int i = 0; i < N; i++)
    {
        ANS = min(ANS,Cost[i] + road[i] * C);
    }
    return ANS;
}

void binary(ll a,ll b)
{
    int l = 0;int r = N;
    while(r - l > 0)
    {
        int m = (l + r) / 2;
        if(road[m] == a)
        {
            Cost[m - 1] += b;
            break;
        }
        if(a > road[m])l = m + 1;
        else r = m;
    }
    return;
}

void dijkstra(ll a)
{
    priority_queue<pii,vector<pii>,greater<pii> > que;
    for(int i = 0; i < N; i++)
    {
        D[i + 1] = INF;
    }
    D[1] = 0;
    que.push(pii(0,1));
    while(que.size())
    {
        pii test = que.top();que.pop();
        ll now = test.second;
        if(D[now] > test.first)continue;
        for(int i = 0; i < vec[now].size(); i++)
        {
            edge E = vec[now][i];
            if(D[E.to] > D[now] + E.cost)
            {
                D[E.to] = D[now] + E.cost;
                que.push(pii(D[E.to],E.to));
            }
        }
    }
    return;
}

Measured memory_bytes: 18444
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    string s;
    cin >> s;
    //s.push_back('>');
    int n = s.size();
    vector<int> cm(26,-1);
    vector<int> cd(26,-1);
    Rep(i,n){
        int c = s[i]-'a';
        int temp = i-1-cd[c];
        cd[c] = i;
        chmax(cm[c],temp);
    }
    REP(i,26){
        int temp = n-1-cd[i];
        chmax(cm[i], temp);
    }
    int res = INT_MAX;
    REP(i,26){
        if(cm[i]>=0){
            chmin(res,cm[i]);
        }
    }
    put(res);
    return 0;
}


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

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

int main(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  reverse(all(a));
  debug(a);
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)

int ara[1000006];
int main()
{
    int n,k,q;
    cin>>n>>k>>q;
    for(int i=0;i<q;i++)
    {
        int id;
        cin>>id;
        ara[id]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(ara[i]+k-q>0)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }

}


Measured memory_bytes: 1024
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
asum=0
bsum=0
pointer=0
while pointer<m and bsum+b[pointer]<=k:
	bsum+=b[pointer]
	pointer+=1
ans=pointer
for i in range(n):
	asum+=a[i]
	while asum+bsum>k and pointer>=0:
		pointer-=1
		bsum-=b[pointer]
	if asum+bsum>k:
		break
	ans=max(ans,(i+1)+pointer)
print(ans)

Measured memory_bytes: 117824
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
long long a[1000005];
int main(){
  long long n;
  cin>>n;
  for (long long i=0;i<n;i++)
    cin>>a[i];
  sort (a,a+n);
  if(n&1){
  	long long ans = 2100000000;
    long long l = a[n-1]/2;
    long long r = a[n-1]/2+1;
    for(long long i=0;i<n-1;i++){
      if(abs(l-ans) > abs(a[i]-l))  ans=a[i];
      if(abs(r-ans) > abs(a[i]-r))  ans=a[i];
    }
  cout<<a[n-1]<<" "<<ans;
  }
  else{
    long long ans = 2100000000;
  	long long val = a[n-1]/2;
    for(long long i=0;i<n-1;i++)
      if(abs(val-ans) > abs(a[i]-val))
        ans=a[i];
    cout<<a[n-1]<<" "<<ans;
}
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
#include <regex>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep2(i, N, M) for (ll i = N; i < M; i++)
#define pb push_back



typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef priority_queue<pll, vector<pll>, greater<pll>> greater_pq;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>

#define MAX_NUM 2<<20



int main() {
	int N, K;
	cin >> N >> K;
	cout << (N%K == 0 ? 0 : 1);
	return 0;
}



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

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

    for (int i = 1; i <= 50000; i++)
    {
        int x = i;
        if (N == x * 108 / 100)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}


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

int main (void) {

    int x[5];


    for(int c = 0; c<5; c++) {

        scanf("%d",&x[c]);
        if(x[c]== 0) {
            printf("%d",c +1);
            

            

        }

    }

    return 0;
}



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

#define ld long double

ld dp[3010][3010];
ld p[3010];

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) cin >> p[i+1];
  
  for (int i = 0; i < N+2; i++) {
    for (int j = 0; j < N+2; j++) {
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= i+1; j++) {
      dp[i+1][j] += dp[i][j] * (1-p[i+1]);
      dp[i+1][j+1] += dp[i][j] * p[i+1];
    }
  }
  
    
    
  ld ans = 0;
  for (int i = N/2 + 1; i <= N; i++) {
    ans += dp[N][i];
  }
  
  cout << fixed << setprecision(10) << ans << endl;
  
  
  
  
  
}

Measured memory_bytes: 141568
#include<bits/stdc++.h>
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<int(N);I++)
#define REPP(I, N) for(int I=1;I<=int(N);I++)
#define ll long long
#define SZ(x) (int)(x).size()
#define F first
#define S second
#define PB(x) push_back(x)
#define N 100000
inline int rit(){
    int f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
using namespace std;
typedef pair<int,int> P;
int n,m,a,b,v,d,c,Q;
vector<int> vct[N+5];
int clr[N+5];
int vis[N+5], tim;
bool fn[N+5][15];
struct st_{
	int pt, dis, cl;
}st[N+5];
void BFS(int x, int mxd, int mdcl){
	queue<P> que;
	que.push(P(x,mxd));
	while(!que.empty()){
		P tmp = que.front();
		que.pop();
		vis[tmp.F] = tim;
		fn[tmp.F][tmp.S] = true;
		if(!clr[tmp.F])	clr[tmp.F] = mdcl;
		if(tmp.S){
			for(auto to:vct[tmp.F]) if(vis[to]!=tim&&!fn[to][tmp.S-1]){
				que.push(P(to,tmp.S-1));
			}
		}
	}
}
int main(void){
	RII(n,m);
	REP(i,m){
		RII(a,b);
		vct[a].PB(b);
		vct[b].PB(a);
	}
	RI(Q);
	REPP(i,Q){
		RIII(v,d,c);
		st[i].pt = v, st[i].dis = d, st[i].cl = c;
	}
	for(int i=Q;i;--i){
		if(!fn[st[i].pt][st[i].dis]){
			++tim;
			BFS(st[i].pt, st[i].dis, st[i].cl);
		}
	}
	REPP(i,n) printf("%d\n",clr[i]);
}

Measured memory_bytes: 10392
#include<bits/stdc++.h>
using namespace std;
#define db double
#define ll long long
const int MX=3000;
ll dp[MX+5][MX+5];
ll a[MX+5];
int n,k;
ll solve(int i, int j)
{
  if(i>j)return 0;
  if(~dp[i][j])return dp[i][j];
  ll mx;
  mx=max(a[i]-solve(i+1,j),a[j]-solve(i,j-1));
  return dp[i][j]=mx;
}
int main()
{
  cin>>n;
  for(int i=1;i<=n;i++)cin>>a[i];
  memset(dp,-1,sizeof(dp));
  ll res=solve(1,n);
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 71040
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if (500 * i + 100 * j + 50 * k == X): cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using std::cin;
using std::cout;
using std::endl;
using std::pair;
using std::make_pair;
using std::vector;
using std::priority_queue;

int main(void) {
    int n;
    int m;
    int a;
    while (1) {
        cin >> n >> m >> a;
        if (n == 0 && m == 0 && a == 0) {
            break; 
        }

        int height;
        pair<int, int> connection;
        int swap;

        vector<int> amida(n + 1);
        for (int i = 1; i <= n; i++) {
            amida[i] = i;
        }
        priority_queue<pair<int, pair<int, int> > > que;
        for (int i = 0; i < m; i++) {
            cin >> height >> connection.first >> connection.second;
            que.push(make_pair(height, connection));
        }
        for (int i = 0; i < m; i++) {
            height = que.top().first;
            connection = que.top().second;
            que.pop();
            swap = amida[connection.first];
            amida[connection.first] = amida[connection.second];
            amida[connection.second] = swap;
        }
        for (int i = 1; i <= n; i++) {
            if (amida[i] == a) {
                cout << i << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3028
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;

int n;

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

  scan(n);
  // scan(b);
  vint h(n);
  REP(i, n) scan(h[i]);

  int cnt = 0;
  bool f = true;
  REP(i, n){
    REP(j, i){
      if(h[j]>h[i]) f=false;
    }
    if(f) cnt++;
    f=true;
  }

  prin(cnt);


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9 + 7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcountll
#define setbitcnt __builtin_ctz
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define roundup(a,b)  std::cout << std::fixed;std::cout << std::setprecision(b); std::cout << a
const int siz = (1e6 + 10);
const int logi = 21;
const double epsilon = 1e-6;
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}



signed main()
{
	#ifndef ONLINE_JUDGE
 	freopen("in.txt", "r", stdin);
 	freopen("out.txt", "w", stdout);
 	#else
// // online submission
 	#endif 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	int val = 0;
	while(t--)
	{
		int a,b,c;
		int k;
		cin>>a>>b>>c>>k;

		int cnt = 0 ;

		while(b <= a)
		{
			b *= 2;
			cnt++;
		}

		while(c <= b)
		{
			c *= 2;
			cnt++;
		}

		//cout<<a<<" "<<b<<" "<<c<<"\n";

		if(cnt <= k)
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
	}
}

Measured memory_bytes: 3580
n, w = [ int(v) for v in input().split() ]
knapsack = [ [ int(v) for v in input().split() ] for i in range(n) ]

dp_list = [ [ None for i in range(4*n+1) ] for i in range(n+1) ]
dp_list[0][0] = 0
base = knapsack[0][0]


for wi, vi in knapsack:
    wi -= base
    for i in range(n-1,-1,-1):
        for j in range(4*n,-1,-1):
            if 0 <= j-wi < 4*n+1 and 0 <= j < 4*n+1:
                if dp_list[i][j-wi] is not None:
                    if dp_list[i+1][j] is None:
                        dp_list[i+1][j] = dp_list[i][j-wi] + vi
                    else:
                        dp_list[i+1][j] = max(dp_list[i][j-wi] + vi, dp_list[i+1][j])

ans_list = [0]
for i in range(1,n+1):
    l = w - i*base
    for j in range(min(4*n+1,l+1)):
        if dp_list[i][j] is not None:
            ans_list.append(dp_list[i][j])


print(max(ans_list))


Measured memory_bytes: 42988
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)

#define huge 1000000007
typedef long long ll;
ll gcd(ll a, ll b);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll T = 0;
	//ll M = 0;
	ll c[100] = {};
	ll t[100] = {};
	ll v[3] = {};
	//ll *a, *b, *x;
	//string S, T, U[52];
	ll count = 0;
	ll sum = 0;
	ll min = 100000;
	ll max = 0;
	int flag = 0;
	char temp, head;
	//int is = 0;

	//vector<int> c(3);
	//char p;






	//cin >> S;

	//a = (ll *)malloc(M * sizeof(ll));
	//b = (ll *)malloc(M * sizeof(ll));
	//vector<pair<int,int>> ch(50);

	//vector<bool> flag(N);

	cin >> N >> T;

	rep(i, 0, N) {
		cin >> c[i] >> t[i];
	}

	rep(i, 0, N) {

		if (t[i] <= T) {
			if (min > c[i]) {
				min = c[i];
			}
		}
	}

	/*rep(i, 0, M) {
	cin >> ch[i].first >> ch[i].second;
	}*/
	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(c.begin(), c.end());

	//cout << c[2] - c[1] << endl;


	if (min > 10000)
		cout << "TLE" << endl;
	else
		cout << min << endl;

	
	return 0;

}

ll gcd(ll a, ll b) {
	ll c;
	c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}

	return b;
}



Measured memory_bytes: 256
#include <iostream>

int score_a, score_b;

int main(void)
{
    int n, data_a, data_b;

    while(1)
    {
        std::cin >> n;
        if (n == 0) break;
        score_a = 0;
        score_b = 0;
        for(; n > 0 ; n--) {
            std::cin >> data_a;
            std::cin >> data_b;
            if (data_a > data_b) {
                score_a += (data_a + data_b);
            } else if(data_a < data_b) {
                score_b += (data_a + data_b);
            } else {
                score_a += data_a;
                score_b += data_b;
            }
        }
        std::cout << score_a << " " << score_b << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1160
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;




public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e18;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 32;
    public static int[] Bit;
    public static long[] dp;
    public static long[] fac,inv;
	public static void main(String[] args) {
	
	FastReader sc = new FastReader();
	
	int n = sc.nextInt();
	int[] p = new int[n];
	int ans = 0;
	int min = n;
	for(int i=0;i<n;++i) {
		p[i] = sc.nextInt();
		min = Math.min(min,p[i]);
		if(p[i] <= min) ++ans;
	}
	out.print(ans);
	out.close();
}
}

Measured memory_bytes: 47912
//grundy(n) = grundy(n-n/k-1)
// khong biet chung minh
//khao sat ket qua

#include <bits/stdc++.h>

using namespace std;

int n,res;

int cal(int n,int k) {
    if (n<k) return 0;
    if (n%k==0) return n/k;
    int dif = n/k + 1;
    return cal(n - max(1,(n%k)/dif) * dif,k);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=1;i<=n;i++) {
        int x,k;
        cin>>x>>k;
        res^=cal(x,k);
        //cout<<cal(x,k)<<endl;
    }
    if (res) cout<<"Takahashi";
    else cout<<"Aoki";
}


Measured memory_bytes: 256