akhauriyash/Code-Regression huggingface dataset:
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n, a[N];

typedef pair<int, int> pii;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    for (int i = 0; i < n; i++){
        cin>>a[i];
    }
    
    sort(a, a+n);
    
    int ans = 0;
    
    vector<pii> mov;
    
    ans += a[n-1] - a[0];
    
    mov.push_back({a[n-1], a[0]});
    
    
    
    int neg = 0;
    for (int i = 1; i < n-1; i++){
        if(a[i]>=0){
            pii tmp = mov.back();
            mov.pop_back();
            mov.push_back({tmp.second, tmp.first});
            mov.push_back({a[i], -ans});
        }else{
            mov.push_back({ans, a[i]});
        }
        ans += abs(a[i]);
    }
    
    cout<<ans<<endl;
    

    for (int i = 0; i < n-1; i++){
        cout<<mov[i].first<<' '<<mov[i].second<<endl;
    }
    
    
    
    
    
    return 0;
}



Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <cmath>

using namespace std;

using ll = long long;
using vl = vector<long long>;
using vi = vector<int>;
using vvl = vector<vl>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

int main()
{
    int n; cin >> n;
    vvi c(n, vi(3));
    for (auto &e : c)
        for (auto &v : e)
            cin >> v;
    vvi dp(n, vi(3, 0));
    for (int i = 0; i < 3; i++)
        dp[0][i] = c[0][i];
    for (int i = 1; i < n; i++)
        for (int j = 0; j < 3; j++)
            for (int k = 0; k < 3; k++)
                if (k != j)
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + c[i][j]);
    int res = 0;
    for (int i = 0; i < 3; i++)
        res = max(res, dp[n - 1][i]);
    cout << res;
    return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//or-> ||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	ll N;
	cin>>N;
	ll A[N+1];
	rep(i,0,N+1) cin>>A[i];
	ll minn[N+1],maxx[N+1];
	for(ll i=N;i>=0;i--){
		if(i==N){
			minn[i]=maxx[i]=A[i];
		}
		else{
			if(minn[i+1]%2==0){
				minn[i]=minn[i+1]/2+A[i];
			}
			else{
				minn[i]=minn[i+1]/2+A[i]+1;
			}
			maxx[i]=maxx[i+1]+A[i];
		}
	}

	ll ans;
	ans=0;
	if(minn[0]>1){
		ans=-1;
	}
	else{
		ans=1;//根
		ll prevv=1;
		rep(i,1,N+1){
			prevv=2*(prevv-A[i-1]);
			prevv=min(INF,prevv);
			DBG(i,prevv,maxx[i],"");
			ans+=min(prevv,maxx[i]);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int bit2count(int a)
{
    for (int i = 0; i < 31; ++i)
        if (a & (1 << i))
            return i;
    return -1;
}

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i], a[i] /= 2;
    int m2 = bit2count(a[0]);
    ll lcm = 1;
    rep(i, n)
    {
        if (bit2count(a[i]) != m2)
        {
            cout << 0 << endl;
            return 0;
        }
        lcm = lcm / __gcd(lcm, ll(a[i])) * ll(a[i]);
        if (lcm > m)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = 0;
    for (ll i = lcm; i <= m; i += ll(2) * lcm)
        ++ans;
    cout << ans << endl;
}

Measured memory_bytes: 3740
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define reps(i,n) for(int i=1;i<=(int)n;i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    ll X,Y; cin >> X >> Y;
    if(X % Y == 0){
        cout << -1 << endl;
        return 0;
    }else{
        cout << X << endl;
        return 0;
    }

}

Measured memory_bytes: 3568
n = int(input())
A = []
B = []
for i in range(n):
    a, b = [int(_) for _ in input().split()]
    A.append(a)
    B.append(b)
cnt = 0
A = A[::-1]
B = B[::-1]
for i in range(n):
    A[i] += cnt
    if A[i]%B[i] != 0:
        cnt += B[i] - A[i]%B[i]

print(cnt)

Measured memory_bytes: 14856
import sys
input = sys.stdin.readline

a,b=map(int,input().split())

def yakusu(x,X):
    for i in range(1,int(x**0.5)+1):
        if x%i==0:
            X.append(i)
            if x!=i:
                X.append(x//i)
    
A=[]
B=[]
yakusu(a,A)
yakusu(b,B)
A.sort()
B.sort()
#print(A,B)
kouyakusu=[]
i=0
j=0
while i<len(A) and j<len(B):
    if A[i]==B[j]:
        kouyakusu.append(A[i])
        i+=1
        j+=1
    elif A[i]>B[j]:
        j+=1
    else:
        i+=1

ans=0
for i in range(1,len(kouyakusu)):
    if not(kouyakusu[i]): continue
    ans+=1
    for j in range(i+1,len(kouyakusu)):
        if kouyakusu[j]%kouyakusu[i]==0:
            kouyakusu[j]=False
#print(kouyakusu)
print(ans+1)

Measured memory_bytes: 40432
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) a.begin(),a.end()
using namespace std;

int main()
{
	int d;
	cin >> d;
	if (d == 25) {
		cout<<"Christmas"<<endl;
	}
	else if (d == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (d == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if(d == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
	return 0;
}


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

int main() {

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    long long n;
    cin>>n;
    long long temp = n;
    int units = n % 10;
    int digits = 0;
    int sum = 0;
    int msb;
    while(n > 0) {
    	msb = n % 10;
    	n /= 10;
    	digits++; 
    }
    digits--;
    if(units == 9)
    	sum += (digits * 9) + msb;
    else if(digits == 0)
    	sum += msb;
    else
    	sum += (digits * 9) + --msb;

    cout << sum;


	return 0;		
}


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

int main() {
    int N,K;
    cin>>N>>K;
    vector<int> A(N+1);
    for(int i=0; i<N; i++) {
        int n;
        cin>>n;
        ++A[n];
    }
    sort(A.begin(), A.end());
    int ans=0;
    for(int i=0; i<=N-K; i++) 
        ans+=A[i];
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  map<string, int>mp;
  for (int i=0; i<n; i++){
    string s;
    cin>>s;
    mp[s]++;
  }
  int mx = 0;
  for (auto p : mp) mx = max(mx, p.second);
  for (auto p : mp){
    if (p.second == mx) cout << p.first << endl;
  }
}

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

int main() {
	ll n;
	cin >> n;
	cout << n * (n-1) / 2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstddef>
#include <algorithm>

#pragma warning(disable : 4996)

using namespace std;

int main()
{
	while (true)
	{
		int N, A; size_t MAX = 15000;

		vector<char> D;

		scanf("%d", &N);

		if (N == 0) { break; }

		for (int i = 0; i < N; i++)
		{
			scanf("%d", &A);

			D.push_back(A);
		}

		for (int i = 0; i < N; i++)
		{
			for (char j = 1; j <= 3; j++)
			{
				if (D[i] != j)
				{
					vector<char> E(D.begin(), D.end());

					E[i] = j;

					for (int k = 0; k < E.size() - 3; k++)
					{

					loop:;

						if (E.size() <= 3)
						{
							break;
						}

						if (E[k] == E[k + 1] && E[k + 1] == E[k + 2] && E[k + 2] == E[k + 3])
						{
							for (char l = 0; l < 3; l++)
							{
								E.erase(E.begin() + k);
							}

							while (k < E.size() - 1 && E[k] == E[k + 1])
							{
								E.erase(E.begin() + k);
							}

							if (k < E.size())
							{
								E.erase(E.begin() + k);
							}

							k = 0;

							goto loop;
						}
					}

					MAX = min(E.size(), MAX);
				}
			}
		}

		printf("%d\n", MAX);
	}

	return 0;
}

// Time : O( 3n ^ 3 )

Measured memory_bytes: 2600
while True:
    H,W = tuple(int(n) for n in input().split())
    if H == 0 and W == 0:
        break
    for h in range(H):
        if h % 2 == 0:
            if W % 2 == 0:
                print("#."*(W//2))
            elif W % 2 == 1:
                print("#."*(W//2) + "#")
        elif h % 2 == 1:
            if W % 2 == 0:
                print(".#"*(W//2))
            elif W % 2 == 1:
                print(".#"*(W//2) + ".")
    print("")


Measured memory_bytes: 5616
#include<cstdio>
#include<iostream>

using namespace std;

int main(void){

	int x,y;

	while(1){

		cin>>x>>y;
		if(x==0&&y==0) break;
	
		if(x>y) x=x+y,y=x-y,x=x-y;
		cout<<x<<" "<<y<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int dp[3005][3005][2];
bool vis[3005][3005][2];
long long n;
long long rec(long long m,long long a,bool ok){
    if(m==0){
            if(ok)
        return 1;
        else
            return 0;
    }

    if(vis[m][a][ok])
        return dp[m][a][ok];
    vis[m][a][ok]=1;
    long long ans=0;
    if(a){
        if(a-1==0)
            ans=(ans+rec(m-1,a-1,1))%MOD;
        else
            ans=(ans+rec(m-1,a-1,ok))%MOD;
        if(a==1)
            ans=(ans+rec(m-1,a,1))%MOD;
        else
            ans=(ans+rec(m-1,a,ok))%MOD;
    }
    if(n-a){
        ans=(ans+rec(m-1,a+1,ok))%MOD;
        ans=(ans+rec(m-1,a,ok))%MOD;
    }
    return dp[m][a][ok]=ans;
}
int main(){
    int m;cin >> n >> m;
    long long ans=0;
    for(int i=1;i<=n;++i){
        ans=(ans+rec(m,i,0))%MOD;

        }
    ans=(ans+rec(m,0,1))%MOD;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 88576
#include <string>
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

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

    int w[n];
    for (int i = 0; i < n; i++) cin >> w[i];
    
    int s1 = 0, s2 = 0, min;
    s1 = w[0];
    for (int j = 1; j < n; j++) s2 += w[j];
    min = abs(s1 - s2);

    for (int i = 1; i < n; i++) {
        s1 = 0;
        s2 = 0;
        for (int j = 0; j <= i; j++) s1 += w[j];
        for (int j = i + 1; j < n; j++) s2 += w[j];
        if (min > abs(s1 - s2)) min = abs(s1 - s2);
    }
    
    cout << min << endl;

}


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

bool isOrder(string s){
  int n = s.size();
  rep(i,n){
    if(s[i]<=s[i+1]){
      return 0;
    }
  }
  return 1;
}

int main(){
  
  string s;
  cin >> s;
  int n = s.size();
  
  set<char> check;
  for(char c : s) check.insert(c);
  
  char next = 'a';
  while(check.count(next)>0){
    next ++;
  }
  
  if(n<26){
    cout << s << next << endl;
    return 0;
  }
  
  for(int i=n-1;i>=0;i--){
    string sub = s.substr(i,n-i);
    if(isOrder(sub)) continue;
    check = {};
    for(int j=0;j<i+1;j++){
      check.insert(s[j]);
      if(j==i){
        char next = s[j];
        while(check.count(next)>0){
          next ++;
        }
        cout << next << endl;
        return 0;
      }
      cout << s[j];
    }
  }
  
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
 
using namespace std;
 
int getPoint(int n,int k,vector<int> &v){
    int res = 0;
    for(int i = 0 ; i < n ; i++){
	if(i+k > n) break;
	int mul = 1;
	for(int j = i ; j < i+k ; j++){
	    mul *= v[j];
	}
	res = max(res,mul);
    }
    return res;
}
 
int main(){
    int n,k;
    while(true){
	cin >> n >> k;
	if(n == 0 && k == 0) break;
	vector<int> v(n);
	for(int i = 0 ; i < n ; i++){
	    cin >> v[i];
	}
	int Cb = getPoint(n,k,v),Ca = 0;
	for(int i = 0 ; i < n ; i++){
	    for(int j = i+1 ; j < n ; j++){
		swap(v[i],v[j]);
		Ca = max(Ca,getPoint(n,k,v));
		swap(v[i],v[j]);
	    }
	}
	if(Ca-Cb < 0){
	    cout << "NO GAME" << endl;
	}else{
	    cout << Ca-Cb << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    cout<< "ABC" << n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
typedef long long ll;
typedef complex<int> P;
typedef pair<int, int> Pii;



bool solve(){
	int n, k, m;
	cin>> n>> k>> m;
	if(n==0 && k==0 && m==0) return false;
	
	vector<int> a(n);
	for(int i=0;i<n;i++) a[i] = (i+1) % n;
	
	int p = m - 1;
	for(int j=0;j<n-1;j++){
		//cout<< p<< endl;
		for(int i=0;i<n;i++) if(a[i] == p) a[i] = a[p];
		//for(int i=0;i<n;i++) cout<< a[i]; cout<< endl;
		for(int i=0;i<k;i++) p = a[p];
	}
	
	cout<< p+1<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());

	return 0;
}

 

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N; cin >> N;
    map<string, int> MP;
    int M = 0;
    rep(i, 0, N){
        string S; cin >> S;
        MP[S]++;
        chmax(M, MP[S]);
    }
    for(auto e: MP){
        if(e.second == M){
            cout << e.first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 23808
use std::io;
use std::str::FromStr;

fn main() {
    let mut first_line = String::new();
    io::stdin().read_line(&mut first_line).unwrap();

    let n = i32::from_str(&first_line.trim()).unwrap();
    let mut counts: [u64; 5] = [0, 0, 0, 0, 0];

    for _ in 0..n {
        let mut line = String::new();
        io::stdin().read_line(&mut line).unwrap();
        match line.chars().next() {
            Some('M') => counts[0] += 1,
            Some('A') => counts[1] += 1,
            Some('R') => counts[2] += 1,
            Some('C') => counts[3] += 1,
            Some('H') => counts[4] += 1,
            _ => ()
        }
    }
    let mut answer: u64 = 0;
    for i in 0..5 {
        for j in 0..i {
            for k in 0..j {
                answer += counts[i] * counts[j] * counts[k];
            }
        }
    }
    println!("{}", answer);
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
 
using namespace std;
 
int dp[100005];
 
void solve() {
    string s;
    cin >> s;
    int n = s.size();
    dp[0] = 1;
    for (int i=0; i < n; ++i) {
        if (dp[i] == 0) continue;
        if ((i + 5 <= n) && (s.substr(i, 5) == "dream")) dp[i+5] = 1;
        if ((i + 7 <= n) && (s.substr(i, 7) == "dreamer")) dp[i+7] = 1;
        if ((i + 5 <= n) && (s.substr(i, 5) == "erase")) dp[i+5] = 1;
        if ((i + 6 <= n) && (s.substr(i, 6) == "eraser")) dp[i+6] = 1;
    }
    cout << (dp[n] ? "YES" : "NO");
 
}
 
int main() {
 
    solve();
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N1, N2, N3;
    cin >> N1 >> N2 >> N3;
    if (N1 + N2 + N3 >= 22) {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }
}


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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;

int main() {
    cin >> N;

    int t, x, y, last_t = 0, last_x = 0, last_y = 0;
    bool able = true;
    for (int i = 0; i < N; i++) {
        cin >> t >> x >> y;
        if ((x + y) % 2 != t % 2) {
            able = false;
            continue;
        }
        if (abs(last_t - t) < abs(last_x - x) + abs(last_y - y)) {
            able = false;
            continue;
        }
    }
    if (able) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import deque
#from functools import lru_cache

def permutation(n, x, mod=10**9+7):
    # nPx
    # 順列
    # ex) permutaion(5, 2) = 20
    tmp = 1
    for i in range(n, n-x, -1):
        tmp = (tmp * i) % mod
    return tmp

def power_func(a,n,p=10**9+7):
    bi = str(format(n,"b"))#2進表現に
    res = 1
    for i in range(len(bi)):
        res = (res*res) %p
        if bi[i] == "1":
            res = (res*a) %p
    return res


n,v=map(int,input().split())
m=10**9+7
perm1=deque([1])
perm2=deque([permutation(v,n)])
comb=deque([1])
ones=deque([1])
acc=((comb[-1]*perm1[-1]%m)*perm2[-1]**2)%m
for k in range(n):
  #nCk+1=nCk*(n-k/k+1)
  comb.append((comb.pop()*(n-k)*power_func(k+1,m-2))%m)
  #vPk+1=vPk*(v-k)
  perm1.append((perm1.pop()*(v-k))%m)
  #v-(k+1)Pn-(k+1)=v-kPn-k/(v-k)
  perm2.append((perm2.pop()*power_func(v-k,m-2))%m)
  #(-1)^k+1=(-1)^k*(-1)
  ones.append(ones.pop()*(-1))
  acc+=ones[-1]*((comb[-1]*perm1[-1]%m)*perm2[-1]**2)%m
print(acc%m)


Measured memory_bytes: 74440
#pragma warning(disable:4996)
#include<stdio.h>


int main(void) {
	int n;
	scanf("%d", &n);

	int ans = 0;
	int i = 1;
	int w = n / i;
	int count = 0;
	while (w) {
		i *= 10;
		++count;
		w = n / i;
	}

	switch (count) {
	case 6:
		ans = 90909;
		break;

	case 5:
		ans = 909;
		ans += (n - 9999);
		break;

	case 4:
		ans = 909;
		break;

	case 3:
		ans = 9;
		ans += (n - 99);
		break;

	case 2:
		ans = 9;
		break;

	case 1:
		ans =n;
		break;
	}
//	printf("%d\n", count); test
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final int h = 40;
		final int w = 100;

		System.out.println(h + " " + w);

		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int a = stdin.nextInt();
		int b = stdin.nextInt();

		for (int x = 0; x < w; x++) {
			System.out.print("#");
		}
		System.out.println();
		int count = 1;
		for (int y = 1; y < (h / 2); y++) {
			for (int x = 0; x < w; x++) {
				if ((x == 0) || (x == (w - 1))) {
					System.out.print("#");
				}
				else if ((count < a) && ((x + y) % 3 == 0)) {
					System.out.print(".");
					count++;
				}
				else {
					System.out.print("#");
				}
			}
			System.out.println();
		}

		for (int x = 0; x < w; x++) {
			System.out.print(".");
		}
		System.out.println();
		count = 1;
		for (int y = 1; y < (h / 2); y++) {
			for (int x = 0; x < w; x++) {
				if ((x == 0) || (x == (w - 1))) {
					System.out.print(".");
				}
				else if ((count < b) && ((x + y) % 3 == 0)) {
					System.out.print("#");
					count++;
				}
				else {
					System.out.print(".");
				}
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

pair<int, int> IN[100005];

int main(){
    long long n, k;
    cin >> n >> k;

    rep(i,n) cin >> IN[i].first >> IN[i].second;
    sort(IN, IN + n);
    show(IN[0].first)

    rep(i,n){
        if(k <= IN[i].second){
            cout << IN[i].first << endl;
            break;
        }else{
            k-=IN[i].second;
        }
    }
}


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

using namespace std;
typedef long long ll;

const int MAXN = 3e3 + 5;

ll ans;
int r, c, k;
int val[MAXN][MAXN];
ll dp[MAXN][MAXN][4];
int x, y, v;

int main() {
    // freopen("1.in", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> r >> c >> k;
    for (int i = 1; i <= k; i++) cin >> x >> y >> v, val[x][y] = v;
    for (int i = 1; i <= r; i++)
        for (int j = 1; j <= c; j++) {
            dp[i][j][0] = dp[i][j - 1][0];
            for (int k = 0; k <= 3; k++)
                dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][k]);
            for (int p = 1; p <= 3; p++) {
                dp[i][j][p] = dp[i][j - 1][p];
                if (val[i][j]) {
                    dp[i][j][p] =
                        max(dp[i][j][p], dp[i][j - 1][p - 1] + val[i][j]);
                    if (p == 1)
                        for (int k = 0; k <= 3; k++)
                            dp[i][j][p] =
                                max(dp[i][j][p], dp[i - 1][j][k] + val[i][j]);
                }
            }
        }
    for (int k = 0; k <= 3; k++) ans = max(ans, dp[r][c][k]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 320544
let () =
  let open Queue in
  let que = create () in
  let (n, q) = Scanf.scanf "%d %d\n" (fun n q -> (n, q)) in
  let rec read i =
    if i >= n then ()
    else (Scanf.scanf "%s %d\n" (fun s t -> add (s, t) que); read (i + 1))
  in
  read 0;
  let rec doit cnt ret =
    if is_empty que then List.rev ret
    else begin
      let (s, t) = take que in
      let rest = t - q in
      if rest <= 0 then let x = cnt + t in doit x ((s, x) :: ret)
      else (add (s, rest) que; doit (cnt + q) ret)
    end
  in
  List.iter (fun (s, t) -> Printf.printf "%s %d\n" s t) (doit 0 [])

Measured memory_bytes: 12152
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		while (sc.hasNext()) {
			String str = sc.next();
			String[] c = str.split(",");
			int[] vals=new int[5];
			for(int i=0;i<5;i++){
				vals[i]=Integer.parseInt(c[i]);
			}
			Arrays.sort(vals);

			Integer[] match = new Integer[5];
			Arrays.fill(match,0);
			boolean isStreight = true;
			int prev = -1;
			for (int i = 0, j = -1; i < 5; i++) {
				if (prev != vals[i])
					j++;
				if (i > 0 && (prev + 1 != vals[i]) ){
						isStreight = false;
				}
				prev = vals[i];
				match[j]++;
			}

			if(Arrays.equals(vals,new int[]{1,10,11,12,13})){
				isStreight=true;
			}

			Arrays.sort(match, Collections.reverseOrder());

			switch (match[0]) {
			case 4:
				ln("four card");
				break;
			case 3:
				if (match[1] == 2) {
					ln("full house");
					break;
				}
				if (isStreight) {
					ln("straight");
					break;
				}
				ln("three card");
				break;
			case 2:
				if (isStreight) {
					ln("straight");
					break;
				}
				switch (match[1]) {
				case 2:
					ln("two pair");
					break;
				default:
					ln("one pair");
					break;
				}
				break;
			default:
				if (isStreight) {
					ln("straight");
					break;
				}
				ln("null");
				break;
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.stream.IntStream;

class Main {
    private static int[][] area;
    private static int[] linesRows = new int[2];
    private static int[][] around = { { -1, -1 }, { -1, 0 }, { -1, 1 },
                                      { 0, -1 }, { 0, 1 },
                                      { 1, -1 }, { 1, 0 }, { 1, 1 } };

    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        while ((linesRows[1] = scanner.nextInt()) != 0) {
            linesRows[0] = scanner.nextInt();
            area = IntStream.range(0, linesRows[0])
                .mapToObj(l -> IntStream.range(0, linesRows[1])
                          .map(r -> scanner.nextInt())
                          .toArray())
                .toArray(int[][]::new);
            System.out.println(solve());
        }
    }
    private static long solve() {
        return IntStream.range(0, linesRows[0] * linesRows[1])
            .filter(n -> area[n / linesRows[1]][n % linesRows[1]] == 1)
            .filter(Main::traceIsland)
            .count();
    }
    private static boolean traceIsland(int n) {
        Queue<Integer> queue = new LinkedList<>();
        queue.offer(n);
        while (!queue.isEmpty()) {
            int s = queue.poll();
            if (area[s / linesRows[1]][s % linesRows[1]] == 1) {
                area[s / linesRows[1]][s % linesRows[1]] = 2;
                Arrays.stream(around)
                    .filter(a -> s % linesRows[1] + a[1] >= 0)
                    .filter(a -> s % linesRows[1] + a[1] < area[0].length)
                    .filter(a -> s / linesRows[1] + a[0] >= 0)
                    .filter(a -> s / linesRows[1] + a[0] < area.length)
                    .filter(a -> area[s / linesRows[1] + a[0]][s % linesRows[1] + a[1]] == 1)
                    .forEach(a -> queue.offer((s / linesRows[1] + a[0]) * linesRows[1] + (s % linesRows[1] + a[1])));
            }
        }
        return true;
    }
}



Measured memory_bytes: 57680
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int ques[] = new int[N];
        int correct = 0;
        int penalties = 0;
        for(int i=0; i<M; i++){
            int prob= sc.nextInt();
            String verdict= sc.next();
            if(ques[prob-1]==-1){
                continue;
            }
            if(verdict.equals("AC")){
                correct++;
                penalties += ques[prob-1];
                ques[prob-1] = -1;
            }
            else{
                ques[prob-1] += 1;
            }
        }
        System.out.println(correct);
        System.out.println(penalties);
    }
}

Measured memory_bytes: 64544
import numpy as np


def is_prime(a):
	if a==1:
		return False
	for k in range(2, int(np.sqrt(a)) +1):
		if a % k == 0:
			return False
	return True
def main():
	a = int(input())
	while True:
		if a==2:
			print(a)
			exit()
		else:
			if is_prime(a):
				print(a)
				exit()
			else :
				a +=1
if __name__ == "__main__":
	main()


Measured memory_bytes: 12496
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N1 100100
#define N2 1000010
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);



signed main()
{
    
    speed
    int x,y,z;cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;

    

    
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n;
string s,c;
int main(){
	in(n);
    cin>>s>>c;
    for(int i=0;i<n;i++)cout<<s[i]<<c[i];
    puts("");
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define rep(n,m) for(int i = n; i < m; i++)

int main(void) {
	int n = 0;
	int num[10];
	int count = 0;
	cin >> n;
	rep(0, n) {
		cin >> num[i];
		if (num[i] % 2 == 0) count++;

	}
	cout << pow(3, n) - pow(2, count) << endl;
}

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


int main(void){
    long long n, a, b;
    cin >> n >> a >> b;
    
    long long ans;
    long long rep_times = n / (a+b);
    long long res_number = n - rep_times * (a + b);
    
    if (res_number >= a) ans = a * rep_times + a;
    else ans = a * rep_times + res_number; 
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DEBUG_OUTPUT_ENABLED 1
	#define DBG(X) dout << #X << "=" << (X) << '\n';
	#define SAY(X) dout << (X) << '\n';
#else
	#define DEBUG_OUTPUT_ENABLED 0
	#define DBG(X) 42;
	#define SAY(X) 42;
#endif

#define dout   debug::instance

using namespace std;

template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
namespace debug {
	struct DebugStream {
		private:
			bool is_first;
		public:
			DebugStream(bool _is_first): is_first(_is_first) {}
			template<typename T> DebugStream operator<<(const T& value) const {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				cout << value;
				return DebugStream(false);
			};

			template<typename T> DebugStream printArray(T* l, T* r) {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				while(l != r) {
					cout << (*l);
					++l;
					if(l == r) {
						cout << '\n';
					} else {
						cout << ' ';
					}
				}
				return DebugStream(false);
			}
	};
	DebugStream instance(true);
};

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	ll a = fetch<ll>();
	ll rez = 0;
	rez += (a / 500) * 1000;
	a %= 500;
	rez += (a / 5) * 5;
	cout << rez << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll int
#define mx 
using namespace std;
inline void in(ll &x){x=0;char c;bool f=0;while((c=getchar())>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=getchar())<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;} 
inline void out(ll x){if(x<0){putchar('-');x=-x;}if(x>9)out(x/10);putchar(x%10+48);} 
inline void outn(ll x){out(x);printf("\n");}
inline ll max(ll x,ll y){return x>y?x:y;}
inline ll min(ll x,ll y){return x<y?x:y;}
int main(){
	ll l,r,n,f=1,mid;
	in(n);in(l);in(r);
	if(l>r){swap(l,r);f=!f;}
	while(l+1<r-1){l++;r--;}
	if(l+1==r){if(!f)printf("Alice\n");else printf("Borys\n");return 0;}
	if(f)printf("Alice\n");else printf("Borys\n");return 0;
}

Measured memory_bytes: 128
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y
from itertools import accumulate as acc

class PrimeOptimizer:
    def __init__(self, MAX_NUM=10**3):
        """MAX_NUM以下の素数テーブルを生成する。
        生成した素数テーブルはprime_factorizationで使用する。
        """
        is_prime = [True] * MAX_NUM
        is_prime[0] = False
        is_prime[1] = False
        primes = []
        for i in range(MAX_NUM):
            if is_prime[i]:
                primes.append(i)
                for j in range(2*i, MAX_NUM, i):
                    is_prime[j] = False
        self.primes = primes

    def prime_factorization(self, x):
        """xを素因数分解する。
        分解先の素数はself.primesを利用する。
        @param x (int): 分解対象の正整数
        @return res (dict): key = 素数、value = 素数の数で構成される辞書
        """
        res = {}
        for prime in self.primes:
            while x % prime == 0:
                if not prime in res:
                    res[prime] = 0
                res[prime] += 1
                x //= prime
        if x > 1:
            res[x] = 1
        return res

def main():
    q = II()
    lr = [MII() for _ in range(q)]
    pm = PrimeOptimizer(MAX_NUM=10**5)
    prims = set(pm.primes)
    like_2017 = [0]*10**5
    for n in range(1,10**5):
        if n in prims and (n+1)//2 in prims:
            like_2017[n] = 1
    acc_like_2017 = list(acc(like_2017))
    for l,r in lr:
        print(acc_like_2017[r]-acc_like_2017[l-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 33044
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=2e5+5;
char s[305][305],t[305][305];
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll n,ans=0;cin>>n;
    for(ll i=0;i<n;i++)for(ll j=0;j<n;j++)cin>>s[i][j];
    for(ll b=0,a=0,f=1;b<n;b++,f=1){
        for(ll i=0;i<n;i++)for(ll j=0;j<n;j++)t[i][j]=s[(i+a)%n][(j+b)%n];
        for(ll i=0;i<n;i++)for(ll j=0;j<n;j++)f&=(t[i][j]==t[j][i]);
        ans+=(f*n);
    }
    cout<<ans;
}

Measured memory_bytes: 512
#include <iostream>

int main() {
    long long int a, b, c, d;
    long long int ans;

    std::cin >> a >> b >> c >> d;

    if(b <= 0 && d <= 0) {
        ans = a * c;
    }
    else if(d <= 0 && a >= 0) {
        ans = a * d;
    }
    else if(d <= 0 && a <= 0) {
        ans = a * c;
    }
    else if(b <= 0 && c >= 0) {
        ans = b * c;
    }
    else if(b <= 0 && c <= 0) {
        ans = a * c;
    } 
    else {
        ans = b * d;

        if(ans < (a * c)) {
            ans = a * c;
        }
    }

    std::cout << ans << std::endl;

    return 0;    
}


Measured memory_bytes: 3632
MOD = 10 ** 9 + 7

N, K = map(int, input().split())

ans = 0
count = [-1] * (K + 1)
for i in range(K, 0, -1):
    count[i] = pow(K // i, N, MOD) - sum(count[i + i :: i])
    ans += count[i] * i
    ans %= MOD

print(ans)


Measured memory_bytes: 11924
#include<stdio.h>


int main(){
    int a, i;
    scanf("%d", &a);

    for(i = 1; i <= a; i++){
        int x = i;
        if(i % 3 == 0){
            printf(" ");
            printf("%d", i);
        }
        else{
            while(x != 0){
                if(x % 10 == 3){
                    printf(" ");
                    printf("%d", i);
                    break;
                }
                x /= 10;
            }
        }
        
    }
    printf("\n");
    return 0;
}


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

int main(void)
{
    int n; cin >> n;
    vector<int> a(n, 0);

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

    int min_p = 1;
    long long int counter = 0;

    for(int i = 0; i < n; i++){
        
        if(a[i] < min_p) continue;
        else if(a[i] == min_p){
            min_p += 1;
            continue;
        }else{
            counter += (a[i]-1) / min_p;
            if(i == 0) min_p = 2;
        }
    }

    cout << counter << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  for (int i = 6; i >= 0; i--) {
    if (pow(2, i) <= N) {
      cout << pow(2, i) << endl;
      break;
    }
  }
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vector<int> cnt(n + 1, 0);
    for (int i = 0 ; i < n - 1 ; i++) {
        int v; cin >> v;
        cnt[v]++;
    }
    for (int i = 1 ; i <= n ; i++)
        cout << cnt[i] << '\n';

}


Measured memory_bytes: 3988
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int a, b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    if ((max(a, b) + min(a, b)) % 2 == 0)
    {
        cout << (max(a, b) + min(a, b)) / 2 << "\n";
        return 0;
    }
    cout << "IMPOSSIBLE"
         << "\n";
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;


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

	int N;
	cin >> N;

	std::vector<std::vector<int>> matrix(N, vector<int>(N));
    const unsigned long num_node = matrix.size();
    FOR(y, 0, N) {
        FOR(x, 0, N) {
            cin >> matrix[y][x];
        }
    }

    set<pair<int, int>> se;
    for (int m = 0; m < num_node; ++m) {
        for (int s = 0; s < num_node; ++s) {
            for (int e = 0; e < num_node; ++e) {
                if (matrix.at(s).at(m) != INT_MAX and matrix.at(m).at(e) != INT_MAX) {
                    if (matrix.at(s).at(e) > matrix.at(s).at(m) + matrix.at(m).at(e)) {
                        cout << "-1" << endl;
                        return 0;
                    }

                    if (s == e or s == m or e == m) {
                        continue;
                    }
                    if (matrix.at(s).at(e) == matrix.at(s).at(m) + matrix.at(m).at(e)) {
                        se.insert(make_pair(s, e));
                        se.insert(make_pair(e, s));
                    }
                }
            }
        }
    }

    LL ans = 0;
    FOR(y, 0, N) {
        FOR(x, 0, N) {
            auto k = make_pair(y, x);
            if (se.find(k) == se.end()) {
                ans += matrix[y][x];
            }
        }
    }
    print(ans / 2);

	return 0;
}

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

int main() {
    int x,y;
    cin >> x;
    cin >> y;
    int i;
    for(i=0;i<=x;i++){
        if((2 * i + 4 * (x - i)) == y){
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 3596
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
//#include <unordered_set>
//#include <unordered_map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;

class SplitStream {
	typedef basic_ostream<char, char_traits<char> > BaseOst;
	std::ostream& ost_m;
	bool line_is_empty_m;
public:
	SplitStream(std::ostream& ost);
	template <typename T>
	SplitStream& operator<<(T right);
	SplitStream& operator<<(BaseOst& (*right)(BaseOst&));
};
SplitStream::SplitStream(std::ostream& ost) : ost_m(ost), line_is_empty_m(true) {}
template <typename T>
SplitStream& SplitStream::operator<<(T right) {
	if (!line_is_empty_m) ost_m << ' ';
	line_is_empty_m = false;
	ost_m << right;
	return *this;
}
/* std::endl のみ */
SplitStream& SplitStream::operator<<(BaseOst& (*right)(BaseOst&)) {
	ost_m << '\n';
	ost_m.flush();
	line_is_empty_m = true;
	return *this;
}
SplitStream Scout(cout);

template <typename T, int Begin, int End>
class OffsetArray {
	T arr_m[End - Begin];
public:
	OffsetArray();

	T& operator[](int index);
	T operator[](int index) const;
};
template<typename T, int Begin, int End>
OffsetArray<T, Begin, End>::OffsetArray() : arr_m() {}
template<typename T, int Begin, int End>
T& OffsetArray<T, Begin, End>::operator[](int index) {
	return arr_m[index - Begin];
}
template<typename T, int Begin, int End>
T OffsetArray<T, Begin, End>::operator[](int index) const {
	return arr_m[index - Begin];
}

int K, S;

int main() {
	int cnt = 0;
	cin >> K >> S;
	REP(i, 0, K + 1) {
		REP(j, 0, K + 1) {
			if ((S - i - j) >= 0 && (S - i - j) <= K) cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256