akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define out(x) printf("%lld",x)
#define in(x) scanf("%lld",&x)
#define puts() printf("\n")
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pf push_front           
#define pbp pop_back
#define pfp pop_front
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define rep(i,b,e) for(int i=b;i<=e;++i)
#define per(i,b,e) for(int i=b;i>=e;--i)
#define sz size()   
#define fr(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string S;                                                                
typedef double D;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<pair<int,int> >VII;
typedef map<int,int> MII;

const S ou = " ";
const int N = 1e5 + 17;
const int mod = 1e9 + 7;
const int INF = 2e9 - 19;

ll MX=(ll)1e10,MN=(ll)-1e10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

///////////////////////////////////
//Best code from Asanaly Serekbay//
///////////////////////////////////
//
//	Suported by Google Taxi & Yandex Taxi & Indriver & IOI
//
//  Checked by Zeus & Phantom Assasin
//

int mn = MX ;

int get_sum( int n ){
		
		int ans = 0 ;

		while( n ){
			ans += n % 10 ;
			n/= 10 ;
		} 
		return ans ;
}
int q , w ;
                        
int main(){
 #ifdef BloodCandy
 			cout<<"Welcome my lord ^_^\n";
			//fr("test");
 #endif

 int n ;

 cin >> n ;


for( int i = 1 ; i < n ; ++i ){
 
 		   if( mn > get_sum(i) + get_sum( n - i ) ) mn = get_sum(i) + get_sum( n - i );
 }

 cout << mn;

 return 0;


}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

main(){
  int n, m;
  while(cin >> n && n){
    cin >> m;
    int sum = 0;
    for(int i=0;i<m;i++){
      int a, b;
      cin >> a >> b;
      sum += b - a;
    }
    if(sum < n) cout << n - sum << endl;
    else cout << "OK" << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

ll a, b, c, n, n_max=1;
ll x[51] = {};
ll dp[55][55][2505] = {};


int main(){
    cin>>n;
    for(int i=1; i<=100000; i++){
        if(i*i>n)break;
        n_max = i*i;
    }
    cout<<n_max<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    
    ll N, maxur, minur, maxlr, minlr, md1 = 0, md2 = 0, md3 = 0, md4 = 0; cin >> N;
    vl x(N), y(N);

    rep(i, N) cin >> x[i] >> y[i];

    maxur = y[0] - x[0];
    minur = y[0] - x[0];
    maxlr = y[0] + x[0];
    minlr = y[0] + x[0];

    rpt(i, 1, N) {
        maxur = max(maxur, y[i] - x[i]);
        minur = min(minur, y[i] - x[i]);
        maxlr = max(maxlr, y[i] + x[i]);
        minlr = min(minlr, y[i] + x[i]);
    }

    cout << max(maxur - minur, maxlr - minlr) << endl;

}

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

#define MAX_SIZE (1000000)

int prime[MAX_SIZE];

int main()
{
	int n;
	
	prime[0] = prime[1] = 0;

	for (int i = 2; i < MAX_SIZE; i++){
		prime[i] = 1;
	}

	// Sieve of Eratosthenes
	for (int i = 2; i * i < MAX_SIZE; i++){
		if (prime[i]){
			for (int j = i * i; j < MAX_SIZE; j += i){
				prime[j] = 0;
			}
		}
	}

	for (int i = 1; i < MAX_SIZE; i++){
		prime[i] += prime[i - 1];
	}

	while (scanf("%d", &n) != EOF){
		printf("%d\n", prime[n]);
	}

	return (0);
}

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if (a[a.length()-1] == b[0] && b[b.length()-1] == c[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;


signed _main(){
  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 "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
typedef long long ll;
void self_max(int &a, int b) {
	a = max(a, b);
}
vector<int>v[N];
bool check[N];
int dp[N];
int degree[N];
void dfs(int s) {
	check[s] = true;
	for(int i : v[s]) {
		self_max(dp[i], dp[s] + 1);
		degree[i]--;
		if(degree[i] == 0)
			dfs(i);
	}
}
int main() {
	int n, m;
	cin>>n>>m;
	rep(i, 0, m) {
		int a, b;
		cin>>a>>b;
		v[a].pb(b);
		degree[b]++;
	}
	int ans = 0;
	rep(i, 1, n + 1) {
		if(!check[i] && degree[i] == 0) {
			dfs(i);
		}
	}
	for(int i = 1; i <= n; i++) 
		self_max(ans, dp[i]);
	cout<<ans<<endl;
}



Measured memory_bytes: 9728
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}

int main(){
    ll n,ans=0;
    cin >> n;
    ll a[n],b[n];
    for (ll i=0;i<n;i++){
        cin >> a[i];
    }
    for (ll i=0;i<n;i++){
        cin >> b[i];
    }
    ll l[n+1],r[n+1];
    fill(l,l+n+1,0);
    fill(r,r+n+1,0);
    for (ll i=1;i<n+1;i++){
        l[i]=l[i-1]+a[i-1];
    }
    for (ll i=1;i<n+1;i++){
        r[i]=r[i-1]+b[n-i];
    }
    for (ll i=1;i<=n;i++){
        ans=max(ans,l[i]+r[n-i+1]);
    }
    cout << ans << endl;
    return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> s;
    deque<char> dq;

    REP(i, s.size()) {
        if (s.at(i) == 'B') {
            if (dq.empty()) continue;
            dq.pop_back();
        } else {
            dq.push_back(s.at(i));
        }
    }

    while (!dq.empty()) {
        cout << dq.front();
        dq.pop_front();
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n>=400&&n<=599)
	cout<<8<<endl;
	else if(n>=600&&n<=799)
	cout<<7<<endl;
	else if(n>=800&&n<=999)
	cout<<6<<endl;
	else if(n>=1000&&n<=1199)
	cout<<5<<endl;
	else if(n>=1200&&n<=1399)
	cout<<4<<endl;
	else if(n>=1400&&n<=1599)
	cout<<3<<endl;
	else if(n>=1600&&n<=1799)
	cout<<2<<endl;
	else if(n>=1800&&n<=1999)
	cout<<1<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int x; 
    cin >> x;
    int a, b;
    a = x/500;
    b = (x%500)/5;
    cout << 1000*a + 5*b << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[100010];
int B[100010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	REP(i,N){
		B[A[i]-1]=i+1;
	}
	REP(i,N){
		cout<<B[i];
		if(i<N-1){
			cout<<" ";
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 2432
#include<stdio.h>
int main(void)
{
	int a[100];
	int b[100];
	char op[100];
	int i = 0,j;
	
	while(1){
		scanf("%d %c %d", &a[i], &op[i], &b[i]);
		if(op[i] == '?')break;
		i++;
	}
	
	for(j = 0;j < i;j++){
		if(op[j] == '+'){
			printf("%d\n", a[j] + b[j]);
		}else if(op[j] == '-'){
			printf("%d\n", a[j] - b[j]);
		}else if(op[j] == '*'){
			printf("%d\n", a[j] * b[j]);
		}else if(op[j] == '/'){
			printf("%d\n", a[j] / b[j]);
		}
	}

	
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

    int main(){
        int A,B,x,y,z,temp;
        scanf("%d", &A);
        scanf("%d", &B);
        x = A+B;
        y = A-B;
        z = A*B;

        temp = z;
        if (temp < y){
            temp = y;
        }if (temp < x){
            temp = x;
        }
        printf("%d", temp);
          return 0;
}


Measured memory_bytes: 128
from itertools import combinations_with_replacement as combi

n, m, q = map(int, input().split())
c = []
for i in range(q):
    c.append(list(map(int, input().split())))

com = list(combi(list(range(1, m+1)), n))

total = []

for lis in com:
    tot = 0
    for cond in c:
        idx1 = cond[0]-1
        idx2 = cond[1]-1
        diff = cond[2]
        if lis[idx2] - lis[idx1] == diff:
            tot += cond[3]
    total.append(tot)

print(max(total))


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

int n;
int a[3005];
const ll INF = 1e18;

// dp[i][j] 区間[i,j)におけるX-Yの値
ll dp[3005][3005];

ll solve(int i, int j) {
    if(dp[i][j] != -INF) return dp[i][j];
    if (j - i == 0) return dp[i][j] = 0;

    if ((n-(j-i)) % 2 == 0) {
        // 先手
        dp[i][j] = max(solve(i+1, j) + a[i], solve(i, j-1) + a[j-1]);      
    } else {
        // 後手
        dp[i][j] = min(solve(i+1, j) - a[i], solve(i, j-1) - a[j-1]);
    }

    return dp[i][j];
}

int main() 
{
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,3005)rep(j,3005) dp[i][j] = -INF;

    ll ans = solve(0, n);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 70912
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
    string s;
    cin>>s;
    ll sum=0;
    for(char c:s)
    	sum+=c-'0';
    if(sum%9==0)
    {
    	cout<<"Yes"<<endl;
    }
    else
    {
    	cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3740
#include<iostream>
using namespace std;
int main()
{
int N,M,H;
cin >> N >> M >> H;
 
int im[N];
int ih[N];
int cot=0;
for(int j=0;j<N;j++){
cin >> im[j];
cin >> ih[j];
if(im[j]>=M&&ih[j]>=H) cot++;
}
cout << cot;
return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),g=s.nextInt()/100;
		int[]dp=new int[g+1];
		int inf=9000;
		Arrays.fill(dp,inf);
		dp[0]=0;
		for(int i=1;i<=n;++i) {
			int m=s.nextInt(),b=s.nextInt()/100;
			for(int j=g-1;j>=0;--j) {
				for(int k=1;k<=m;++k) {
					int t=Math.min(g,j+k*i+(k<m?0:b));
					dp[t]=Math.min(dp[t],dp[j]+k);
				}
			}
		}
		System.out.println(dp[g]);
	}
}


Measured memory_bytes: 23892
import numpy as np
import math

# K = int(input())
# N, K = map(int, input().split())
# A = list(map(int, input().split()))
# S = input() # String

S = input() # String
T = input() # String

StoT = dict()
TtoS = dict()

for i, _ in enumerate(S):
    if S[i] not in StoT:
        if T[i] in TtoS and TtoS[T[i]] != S[i]:
            print('No')
            exit(0)
        StoT[S[i]] = T[i]
        TtoS[T[i]] = S[i]
    else:        
        # print(S[i])
        # print(mapping[c])
        if StoT[S[i]] != T[i]:
            print('No')
            exit(0)

print('Yes')


Measured memory_bytes: 21124
#include <iostream>
#include <utility>
#include <algorithm>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include <math.h>
#include <map>
#include <vector>
#include <iomanip>
#include <set>
#include <deque>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define ll long long
#define pb push_back
using namespace std;

const int N = 2e6, PI = 3.14159265359, M = 1e9 + 7;
typedef pair <ll, ll> pii;
map <ll, ll> dp;
ll a[N], ans = 0;
map <pii, ll> ma;

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max((ll)0, a + b - n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> s(N, 0);
  for (int i = 1; i < N; i++){
    if (S[i - 1] == 'A' && S[i] == 'C'){
      s[i] = s[i - 1] + 1;
    } else {
      s[i] = s[i - 1];
    }
  }
  for (int i = 0; i < Q; i++){
    int l, r;
    cin >> l >> r;
    cout << s[r - 1] - s[l - 1] << endl;
  }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vector<vector<ll>> dp(51,vector<ll>(n+1,0));
    rep(i,n) cin >> dp[0][i];
    rep(i,min(50ll,k)){
        rep(j,n){
            if (dp[i][j] == 0){
                dp[i+1][j]++;
                dp[i+1][j+1]--;
                continue;
            }
            dp[i+1][max(0ll,j-dp[i][j])]++;
            dp[i+1][min(n,j+dp[i][j]+1)]--;
        }
        rep(j,n){
            dp[i+1][j+1] += dp[i+1][j];
        }
    }
    array_output(dp[min(50ll,k)].begin(),dp[min(50ll,k)].begin()+n);
}


Measured memory_bytes: 86356
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;
 


int main()
{
   
    
    string s, t;
    cin >> s >> t;
    string ans = "";
    vector<vector<int>>p(s.size()+4,vector<int>(t.size()+2));
    for (int i = 0; i < s.size(); i++) {
        
        for (int j = 0; j < t.size(); j++) {
            if (t[j] == s[i]) {
                p[i + 1][j + 1] = max(p[i + 1][j + 1], p[i][j] + 1);
            }
            p[i + 1][j + 1] = max(p[i + 1][j + 1], p[i][j+1] );
            p[i + 1][j + 1] = max(p[i + 1][j + 1], p[i+1][j ]);

        }
        
    }
    string res = "";
    int a = s.size(), b = t.size();

    while (a > 0 && b > 0) {
        if (p[a][b] == p[a - 1][b]) { a--; }
        else if (p[a][b] == p[a][b - 1])b--;
        else {
            res = s[a - 1] + res;
            a--; b--;
        }

    }
    cout << res << endl;



    return 0;

}

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

int main(){
	int ax, ay;
	char f[12][12];
	bool flag = false;

	for(int y=0 ; y<12 ; y++){
		for(int x=0 ; x<12 ; x++){
			f[y][x] = 0;
		}
	}

	while( 1 ){
		for(int i=0 ; i<8 ; i++) {
			if( scanf("%s", f[i]) == EOF ){
				flag = true;
				break;
			}
		}
		if(flag) break;

		for(int i=0 ; i<64 ; i++){
			if(f[i/8][i%8]=='1'){
				ax = i%8;
				ay = i/8;
				break;
			}
		}
		if( f[ay+1][ax]=='1' && f[ay][ax+1]=='1' && f[ay+1][ax+1]=='1' ){
			printf("A\n");
		}else if( f[ay+1][ax]=='1' && f[ay+2][ax]=='1' && f[ay+3][ax]=='1' ){
			printf("B\n");
		}else if( f[ay][ax+1]=='1' && f[ay][ax+2]=='1' && f[ay][ax+3]=='1' ){
			printf("C\n");
		}else if( f[ay][ax+1]=='1' && f[ay+1][ax+1]=='1' && f[ay+1][ax+2]=='1' ){
			printf("E\n");
		}else if( f[ay+1][ax]=='1' && f[ay+1][ax+1]=='1' && f[ay+2][ax+1]=='1' ){
			printf("F\n");
		}else if( f[ay][ax+1]=='1' && f[ay+1][ax]=='1' && f[ay+1][ax-1]=='1' ){
			printf("G\n");
		}else if( f[ay+2][ax-1]=='1' && f[ay+1][ax]=='1' && f[ay+1][ax-1]=='1' ){
			printf("D\n");
		}
	}
}

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

void textIO()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

}
typedef pair<long long, long long> pi;

int main()
{
    textIO();
    fastIO();

    long long x, n, ans = -1, diff = LONG_MAX;
    cin >> x >> n;

    vector<long long> arr(102);

    for(int i=0;i<n;i++){
        long long p;
        cin >> p;
        arr[p] = 1;
    }

    for(int i=0;i<=101;i++){
        if(arr[i] == 0){
            if(abs(i-x) < diff){
                diff = abs(i-x);
                ans = i;
            }
        }
    }

    if(abs(-1-x) <= diff){
        ans = -1;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3604
from sys import stdin, stdout,stderr
import time,math
from collections import defaultdict as dd
 
def pn(ob):stdout.write(str(ob))
def inp():return stdin.readline()

mod = 10**9 + 7

def main():
	n = int(inp())
	arr = list(map(int, inp().split()))

	tot = 0
	res = 0

	for x in arr:
		tot += x
		tot %= mod

	for x in arr:
		tot -= x
		res = (res + (x * tot)% mod) % mod
		res %= mod

	pn(res)
  
if __name__ == '__main__':
	main()
	
#n,m=map(int,input().split()) 
# for i in range(n):
#     t=int(stdin.readline()) # input using fast i/p method 
#     if t%m == 0:
#         stdout.write(str(t)+'\n') #input using fast o/p method
 
# take line of integers as input
# 	arr = list(map(int, inp().split()))

Measured memory_bytes: 32624
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
 
int main(){ 
        int n;
        cin >> n;
        int mx = -1e9;
        int mn = 1e9;
        int a;
        long long sum = 0;
        for(int i = 0; i < n; i++){
                cin >> a;
                if(mx < a)mx = a;
                if(mn > a)mn = a;
                sum += a;
        }
        cout << mn << " " << mx << " " << sum << endl;
}

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

int main(){
	int i;
	string A, B;
	cin >> A;
	cin >> B;
	if(A.size() > B.size()){
		printf("GREATER\n");
		return 0;
	}
	if(A.size() < B.size()){
		printf("LESS\n");
		return 0;
	}
	for(i = 0; i < A.size(); i++){
		if(A[i] > B[i]){
			printf("GREATER\n");
			return 0;
		}
		if(A[i] < B[i]){
			printf("LESS\n");
			return 0;
		}
	}
	printf("EQUAL\n");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,i,j=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++)
	{
		if(c%i==0)
		j++;
		else
		continue;
	}
	printf("%d\n",j);
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, std::vector<long long> A)
{
    ll ans = 0;
    ll tmp = A[0];
    if (tmp != 0)
    {
        cout << -1 << endl;
        return;
    }
    for (ll i = N - 1; i >= 1; i--)
    {
        if(A[i] - A[i-1] > 1){
            cout << -1 << endl;
            return;
        }
        if (A[i] < A[i - 1])
        {
            ans += A[i];
        }
        else
        {
            if (A[i - 1] == 0)
            {
                ans += A[i];
            }
            else
            {
                tmp = A[i - 1] + 1;
                ans += (A[i] / tmp) + (A[i] % tmp);
            }
        }
    }

    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define md 998244353
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=((res)*(x))%md;
        }
        x=((x)*(x))%md;
        y=y/2;
    }
    return res;
}
 




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

  ll n,i,j,k;

  sfl(n);

  string s;

  cin>>s;

  vector<int>v;

  int c[n+1][3];

  f(i,0,n+1){
      f(j,0,3){
          c[i][j]=0;
      }
  }

  for(char z:s){

      if(z=='R')v.pb(0);

      else if(z=='G')v.pb(1);

      else v.pb(2);

  }

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

      f(j,0,3)c[i+1][j]=c[i][j];

      c[i+1][v[i]]++;
  }

  ll ans=0;

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

      for(j=i+2;j<n;j++){

          if(v[i]!=v[j]){

              f(k,0,3)if(k!=v[i]&&k!=v[j])break;

              ans+=(c[j+1][k]-c[i][k]);

              if((j-i)%2==0){
                ll x=(j-i)/2;
                if(v[i+x]==k)ans--;
              }

          }

      }
  }

  pfl(ans);



   return 0;
 
  
 
    
 }

Measured memory_bytes: 3844
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll N;
    ll k=2;
    ll ans=0;
    ll M=0;
    ll S=0;
    ll j=1;
    cin>>N;
    ll P=N;
    while(k<=N){
        while(N%k==0){
            N=N/k;
            M++;
        }
        while(S<M){
            S=S+j;
            j++;
            if(S<=M)ans++;
        }
        M=0;
        S=0;
        j=1;
        k++;
        if(k*k>P){
            ans+=1;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
N=gets.chomp.split('')
if(N.size==1)
	puts N[0]
elsif(N[1..-1].reject{|a|a.to_i==9}.size==0)
	puts N[0].to_i+(N.size-1)*9
else
	puts N[0].to_i-1+(N.size-1)*9
end

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 100000;
int n,m;
vi g[MAX_N];
bool vis[3][MAX_N];
int s,t;

typedef tuple<int,int,int> qelem;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> m;
  forn(i,m) {
    int u,v; cin >> u >> v;
    u--,v--;
    g[u].push_back(v);
  }

  cin >> s >> t;
  s--,t--;

  queue<qelem> q;
  q.push((qelem){s,0,2});
  vis[2][s] = true;

  while (!q.empty()) {
    int u,c,d;
    tie(u,c,d) = q.front(); q.pop();
    //printf("%d %d %d\n",u,c,d);
    if (u == t && d == 2) {
      cout << c << endl;
      return 0;
    }

    for (int v : g[u]) {
      if (vis[(d+1)%3][v]) continue;
      int c2 = d==2?(c+1):c;
      int d2 = d==2?0:d+1;
      vis[d2][v] = true;
      q.push((qelem){v,c2,d2});
    }
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 6016
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£????????????
		Scanner sc = new Scanner(System.in);
		//??????????????????
		String str = sc.next();
		StringBuffer sb = new StringBuffer(str);

		//??????????????°?????????
		int n = sc.nextInt();
		for(int i = 0; i<n;i++){
			//??????????????????
			String order = sc.next();
			//?????¶?????????
			int a = sc.nextInt();
			int b = sc.nextInt()+1;
			//???????????????????????? 1 ?????????????????´???
			if(order.equals("replace")){
				//????????????????????????
				String wordRe = sc.next();
				sb = sb.replace(a, b, wordRe);
				 str= sb.toString();
				//System.out.println("????????????="+str);
				//2??????????????????
			}else if(order.equals("reverse")){
				StringBuffer sb2 = new StringBuffer(sb.substring(a,b));
				str =sb2.reverse().toString();;
				sb.replace(a, b, str);
				//System.out.println("???="+sb);
			//3??????????????????????????¨???
			}else if(order.equals("print")){
				//???????????????????????¨???
				str= sb.substring(a, b);
				System.out.println(str);
			}
		}
	}
}

Measured memory_bytes: 29124
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[][] delta = new int[][]{{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] g = new char[h][w];
		for (int i = 0; i < h; i++) {
			g[i] = sc.next().toCharArray();
		}

		int answer = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (g[i][j] != '.') continue;
				//boolean[][] visited = new boolean[h][w];
				int[][] d = new int[h][w];
				for (int l = 0; l < h; l++) {
					Arrays.fill(d[l], 10000);
				}

				Queue<int[]> q = new LinkedList<>();
				q.offer(new int[]{i, j, 0});
				d[i][j] = 0;
				while (!q.isEmpty()) {
					int[] p = q.poll();
					//visited[p[0]][p[1]] = true;
					for (int k = 0; k < 4; k++) {
						int ny = delta[k][0] + p[0];
						int nx = delta[k][1] + p[1];
						if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
						if (g[ny][nx] != '.' || d[ny][nx] != 10000) continue;
						d[ny][nx] = d[p[0]][p[1]] + 1;
						q.offer(new int[]{ny, nx});
					}

					//if (q.isEmpty()) answer = Math.max(answer, p[2]);
				}

				for (int k = 0; k < h; k++) {
					for (int l = 0; l < w; l++) {
						if (d[k][l] < 10000) answer = Math.max(answer, d[k][l]);
					}
				}
			}
		}
		System.out.println(answer);
	}
}


Measured memory_bytes: 29560
N = int(input())
A = list(map(int,input().split()))
c = True
for i in range (N):
    if A[i]%2==1 or A[i]%3==0 or A[i]%5==0:
      c = True
    else:
      c = False
      break
      
if (c):
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,cnt=1;
    cin>>n;
    a=n%10;
    n=n/10;
    while(n){
        b=n%10;
        n=n/10;
        if(a==b)cnt++;
        else cnt=1;
        if(cnt>2){
            cout<<"Yes";
            return 0;
        }
        else
        a=b;
    }
    cout<<"No";
    return 0;
}


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

int a,b,c,d;
int x,y;

int main(){
	ios::sync_with_stdio(false);
	cin >> a >> b >> c >> d;
	x = c - a,y = d - b;
	cout << c - y << " " << d + x << " " << a - y << " " << b + x;
	return 0;
}

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

const ll INF = 1ll << 60;
ll MOD = 998244353;

int main()
{

    int n, d;
    cin >> n;
    cin >> d;

    int a = 2 * d + 1;
    int ans = (n + (a - 1)) / a;
    cout << ans << endl;
    return 0;
}

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


int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int n = a * 100 + b * 10 + c;
    if (n % 4 == 0) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	final int INF = Integer.MAX_VALUE;
	
	private void doit() {
		Scanner sc = new Scanner(System.in);
		int MAX = 1000000;
		int [] dpAll = new int[MAX + 1];
		int [] dpOdd = new int[MAX + 1];
		Arrays.fill(dpAll,INF);
		Arrays.fill(dpOdd, INF);
		ArrayList<Integer> data = new ArrayList<Integer>();
		for(int i = 0; ;i++){
			int sum = i * (i + 1) * (i + 2) / 6;
			if(sum > MAX) break;
			data.add(sum);
		}
		int len = data.size();
		for(int i=0; i < len; i++){
			int value = data.get(i);
			dpAll[value] = 1;
			if(value % 2 == 1){
				dpOdd[value] = 1;
			}
		}
		
		for(int i=0; i <MAX; i++){
			for(int j = 0;j < len; j++ ){
				int ind = i + data.get(j);
				if(ind <= MAX){
					int value = dpAll[i] + 1;
					dpAll[ind] = Math.min(value, dpAll[ind]);
					if(dpOdd[i] != INF && data.get(j) % 2 == 1){
						value = dpOdd[i] + 1;
						dpOdd[ind] = Math.min(value, dpOdd[ind]);
					}
				}
			}
		}
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			System.out.println(dpAll[n] + " " + dpOdd[n]);
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 20000
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
ld pie=3.141592653589793238462643383279;
int mod=1e9+7;

struct Edge {
    int a, b, cost;
};

int n, m;
vector<Edge> edges;
const int INF = 1000000000;

void solve()
{
    cin>>n>>m;
    for(int i=0;i<m;++i){
      int A,B,C; cin>>A>>B>>C;
      --A; --B;
      Edge lp; lp.a=A; lp.b=B; lp.cost=C;
      edges.pb(lp);
    }
    vector<int> d(n);
    vector<int> p(n, -1);
    int x;
    for (int i = 0; i < n; ++i) {
        x = -1;
        for (Edge e : edges) {
            if (d[e.a] + e.cost < d[e.b]) {
                d[e.b] = d[e.a] + e.cost;
                p[e.b] = e.a;
                x = e.b;
            }
        }
    }

    if (x == -1) {
        cout << "NO";
    } else {
        for (int i = 0; i < n; ++i)
            x = p[x];

        vector<int> cycle;
        for (int v = x;; v = p[v]) {
            cycle.push_back(v);
            if (v == x && cycle.size() > 1)
                break;
        }
        reverse(cycle.begin(), cycle.end());

        cout << "YES\n";
        for (int v : cycle)
            cout << v << ' ';
        cout << endl;
    }
}
int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int x,y;
  cin>>x>>y;
  bool poss=1;
  if(y&1) poss=0;
  else{
    y/=2;
    int a,b; b=y-x;
    a=2*x-y;
    if(a<0 || b<0) poss=0;
  }
  if(poss) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}


Measured memory_bytes: 3636
n, q = map(int, input().split())
stack = []
for _ in range(n):
    stack.append([])

for _ in range(q):
    c = list(map(int, input().split()))
    if c[0] == 0:
        stack[c[1]].append(c[2])
    elif c[0] == 1:
        if len(stack[c[1]]) > 0:
            print(stack[c[1]][-1])
    elif c[0] == 2:
        if len(stack[c[1]]) > 0:
            del(stack[c[1]][len(stack[c[1]])-1])



Measured memory_bytes: 13696
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int n, a[100005]; 
int dp[100005]; 
 
int func(int ind) {
	if(ind==(n-1)) return 0; 
	if(ind>=n) return INT_MAX; 
 
	if(dp[ind]!=-1) return dp[ind]; 
    
	int left = abs(a[ind]-a[ind+1]) + func(ind+1); 
	int right = INT_MAX; 
	if(ind+2<n) {
		right = abs(a[ind] - a[ind+2]) + func(ind+2); 
	}
 
	return dp[ind] = min(left, right); 
}
signed main() {
	
	cin >> n;
 
	memset(dp, -1, sizeof dp); 
	
	for(int i = 0;i<n;i++) {
		cin >> a[i]; 
	}
 
	cout << func(0); 
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  for(int i=n; i<=999; i++){
    int a = i%10;
    int b = i/100;
    int c = (i-(i/100)*100)/10;
    if(a == b && b == c){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
#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()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll inputLValue(){
    ll a;
    cin >> a;
    return a;
};

int main()
{
    int X = inputValue();
    int xm = X % 100;
    int n = X / 100;
    int m = n * 5;
    int ans = 0;
    if(X > 2000){
        ans = 1;
    }else if(xm <= m){
        ans = 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

typedef map<int, int> Num;

int check2(Num a) {
	int sum = 0;
	for (int i = 1; i <= 9; i++)
		sum += a[i];
	return sum;
}

void check1(Num a, int n, int *ans) {
	if (check2(a) == 0) {
		*ans |= (0x01 << n);
		return;
	}

	for (int i = 1; i <= 9; i++) {
		if (a[i] >= 3) {
			a[i] -= 3;
			check1(a, n, ans);
			a[i] += 3;
		}
	}

	for (int i = 3; i <= 9; i++) {
		if (a[i-2] && a[i-1] && a[i]) {
			a[i-2] -= 1;
			a[i-1] -= 1;
			a[i] -= 1;
			check1(a, n, ans);
			a[i-2] += 1;
			a[i-1] += 1;
			a[i] += 1;
		}
	}
}

int solve(Num a) {
	int ans = 0;
	for (int i = 1; i <= 9; i++) {
		if (a[i] == 4) continue;

		a[i]++;
		for (int j = 1; j <= 9; j++)
			if (a[j] > 1) {
				a[j] -= 2;
				check1(a, i, &ans);
				a[j] += 2;
			}
		a[i]--;
	}
	return ans;
}

int main() {
	string str;
	while (cin >> str) {
		Num a;
		for (int i = 1; i <= 9; i++)
			a[i] = 0;
		for (int i = 0; i < str.size(); i++) {
			int s = str[i] - '0';
			a[s]++;
		}
		int ans = solve(a);
		if (ans == 0)
			cout << 0 << endl;
		else {
			int ifs = 0;
			for (int i = 1; i <= 9; i++) {
				if (ans & (0x01 << i))
					cout << ((ifs++) ? " " : "") << i;
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1188
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

def gcd(n, m):
    if m > n:
        n, m = m, n
    if m == 0:
        return n
    r = 0
    while n % m != 0:
        r = n % m
        n = m
        m = r
    return m

def lcm(n, m):
    return n * m // gcd(n, m)

def lcm_vec(v):
    r = v[0]
    for i in v[1:]:
        r = lcm(r, i)
    return r

print(lcm_vec(a))


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

typedef long long ll;
typedef long double ld;

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    ll N, M;
    cin >> N >> M;
    ll L = gcd(N,M);
    string S,T;
    cin >> S >> T;

    bool flag = true;

    N /= L;
    M /= L;

    rep(i,L) {
        if(S[i*N] != T[i*M]) flag=false;
    }

    if(flag){
        cout << N*M*L << endl;
    }
    else{
        cout << -1 << endl;
    }

}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int n,a[2100];
bitset < 4001000 > dp;
int main()
{
    int n;cin>>n;
    dp[0]=1;int avg=0,sum=0;
    for(int i=0;i<n;i++) {
            cin>>a[i];sum+=a[i];dp = dp | dp<<a[i];
    }
    avg=sum/2;
    if(sum%2) avg++;
    for(int i=avg;i<=sum;i++){

        if(dp[i]) {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  i64 N, M;
  cin >> N >> M;
  vector<i64> A(N);
  rep(i,0,N) cin >> A[i];
  priority_queue<i64> que;
  rep(i,0,N) {
    que.push(A[i]);
  }

  while(M > 0 && !que.empty()) {
    i64 z = que.top();
    que.pop();
    if(z / 2 > 0) {
      que.push(z / 2);
    }
    M--;
  }
  i64 ans = 0;

  while(!que.empty()) {
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 2168
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#pragma GCC optimize(2)
#include <immintrin.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[101];
	int l;
	gets(a);
	l = strlen(a);
	cout << a[0] << l-2 << a[l-1];
	return 0;
}

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

using namespace std;
#define int long long

signed main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    
    sort(a,a+3);
    
    if(a[0]+a[1]==a[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x,y;
    while(cin>>x>>y){
        x+=y;
        int c=1;
        while(x/=10)++c;
        cout<<c<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3176