akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int mod = 998244353;
string XOR(string a, string b){
    for(int i = 0; i < b.size(); i++)
        a[i] ^= b[i];
    return a;
}
int po(int x){
    int ans = 1;
    for(int i = 0; i < x; i++){
        ans = ans + ans;
        if(ans >= mod) ans -= mod;
    }
    return ans;
}
main(){
    int n, m;
    cin >> n >> m;
    int ans = 0;
    vector<string> v;
    string nul = "";
    for(int i = 0; i < m; i++)
        nul += (char)0;
    for(int i = 1; i <= n; i++){
        string x = "";
        for(int i = 0; i < m; i++){
            int t;
            cin >> t;
            x += t;
        }
        for(int j = v.size() - 1; j >= 0; j --){
            x = min(x, XOR(x, v[j]));
        }
        v.push_back(x);
        if(x == nul) ans++;
        sort(v.begin(), v.end());
    }
    cout << (po(n+m-1) - po(ans + m - 1) + mod) % mod << endl;

}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>

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

using namespace std;

int A, B, C;

int main() {
	int x;
	scanf("%d %d %d", &A, &B, &C);
	if (B / A > C) printf("%d\n", C);
	else printf("%d\n", B / A);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int strsum(const int n){
    string s = to_string(n);
    int b(0);
    rep(i,s.size()){
        b += s[i]-'0';
    }
    return b;
}

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

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

    return 0;
}

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

const int mod = 1e+9 + 7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    bool flag = true;
    if (n % 2 == 0){
        rep(i, n / 2){
            if (a[2 * i] != 2 * i + 1 || a[2 * i + 1] != 2 * i + 1) flag = false;
        }
    }
    else {
        if (a[0] != 0) flag = false;
        rep(i, (n - 1) / 2){
            if (a[2 * i + 1] != 2 * (i + 1) || a[2 * i + 2] != 2 * (i + 1)) flag = false;
        }
    }
    if (flag) { 
        ll ans = 1;
        rep(i, n/2) ans = ans * 2 % mod;
        cout << ans << endl;
    }
    else cout << 0 << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
 int main(void)
 {
     int N;
     int i;

     scanf("%d",&N);

     if((N%7)%4==0) { printf("Yes\n"); return 0; }
     if((N%4)%7==0) { printf("Yes\n"); return 0; }

     for(i=0;i<=14;i++){
       if(N-7*i<=0) { printf("No\n"); return 0; }
       if((N-7*i)%4==0) { printf("Yes\n"); return 0; }
     }

     for(i=0;i<=24;i++){
       if(N-4*i<=0) { printf("No\n"); return 0; }
       if((N-4*i)%7==0) { printf("Yes\n"); return 0; }
     }

     printf("No\n");

     return 0;
 }


Measured memory_bytes: 1644
import math
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)

    if op=='?':
        break

    if op=='+':
        print(a+b)
    elif op=='-':
        print(a-b)
    elif op=='*':
        print(a*b)
    else:
        print(math.floor(a/b))


Measured memory_bytes: 5660
function Main(input){
    const arr = input.split('\n');
    const ABC_RGB = arr[0].split(' ').map(Number);
    const red = ABC_RGB[0];
    const green = ABC_RGB[1];
    const blue = ABC_RGB[2];
    const K = Number(arr[1]);
    let answer = 'No';
    const all = (red, green, blue, num) => {
        if(num <= 0){
            if(green>red && blue>green){
                answer = 'Yes';
                return;
            }
            return;
        }
        all(red*2, green,   blue,   num-1);
        all(red,   green*2, blue,   num-1);
        all(red,   green,   blue*2, num-1);
    }
    all(red, green, blue, K);
    console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29592
program sample
    implicit none
  
    integer(8) :: i,j,m,n,x,y,s,t
    integer(8),allocatable :: a(:),b(:),c(:),d(:)
  
    read(*,*) n,m
    allocate(a(n),b(n),c(m),d(m))
    do i=1,n
    read(*,*)a(i),b(i)
    end do
    do i=1,m
    read(*,*)c(i),d(i)
    end do
    do i=1,n
        x=a(i)
        y=b(i)
        s=abs(x-c(1))+abs(y-d(1))
        t=1
        do j=2,m
            if(abs(x-c(j))+abs(y-d(j))<s)then
                s= abs(x-c(j))+abs(y-d(j))
                t=j
            end if
        end do
        write(*,*) t
    end do         

   
  
    stop
end program sample
  



Measured memory_bytes: 2812
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define all(v) v.begin(),v.end();
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> t;
    vector<int> x;
    vector<int> y;
    t.push_back(0);
    x.push_back(0);
    y.push_back(0);
    rep(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        t.push_back(a);
        x.push_back(b);
        y.push_back(c);
    }
    rep(i,n){
        int difx=abs(x[i]-x[i+1]);//次の座標とのx座標の差
        int dify=abs(y[i]-y[i+1]);//次の座標とのy座標の差
        int dift=abs(t[i]-t[i+1]);//次の座標との時間差
        //所要時間...difx+dify
        if(difx+dify>dift){
            cout<<"No"<<endl;
            return 0;
        }
        else if((dift-(difx+dify))%2!=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1644
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define bit(n,m)((n>>m)&1)

ll dp[1<<20];
int cnt[1<<20];
int idx[1<<20];

int c(const void*p,const void*q){
	if(cnt[*(int*)p]<cnt[*(int*)q])return -1;
	if(cnt[*(int*)p]>cnt[*(int*)q])return  1;
	if(dp[*(int*)p]<dp[*(int*)q])return -1;
	return 1;
}

int bs(int c,ll x,int num){
	//dp[l]<x<=dp[r]
	int l=0,r=num;
	if(c<cnt[idx[0]]||c==cnt[idx[0]]&&x<=dp[idx[0]])return 0;
	while(r-l>1){
		int m=(l+r)/2;
		if(c<cnt[idx[m]]||c==cnt[idx[m]]&&x<=dp[idx[m]])r=m;
		else l=m;
	}
	return r;
}


ll a[40];
int main(){
	int n,k;
	ll l,r;
	scanf("%d%d%lld%lld",&n,&k,&l,&r);
	for(int i=0;i<n;i++)scanf("%lld",a+i);
	int N=n-n/2;
	n/=2;
	for(int i=0;i<1<<n;i++){
		for(int k=0;k<n;k++)if(bit(i,k)){
			dp[i]+=a[k];
			cnt[i]++;
		}
		idx[i]=i;
	}
	qsort(idx,1<<n,sizeof(int),c);
	ll ans=0;
	for(int i=0;i<1<<N;i++){
		ll s=0;
		int temp=0;
		for(int k=0;k<N;k++)if(bit(i,k)){
			s+=a[n+k];
			temp++;
		}
		ans+=bs(k-temp,r+1-s,1<<n)-bs(k-temp,l-s,1<<n);
	}
	printf("%lld\n",ans);
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define MOD         (1000000007LL)
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define se          second
#define fi          first

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, m;cin >> n >> m;
    map<int, int> mmap;
    inc(i, 0, m){
        int a, b;cin >> a >> b;
        mmap[a]++;
        mmap[b]++;
    }
    string ans = "YES";
    for(auto kv : mmap){
        if(kv.second%2 != 0) ans = "NO";
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main()
{
    string S;
    cin >> S;
    bool po = false;
    for (int i = 0; i < S.length(); i++){
        if (S.at(i) == '7'){
            po =true; 
        }
    }
    if(po == true){
        cout << "Yes";
    }else{
        cout << "No";
    }    
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	while(1){
		int d[5]={},kd[4]={},c=0;
		cin>>d[0];
		if(d[0]==0) break;
		rep(i,1,5) cin>>d[i];
		rep(i,0,5) if(kd[d[i]]==0) kd[d[i]]++;
		rep(i,1,4) if(kd[i]) c++;
		//o(c);
		if(c==1||c==3) rep(i,0,5) o(3);
		else if(kd[1]==1&&kd[2]==1){
			rep(i,0,5){
				if(d[i]==1) o(1);
				else o(2);
			}
		}else if(kd[2]==1&&kd[3]==1){
			rep(i,0,5){
				if(d[i]==2) o(1);
				else o(2);
			}
		}else if(kd[3]==1&&kd[1]==1){
			rep(i,0,5){
				if(d[i]==3) o(1);
				else o(2);
			}
		}
	}
}

Measured memory_bytes: 1156
#include<set>
#include<queue>
#include<utility>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<numeric>
#include<functional>
#include<string>
#include<iostream>
using namespace std;
const long long int one = 1;
const long long int big = (one<<40);
typedef long long int llint;
bool solve(void){
	int n,m,i,x,y,gx,gy,ok;
	set<pair<llint,llint>> Ms;
	set<pair<llint,llint>> Ns;
	scanf("%d",&m);
	if(m==0){return false;}
	for(i=0;i<m;i++){
		scanf("%d %d",&x,&y);
		Ms.insert(make_pair(x,y));
		if(i==0){gx=x;gy=y;}
	}
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&x,&y);
		Ns.insert(make_pair(x,y));
	}
	for(auto it=Ns.begin();it!=Ns.end();it++){
		x=it->first-gx;
		y=it->second-gy;
		ok=1;
		for(auto its=Ms.begin();its!=Ms.end();its++){
			if(Ns.find(make_pair(its->first+x,its->second+y))==Ns.end()){
				ok=0;break;
			}
		}
		if(ok==1){printf("%d %d\n",x,y);}
	}
	return true;
}
int main(void){while(solve()){}return 0;}

Measured memory_bytes: 3208
#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>;

const int INF = 1001001001;

int a[12][12];

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    rep(i, n){
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }

    int ans = INF;
    rep(s, 1 << n) {
        int cost = 0;
        vector<int> d(m);
        rep(i, n){
            if(s>>i&1) {
                cost += c[i];
                rep(j, m) d[j] += a[i][j];
            }
        }
        bool ok = true;
        rep(j, m) if(d[j] < x) ok = false;
        if(ok) ans = min(ans, cost);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

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

int dp[110000];
const int MAX_N = 110000;

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

    for (int i = 0; i < MAX_N; i++) dp[i] = n;
    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 1; i+j <= n; j *= 6) {
            dp[i+j] = min(dp[i+j], dp[i]+1);
        }
        for (int j = 1; i+j <= n; j *= 9) {
            dp[i+j] = min(dp[i+j], dp[i]+1);
        }
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,a,b;
    cin >> n >> m;
    vector<vector<ll>> g(n);
    rep(i,m){
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<ll> q;
    q.push(0);
    vector<ll> sign(n);
    vector<bool> done(n,0);
    done[0] = true;
    while(!q.empty()){
        ll v = q.front();
        //PRINT(v);
        q.pop();
        for (ll u:g[v]){
            if (done[u]) continue;
            sign[u] = v;
            done[u] = true;
            q.push(u);
        }
    }
    PRINT("Yes");
    rep(i,1,n){
        PRINT(sign[i]+1);
    }
}


Measured memory_bytes: 13024
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    
    int count = 0;

    for (int i = 0; i < 3; ++i) {
        if (s[i] == t[i]) ++count;
    }

    cout << count << endl;
}


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

using namespace std;

vector<int> arr;

int main(){

    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //freopen("input.txt", "r", stdin);

    int n, k;
    string a;
    char b;

    cin >> n >> a >> k;

    b = a[k - 1];

    for(char i : a){
        if(i == b){
            cout << i;
        } else {
            cout << '*';
        }
    }

    return 0;
}


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

using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int m = max({a,b,c});
  if((3*m)%2==(a+b+c)%2){
    cout << (3*m-(a+b+c))/2;
  }
  else{
    cout << (3*(m+1)-(a+b+c))/2;
  }
  cout << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-12;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

struct data{ double px, py, pz, vx, vy, vz, r, vr; };
vector<data> v;

double col(int A, int B)
{
	data a = v[A], b = v[B];
	double p = pow(a.vx - b.vx, 2) + pow(a.vy - b.vy, 2) + pow(a.vz - b.vz, 2) - pow((a.vr + b.vr), 2);
	double q = 2 * ((a.px - b.px)*(a.vx - b.vx) + (a.py - b.py)*(a.vy - b.vy) + (a.pz - b.pz)*(a.vz - b.vz) + (a.vr + b.vr)*(a.r + b.r));
	double r = pow(a.px - b.px, 2) + pow(a.py - b.py, 2) + pow(a.pz - b.pz, 2) - pow(a.r + b.r, 2);
	if (abs((pow(q, 2) - 4 * p*r)) < EPS) return -1;
	double ans1 = (-q + sqrt(pow(q, 2) - 4 * p*r)) / (2 * p);
	double ans2 = (-q - sqrt(pow(q, 2) - 4 * p*r)) / (2 * p);
	if (ans2>EPS) return ans2;
	else return ans1;
}

struct event{double time; vector<int> del; };
bool comp(const event& l, const event& r)
{
	return l.time < r.time;
}

int main()
{
	int n;
	while (cin >> n, n)
	{
		v.clear();
		double life[202];

		vector<event> events;
		REP(i, n)
		{
			double a[8];
			REP(i, 8) cin >> a[i];
			v.push_back(data{ a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7] });
		}
		REP(i, n)
		{
			life[i] = v[i].r / v[i].vr;
			vi tmp;
			tmp.push_back(i);
			events.push_back(event{life[i], tmp});
		}

		REP(i, n-1)FOR(j,i+1, n)
		{
			double tmp = col(i, j);
			if (tmp < EPS) continue;
			vi t;
			t.push_back(i);
			t.push_back(j);
			if (tmp < life[i] && tmp < life[j]) events.push_back(event{tmp, t});
		}
		sort(ALL(events), comp);
		bool alive[202];
		REP(i, n) alive[i] = true;
		int cnt = 0;
		double ans[202];
		REP(i, events.size())
		{
			vi tmp = events[i].del;
			bool f = true;
			REP(j, tmp.size())
			{
				if (!alive[tmp[j]]) f = false;
			}
			if (f)
			{
				REP(j, tmp.size())
				{
					alive[tmp[j]] = false;
					ans[tmp[j]] = events[i].time;
				}
			}
		}
		REP(i, n) cout << D10 << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1404
import java.util.Scanner;

public interface Main {
	static int a = 1;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.printf("%d %d\n",a*b,(a+b)*2);
	}
}



Measured memory_bytes: 26276
import sys
input = sys.stdin.buffer.readline

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB = sorted(AB)

answer = 0
for a, b in AB:
  if M > b:
    answer += a * b
    M -= b
  else:
    answer += a * M
    break

print(answer)

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

int main() {
	string s, ns;
	int n, k;
	while(cin>>s && s!="-")
	{
		ns = s;
		int sum=0;
		cin>>n;
		while(n--)
		{
			cin>>k;
			sum+=k;
		}
		
		int iteration = sum % s.length();
		int sLen = s.length();
		for(int i=0; i<sLen; i++)
		{
			ns[(sLen + i - iteration) % sLen] = s[i];
		}
		cout<<ns<<endl;
	}
	return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
pair<int, int> a[200001];
int b[200001];
int main(){
    int n,i,j;
    cin>>n;
    for(i=1; i<=n; ++i)
        cin>>a[i].f, a[i].s=i;
    sort(a+1,a+n+1);
    for(i=1; i<=n/2; ++i)
        b[a[i].s]=a[n/2+1].f;
    for(i=n/2+1; i<=n; ++i)
        b[a[i].s]=a[n/2].f;
    for(i=1; i<=n; ++i)
        cout<<b[i]<<"\n";
    return 0;
}


Measured memory_bytes: 4480
x, y = map(int, input().split())
ax, ay = abs(x), abs(y)
ans = 0
if x >= 0:
    if y > 0:
        if x > y:
            x *= -1
            ans += 1
            ans += (-y) - x
            ans += 1
        else:
            ans += y - x
    else:
        ans += abs(ax - ay) + 1
else:
    if y > 0:
        if ax > ay:
            ans += ax - ay
            ans += 1
        else:
            ans += 1
            x *= -1
            ans += y - x
    else:
        if ay <= ax:
            ans += ax - ay
        else:
            ans += 1
            x *= -1
            ans += ay - ax
            ans += 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;;
using namespace atcoder;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S gsecond
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,q;cin >> n >> q;
  fenwick_tree<ull> ft(n);
  rep(i,n){
      ll a;cin >> a;
      ft.add(i, a);
  }
  rep(i,q){
      ll t,a,b;
      cin >> t >> a >> b;
      if(t==0){
          ft.add(a,b);
      }else{
          cout << ft.sum(a,b) << endl;;
      }
  }
}

Measured memory_bytes: 8240
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    let n = read_i64();
    let res = if n % 2 == 0 { n } else { 2 * n };
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec_i64<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
 
public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    System.out.println(n%2!=0?(double)(n/2+1)/n:(double)(n/2)/n);
  }
}

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

int univcnt = 0;
char kigoa[8][4] = {};
char str[8] = {};
int hoge(int n,char kigo){
  if(n==2){
    str[n] = kigo;
    str[n+1] = '\0';
    strcpy(kigoa[univcnt],str);
    univcnt++;
  }else{
    str[n] = kigo;
    hoge(n+1,'+');
    hoge(n+1,'-');
  }
}
int main(){
  int a = 0;
  char c[4] = {};
  int b[3] = {};
  int i = 0;
  int j = 0;
  int init = 0;
  scanf("%c%c%c%c",&c[0],&c[1],&c[2],&c[3]);
  a = c[0]-'0';
  b[0] = c[1]-'0';
  b[1] = c[2]-'0';
  b[2] = c[3]-'0';
  //printf("%d/",a);

  hoge(0,'+');
  hoge(0,'-');
  /*for(i=0;i<8;i++){
    //printf("%d/",b[i]);
    //printf("%s/",kigoa[i]); 
  }*/
  for(i=0;i<8;i++){
    init = a;
    for(j=0;j<3;j++){
      if(kigoa[i][j] == '+'){
        init += b[j];
        c[j] = '+';
      }else{
        init -= b[j];
        c[j] = '-';
      }
    }
    
  
  if(init == 7){  
    printf("%d%c%d%c%d%c%d=7",a,c[0],b[0],c[1],b[1],c[2],b[2]); 
    break;
    }
  }
    
    
    
  return 0;
}
  
    

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

int main() {
  int n;
  cin >> n;
  vector<int> c(n,-1);
  rep(i,0,n) {
    int a;
    cin >> a;
    int k = lower_bound(c.begin(), c.end(), a) - c.begin();
    c[k-1] = a;
  }
  int ans = 0;
  rep(i,0,n) {
    if (c[i] != -1) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N, one, ten, hundred, thousand, good;
  cin >> N;
  
  one = N % 10; //一の位
  ten = (N - one) % 100 / 10; //十の位
  hundred = (N - one - ten * 10) % 1000 / 100; //百の位
  thousand = (N - one - ten * 10 - hundred * 100) / 1000; //千の位
  
  //良い整数ならgood=1,そうでなければgood=0
  if ( ten == hundred ) {
  	if ( one == ten || hundred == thousand ) {
    	good = 1;
    }else { good = 0; }
  }else {
  	good = 0;
  }
  
  if ( good == 1 ) {
  	cout << "Yes" << endl;
  }else {
  	cout << "No" << endl;
  }
}

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

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

const int INF  = 100000001;

typedef pair<int, int> P;

char maze[50][50];

int r,c;
int sy,sx;
int gy,gx;

int d[50][50];

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

int bfs(){
    queue<P> que;
    rep(i,r){
        rep(j,c){
            d[i][j] = INF;
        }
    }
    que.push(P(sx, sy));
    d[sx][sy] = 0;
    
    while(que.size()){
        P p = que.front(); que.pop();
        if(p.first == gx && p.second == gy) break;

        rep(i,4){
            int nx = p.first + dx[i], ny = p.second + dy[i];
            
            if (0 <= nx && nx < r && 0<= ny && ny < c && maze[nx][ny] != '#' && d[nx][ny] == INF){
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    return d[gx][gy];
}

int main() {
    cin>>r>>c;
    sy=0,sx=0;
    gy=c-1,gx=r-1;
    int cc=0;
  
    string str;
    rep(i,r){
      cin>>str;
      rep(j,c){
          if(str[j] == '#'){
              maze[i][j]='#';
              cc++;
          }
          else maze[i][j]='.';
      }
  }

    int res = bfs();
    int ans = r*c - cc - (res+1);
    if(res==INF) ans=-1;
    cout<<ans<<endl;
	return 0;
}

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

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

const string ord = "IVXLCDM";
vector<P> v;

void init() {
    v.push_back(P(2, 1));

    for (int i = 1; i < ord.size(); i++) {
        if (i & 1) v.push_back(P(v[i - 1].first + 1, 5 * v[i - 1].second));
        else v.push_back(P(2 * v[i - 2].first, 2 * v[i - 1].second));
    }
}

int main() {
    init();

    string input;
    while (cin >> input) {
        input += "?";

        int ans = 0;
        int sz = input.size();
        for (int i = 1; i < sz; i++) {
            int pre = ord.find(input[i - 1]), now = ord.find(input[i]);

            if (v[now].first - v[pre].first == 1 || v[now].first / v[pre].first == 2) {
                ans -= v[pre].second;
            } else {
                ans += v[pre].second;
            }
        }
        
        cout << ans << endl;
    }
}


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

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

    //freopen("input.txt","r",stdin);

    int t;
    cin>>t;
    if(t>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}





Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d = scanner.nextInt();
        int x = 0;
        int y = 0;
        x = ((n+a-1) / a) * b;
        y = ((n+c-1) / c) * d;
        if (x >= y) {
            System.out.println(y);
        } else {
            System.out.println(x);
        }
    }
}



Measured memory_bytes: 26232
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	LL A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;
	if(abs(A-B)>T*(V-W))  cout << "NO" << endl;
	else cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    ll a, v;
    cin >> a >> v;
    ll b, w;
    cin >> b >> w;
    ll t;
    cin >> t;

    ll diff = abs(a-b);
    ll vdiff = v-w;

    bool isok = false;
    if (vdiff > 0){
        if (vdiff * t >= diff){
            isok = true;
        }
    }
    if (isok) cout << "YES" << endl;
    else cout << "NO" << endl;
}



Measured memory_bytes: 3636
/* Ohajiki Game */
import java.io.*;

public class Main{
	public static void main(String[] args){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		while((line = in.readLine()) != null){
			int n = Integer.parseInt(line);
			if(n==0) break;
			line = in.readLine();
			String[] tmp = line.split(" ");
			int[] seq = new int[n];
			for(int i=0; i<n; i++){
				seq[i] = Integer.parseInt(tmp[i]);
			}
			
			int rest = 32;
			int idx = 0;
			while(rest > 0){
				rest -= (rest-1) % 5;
				System.out.println(rest);
				
				rest -= seq[idx];
				if(rest <= 0){
					System.out.println(0);
					break;
				}
				System.out.println(rest);
				
				idx = (idx+1)%n;
			}
		}
	}
}

Measured memory_bytes: 9792
#include <stdio.h>
 
int main()
{
    int S,h,m,s;              
    scanf("%d", &S);   
    h=S/3600;
    m=(S%3600)/60;
    s=S%60;
    printf("%d:%d:%d\n", h,m,s); 
    return(0);
}


Measured memory_bytes: 2112
import itertools

N = int(input())
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]

L = [i for i in range(1, N + 1)]
P = tuple(P)
Q = tuple(Q)

i = 1
for e in itertools.permutations(L):
#     print(e)
    if e == P:
        a = i
    if e == Q:
        b = i
    i += 1
print(abs(a - b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


V<string> split(const string& s, char c) {
  V<string> res;
  stringstream ss(s);
  string t;
  while (getline(ss, t, c)) res.push_back(t);
  return res;
}

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string s;
  while (getline(cin, s)) {
    auto ss = split(s, ' ');
    int a = stoi(ss[0]), b = stoi(ss[1]);
    cout << a + b << '\n';
  }
}


Measured memory_bytes: 3160
n = int(input())
robots = []
for i in range(n):
    x_tmp, l_tmp = (int(i) for i in input().split())
    robots.append([x_tmp - l_tmp, x_tmp + l_tmp])

robots.sort()
ans = n
right = robots[0][1]
for i in range(n-1):
    if(robots[i+1][0] < right):
        ans -= 1
        right = min(right, robots[i+1][1])
    else:
        right = robots[i+1][1]
print(ans)


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

int main(){
 while(1){
 string str;
 cin>>str;
 if(str=="0"){
  break;
 }
 int sum=0;
 for(int i=0;i<(int)str.size();i++){
 sum+=str[i]-'0';
}
cout<<sum<<endl;
}
}


Measured memory_bytes: 3140
#include <iostream>

int main() {
  int a,b,c,d,e,k;
  std::cin >> a >> b >> c >> d >> e >> k;
  if(e-a > k)
    std::cout << ":(" << std::endl;
  else
    std::cout << "Yay!" << std::endl;
  return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

bool test (string s) {
  if (s.length % 2) return false;
  foreach (i; 0 .. s.length) {
    if (i % 2) {
      if (s[i] != 'i') return false;
    } else {
      if (s[i] != 'h') return false;
    }
  }
  return true;
}

void main() {
  string s = readln.stripRight;
  writeln (test (s) ? "Yes" : "No");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 1000000000;
const int MAX_E = 100000000;
const int MAX_V = 100000000;
typedef int64_t ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	int X;
	cin >> X;
	for (int i = 0; i <= X/100 ; i++)
	{
		int zan = X - i * 100;
		if (0<= zan && zan<= 5*i)
		{
			puts("1");
			return 0;
		}
	}
	puts("0");
	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = -1e14;
int n,m;
ll x[1005];
ll y[1005];
ll z[1005];
ll v[1005];
int main() {
  cin >> n >> m;
  ll ans = INF;
  for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];

  for(int i = 0; i < 8; i++) {
    int a = (i & 1) ? -1 : 1;
    int b = (i & 2) ? -1 : 1;
    int c = (i & 4) ? -1 : 1;
    for(int j = 0; j < n; j++) {
      v[j] = a * x[j] + b * y[j] + c * z[j];
    }
    sort(v,v+n);
    reverse(v,v+n);
    ll cur = 0;
    for(int j = 0; j < m; j++) cur += v[j];
    ans = max(ans,cur);
  }
  cout << ans << endl;
  }


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    int N, M; cin >> N >> M;
    vvi jobs(M, vi());
    rep(i, 0, N){
        int a, b; cin >> a >> b;
        if(a > M) continue;
        jobs[M-a].push_back(b);
    }
    priority_queue<int> q;
    ll ans = 0;
    for(int i=M-1; i>=0; i--){
        for(int b: jobs[i]){
            q.push(b);
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


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

ll M,N,V,P;
vector< ll > A;

bool judge( ll mid ) {
//  cout << " A[mid] " << A[mid] << endl;
  // A[mid]+M < A[P-1] なら何をやってもNG
  if ( A[mid] + M < A[P-1] ) return false;

  ll zan = (V-1) * M;
//  cout << " " << zan << endl;
  // A[mid]+M よりも大きいスコアが P-1 個以下ならOK
  //  A[mid+1]～A[N-1] は +M しても影響なし。
  zan -= (N-(mid+1)) * M;
//  cout << " " << zan << endl;
  //  大きい順に P-1 個目までは +M しても影響なし。
  zan -= (P-1) * M;
//  cout << " " << zan << endl;
  if ( zan <= 0 ) return true;
  // 残った A[P-1] ～ A[mid-1] までの区間で、A[mid] を超えないように足す
  for (int i=P-1; i<mid; i++) {
    zan -= (A[mid]+M-A[i]);
//    cout << " " << zan << endl;
    if ( zan <= 0 ) return true;
  }
  return false;		// それでも余ったらNG
}

int main() {
  cin >> N >> M >> V >> P;
  REP(i,N) {
    ll a;
    cin >> a;
    A.push_back(a);
  }

  sort(A.begin(), A.end(), greater<ll>() );
  
  ll l = P-1;	// 大きい順にP個目までは、無条件でOK
  ll r = N;
  ll mid;
  while( l+1 < r ) {
    mid = (l+r)/2;
    if ( judge(mid) ) {
//      cout << mid << " OK" << endl;
      l = mid;
    } else {
//      cout << mid << " NG" << endl;
      r = mid;
    }
  }
  cout << (l+1) << endl;
}


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

int n, K, ans, a[112345];
std::vector<int> g[112345];

int dfs(int u) {
	int mx = 0;
	for (int v: g[u]) {
		mx = std::max(mx, dfs(v) + 1);
	}
	if(u != 1 && mx == K - 1) {
		ans += (a[u] != 1);
		mx = -1;
	}
//	printf("dfs(%d) = %d\n", u, mx);
	return mx;
}

int main() {
	scanf("%d%d", &n, &K);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		if(i > 1) {
			g[a[i]].push_back(i);
		}
	}
	ans = (a[1] != 1);
	dfs(1);
	printf("%d\n", ans);
}

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

int main() 
{
    int n;

    cin >> n;

    for( int i = 1; i <= n; i++ )
    {
        int x = i;

        if( i % 3 == 0 || i % 10 == 3 )
            cout << " " << i;
        else
            while( x != 0)
            {
                x /= 10;
                if( x % 10 == 3 )
                {
                    cout << " " << i;
                    break;
                }
                    
            }
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 3096
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, k, h;
signed main() {
	cin >> n >> k;
	int ans = 0;
	rep(i, n) {
		cin >> h;
		if (h >= k)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, d);
    Sort(d);
    
    int lb = d[n/2-1], ub = d[n/2];
    Cout(ub-lb);
}




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

int main () {
  int N;
  cin >> N;
  
  switch (N % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
      break;      
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string a, b;
    cin >> a;
    cin >> b;
    if (a.size() > b.size()) {
        cout << "GREATER";
        return 0;
    }
    else if (a.size() < b.size()) {
        cout << "LESS";
        return 0;
    }
    else {
        rep(i, 0, a.size()) {
            if (a[i] > b[i]) {
                cout << "GREATER";
                return 0;
            }
            else if (a[i] < b[i]) {
                cout << "LESS";
                return 0;
            }
            else
                continue;
        }
    }
    cout << "EQUAL";
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

public class Main {

	int f(int x) {
		return x == 0 ? 0 : (x % 10 + f(x / 10));
	}
	
	void submit() {
		int n = nextInt();
		int ret = Integer.MAX_VALUE;
		for (int i = 1; i <= n - i; i++) {
			ret = Math.min(ret, f(i) + f(n - i));
		}
		
		out.println(ret);
	}

	void test() {

	}

	void stress() {
		for (int tst = 0;; tst++) {
			if (false) {
				throw new AssertionError();
			}
			System.err.println(tst);
		}
	}

	Main() throws IOException {
		is = System.in;
		out = new PrintWriter(System.out);
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();
	static final int C = 5;

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	private InputStream is;
	PrintWriter out;

	private byte[] buf = new byte[1 << 14];
	private int bufSz = 0, bufPtr = 0;

	private int readByte() {
		if (bufSz == -1)
			throw new RuntimeException("Reading past EOF");
		if (bufPtr >= bufSz) {
			bufPtr = 0;
			try {
				bufSz = is.read(buf);
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
			if (bufSz <= 0)
				return -1;
		}
		return buf[bufPtr++];
	}

	private boolean isTrash(int c) {
		return c < 33 || c > 126;
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isTrash(b))
			;
		return b;
	}

	String nextToken() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!isTrash(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	String nextString() {
		int b = readByte();
		StringBuilder sb = new StringBuilder();
		while (!isTrash(b) || b == ' ') {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	char nextChar() {
		return (char) skip();
	}

	int nextInt() {
		int ret = 0;
		int b = skip();
		if (b != '-' && (b < '0' || b > '9')) {
			throw new InputMismatchException();
		}
		boolean neg = false;
		if (b == '-') {
			neg = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				ret = ret * 10 + (b - '0');
			} else {
				if (b != -1 && !isTrash(b)) {
					throw new InputMismatchException();
				}
				return neg ? -ret : ret;
			}
			b = readByte();
		}
	}

	long nextLong() {
		long ret = 0;
		int b = skip();
		if (b != '-' && (b < '0' || b > '9')) {
			throw new InputMismatchException();
		}
		boolean neg = false;
		if (b == '-') {
			neg = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				ret = ret * 10 + (b - '0');
			} else {
				if (b != -1 && !isTrash(b)) {
					throw new InputMismatchException();
				}
				return neg ? -ret : ret;
			}
			b = readByte();
		}
	}
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
  int n;cin>>n;
  vector<ll> vec(n);
  
  rep(i,n) cin>>vec[i];
  vector<ll> copy = vec;
  sort(copy.begin(),copy.end());
  ll max = copy[n-1];
  ll max2 = copy[n-2];
  rep(i,n) {
    if (vec[i]==max) {
      cout<<max2<<endl; 
    }
    else {
      cout<<max<<endl;
    }
  }
}

Measured memory_bytes: 4736
a_list = []
for i  in range(3):
  a_list.append(list(map(int,input().split())))
n = int(input())
b_list = []
result_list = [[0,0,0] for i in range(3)]
for i in range(n):
  b_list.append(int(input()))
for s in range(3):
  for m in range(3):
    if a_list[s][m] in b_list:
      result_list[s][m] = 1
check = False
if result_list[0][0] == result_list[1][1] and result_list[0][0] == result_list[1][1] and result_list[1][1] ==1:
  check = True
elif result_list[0][2] == result_list[1][1] and result_list[2][0] == result_list[1][1] and result_list[1][1] ==1:
    check = True
elif result_list[0][1] == result_list[0][2] and result_list[0][2] == result_list[0][0] and result_list[0][0] ==1:
    check = True
elif result_list[1][1] == result_list[1][2] and result_list[1][2] == result_list[1][0] and result_list[1][0] ==1:
    check = True 
elif result_list[2][1] == result_list[2][2] and result_list[2][2] == result_list[2][0] and result_list[2][0] ==1:
    check = True
elif result_list[0][0] == result_list[1][0] and result_list[1][0] == result_list[2][0] and result_list[2][0] ==1:
    check = True
elif result_list[0][1] == result_list[1][1] and result_list[1][1] == result_list[2][1] and result_list[2][1] ==1:
    check = True
elif result_list[0][2] == result_list[1][2] and result_list[1][2] == result_list[2][2] and result_list[2][2] ==1:
    check = True
if check == True:
  print("Yes")
else:
  print("No")

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

int main(){
    ll N; cin >> N;
    vector<ll> H(N);
    for(int i = 0; i < N; i++) cin >> H[i];

    for(int i = 0; i < N; i++){
        if(i == 0) H[i]--;
        else if(H[i] - H[i-1] >= 1) H[i]--;

        if(i != 0 && H[i-1] > H[i]){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;
    cin >> h >> w;
    if(h==1||w==1){
        cout << 1 << endl;
    }else if(h%2LL==0LL||w%2LL==0LL){
        ll ans = (h*w)/2LL;
        cout << ans << endl;
    }else{
        ll ans = (h*(w-1))/2LL + (h+1)/2LL;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256