akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin>>n;
    if(n==5 || n==7 || n==3){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int mod=1000000007;
    int diff=abs(n-m);
    if(diff>1){
        cout<<0<<endl;
    }else{
        ll ntemp=1;
        ll mtemp=1;
        for(int i=1;i<=n;i++){
            ntemp*=i;
            ntemp%=mod;
        }
        for(int i=1;i<=m;i++){
            mtemp*=i;
            mtemp%=mod;
        }
        ll ans=ntemp*mtemp%mod;
        if(diff==0){
            cout<<ans*2%mod<<endl;
        }else{
            cout<<ans<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N ,T = map(int,input().split(" "))
ct = []
for i in range(N):
    c,t = map(int,input().split(" "))
    ct.append((c,t))

ct.sort()

for i in range(N):
    if ct[i][1] <= T:
        print(ct[i][0])
        exit(0)

print("TLE")

Measured memory_bytes: 39236
#include <bits/stdc++.h>
#define fir first
#define sec second
#define mp std::make_pair

typedef long long ll;

const int N = 2005;
const int MOD = 1e9 + 7;
int n, k;
ll c[N][N];
inline void init() {
    for (int i = 0; i <= 2000; i++)
        c[i][0] = 1;
    for (int i = 1; i <= 2000; i++)
     {
        for (int j = 1; j <= i; j++) {
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;
        }
    }
}

int main() {
    init();
    std::cin >> n >> k;
    for (int i = 1; i <= k; i++) {
        printf("%lld\n", c[k - 1][i - 1] * c[n - k + 1][i] % MOD);
    }
    return 0;
}


Measured memory_bytes: 30208
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename T> struct grid : public vector<vector<T>> {
    int n, m;
    grid(int n, int m) : vector<vector<T>>(n, vector<T>(m)), n(n), m(m) {}
    grid(int n, int m, T zero) : vector<vector<T>>(n, vector<T>(m, zero)), n(n), m(m) {}
    grid(const grid& a) : vector<vector<T>>(a), n(a.n), m(a.m) {}
};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, W;
    cin >> n >> W;
    vector<ll> w(n + 1), v(n + 1);
    for(int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }
    grid<ll> opt(n + 1, W + 1);
    for(int i = 0; i <= n; i++) {
        for(int c = 0; c <= W; c++) {
            if(i == 0) {
                opt[i][c] = 0;
            } else {
                opt[i][c] = opt[i - 1][c];
                if(c - w[i] >= 0) {
                    opt[i][c] = max(opt[i][c], opt[i - 1][c - w[i]] + v[i]);
                }
            }
        }
    }
    cout << opt[n][W] << endl;
    return 0;
}


Measured memory_bytes: 80256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cctype>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

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

  string n = to_string(N);

  if(n[0] == '9' || n[1] == '9') cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

int main() {
  int n ; 
  string s ;
  cin >> n >> s ;
  int ans = 0;
  
 for(int i=1;i<n;i++){
   int cnt=0;
   
   for(char c='a';c<='z';c++){
     bool left = false;
     bool right= false;
     
     for(int j=0;j<i;j++)
       if(s.at(j) == c)
         left =true;
     
     for(int j=i;j<n;j++)
       if(s.at(j) ==c)
         right =true;
     
     if(left && right) cnt ++;
     
   }
   
   ans = max(ans,cnt);
   
 }
  
  cout << ans <<endl;
   
  
 
  
}


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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;


int main(void) {
	ll MOD = 1'000'000'007;
	ll N, M;
	cin >> N >> M;

	if (N != M && abs(N - M) > 1) {
		cout << 0 << endl;
		return 0;
	}

	ll x = 1;
	for (ll i = 2; i <= N; ++i) {
		x *= i;
		x %= MOD;
	}
	ll y = 1;
	for (ll i = 2; i <= M; ++i) {
		y *= i;
		y %= MOD;
	}
	ll ans = (x * y) % MOD;
	if (N == M) {
		ans *= 2;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

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

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

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

int main(){
    ll n, X; cin >> n >> X;
    vector<ll> x(n), l(n); rep(i,n) cin >> x[i];

    ll minn = 1e10, ans = 1e10;

    x.push_back(X);

    sort(x.begin(), x.end());
    
    for(long long i = 0; i < n; i++){
        l[i] = x[i+1] - x[i];
        minn = min(minn, x[i+1] - x[i]);
    }

    for(long long i = 0; i < n; i++){
        ans = min(ans,gcd(l[i], minn));
    }

    put(ans);
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cstdio>
#include <vector>

const int N = 100000;

int n, m, a[N], b[N], parent[N], parity[N], weight[2][N];
long long extra;
std::vector<int> tree[N], values;

int find(int u)
{
    if (parent[u] != u) {
        int r = find(parent[u]);
        parity[u] ^= parity[parent[u]];
        parent[u] = r;
    }
    return parent[u];
}

std::pair<int, int> dfs(int p, int u)
{
    std::pair<int, int> res { weight[0][u], weight[1][u] };
    for (auto v : tree[u]) {
        if (v != p) {
            auto tmp = dfs(u, v);
            if (tmp.second == 0) {
                extra += std::abs(tmp.first);
            } else {
                values.push_back(tmp.first * tmp.second);
            }
            res.first += tmp.first;
            res.second += tmp.second;
        }
    }
    return res;
}

long long solve()
{
#ifdef LOCAL_JUDGE
    freopen("F.in", "r", stdin);
#endif
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++ i) {
        parent[i] = i, parity[i] = 0;
    }
    int found = -1;
    for (int i = 0; i < m; ++ i) {
        scanf("%d%d", a + i, b + i);
        int pa = find(-- a[i]);
        int pb = find(-- b[i]);
        if (pa == pb) {
            found = i << 1 | (parity[a[i]] == parity[b[i]]);
        } else {
            parent[pa] = pb, parity[pa] = 1 ^ parity[a[i]] ^ parity[b[i]];
            tree[a[i]].push_back(b[i]);
            tree[b[i]].push_back(a[i]);
        }
    }
    if (found == -1) {
        found = 0;
    }
    int imbalance = 0;
    for (int i = 0; i < n; ++ i) {
        find(i);
        imbalance += (weight[0][i] = parity[i] ? 1 : -1);
    }
    if (found & 1) {
        if (imbalance % 2 != 0) {
            return -1;
        }
        imbalance /= 2;
        extra += std::abs(imbalance);
        weight[0][a[found >> 1]] -= imbalance;
        weight[0][b[found >> 1]] -= imbalance;
    } else {
        if (imbalance != 0) {
            return -1;
        }
        weight[1][a[found >> 1]] = 1;
        weight[1][b[found >> 1]] = -1;
    }
    values.push_back(0);
    dfs(-1, 0);
    std::sort(values.begin(), values.end());
    int mid = values[values.size() / 2];
    for (auto v : values) {
        extra += std::abs(v - mid);
    }
    return extra;
}

int main()
{
    printf("%lld\n", solve());
}



Measured memory_bytes: 17532
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
	ll N, M;
	cin >> N >> M;
	vll A, B;
	ll i, j, k;
	for (i = 0; i < M; i++){
		ll a, b;
		cin >> a >> b;
		A.push_back(a);
		B.push_back(b);
	}
	vll C(N, 0);
	for (i = 0; i < M; i++){
		C[A[i] - 1]++;
		C[B[i] - 1]++;
	}
	for (i = 0; i < N; i++){
		if (C[i] % 2 == 1){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 2796
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！
        Scanner sc = new Scanner(System.in);
      for(int i=1;i<=5;i++){
          //System.out.println(i);
          int n = sc.nextInt();
          if(n==0){
                        System.out.println(i);
          }



      }
    }
}

Measured memory_bytes: 35664
#include<iostream>
using namespace std;
int main(){
  int i,j,H,W;
  while(true){
    cin >> H >> W;
    if(H==0 && W==0)break;
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1152
//SumOfNumbers.cpp
#include<iostream>
#include<string>
using namespace std;

int main()
{
    long sum,flag,n,i;
    string s;
    flag=0;
    while (flag==0)
    {
        cin>>s;
        if (s=="0") flag=1;
        else
        {
            sum=0;
            n=(int)(s.length());
            for ( i = 0; i < n; i++) sum+=s[i]-'0';
            cout<<sum<<endl;
        }
    }
}


Measured memory_bytes: 3160
#include <stdio.h>
#include <bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
using namespace std;  
int n;
ll cnt[5];
char s[15];
ll ans;
void dfs(int d,ll sum,int k){
	if(d==5){
		if(k==3) ans+=sum;
		return ;
	}
	if(k<3 && cnt[d]){
		dfs(d+1,sum*cnt[d],k+1);	
	}
	dfs(d+1,sum,k);
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%s",s);
		if(s[0]=='M')cnt[0]++;
		if(s[0]=='A')cnt[1]++;
		if(s[0]=='R')cnt[2]++;
		if(s[0]=='C')cnt[3]++;
		if(s[0]=='H')cnt[4]++;		
	}
	dfs(0,1,0);
	cout<<ans;
	return 0;  
}
/**/


Measured memory_bytes: 256
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N, X, T = map(int, input().split())

    fintime = 0
    fintime += (1 + N // X) * T
    if N - (N // X) * X == 0:
        fintime -= T
    print(fintime)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 72788
#include<stdio.h>

int ar[100][100];

int main()
{
    int n,m,z,i,j,p,c,d=0;
    scanf ("%d %d",&n,&m);
    for (i=0;i<n;++i){

        scanf ("%d",&z);
        for (j=1;j<=z;++j){

            scanf ("%d",&p);
            ar[i][p-1]=1;


        }
    }
    for (i=0;i<m;++i){

        c=0;
        for (j=0;j<n;++j){

                if (ar[j][i]==1)++c;


        }
        if (c==n)++d;
    }
    printf ("%d\n",d);
    return 0;

}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
    int a,b,n,A[100000];
    int x=0,y=0,z=0;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++) cin>>A[i];
    for(int i=0;i<n;i++){
        if(A[i]<=a) x++;
        else if(A[i]<=b) y++;
        else z++;
    }
    cout<<min({x,y,z});
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

typedef long long ll;
ll n, ans, a[3][N], s[3][N];
int main()
{
	ll i, j, k, t, num;
	cin >> n;
	for (j = 0; j < 3; j++) {
		for (i = 0; i < n; i++) {
			scanf ("%lld", &a[j][i]);
		}
		sort(a[j], a[j] + n);
	}
	for (i = n - 1; i >= 0; i--) s[2][i] = s[2][i + 1] + 1;
	for (j = 1; j >= 0; j--) {
		k = n - 1;
		for (i =n - 1; i>= 0; i--) {
			for (; k >= 0; k--) {
				if (a[j][i] >= a[j + 1][k]) break;
			}
//			t = upper_bound(a[j +1], a[j + 1] + n, a[j][i]) - a[j + 1];
			num = s[j + 1][k + 1];
			s[j][i] = s[j][i +1] + num;
			if (j == 0) ans += num;
		}
	}
	cout << ans;
    return 0;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    vector<int> a(100);
    for(int i=0; i<9; i++){
        cin >> a.at(i);
    }
    int N;
    cin >> N;
    vector<int> b(N);
    rep(i,N){
        cin >> b.at(i);
    }
     rep(i,N){
        rep(j,9){
            if(a.at(j) == b.at(i)){
                a.at(j) = 0;
            }
        }
    }
    bool ans = false;
    if(a.at(0) == a.at(1)&&a.at(1) == a.at(2) && a.at(0) == 0){
        ans = true;
    }
    if(a.at(3) == a.at(4)&&a.at(4) == a.at(5) && a.at(3) == 0){
        ans = true;
    }
    if(a.at(6) == a.at(7)&&a.at(7) == a.at(8) && a.at(6) == 0){
        ans = true;
    }
    if(a.at(0) == a.at(3)&&a.at(3) == a.at(6) && a.at(0) == 0){
        ans = true;
    }
    if(a.at(1) == a.at(4)&&a.at(4) == a.at(7) && a.at(1) == 0){
        ans = true;
    }
    if(a.at(2) == a.at(5)&&a.at(5) == a.at(8) && a.at(2) == 0){
        ans = true;
    }
    if(a.at(0) == a.at(4)&&a.at(4) == a.at(8) && a.at(0) == 0){
        ans = true;
    }
    if(a.at(2) == a.at(4)&&a.at(4) == a.at(6) && a.at(2) == 0){
        ans = true;
    }

    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll mod = 1000000007;

ll x, y;

ll extended_gcd(ll a, ll b){
	if(b==0){
		x = 1;
		y = 0;
		//printf("%lld*%lld + %lld*%lld = %lld\n", a, x, b, y, a); 
		return a;
	}
	else{
		ll g = extended_gcd(b, a%b);
		/*
			b*x + y*(a - a/b*b) = g
			a*y + b*(x - a/b*y) = g
		*/
		ll tmp = x;
		x = y;
		y = tmp-a/b*y;
		//printf("%lld*%lld + %lld*%lld = %lld\n", a, x, b, y, g);
		return g;
	}
}

ll modinverse(ll a){
	ll g = extended_gcd(a, mod);
	//cout<<g<<"\n";
	while(x<0)
		x+=mod;
	return x;
}

ull nCr(ll n, ll r){
	ull prod = 1;
	for(int i=n-r+1;i<=n;i++)
		prod = (prod*i)%mod;
	for(int i=1;i<=r;i++)
		prod = (prod*modinverse(i))%mod;
	//cout<<prod<<"\n";
	return prod;
}

ull powx(ll b, ll exp){
	if(exp == 0)
		return 1;
	else{
		ull ans = powx(b, exp/2);
		ans = (ans*ans)%mod;
		if(exp%2)
			ans = (ans*b)%mod;
		return ans;
	}
}

int main(){
	ll n, a, b;
	cin>>n>>a>>b;
	ll ans = powx(2, n)-1;
	ans = (ans-nCr(n, a));
	while(ans<0)
		ans+=mod;
	ans = (ans-nCr(n, b));
	while(ans<0)
		ans+=mod;
	ans = ans%mod;	
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
($n,$m)=glob<>;
@L;
for(1..$m){
    @s=glob<>;
    my$sn=shift(@s);
    my $k=0;
    for (my$i=0;$i<$sn;$i++){
        $k+=2**($s[$i]-1);
    }
    push(@L,$k);
}
@J=glob<>;
$max=2**$n;
$ans=0;
for(my$i=0;$i<$max;$i++){
    $on=0;
    for(my$j=0;$j<$m;$j++){
        my$str=sprintf("%b",$L[$j]&$i);
        $c=(()= $str =~ m/1/g);
        $on++ if($c%2==$J[$j]);
    }
    $ans++ if($on==$m);
}
print $ans

Measured memory_bytes: 768
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}




signed main(){
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<set<int>> v(26);
    for(int i = 0; i < n; ++i)
        v[s[i] - 'a'].insert(i);

    for(int i = 0; i < q; ++i){
        int type;
        cin >> type;
        if(type == 1){
            int x; char c;
            cin >> x >> c;
            --x;
            v[s[x] - 'a'].erase(x);
            v[c - 'a'].insert(x);
            s[x] = c;
        }
        else{
            int l, r;
            cin >> l >> r;
            --l;
            int ans = 0;
            for(int j = 0; j < 26; ++j){
                ans += (v[j].lower_bound(l) != v[j].lower_bound(r));
            }
            cout << ans << endl;
        }
    }
    /*
    for(int i = 0; i < n; ++i)
        for(int j = i + 1; j < n; ++j){
            int l = i, r = j;
            int ans = 0;
            cout << s.substr(i, j - i) << ": ";
            for(int j = 0; j < 26; ++j){
                ans += (v[j].lower_bound(l) != v[j].lower_bound(r));
                if(v[j].lower_bound(l) != v[j].lower_bound(r))
                    cout << char('a' + j) << " ";
            }
            cout << " => " << ans << endl;
        }
        */
    return 0;
}


Measured memory_bytes: 26244
<?php

fscanf(STDIN,"%d",$n);

for ($i=0; $i < $n; $i++) {
    fscanf(STDIN,"%d",$botton[$i]);
    $isDone[$i] = False;
}
$isDone[1] = True;

if(in_array(2,$botton)){
    $i = 0;
    $ans=0;
    while($isDone[$i] == False){
        $isDone[$i] = True;
        $i = $botton[$i] - 1;
        $ans++;
    }
    if($i == 1){
        echo $ans.PHP_EOL;
        return;

    }
}
echo (-1).PHP_EOL;


Measured memory_bytes: 33012
#include<iostream>
using namespace std;
int main() {
	int N, T;
	int c[101];
	int t[101];
	bool d[101];
	int ans = 1001;
	bool X = false;
	cin >> N >> T;
	for (int i = 0; i < N; ++i) {
		bool d = false;
		cin >> c[i] >> t[i];
		if (t[i] <= T) {
			d = true;
			X = true;
		}
		if (d) {
			if (ans > c[i])
				ans = c[i];
		}
	}
	if (X) {
		cout << ans << endl;
	}
	else {
		cout << "TLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int k, s; cin >> k >> s;

    int cnt = 0;
    repq(i,0,k) repq(j,0,k) {
        if(i+j > s) continue;
        else {
            // printf("%lld %lld\n", i, j);
            int x = s - (i + j);
            if(x > k) continue;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
A = []
B = []

for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())

for i in range(N - M + 1):
    offset = 0
    while offset + M <= N:
        pos = A[i][offset:].find(B[0])        
        if -1 == pos:
            break
        offset += pos
        for j in range(1,M):
            if 0 != A[i+j][offset:].find(B[j]):
                offset += 1
                break
        else:
            print('Yes')
            exit()
else:
    print('No')


Measured memory_bytes: 3064
N, K, Q = [int(num) for num in input().split(' ')]
A = [0 for i in range(N)]

#print('{},{},{}'.format(N,K,Q))
#print(A)

for i in range(Q):
  #print(A)
  Ai = int(input())
  A[Ai-1]+=1
  
for Ai in A:
  if Ai+K-Q > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 4708
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/


typedef long long ll;
int N, M;
vector<int> E[101010];
//---------------------------------------------------------------------------------------------------
int col[101010];
int ok = 1;
void dfs(int cu) {
    fore(to, E[cu]) {
        if (col[cu] == col[to]) {
            ok = 0;
            return;
        }

        if (!col[to]) {
            col[to] = 3 - col[cu];
            dfs(to);
        }
    }
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }

    col[0] = 1;
    dfs(0);

    if (ok) {
        int B = 0, W = 0;
        rep(i, 0, N) {
            if (col[i] == 1) B++;
            else W++;
        }

        ll ans = 1LL * B * W - M;
        cout << ans << endl;
    } else {
        ll ans = 1LL * N * (N - 1) / 2 - M;
        cout << ans << endl;
    }
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int gi()
{
	char c; int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+c-'0';
	return x*f;
}

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a>=b&&a>=c) printf("%d",b+c);
	else if(b>=a&&b>=c) printf("%d",a+c);
	else printf("%d",a+b);
}


Measured memory_bytes: 256
import sys

input = sys.stdin.buffer.readline


class SegmentTree:
    ele = 0

    def func(self, a, b):
        return a + b

    # SEG木は1-index
    # Aに関しては0-index

    def __init__(self, n):  # Aは0-idx
        self.n = n
        self.num = 2 ** ((self.n - 1).bit_length())
        self.SEG = [self.ele] * (2 * self.num)

    def search(self, idx):
        return self.SEG[idx + self.num]

    def initialize(self, A):
        for i in range(self.n):
            self.SEG[i + self.num] = A[i]
        for i in range(self.num - 1, 0, -1):
            self.SEG[i] = self.func(self.SEG[2 * i], self.SEG[2 * i + 1])

    def update(self, idx, val):
        idx += self.num
        self.SEG[idx] += val
        idx //= 2
        while idx:
            self.SEG[idx] = self.func(self.SEG[2 * idx], self.SEG[2 * idx + 1])
            idx //= 2

    def query(self, left, right):
        # 開区間
        resleft = self.ele
        resright = self.ele
        left += self.num
        right += self.num
        while right - left > 0:
            if left % 2 == 1:
                resleft = self.func(resleft, self.SEG[left])
                left += 1
            if right % 2 == 1:
                right -= 1
                resright = self.func(resright, self.SEG[right])
            left //= 2
            right //= 2
        return self.func(resleft, resright)


n, q = map(int, input().split())
ST = SegmentTree(n)
ST.initialize(list(map(int, input().split())))
for _ in range(q):
    s, a, b = map(int, input().split())
    if s:
        print(ST.query(a, b))
    else:
        ST.update(a, b)


Measured memory_bytes: 134880
#include <stdio.h>
#include <math.h>
 
int isPrime(int);
 
int main(){
  int a[10000],i,n,c=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(isPrime(a[i])==1)c++;
  }
 printf("%d\n",c);
 return 0;
}
     
int isPrime(int x){
  int i;
  if(x==2)return 1;
  if(x<2||x%2==0)return 0;
  i=3;
  while(i<=sqrt(x)){
    if(x%i==0)return 0;
    i=i+2;
  }
  return 1;
}

Measured memory_bytes: 632
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
x,n=map(int,stdin.readline().split())
a=set(map(int,stdin.readline().split()))
if(x not in a):
    print(x)
else:
    diff=1
    while(True):
        if(x-diff not in a):
            print(x-diff)
            break
        elif(x+diff not in a):
            print(x+diff)
            break
        diff+=1

Measured memory_bytes: 9412
#include <stdio.h>;

int main() {
	int r,g,b,res;
	scanf("%d%d%d",&r,&g,&b);
	res=100*r+10*g+b;
	if(res%4==0){
		printf("YES");
	}
	else{
		printf("NO");
	}

return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

void bomb(int fieldi[8][8], int x, int y);

void printmapi(int fieldi[8][8]){
		int i, j;
	for(i = 0;i < 8;i++){
		for(j = 0;j < 8;j++){
			// printf("%c", fieldi[i][j] + '0');
		}
		// printf("\n");
	}
}

int main(void){
	int n, i, j, k, x, y;
	char field[8][8];
	int fieldi[8][8];

	scanf(" %d", &n);

	for(i = 0;i < n;i++){
		for(j = 0;j < 8;j++){
			for(k = 0;k < 8;k++){
				scanf(" %c", &field[k][j]);
				//printf("%c\n", field[j][k]);
			}
		}

		//printmap(field);

		scanf(" %d", &x);
		scanf(" %d", &y);

		for(j = 0;j < 8;j++){
			for(k = 0;k < 8;k++){
				fieldi[j][k] = field[j][k] - '0';
			}
		}

		bomb(fieldi, x - 1, y - 1);

		printf("Data %d:\n", i + 1);
		for(j = 0;j < 8;j++){
			for(k = 0;k < 8;k++){
				printf("%d", fieldi[k][j]);
			}
			printf("\n");
		}

	}

	return 0;
}

void bomb(int fieldi[8][8], int a, int b){
	int i;
	// printf("%d %d\n", a, b);
	printmapi(fieldi);
	fieldi[a][b] = 0;
	for(i = -3;i <= 3;i++){
		if(a + i >= 0 && a + i < 8){
			if(fieldi[a + i][b] == 1){
				bomb(fieldi, a + i, b);
			}
		}
	}

	for(i = -3;i <= 3;i++){
		if(b + i >= 0 && b + i < 8){
			if(fieldi[a][b + i] == 1){
				bomb(fieldi, a, b + i);
			}
		}
	}
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int a, b;
  cin >> a >> b;
  
  int c = min(a, b);
  int d = max(a, b);
  for( int i = 0; i < d; i++ ) cout << c;
  cout << endl;
  
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=2000+5;
int a[maxn],n,sum=0;
bitset<4000010> f;
int main()
{
    scanf("%d",&n);
    f[0]=1;
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
        f|=(f<<a[i]);
        sum+=a[i];
    }
    int i=(sum+1)/2;
    for(;!f[i];i++);
    printf("%d\n",i);
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    ll sum=0,flag=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    for(auto itr:a)
    {
        sum+=pow(2,(itr+1)/2)-1;
        if(sum>k)
        {
            flag=1;
            break;
        }
    }
    ll l,r,mid,val,val1,ans=-1;
    l=1,r=1e18;   
    sum*=4;
    if(sum<=k && flag==1)
    {
        cout<<0<<endl;
        goto end;
    }
    while(l<=r)
    {
        mid=(l+r)/2;
        val=0;
        for(auto itr:a)
        {
            val1=(itr-1)/mid;
            val+=val1;
        }
        if(val>k)
        {
            l=mid+1;
        }
        else
        {
            ans=mid;
            r=mid-1;
        }
    }
    cout<<ans<<endl;
    end:;
}


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

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

   rep(i, 3) {
       s[i] = (s[i] == '1') ? '9' : '1';
   }

   cout << s << endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

int N;

struct G {
    int T;
    int S;
}
G[] gs;

bool input() {
    scanf("%d\n", &N);
    if (N == 0) return false;
    gs = new G[N];
    foreach (i; 0 .. N) {
        int M, L; scanf("%d %d\n", &M, &L);
        gs[i].S = L;
        foreach (j; 0 .. M) {
            int S, E; scanf("%d %d\n", &S, &E);
            gs[i].T |= (1 << E) - (1 << S);
        }
    }
    return true;
}

void solve() {
    int dfs(int index, int T) {
        if (index == N) return 0;
        int ret = 0;
        if (!(T & gs[index].T)) {
            ret = dfs(index + 1, T | gs[index].T) + gs[index].S;
        }
        return max(ret, dfs(index + 1, T));
    }
    writeln(dfs(0, 0));
}

void main() {
    while (input) solve;
}

Measured memory_bytes: 1084
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    string S;
    cin >> S;

    bool isKaibun =true; 
    for (int i=0; i<S.size()/2; i++) {
      if (!(S[i] == S[S.size()-1-i] && S[i] == S[(S.size()-1)/2-i-1])) {
        isKaibun = false;
        break;
      }
    }

    if (isKaibun) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import std.conv, std.stdio;
import std.algorithm, std.array, std.string, std.range;
void main()
{
    auto buf = readln.chomp.split.to!(int[]);
    (buf[0].c2 + buf[1].c2).writeln;
}
auto c2(in int n)
{
    return n * (n - 1) / 2;
}


Measured memory_bytes: 256
mod = 10 ** 9 + 7

l = input()
n = len(l)

dp = [[0] * 2 for _ in range(n + 1)]
dp[0][0] = 1
# dp[][smaller] : 1 == 確定

for i, c in enumerate(l):
    if c == '0':
        dp[i + 1][0] += dp[i][0]
        dp[i + 1][1] += dp[i][1] * 3
    else:
        dp[i + 1][0] += dp[i][0] * 2
        dp[i + 1][1] += dp[i][0]
        dp[i + 1][1] += dp[i][1] * 3
    dp[i + 1][0] %= mod
    dp[i + 1][1] %= mod

print((dp[n][0] + dp[n][1]) % mod)


Measured memory_bytes: 19676
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ans = new int[100001];
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            ans[a]++;
            if(a != 99999) ans[a+1]++;
            if(a != 0) ans[a-1]++;
            else ans[100000]++;
        }
        Arrays.sort(ans);

        System.out.println(ans[100000]);
        sc.close();
    }

}


Measured memory_bytes: 50676
n=int(input())
s=list(map(int,input().split()))
d1=dict()
d2=dict()
for i in range(0,n,2):
  if s[i] not in d1:
    d1[s[i]]=1
  else:
    d1[s[i]]+=1
for i in range(1,n,2):
  if s[i] not in d2:
    d2[s[i]]=1
  else:
    d2[s[i]]+=1
dmk,dm,dmmk,dmm=[],0,[],0
for i in d1.keys():
  if dm<d1[i]:
    dmm=dm
    dmmk=dmk
    dm=d1[i]
    dmk=[i]
  elif d1==d1[i]:
    dmk+=[i]
  elif dmm<d1[i]:
    dmm=d1[i]
    dmmk=[i]
  elif dmm==d1[i]:
    dmmk+=[i]
d1=[dm,dmk,dmm,dmmk]
dmk,dm,dmmk,dmm=[],0,[],0
for i in d2.keys():
  if dm<d2[i]:
    dmm=dm
    dmmk=dmk
    dm=d2[i]
    dmk=[i]
  elif d2==d2[i]:
    dmk+=[i]
  elif dmm<d2[i]:
    dmm=d2[i]
    dmmk=[i]
  elif dmm==d2[i]:
    dmmk+=[i]
d2=[dm,dmk,dmm,dmmk]
if len(d1[1])>1 or len(d2[1])>1 or d1[1]!=d2[1]:
  print(n-d1[0]-d2[0])
else:
  print(n-max(d1[0]+d2[2],d1[2]+d2[0]))


Measured memory_bytes: 18016
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define int long long 
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
#define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
#define inf 2000000000000000000LL
#define mod 1000000007
#define mod1 998244353
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

int dp[100005][105];

signed main() {
    FASTIO;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    //     freopen("stderr.txt", "w", stderr);
    // #endif

    // int tt=1;
    // cin>>tt;
    // while(tt--){
        int n,k=2;
        cin>>n;
        vi a(n);
        vi dp(n,inf);
        rep(i,n) cin>>a[i];
        dp[0]=0;
        loop(i,1,n){
            loop(j,1,k+1){
                if(i-j<0) continue;
                dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
            }
        }
        cout<<dp[n-1]<<endl;
        
        
    // }
    cerr<<"Time Elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<" sec";
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
w = [int(x) for x in input().split()]

tmp = 10000
for i in range(n):
    first = sum(w[:i])
    last = sum(w[i:])
    if first >= last:
        diff = first - last
    else:
        diff = last - first
    tmp = min(tmp, diff)

print(tmp)

Measured memory_bytes: 3060
N, K, Q = map(int, input().split())
As = []
for i in range(Q):
    As.append(int(input()))
Ts = [0] * (N + 1)
for a in As:
    Ts[a] += 1
for i in range(1, len(Ts)):
    Ts[i] = K - (Q - Ts[i])
    if Ts[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 56664
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N;
    cin >> N;
    lint dp[500000];
    rep(i,500000) dp[i]=INF;
    dp[0]=0;
    rep(i,N){
        dp[i+1]=min(dp[i+1],dp[i]+1);
        rep(j,8){
            int add=pow(6,j);
            dp[i+add]=min(dp[i+add],dp[i]+1);
        }
        rep(j,6){
            int add=pow(9,j);
            dp[i+add]=min(dp[i+add],dp[i]+1);
        }
    }
    cout << dp[N] << endl;
}


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

using namespace std;

typedef long long ll;

ll n, ans;
bool v[505][505];
ll a[505][505];
ll dx[4] = {0, 1, 0, -1};
ll dy[4] = {1, 0, -1, 0};

void f(ll p, ll q)
{
    if(p < 1 || p > n) return;
    if(q < 1 || q > n) return;
    for(ll i = 0; i < 4; i++)
    {
        if(a[p + dx[i]][q + dy[i]] > a[p][q] + v[p][q])
        {
            a[p + dx[i]][q + dy[i]] = a[p][q] + v[p][q];
            f(p + dx[i], q + dy[i]);
        }
    }
}

int main()
{
    scanf("%lld", &n);
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= n; j++)
        {
            v[i][j] = true;
            a[i][j] = min(min(i - 1, n - i), min(j - 1, n - j));
        }
    }
    for(ll i = 0; i < n * n; i++)
    {
        ll t;
        scanf("%lld", &t);
        ll x, y;
        t--;
        x = t % n + 1, y = t / n + 1;
        ans += a[x][y];
        v[x][y] = false;
        for(ll j = 0; j < 4; j++)
        {
            a[x][y] = min(a[x][y], a[x + dx[j]][y + dy[j]] + v[x + dx[j]][y + dy[j]]);
        }
        f(x, y);
    }
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

long f(long a) {
    if (a == 0) return 0;
    return a % 10 + f(a / 10);
}

double g(long a) {
    return ((double) a) / f(a);
}

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

    vector<long> vec;

    for (long i : {1,2,3,4,5,6,7,8,9,19,29,39,49,59,69,79,89,99}) {
        vec.emplace_back(i);
    }
    long ten_pow = 1;
    for (long a = 0; a <= 12; a++) {
        for (long b = 101; b <= 1000; b++) {
            long i = b * ten_pow - 1;
            vec.emplace_back(i);
        }
        ten_pow *= 10;
    }
    vector<long> ans_vec;
    double M = 1000000000000000.0;
    for (int i = vec.size() - 1; i >= 0; i--) {
        auto j = vec[i];
        if (M >= g(j)) {
            M = g(j);
            ans_vec.emplace_back(j);
        }
    }
    reverse(ans_vec.begin(), ans_vec.end());
    for (auto const& i : ans_vec) {
        cout << i;
        cnt--;
        if (cnt == 0) return 0;
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	//Siis AC, WA, TLE, or RE.
	int arr[4];
	fill(arr, arr + 4, 0);
	int N; cin >> N;
	while (N--)
	{
		string str;
		cin >> str;
		if (str == "AC")
			arr[0] = arr[0] + 1;
		else if (str == "WA")
			arr[1] = arr[1] + 1;
		else if (str == "TLE")
			arr[2] = arr[2] + 1;
		else
			arr[3] = arr[3] + 1;
	}

	cout << "AC" << ' ' << 'x' << ' ' << arr[0] << '\n';
	cout << "WA" << ' ' << 'x' << ' ' << arr[1] << '\n';
	cout << "TLE" << ' ' << 'x' << ' ' << arr[2] << '\n';
	cout << "RE" << ' ' << 'x' << ' ' << arr[3] << '\n';
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int a, b;
    cin >> a >> b;
    cout << (a - b + 1) << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        printHantei(W,H,x,y,r);

    }

    public static void printHantei(int W,int H,int x,int y,int r) {
        if(x>=r && y>=r) {
            if((H-x)>=r && (H-y)>=r) {
                System.out.println("Yes");
            }else {
                System.out.println("No");
            }
        }else {
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 26220
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
static const int NMAX=8;
static const int MMAX=28;

bool graph[NMAX][NMAX],visited[NMAX];
int a[MMAX],b[MMAX];
int n,m,cunt;
int  dfs(int v){
    visited[v]=true;

    bool flag=true;
    
    for(int v=0;v<n;v++){
        if(visited[v])continue;
        else flag=false;
    }
    
    if(flag)cunt++;
    
    for(int v2=0;v2<n;v2++){
        if(!graph[v][v2])continue;
        if(visited[v2])continue;
        
        dfs(v2);
        
        visited[v2]=false;
    }
    return cunt;
}

int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        
        a[i]--;b[i]--;
        graph[a[i]][b[i]]=graph[b[i]][a[i]]
            =true;
    }

    cout<<dfs(0)<<"\n";    
    

    return 0;
}



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

using namespace std;

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

vector<int> m;
vector< pair<int,int> > q;

void fact(int x){
    for(int i = 2; i * i <= x; i++){
        if (x % i == 0) {
            pair<int, int> p;
            p.first = i;
            p.second = 0;
            while(x % i == 0){
                x /= i;
                p.second++;
            }
            q.push_back(p);
        }
    }
    if (x != 1) {
        pair<int, int> p;
        p.first = x;
        p.second = 1;
        q.push_back(p);
    }
}

void fact2(int c[], int num){
    if (num == q.size()) {
        // for(int i = 0; i < q.size(); i++){
        //     cout << q[i].first << " " << c[i] << endl;
        // }
        
        int fac = 1;
        for(int i = 0; i < q.size(); i++){
            fac *= pow(q[i].first, c[i]);
        }
        
        m.push_back(fac);
        return;
    }
    int d[q.size()];
    for(int i = 0; i < q.size(); i++){
        d[i] = c[i];
    }
    for(int i = 0; i <= q[num].second; i++){
        d[num] = i;
        fact2(d, num + 1);
    }
    
}


int main(){

    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, n) cin >> a[i];

    int sm = 0;
    rep(i, n) sm += a[i];

    fact(sm);
    int b[q.size()];
    fact2(b, 0);
    // for(int i = 0; i < q.size(); i++){
    //     cout << q[i].first << " " << q[i].second << endl;
    // }
    // for(int i = 0; i < m.size(); i++){
    //     cout << m[i] << endl;
    // }
    sort(m.begin(), m.end(), greater<int>());
    for(int i = 0; i < m.size(); i++){
        int mod = m[i];
        int md[n];
        for(int j = 0; j < n; j++){
            md[j] = a[j] % mod;
        }
        sort(md, md + n);
        int ans = 0;
        int modsm = 0;
        for(int j = 0; j < n; j++){
            modsm += md[j];
        }
        modsm /= mod;
        for(int j = n - 1; j >= n - modsm; j--){
            ans += mod - md[j];
        }
        if (ans <= k) {
            cout << mod << endl;
            return 0;
        }   
    }
    cout << 1 << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    String c = sc.next();
    System.out.println(a.substring(0,1)+b.substring(1,2)+c.substring(2,3));
  }
  

  
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[303030];
void solve(){
	cin >> n;
	for(int i = 0; i < 3*n; i++){
		cin >> a[i];
	}
	sort(a,a+3*n,greater<int>());
	
	i64 ans = 0;
	for(int i = 1; i < 2*n; i+=2) ans += a[i];
	cout << ans << endl;
}

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


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main()
{
    string  s;
    cin>>s;
    if(s=="abc"||s=="cba"||s=="bac"||s=="cab"||s=="acb"||s=="bca")
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
 
 
 
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split(' '))
sc = []
for i in range(m):
    a, b = map(int, input().split(' '))
    sc.append((a, b))
d = '0' * n
for i, j in sc:
    if d[i - 1] != '0' and int(d[i - 1]) != j or n > 1 and i == 1 and j == 0:
        d = '-1'
        break
    d = d[:i - 1 if i > 1 else 0] + str(j) + d[i if i < 3 else 3:]
if d[0] == '0' and n > 1:
    d = '1' + d[1:]
print(d)

Measured memory_bytes: 3064
s = input()

top = int(s[0]) * 10 + int(s[1])
btm = int(s[2]) * 10 + int(s[3])


is_m = lambda n: 0 < n < 13

if is_m(top) and is_m(btm):
    print("AMBIGUOUS")
elif is_m(top):
    print("MMYY")
elif is_m(btm):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060