akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//#define CHKR
#define ll int
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define ARRS int(2e5+500)
#define BARRS int(6e4+600)
#define MAX ((long long)(1e9+1))
#define EP ((long double)(1e-9))
#define MMAX ((long long)(1e9+10))
#define HS1 ((long long)(1000001329))
#define HS2 ((long long)(1000001531))
#define MOD ((long long)1000000009ll)
#define SQ 31622780
#define PI 3.14159265358979323846264338327950288419716939937510
#define BG 4294967232ll
#define MH 200008
ll n,m;
string s[2100];

ll b[2100][2100][5];
ll sm[2100][2100][5];
ll f[2100][2100];
void go(ll x,ll y,ll t){
    if(x<0||y<0||x>=n||y>=m||s[x][y]=='0'||f[x][y])return;
    f[x][y]=1;
    b[x][y][t]++;
    go(x-1,y,3);
    go(x+1,y,4);
    go(x,y-1,1);
    go(x,y+1,2);
}




#ifndef CHKR
int main(){
#else
int doit(fstream &in,fstream &out){
    cin.rdbuf(in.rdbuf());
    cout.rdbuf(out.rdbuf());
#endif
    #ifdef KHOKHO
        #ifndef CHKR
        freopen("in.in","r",stdin);
        freopen("out.out","w+",stdout);
        #endif //CHKR
    #endif //KHOKHO
    ll k,p,pas=0,q;
    cin>>n>>m>>q;
    for(int i=0; i<n; i++){
        cin>>s[i];
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(s[i][j]=='1'&&!f[i][j]){
				//cout<<"root "<<i<<" "<<j<<endl;
                go(i,j,0);
            }
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){

            sm[i+1][j+1][0]=sm[i+1][j][0]+sm[i][j+1][0]-sm[i][j][0]+b[i][j][0];

			sm[i+1][j+1][1]=sm[i][j+1][1]+b[i][j][1];
			sm[i+1][j+1][2]=sm[i][j+1][2]+b[i][j][2];

			sm[i+1][j+1][3]=sm[i+1][j][3]+b[i][j][3];
			sm[i+1][j+1][4]=sm[i+1][j][4]+b[i][j][4];

			//cout<<sm[i+1][j+1][1]<<" ";
        }
       // cout<<endl;
    }

    while(q--){
		ll u,l,d,r;
		cin>>u>>l>>d>>r;
        cout<<sm[d][r][0]-sm[d][l-1][0]-sm[u-1][r][0]+sm[u-1][l-1][0]  +
			1*(sm[d][r][3]-sm[d][l-1][3] +
			sm[u][r][4]  -  sm[u][l-1][4] +
			sm[d][r][1]-sm[u-1][r][1]  +
			sm[d][l][2]-sm[u-1][l][2])<<endl;
    }

    return 0;
}


Measured memory_bytes: 191232
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define rep(i,m) for(int i=0;i<m;i++)
#define pb(n) push_back(n)

#define int long long

signed main() {
    string s;cin >>s;
    int n=s.size();int ma=0;
    rep(i,(n+1)/2){
        if(s[i]!=s[n-1-i])ma++;
    }
    cout <<ma <<endl;
}


Measured memory_bytes: 256
S = input()
l = len(S)
n = pow(2, l-1) #n通りの数式
ans = 0

for i in range(n): #2のn乗通りの全探索
  f = S[0] 
  for j in range(l-1):
    if i >> j & 1: #iのjビット右シフト,bitAND
      f += '+' #s[k]の直後に+を挿入
    f += S[j+1] #s[j]または+の直後にs[j+1]を入れる
  ans += sum(map(int, f.split('+'))) #int型に, '+'で区切る -> 数式としてを和をとる それの和をとる
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
using namespace std;
char in[3][120];
int t[3];
int main(){
	scanf("%s%s%s",in[0],in[1],in[2]);
	int at=0;
	while(1){
		if(!in[at][t[at]]){
			printf("%c\n",'A'+at);
			return 0;
		}
		at=in[at][t[at]++]-'a';
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n,a;
  cin >> n >> a;
  if(n==0&&a<100){ cout<<a<<endl; return 0;}
  if(n==0&&a==100){ cout<<101<<endl; return 0;}
  if(n==1&&a<100){ cout<<a*100<<endl; return 0;}
  if(n==1&&a==100){ cout<<10100<<endl; return 0;}
  if(n==2&&a<100){ cout<<a*10000<<endl; return 0;}
  if(n==2&&a==100){ cout<<1010000<<endl; return 0;}

  return 0;
}

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


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


	long long sum =0;
	char n;
	while(cin>>n)
	{
		sum += ( n - '0');
	}
	if(sum%9==0)
		cout<<"Yes";
	else
		cout<<"No";
	
	return 0;
}

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

int main()
{
	int n, k;
	std::cin >> n >> k;
	std::vector<long long> A;
	std::vector<long long> MAX;
	MAX.push_back(0);
	for (int i = 0; i < n; i++)
	{
		long a;
		std::cin >> a;
		A.push_back(a);
		MAX.push_back(a);
	}
	for (int i = 0; i < n; i++)
	{
		MAX.at(i + 1) = std::max(MAX.at(i), MAX.at(i + 1));
	}
	long long ans = 112345678901;
	for (int bit = 0; bit < (1 << n); bit++)
	{
		std::vector<long long> index;
		for (int i = 0; i < n; i++)
		{
			if (bit & (1 << i))
				index.push_back(i);
		}
		if (index.size() != k)
			continue;
		long long max_height = 0;
		long long cost = 0;
		for (int i = 0; i < k; i++)
		{
			max_height = std::max(max_height, MAX.at(index.at(i)));
			if (A.at(index.at(i)) <= max_height)
			{
				max_height++;
				cost += max_height - A.at(index.at(i));
			}
			else
				max_height = A.at(index.at(i));
		}
		ans = std::min(ans, cost);
	}
	std::cout << ans << '\n';


}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;
const ll inf = 1e12;


int n;
double x[maxn], y[maxn];
char d[maxn];


double sim(double t) {
    double xlo=inf,xhi=-inf,ylo=inf,yhi=-inf;
    for (int i=0; i<n; i++) {
	double X = x[i];
	double Y = y[i];
	if (d[i]=='U') Y += t;
	if (d[i]=='D') Y -= t;
	if (d[i]=='L') X -= t;
	if (d[i]=='R') X += t;
	xlo=min(xlo,X);
	xhi=max(xhi,X);
	ylo=min(ylo,Y);
	yhi=max(yhi,Y);
    }

    return (xhi-xlo)*(yhi-ylo);
}

const double eps = 1e-7;

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

    cin>>n;
    for (int i=0; i<n; i++) {
	cin>>x[i]>>y[i]>>d[i];
    }

    double lo = 0;
    double hi = 2e8;


    for (int iter=0; iter<500; iter++) {
	double mid1 = lo + (hi-lo)/3;
	double mid2 = hi - (hi-lo)/3;
	double res1 = sim(mid1);
	double res2 = sim(mid2);
	if (res1 < res2) {
	    hi = mid2;
	} else {
	    lo = mid1;	    
	}
    }

    cout<<fixed<<setprecision(12)<<sim(lo)<<endl;    
    return 0;
}


Measured memory_bytes: 5320
import sys
input = sys.stdin.readline
def print_ans(N, M, ar):
    """Test Case
    >>> print_ans(41, 2, [5, 6])
    30
    >>> print_ans(10, 2, [5, 6])
    -1
    >>> print_ans(11, 2, [5, 6])
    0
    """
    tmp = N -sum(ar)
    if(tmp >= 0):
        print(tmp)
    else:
        print("-1")



if __name__ == '__main__':
    N, M = map(int, input().rstrip().split())
    ar = list(map(int, input().rstrip().split()))
    print_ans(N, M, ar)




Measured memory_bytes: 9876
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>
void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}




signed main() {
	int n;
	cin >> n;
	vector<int>vec(n),vec2;
	vecin(vec);
	vec2 = vec;
	sort(all(vec2));
	rep(i, n) {
		if (vec[i] <= vec2[n / 2 - 1]) {
			cout << vec2[n / 2] << endl;
		}
		else {
			cout << vec2[n / 2 - 1] << endl;
		}
	}
}


Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int a[5][5],b[5][5];
int main() {
  ios::sync_with_stdio(false);
  for(int i=1;i<=3;i++){
    for(int j=1;j<=3;j++){
      cin>>a[i][j];
    }
  }
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    for(int j=1;j<=3;j++){
      for(int k=1;k<=3;k++){
        if(a[j][k]==x)b[j][k]=1;
      }
    }
  }
  for(int i=1;i<=3;i++){
    int sta=0;
    for(int j=1;j<=3;j++){
      if(!b[i][j])sta=1;
    }
    if(!sta)return cout<<"Yes\n",0;
  }
  for(int i=1;i<=3;i++){
    int sta=0;
    for(int j=1;j<=3;j++){
      if(!b[j][i])sta=1;
    }
    if(!sta)return cout<<"Yes\n",0;
  }
  if(b[1][1]&&b[2][2]&&b[3][3])cout<<"Yes\n";
  else if(b[1][3]&&b[2][2]&&b[3][1])cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}


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

char c[4]={'m','c','x','i'};
int main(){
    int n;
    cin>>n;
    for(int k=0;k<n;k++){
        string s[2];
        cin>>s[0]>>s[1];
        int x[2];
        x[0]=0;
        x[1]=0;
        int buf=1;
        for(int j=0;j<2;j++)
        for(int i=0;i<s[j].size();i++){
            if('2'<=s[j][i] && s[j][i]<='9'){
                buf=s[j][i]-'0';
                }
            else{
            if(s[j][i]=='m')
                    x[j]+=buf*1000;
            if(s[j][i]=='c')
                    x[j]+=buf*100;
            if(s[j][i]=='x')
                    x[j]+=buf*10;
            if(s[j][i]=='i')
                    x[j]+=buf;
            buf=1;
            }


        }
        int sum=x[0]+x[1];
        int y[4];
        for(int i=0;i<4;i++){
            y[3-i]=sum%10;
            sum/=10;

        }
        string res="";
        for(int i=0;i<4;i++)
            if(y[i]!=0){
                if(y[i]==1)
                    res+=c[i];
                else{

                    res+=(y[i]+'0');
                    res+=c[i];
                }

            }
        cout<<res<<endl;
    }

    return 0;
}

Measured memory_bytes: 3116
#include<stdio.h>
#define N 10000

int* bubbleSort(int* list, int len){
  int i,j,temp;

  for(i=0; i<len; i++){
    for(j=len-1; j>i; j--){
      if(list[j] > list[j-1]){
        temp = list[j];
        list[j] = list[j-1];
        list[j-1] = temp;
      }
    }
  }

  //for(i=0; i<len; i++){                                                                              
  //  printf("%d\n",list[i]);                                                                          
  //}                                                                                                  

  return list;
}

int main(){
  int inputs[N];
  int *result;
  int number=0,i;
  int catchd = 1;
  for(i=0; i<N; i++){
    number = i;
    catchd = scanf("%d",&inputs[i]);
    if(catchd == EOF) break;
  }

  //printf("len is %d",number);                                                                        

  bubbleSort(inputs, number);
  printf("%d\n",inputs[0]);
  printf("%d\n",inputs[1]);
  printf("%d\n",inputs[2]);

  return 0;
}

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


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    Sd = IS(str)
    T = IS(str)
    T_len = len(T)

    for i in range(len(Sd) - T_len, -1, -1):
        S_i = Sd[i: i + T_len]
        matched = all([s == '?' or s == t for s, t in zip(S_i, T)])
        if matched:
            left = ''.join(['a' if s == '?' else s for s in Sd[: i]])
            right = ''.join(['a' if s == '?' else s for s in Sd[i + T_len:]])
            print(left + T + right)
            exit()
    print('UNRESTORABLE')

solve()


Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,t,i,j,k,l,m,n,x,y;
	ll		ans = INF;
	string	s;
	cin >> n;
	vector<ll>	w(n);
	for(i=0;i<n;i++) cin >> w[i];

	for(t=0;t<n-1;t++) {
		a = b = 0;
		for(i=0;i<n;i++) {
			if (i<=t) a += w[i];
			else b += w[i];
		}
		ans = min(ans , abs(a-b));
	}

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


Measured memory_bytes: 3608
while True:
    m, f, r = list(map(int, input().split()))
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65:
        print('B')
    elif m + f >= 50:
        print('C')
    elif m + f >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')



Measured memory_bytes: 5596
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}

inline void solve() {
    int n;
    cin >> n;

    vector<LL> a(n, 0);

    REP(i, n) cin >> a[i];

    LL res = 0;
    LL cur = a[0];

    for (int i = 1; i < n; ++i) {
        if (a[i] < cur) {
            res += cur - a[i];
        } else {
            cur = a[i];
        }
    }

    cout << res << endl;

}

int main() {
    // open("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 5000000000000000;
constexpr auto MOD = 1000000007;

ll lpow(int p, int q) {
	ll ans = 1;
	ll pp = p;
	while (q) {
		if (q % 2) {
			ans *= pp;
			ans %= MOD;
		}
		q /= 2;
		pp *= pp;
		pp %= MOD;
	}
	return ans;
}


ll com(int n, int r) {
	if(n<r||n<0||r<0)	return 0;
	ll ans = 1;
	int k = n - r;

	rep1(i, n) {
		ans *= i;
		ans %= MOD;
	}

	rep1(i, r) {
		ans *= lpow(i, MOD - 2);
		ans %= MOD;
	}

	rep1(i, k) {
		ans *= lpow(i, MOD - 2);
		ans %= MOD;
	}

	return ans;
}




int main() {

	int n, k;
	cin >> n >> k;

	rep1(i, k) {
		ll ans = (com(n - k + 1, i) * com(k - 1, i - 1)) % MOD;
		cout << ans << endl;
	}
}

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

int main(){
	int N;
	cin>>N;
	int V[N],C[N];
	for(int i=0;i<N;++i){
		cin>>V[i];
	}
	for(int i=0;i<N;++i){
		cin>>C[i];
	}
	int ans=0;
	for(int i=0;i<N;++i){
		if(V[i]-C[i]>0)ans+=V[i]-C[i];
	}
	cout<<ans<<endl;
}


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

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

    int a,b;
    cin>>a>>b;

    cout<<(a+b+1)/2<<endl;

    return 0;
}

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

int main() {
  int N, x[100];
  cin >> N;
  if (N == 0) {
    cout << '0';
    return 0;
  }
  for (int i = 0; i < 100; i++) {
    x[i] = 0;
  }
  for (int i = 0; N != 0; i++, N -= N & 1, N /= -2) {
    x[i] = N & 1;
  }
  int foo = 99;
  for (; x[foo] == 0; foo--);
  for (; foo >= 0; foo--) {
    cout << x[foo];
  }
  return 0;
}

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

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

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

int main()
{
   ll a, b;
   cin >> a >> b;
   cout <<  lcm(a, b) << endl;
}


Measured memory_bytes: 256
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> 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, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
fn main() {
    input! { ab: usize, bc: usize }
    println!("{}", ab*bc/2);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){
    int a, b, c, d;
    bool winner = false;
    cin >> a >> b >> c >> d;

    while(true){
        a -= d;
        c -= b;
        if (c <= 0) {
            winner = true;
            break;
        }
        if (a <= 0) {
            winner = false;
            break;
        }
    }
    cout << (winner ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>

using namespace std;

int main(void)
{
	int a1,a2,a3,a4,b1,b2,b3,b4;
	while(cin>>a1>>a2>>a3>>a4>>b1>>b2>>b3>>b4)
	{
		int hit,blow;
		hit=blow=0;
		if(a1==b1) hit++;
		else if(a1==b2||a1==b3||a1==b4) blow++;
		if(a2==b2) hit++;
		else if(a2==b1||a2==b3||a2==b4) blow++;
		if(a3==b3) hit++;
		else if(a3==b1||a3==b2||a3==b4) blow++;
		if(a4==b4) hit++;
		else if(a4==b1||a4==b2||a4==b3) blow++;
		cout<<hit<<" "<<blow<<endl;
	}
}

Measured memory_bytes: 1156
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
using namespace std;
typedef pair<int, int>p;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
vector<long long> divisor(long long n) {
	vector< long long> ret;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}
struct LazySegmentTree {
private:
	int n;
	vector<int> node, lazy;
	vector<bool> lazyFlag;

public:
	LazySegmentTree(vector<int> v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1, INT_MAX);
		lazyFlag.resize(2 * n - 1, false);

		for (int i = 0; i<sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
	}

	void lazyEvaluate(int k, int l, int r) {
		if (lazyFlag[k]) {
			node[k] = lazy[k];
			if (r - l > 1) {
				lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];
				lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true;
			}
			lazyFlag[k] = false;
		}
	}

	void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			lazyFlag[k] = true;
			lazyEvaluate(k, l, r);
		}
		else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = min(node[2 * k + 1], node[2 * k + 2]);
		}
	}

	int find(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return INT_MAX;
		if (a <= l && r <= b) return node[k];
		int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};
long long mod = 1000000007;
long long a, b, c, d;
long long num(long long x) {
	long long k = x / c + x / d - x / (c*d / gcd(c, d));
	return x - k;
}
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);
	int n, k;
	cin >> n >> k;
	if (k > (n - 1)*(n - 2) / 2) {
		cout << -1;
		return 0;
	}
	vector<p>ans;
	for (int i = 2; i <= n; i++) {
		ans.push_back(p(1, i));
	}
	for (int i = 2; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (k ==(n-1)*(n-2)/2)goto hell;
			ans.push_back(p(i, j));
			k += 1;
		}
	}
hell:
	cout << ans.size() << "\n";
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].first << " " << ans[i].second << "\n";
	}
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
struct Dijkstra {
    using P = pair<T, int>;

    int n;
    T initial;
    vector<vector<P>> graph;

    Dijkstra(int n, vector<vector<P>> graph, T initial)
        : n(n), graph(graph), initial(initial) {}

    vector<T> solve(int start) {
        vector<bool> used(n, false);
        vector<T> dist(n, initial);
        priority_queue<P, vector<P>, greater<P>> que;
        que.push(make_pair(0, start));
        while(!que.empty()) {
            T d; int t;
            tie(d, t) = que.top(); que.pop();
            if (used[t]) continue;
            used[t] = true; dist[t] = d;
            for (auto &e : graph[t]) {
                if (dist[e.second] <= d + e.first) continue;
                que.push(make_pair(d + e.first, e.second));
            }
        }
        return dist;
    }
};

int main() {
    int V, E, r;
    cin >> V >> E >> r;
    vector<vector<pair<int, int>>> graph(V, vector<pair<int, int>>());
    REP(i, E) {
        int s, t, d;
        cin >> s >> t >> d;
        graph[s].push_back(make_pair(d, t));
    }
    Dijkstra<int> dijkstra(V, graph, iINF);
    auto ans = dijkstra.solve(r);
    for(auto x : ans) {
        cout << (x == iINF ? "INF" : to_string(x)) << endl;
    }
}


Measured memory_bytes: 26032
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class AtCoder
{
  public static void Main()
  {
    var abcd = Console.ReadLine().Trim().ToCharArray().Select(e => int.Parse(e.ToString())).ToArray();
    var a = abcd[0];
    var b = abcd[1];
    var c = abcd[2];
    var d = abcd[3];

    var n = 16;
    var i = 0;
    for(i=0; i < n; i++)
    {

      var v = a;      
      v +=  ((i >> 0) & 1) > 0 ? b : -b;
      v +=  ((i >> 1) & 1) > 0 ? c : -c;
      v +=  ((i >> 2) & 1) > 0 ? d : -d;

       if(v == 7) break;
    } 

    var k = new []{ "-", "+"};
    var ans =  
      a + k[(i >> 0) & 1] +
      b + k[(i >> 1) & 1] +
      c + k[(i >> 2) & 1] +
      d + "=7";

    Console.WriteLine(ans);
  }
}

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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int f(int a){
  int count = 0;
  int flag = 0;
  for(int i = 1; i <= pow(a,0.5); ++i){
    if(a % i == 0) count ++;
    if(i*i == a)flag = 1;
  }
  count *= 2;
  if(flag == 1) --count;
  return count;
}


int main(){

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

  char s[n];
  scanf("%s",s);

  int count = 0;
  for(int i = 0; i < n-2; ++i){
    if(strncmp(s+i, "ABC", 3) == 0) count ++;
  }

  printf("%d",count);

  return 0;
}


Measured memory_bytes: 2144
n,m = map(int,input().split())
p = list(map(int,input().split()))
xy = [list(map(int,input().split())) for _ in range(m)]
li = [[] for _ in range(n+1)]
for x,y in xy:
    li[x].append(y)
    li[y].append(x)
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n
    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n)

uni = UnionFind(n+1)
for i in range(n+1):
    for j in li[i]:
        uni.union(i,j)

point = 0

for i in range(n):
    if uni.same(i+1,p[i]):
        point += 1

print(point)

Measured memory_bytes: 45996
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Program{
    public static void Main(){
        string[] S = ReadLine().Split(' ');
        int A = int.Parse(S[0]);
        int B = int.Parse(S[1]);
        if(A > 8 || B > 8){
            WriteLine(":(");
        }
        else{
            WriteLine("Yay!");
        }
    } 
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N,M;cin>>N>>M;
    if(N==1&&M==1)cout<<1<<endl;
    else{
      	if(N==1||M==1)cout<<N*M-2<<endl;
    	else cout<<N*M-(2*M+2*N-4)<<endl;
    }
}


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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

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

	cout << 6 - a - b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


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

  int n;
  cin>>n;
  string s="ABC";
  if(n>=1000){
    s[2]++;
  }
  cout<<s<<endl;


}

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

using namespace std;
const int N = 10e6 * 3;

void solve()
{

int n,m;
long long k;
cin >> n >> m >> k;
vector <int> a(n);
vector <int> b(m);
vector <long long> aa(n+1);
vector <long long> bb(m+1);

aa[0]=0;
bb[0]=0;
for (int i=0; i<n; i++){cin >>a[i]; aa[i+1]=aa[i] + a[i];}
for (int i=0; i<m; i++){cin >>b[i]; bb[i+1]=bb[i] + b[i];}

int rs=0;
int bbb=m;
for (int i=0; i<=n; i++)
{
    while(aa[i]+bb[bbb]>k && bbb>=0) bbb--;
    if (bbb>=0)
    rs = max(rs,i+bbb);
    //cout << i << " " << rs << "\n";
}
cout << rs << "\n";

}

int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t=1;
//cin >> t;
while (t--) solve();

}


Measured memory_bytes: 7928
#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=a;i<=b;++i)

using namespace std;

int k,n,a,ans;
int main()
{
	scanf("%d",&n);
	For(i,1,n)
	{
		scanf("%d%d",&a,&k);
		while(a%k!=0)
		{	
			int qaq=a/k+1,ovo=a%k;
			a-=ovo/qaq*qaq;
			if(a%k!=0)
				a-=qaq;
		}
		ans^=a/k;
	}
	printf("%s",!ans?"Aoki":"Takahashi");
	return 0;
}


Measured memory_bytes: 256
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def xy(x,y):
  x,y=abs(x),abs(y)
  g=gcd(x,y)
  x//=g
  y//=g
  return (10**20)*x+y
from collections import defaultdict
mod=10**9+7
n=int(input())
aabb=[list(map(int,input().split()))for _ in range(n)]
ab=[]
ans=0
for i in aabb:
  if i!=[0,0]:ab.append(i)
  else:
    n-=1
    ans+=1
az=bz=0
d=defaultdict(int)
dd=defaultdict(int)
for i in ab:
  if 0 in i:
    if i[0]==0:az+=1
    else:bz+=1
  else:
    a,b=i
    if a*b>0:d[xy(a,b)]+=1
    else:dd[xy(a,b)]+=1
t=[]
tt=1
for i in dd:
  b,a=divmod(i,10**20)
  p,m=d[xy(a,b)],dd[i]
  if p*m:
    n-=p+m
    tt*=(pow(2,p,mod)+pow(2,m,mod)-1)
    tt%=mod
if az*bz:
  n-=az+bz
  tt*=(pow(2,az,mod)+pow(2,bz,mod)-1)
  tt%=mod
ans+=(tt*pow(2,n,mod)-1)%mod
print(ans%mod)

Measured memory_bytes: 172748
# vim: set fileencoding=utf-8:


def main():
    A, B, K = map(int, raw_input().split())
    for i in xrange(1, K + 1):
        if i % 2 == 0:  # 青木くん
            B, A = func(turn=B, to=A)
        else:  # たかはし
            A, B = func(turn=A, to=B)

    print(str(A) + " " + str(B))


def func(turn, to):
    if turn % 2 == 0:
        temp = turn / 2
        to += temp
        turn -= temp
    else:
        turn -= 1
        temp = turn / 2
        to += temp
        turn -= temp

    return turn, to


if __name__ == "__main__":
    main()


Measured memory_bytes: 2568
import java.util.Scanner;

public class Main {
	final int MAX_N = 200;
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int N = scan.nextInt();
			if (N == 0)
				return;
			if (N == 1) {
				System.out.println(1 + " " + 1);
				continue;
			}

			int[][] map = new int[MAX_N * 2 + 1][MAX_N * 2 + 1];
			for (int i = 0; i <= MAX_N * 2; i++)
				for (int j = 0; j <= MAX_N * 2; j++)
					map[i][j] = -1;

			map[MAX_N][MAX_N] = 0;
			int[] dy = {  0, 1, 0, -1 };
			int[] dx = { -1, 0, 1,  0 };
			for (int k = 1; k < N; k++) {
				int n = scan.nextInt();
				int d = scan.nextInt();
				int x = 0, y = 0;
				for (int i = 0; i <= MAX_N * 2; i++) {
					for (int j = 0; j <= MAX_N * 2; j++) {
						if (map[i][j] == n) {
							y = i;
							x = j;
						}
					}
				}
//				System.out.println(y + " " + x);
				map[y + dy[d]][x + dx[d]] = k;
			}


			int hh = 0;
			label: for (int i = 0; i <= MAX_N * 2; i++) {
				for (int j = 0; j <= MAX_N * 2; j++) {
					if (map[i][j] != -1) {
						hh = i;
						break label;
					}
				}
			}
			int ll = 0;
			label: for (int i = MAX_N * 2; i >= 0; i--) {
				for (int j = MAX_N * 2; j >= 0; j--) {
					if (map[i][j] != -1) {
						ll = i;
						break label;
					}
					
				}
			}

			int hl = 0;
			label: for (int j = 0; j <= MAX_N * 2; j++) {
				for (int i = 0; i <= MAX_N * 2; i++) {
					if (map[i][j] != -1) {
						hl = j;
						break label;
					}
				}
			}

			int lr = 0;
			label: for (int j = MAX_N * 2; j >= 0; j--) {
				for (int i = MAX_N * 2; i >= 0; i--) {
					if (map[i][j] != -1) {
						lr = j;
						break label;
					}
				}
			}
			System.out.println((lr - hl + 1) + " " + (ll - hh + 1));
			
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 66784
n=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))

count=0
for i in T:
    left=0
    right=n
    while left<right:
        mid=(left+right)//2
        if S[mid]==i:
            count+=1
            break
        elif i<S[mid]:
            right=mid
        else:
            left=mid + 1

print(count)


Measured memory_bytes: 16704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int x,y,z,k;
  cin>>x>>y>>z>>k;
  ll a[x];
  ll b[y];
  ll c[z];
  rep(i,0,x) cin>>a[i];
  rep(i,0,y) cin>>b[i];
  rep(i,0,z) cin>>c[i];
  ll d[x*y];
  rep(i,0,x){
    rep(j,0,y){
      d[i*y+j]=a[i]+b[j];
    }
  }
  sort(d,d+(x*y));
  reverse(d,d+(x*y));
  
  ll e[min(k,x*y)*z];
  rep(i,0,min(k,x*y)){
    rep(j,0,z){
      e[i*z+j]=d[i]+c[j];
    }
  }
  sort(e,e+min(k,x*y)*z);
  reverse(e,e+min(k,x*y)*z);
  rep(i,0,k){
    cout<<e[i]<<endl;
  }
}

Measured memory_bytes: 31616
#include<stdio.h>

int main(void)
{ double x[10] ;
  double result=0;
 int n,i;
 char u[10][5];
 
 scanf("%d",&n);
 
 for(i=0;i<n;i++){
 scanf("%lf %s",&x[i],&u[i]);
 }
 
 for(i=0;i<n;i++){
 if(u[i][0]=='J')result=result+x[i];
 else if (u[i][0]='B')result=result+x[i]*380000;
 }
 printf("%f\n",result);
 
 return 0; 
}
  
  
  

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

int main()
{
    int A1,A2,A3;
    cin >> A1 >> A2 >> A3;

    if(A1+A2+A3 <= 21)
        cout << "win";
    else
    {
        cout << "bust";
    }
    
    
    return 0;
}

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

ll n, m;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    ll ans = 1;
    for (ll i = 1; i * i <= m; i++) {
        if (!(m % i)) {
            if (i * n <= m) ans = max(ans, i);
            if (m / i * n <= m) ans = max(ans, m / i);
        }
    }   
    cout << ans;
}   


Measured memory_bytes: 256
/*
sonu_verma1
*/
#include <bits/stdc++.h>
// For policy based data structure
/*#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> */
using namespace std;
/*using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set;*/
 
#define MD 1000000007
#define X first
#define Y second
#define pb push_back
#define debug(val, ch) cout <<val <<ch
#define FOR(i, st, en, ch) for(register int i = (st); i <= (en) ; i += (ch))
#define RFOR(i, st, en, ch) for(register int i = (st); i >= (en) ; i -= (ch))
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
 
typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<int, bool> pib;
typedef pair<bool, int> pbi;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
/*********************************************************************/
void test(int r)
{
	int n,k;
	cin>>n>>k;
	vector<int>v(n+1);
	int i,j;
	for(i=1;i<=n;i++)
		cin>>v[i];
	j=k+1;
	i=1;
	while(j<=n)
	{
		if(v[j]>v[i])
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
		j++;
		i++;
	}
	

}
/***********************************************************************/
int main()
{
	fast();
    int t=1,r;
    // cin>>t;
    for(r=1;r<=t;r++)
        test(r);
    return 0;
}

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

li=[1]*(n+1)

se=set()
se.add(1)
for  i in range(m):
	x,y=map(int,input().split())
	li[x]-=1
	li[y]+=1
	if x in se:
		se.add(y)
		if li[x]==0:
			se.remove(x)
print(len(se))

Measured memory_bytes: 12652
#include<stdio.h>
int main(void)
{
	int n,k,j,P,Q,R,C,flg;
	int i[1001],p1[101],q1[101],r1[101],c[1701],p[1001],q[1001],r[1001];
	flg=0;
	scanf("%d",&n);
	while(n!=0){
		for(j=1;j<=n;j++){
			scanf("%d %d %d %d",&i[j],&p[j],&q[j],&r[j]);
			p1[j]=p[j]*4;
			q1[j]=q[j]*9;
			r1[j]=r[j]*4;
			c[j]=p1[j]+q1[j]+r1[j];
		}
		scanf("%d %d %d %d",&P,&Q,&R,&C);
		for(j=1;j<=n;j++){
			if(p[j]<=P && q[j]<=Q && r[j]<=R && c[j]<=C){
				printf("%d\n",i[j]);
				flg=1;
			}
		} 
		if(flg==0){
			printf("NA\n");
		}
		flg=0;
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1064
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
  ll a[3];
  rep(i, 3) cin >> a[i];
  rep(i, 3) {
    if(!(a[i]%2)) {
      cout << 0 << endl;
      return 0;
    }
  }
  sort(a, a+3);
  cout << a[0]*a[1] << endl;
  return 0;
}

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

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << fixed << setprecision(8)
       << hypot(x1 - x2, y1 - y2) << "\n";
}


Measured memory_bytes: 3344
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

X, N = LI()
p = LI()

ans = X
for i in range(2 * N):
    if X - i not in p:
        ans = X -i
        break
    if X + i not in p:
        ans = X + i
        break

print(ans)



Measured memory_bytes: 10932
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int64_t n, m;
  cin >> n >> m;
  int64_t result = 0;
  if (m - n * (int64_t)2 >= (int64_t)0) {
    m -= n * (int64_t)2;
    result += n;
  } else if (m >= 2) {
    result += m / 2;
    m -= result * 2;
  }
  result += m / (int64_t)4;
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gz[2005][2005],heng[2005][2005],shu[2005][2005],a[2005][2005];
int main(int argc, char** argv) {
	int n,m,q;
	ios::sync_with_stdio(false);
	cin >> n >> m >> q;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			char c;
			cin >> c;
			if(c-48) a[i][j]=1;
			gz[i][j]=gz[i-1][j]+gz[i][j-1]-gz[i-1][j-1]+a[i][j];
			heng[i][j]=heng[i-1][j]+heng[i][j-1]-heng[i-1][j-1]+(a[i][j]==a[i-1][j]&&a[i][j]==1);
			shu[i][j]=shu[i-1][j]+shu[i][j-1]-shu[i-1][j-1]+(a[i][j]==a[i][j-1]&&a[i][j]==1);
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			heng[i][j]=heng[i+1][j];
			shu[i][j]=shu[i][j+1];
		}
	}
	while(q--)
	{
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		int ans=gz[c][d]-gz[a-1][d]-gz[c][b-1]+gz[a-1][b-1];
		--c;
		ans-=heng[c][d]-heng[a-1][d]-heng[c][b-1]+heng[a-1][b-1];
		++c,--d;
		ans-=shu[c][d]-shu[a-1][d]-shu[c][b-1]+shu[a-1][b-1];
	//	cout << shu[c][d]-shu[a-1][d]-shu[c][b-1]+shu[a-1][b-1] << "  ";
		cout << ans << "\n";
	}
	return 0;
}

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

using namespace std;

using pii = pair<int, int>;
using lli = long long int;

#define debug(args...) fprintf(stderr, args)
#define pb push_back
#define all(xs) xs.begin(), xs.end()

const int INF = 1e9;

int main() {
	int x;
	scanf("%d", &x);
	printf("%d\n", !x);
}

Measured memory_bytes: 3812
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[] nums=new int[n];
        for(int i=0;i<n;i++){
            nums[i]=sc.nextInt();
        }
        int ans=0;
        int[] tmp=new int[3];
        for(int i=0;i<n-2;i++){
            for(int j=0;j<3;j++){
                tmp[j]=nums[i+j];
            }
            Arrays.sort(tmp);
            if(tmp[1]==nums[i+1]){
                ans++;
            }
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 21588
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int p = 998244353;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_program(s) cout << s <<endl;return 0
int kai_size = 500001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
vel dist;
int RE() {
	vel v(3, 2);
	return v.at(4); 
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, kai_size-1) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, kai_size) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	if (r < 0 || n < r) { return 0; }
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now, int n, vvel &way) {
	vel dist1 = dis(now, way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}

int per(int a, int b) {
	int ans = a % b;
	if (ans < 0) { ans += b; }
	return ans;
}
V<pin> uni(V<pin> &v) {
	sor(v);
	V<pin> ans(1, v[0]);
	for (int i = 1; i < v.size(); i++) {
		if (v[i] != v[i-1]) { ans.push_back(v[i]); }
	}
	v = ans;
	return v;
}
int s_gcd(int a, int b) {
	if (b == 0) { return a; }
	return s_gcd(b, a%b);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	return s_gcd(a, b);
}
signed main() {
	int n, k; cin >> k >> n;
	int ans = 0;
	make_kai();
	for (int a = n; a * 2 > n; a--) {
		if (k - a <= 0) {
			int pl = com(n, a);
			pl -= com(n, 2 * a - k + 1);
			per(pl, p);
			ans += pl;
		}
	}
	if (n % 2 == 0) {
		int a = n / 2;
		n--;
		if (k - a <= 0) {
			int pl = com(n, a);
			pl -= com(n, 2 * a - k + 1);
			per(pl, p);
			ans += pl;
		}
	}
	cout << ans % p << endl;
	return 0;
}


Measured memory_bytes: 8192
n = gets.to_i
ss = []
n.times do |i|
  ss << gets[0]
end

counts = []
counts << ss.count("M")
counts << ss.count("A")
counts << ss.count("R")
counts << ss.count("C")
counts << ss.count("H")

result = 0
(0...5).each do |i|
  ((i + 1)...5).each do |j|
    ((j + 1)...5).each do |k|
      result += counts[i] * counts[j] * counts[k]
    end
  end
end

puts(result)

Measured memory_bytes: 9340
/****************### With The name of ALLAH, most Gracious, most Compassionate ###****************/

/**============================================================================**\
|   Author      : Md Jubayer Hossen Jame
|   Study       : CSE, BRUR
|   Today       : Sunday, 13 September, 2020
|   Source      : AtCoder Online Judge
|   Problem link: https://atcoder.jp/contests/abc178/tasks/abc178_b
|   Algorithm   :

    After about 2 years latter ---> see you again
|
\**============================================================================**/

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

#define FI                    freopen("input.txt", "r", stdin)
#define FO                    freopen("output.txt", "w", stdout)
#define FasterIO              ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

typedef long long             ll;
typedef unsigned long long    ull;
typedef unsigned int          ui;

#define mem(x,y)              memset(x,y,sizeof(x));
#define pii                   pair<int,int>
#define mk                    make_pair
#define ff                    first
#define ss                    second
#define pb                    push_back
#define ppb                   pop_back
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define for0(i, n)            for (int i = 0; i < (int)(n); ++i)
#define endl                  '\n'

const double PI = acos(-1.0);

#define gcd(a,b)              __gcd(a,b)
#define lcm(a,b)              (a*(b/gcd(a,b)))

///Direction Array
// 4 Direction - DOWN, UP, RIGHT, LEFT
int dx4[]= {+1, -1, +0, +0};
int dy4[]= {+0, +0, +1, -1};
#define isValid(a, b, R, C)   (0 <= a && a < R) && (0 <= b && b < C)
int dx8[]= {+0, +0, +1, -1, -1, +1, -1, +1};
int dy8[]= {-1, +1, +0, +0, +1, +1, -1, -1};

///Knight Moves
int dr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int dc[] = {-2, -2, -1, 1, 2, 2, 1, -1};
/**************************************************************************************************/

void test_case()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    set <ll> s;
    s.insert(a*c); s.insert(a*d);
    s.insert(b*c); s.insert(b*d);

    ll lst;
    for(auto x: s)lst = x;
    cout << lst << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    //FI;
    //FO;
#endif // ONLINE_JUDGE
    //FasterIO

    int T = 1;
    //cin >> T;
    for(int tc = 1; tc <= T; ++tc)
    {
        //cout << "Case #" << tc << ":" << endl;
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3600