akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;

ll n;
ll a[300000];
ll f[300000][2];
bool flag[300000][2];

int get_status(int now, int n)
{
    if (((n-now+1)%2)==0)
        return 0;
    else
        return 1;
}

ll dp(int i, int status)
{
    if (i>n) return 0;
    if (i==n && status==0) return 0;
    if (flag[i][status]) return f[i][status];
    flag[i][status]=1;

    if (status==1)
    {
        f[i][status] = a[i] + dp(i+2, 1);
    }else
    {
        int remain = get_status(i, n);
        if (remain == 0)
        {
            f[i][status] = max(a[i]+ dp(i+2, 0), dp(i+1, 1));
        }else
        {
            f[i][status] = max(a[i] + dp(i+2, 0), dp(i+1,0));
        }
    }

    return f[i][status];

}

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

    cout << dp(1, 0) << endl;
    return 0;
}



Measured memory_bytes: 14968
n = gets

ans = 0
n.size.times do |i|
  next if i.odd?
  lower = ("1" + ("0" * i)).to_i
  upper = [("9" * (i + 1)).to_i, n.to_i].min
  next if upper < lower

  ans += upper - lower + 1
end

puts ans


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

#define N 100006
#define LL long long
using namespace std;

LL a[N];

int main(){
    int n;
    LL l;
    cin >> n >> l;
    
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    
    int ans = -1;
    for(int i=0;i<n-1;i++){
        if(l <= a[i]+a[i+1]){
            ans = i;
        }
    }
    
    if(ans==-1){
        cout << "Impossible" << endl;
    } else {
        cout << "Possible" << endl;
        for(int i=0;i<ans;i++){
            if(i!=ans) printf("%d\n",i+1);
        }
        
        for(int i=n-2;i>ans;i--){
            if(i!=ans) printf("%d\n",i+1);
        }
        cout << ans +1 << endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int a,n,al,bo;
vector <int> ai;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		ai.push_back(a);
	}
	sort(ai.begin(),ai.end());
	for(int i=n-1;i>=0;i--){
		if((n-1-i)%2==0){
			al+=ai[i];
		}else{
			bo+=ai[i];
		}
	}
	cout<<al-bo<<endl;
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
    string s; cin >> s;

    A--; B--; C--; D--;
    bool ok = true;
    {
        // A -> C
        int cons = 0, max_cons = 0;
        for(int i=A; i<=C; i++) {
            if(s[i] == '.') {
                max_cons = max(max_cons, cons);
                cons = 0;
            }
            else {
                cons++;
            }
        }

        ok &= (max_cons < 2);
        fprintf(stderr, "ok1 = %d\n", max_cons < 2);
    }
    {
        // B -> D
        int cons = 0, max_cons = 0;
        for(int i=B; i<=D; i++) {
            if(s[i] == '.') {
                max_cons = max(max_cons, cons);
                cons = 0;
            }
            else cons++;
        }
        ok &= (max_cons < 2);
        fprintf(stderr, "ok2 = %d\n", max_cons < 2);
    }

    if(C > D) {
        bool can = false;
        can |= (s[B-1] == '.' and s[B+1] == '.');
        can |= (s[D-1] == '.' and s[D+1] == '.');
        
        // 追い越す場合は 3 マス以上の空きがどこかに必要
        int cons = 0, max_cons = 0;
        for(int i=B; i<=D; i++) {
            if(s[i] == '#') {
                max_cons = max(max_cons, cons);
                cons = 0;
            }
            else cons++;
        }
        max_cons = max(max_cons, cons);
        can |= (max_cons >= 3);
        // fprintf(stderr, "max_cons = %lld, can = %d\n", max_cons, can);

        ok &= can;
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long ret[210000];
long long fact[210000];
long long inv[210000];
long long finv[210000];
long long C(int a,int b){
	if(a<b||b<0)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		b/=2;
		a=a*a%mod;
	}
	return ret;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	fact[0]=inv[1]=finv[0]=1;
	for(int i=2;i<210000;i++){
		inv[i]=(mod-inv[mod%i]*(mod/i)%mod)%mod;
	}
	for(int i=1;i<210000;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
	long long tmp=1;
	long long aw=0;
	int L=0;
	int R=0;
	for(int i=0;i<a+b;i++){
		ret[i]=(tmp*d2+aw)%mod;
		//printf("%lld %lld\n",tmp*d2%mod,aw);
		R++;
		if(i+1-L==a){
			tmp=(tmp+mod-C(i,L)*pw(d2,i+1)%mod)%mod;
	//		printf("%lld\n",C(i,L)*pw(d2,i+1)%mod);
			L++;
		}
		if(R==b){
			R--;
			tmp=(tmp+mod-C(i,R)*pw(d2,i+1)%mod)%mod;
		//	printf("%lld %lld\n",C(i,R),pw(d2,i+1)%mod);
			aw=(aw+C(i,R)*pw(d2,i+1))%mod;
		}
	}
	for(int i=0;i<a+b;i++){
		printf("%lld\n",ret[i]);
	}
}

Measured memory_bytes: 8576
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
using namespace std;
int main(){
  long long H, W;
  long long L, S;
  cin >> H >> W;
    if((H==1) or (W==1)){
    cout << 1;
    return 0;
  }
  S = (H-1) / 2 + 1;
  L = H / 2;
  cout << S * ((W-1) / 2 + 1) + L * (W / 2);
  return 0;
}

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

int main() {
    // cin.tie(0); ios::sync_with_stdio(0);
    int n, m, k; cin >> n >> m >> k;
    vector<int> a(n), b(m);
    for (int i=0; i<n; i++) cin >> a[i];
    for (int j=0; j<m; j++) cin >> b[j];
    
    int rec = 0, ind = 0, ans = 0;;
    while (ind < n && rec+a[ind] <= k) {
        rec += a[ind];
        ind++;
        ans++;
    }
    int dd = 0;
    int ta = ans;
    while (dd < m) {
        if (rec+b[dd] <= k) {
            while (dd < m && rec+b[dd] <= k) {
                rec += b[dd];
                dd++;
                ta++;
                ans = max(ans, ta);
            }
        } else {
            if (ind == 0) break;
            else {
                ind--;
                rec -= a[ind];
                ta--;
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  ll g;
  cin >> g;
  rep(i, N-1){
    ll tmp;
    cin >> tmp;
    g = gcd(g, tmp);
  }
  cout << g;
  /*
  set<ll> primes;
  for(ll i=2;i<=sqrt(1000000);i++){
    if(is_prime(i))primes.insert(i);
  }

  map<ll, ll> facts;
  for(auto ip:primes){
    ll cnt=0;
    A[0]
  }
  */
  
  return 0;
}


Measured memory_bytes: 256
def absol(a, b):
    if a < b:
        return (b - a)
    else:
        return (a - b)

N = int(raw_input())
W = [int(w) for w in raw_input().split()]

sumlist = []
for T in range(1, N):
    S1 = 0
    S2 = 0
    for i in range(N):
        if i < T:
            S1 += W[i]
        else:
            S2 += W[i]
    sumlist.append(absol(S1, S2))
print str(min(sumlist))

Measured memory_bytes: 2568
#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)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N, A[101010], B[101010];
//---------------------------------------------------------------------------------------------------
ll get() {
    ll sm = 0;
    rep(i, 0, N - 1) sm += abs(B[i + 1] - B[i]);
    return sm;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    sort(A, A + N);

    ll ans = -1;
    if (N % 2 == 0) {
        rep(i, 0, N / 2) B[i * 2 + 1] = A[i];
        rep(i, 0, N / 2) B[i * 2] = A[i + N / 2];
        chmax(ans, get());
    } else {
        rep(i, 0, N / 2) B[i * 2 + 1] = A[i];
        B[N-1] = A[N/2];
        rep(i, 0, N / 2) B[i * 2] = A[i + N / 2 + 1];
        chmax(ans, get());

        B[0] = A[N / 2];
        rep(i, 0, N / 2) B[i * 2 + 2] = A[i];
        rep(i, 0, N / 2) B[i * 2 + 1] = A[i + N / 2 + 1];
        //rep(i, 0, N) printf("%d ", B[i]); printf("\n");
        chmax(ans, get());
    }

    //rep(i, 0, N) printf("%d ", B[i]); printf("\n");

    
    cout << ans << endl;
}

Measured memory_bytes: 1024
s = gets.strip
before = s[0..1].to_i
after = s[2..3].to_i
answer = []

if before > 0 && before <= 12 then
  answer.push('MMYY')
end
if after > 0 && after <= 12 then
  answer.push('YYMM')
end

if answer.length == 1 then
  puts answer[0]
elsif answer.length > 1 then
  puts 'AMBIGUOUS'
else
  puts 'NA'
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
stack<int>st;
queue<int>q;
vector<int>v,v1,v2,v3;
set<int>stt;
set<int>::iterator set_it;
map<string,int>mp;
//initialy map er all index er value zero thake;
//map er jonno this pointer(->) use korte hoy
//akta value dakhar jonno staristics pointer(*) use  korte hoy
// one more value print korar jonno this pointer(->) use korte hoy (must be)
map<string,int>::iterator map_it;
long long int a[20007];
long long int i,j,k,l,m,n,cnt=0,sum=0,mx=0,mn=0;
string s,s1,s2;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
        {
           //cout<<i<<" ";

            sum+=i;
        }
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h> 
using namespace std; 
const int M=105; 
int dp[105][105][5]; 
int K,n1; 
int ct(int p, int c, int t, vector<int> num) 
{ 
    if (p==num.size()) 
	{ 
        if (c==K) return 1; 
        return 0; 
	}
    if (dp[p][c][t]!=-1) 
    	return dp[p][c][t]; 
    int ans=0; 
    int l=(t?9:num[p]); 
    for (int i=0; i<=l; i++) 
	{ 
        int currCnt =c; 
        if (i!=0)  currCnt++; 
        int currTight=t; 
        if (i<num[p]) 
            currTight=1; 
        ans+=ct(p+1, currCnt, currTight, num); 
    } 
    return dp[p][c][t]=ans; 
} 
int countInRange(string x) 
{ 
	n1=x.size();
    vector<int> num; 
    while (n1>0) 
	{
		n1--;
        num.push_back(int(x[n1]-'0')); 
    } 
    reverse(num.begin(), num.end()); 
    memset(dp, -1, sizeof(dp)); 
    return ct(0, 0, 0, num); 
} 
int main() 
{ 
    string R;
	cin>>R; 
    cin>>K;
    cout<<countInRange(R)<<endl; 
} 

Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>
#include <numeric>


int main(){
	int p, q, r;
	std::cin >> p >> q >> r;
	std::cout << p + q + r - std::max({p,q,r}) << std::endl;
	return 0;
}


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

string ten[] = {"Sunny", "Cloudy", "Rainy", "Sunny"};

int main(){
  string s; cin >> s;
  for(int i = 0; i < 3; i++){
    if(s == ten[i]) {
      cout << ten[i + 1] << endl;
      return 0;
    }
  }
  
}

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

typedef long long int int64;
static const int64 mod = 1000000007LL;

int64 inv[100003],fac[100003],invfac[100003];
int n,m;
int64 dp[17][65537];
int a[16];
int bc[65536];
int main()
{
	inv[1] = fac[0] = fac[1] = invfac[0] = invfac[1] = 1;
	for(int i = 2;i <= 100000;++i) {
		fac[i] = (fac[i-1]*i)%mod;
		inv[i] = (mod-mod/i)*inv[mod%i]%mod;
		invfac[i] = (invfac[i-1]*inv[i])%mod;
	}
	scanf("%d%d",&n,&m);
	for(int i = 0;i < m;++i) {
		scanf("%d",&a[i]);
	}
	bc[0] = 0;
	for(int i = 1;i < (1<<n);++i) {
		bc[i] = 1 + bc[i^(i&-i)];
	}
	std::sort(a,a+m,std::greater<int>());
	dp[0][0] = 1;
	for(int i = 0;i < m;++i) {
		memcpy(dp[i+1],dp[i],sizeof(dp[i+1]));
		for(int j = 0;j < (1<<n);++j) {
			int64 cnt = (1<<n)-j-a[i];
			for(int k = 0;k < n && (1<<k)-1 <= cnt;++k) if(((j>>k)&1)==0) {
				dp[i+1][j|(1<<k)] = (dp[i+1][j|(1<<k)] + dp[i][j] * fac[cnt] % mod * invfac[cnt-(1<<k)+1] % mod * (1<<k)) % mod;
			}
		}
	}
	int64 ans = 0;
	for(int i = 0;i < (1<<n);++i) {
		ans += dp[m][i] * fac[(1<<n)-1-i] % mod * ((bc[i]&1) == 0 ? 1 : -1);
	}
	ans %= mod;
	if(ans < 0) ans += mod;
	ans = ans * (1<<n) % mod;
	printf("%lld\n", ans);
}


Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
const int maxn=1e5+10;
int L[maxn],R[maxn],len;
ll ans[maxn],d[maxn],p[maxn];
int main()
{
    ll cnt=0;
    int n,k;scanf("%d%d",&n,&k);
    for(int l=1,r;l<=n;l=r+1)
    {
        r=n/(n/l);
        L[++len]=l;
        R[len]=r;
        ans[len]=(n/l)%mod;
        cnt=(cnt+1LL*(r-l+1)*(n/l))%mod;
        //cout<<L[len]<<" "<<R[len]<<endl;
    }
    if(k==2)
    {
        printf("%lld\n",cnt);
        return 0;
    }
    for(int i=3;i<=k;i++)
    {
        int tt=0;
        ll tmp=0;
        for(int j=len;j>=1;j--)
        {
            int TT=n/L[j];
            while(tt<len&&R[tt+1]<TT)
            {
                tt++;
                tmp+=1LL*(R[tt]-L[tt]+1)*ans[tt];
                tmp%=mod;
            }
            p[j]=tmp+1LL*(TT-L[tt+1]+1)*ans[tt+1];
            p[j]%=mod;
        }
        for(int j=1;j<=len;j++)
            ans[j]=p[j];
    }
    ll s=0;
    for(int j=1;j<=len;j++)
        s=(s+1LL*(R[j]-L[j]+1)*ans[j])%mod;
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
long long const MOD = 1000000007;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<vector<int>> tree(n);
    vector<int> number(n, -1);
    vector<bool> visited(n, false);
    vector<bool> confirmed(n, false);
    number[0] = k;
    visited[0] = true;
    confirmed[0] = true;

    for (auto i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    queue<int> qu;
    for (auto i = 0; i < tree[0].size(); i++)
    {
        qu.push(tree[0][i]);
        number[tree[0][i]] = k - 1 - i;
        confirmed[tree[0][i]] = true;
    }

    while (!qu.empty())
    {

        int now = qu.front();
        qu.pop();
        visited[now] = true;
        for (auto i = 0; i < tree[now].size(); i++)
        {
            if (!visited[tree[now][i]])
            {
                qu.push(tree[now][i]);
            }
        }

        if (tree[now].size() >= 3)
        {
            int tmp = 0;
            for (auto i = 0; i < tree[now].size(); i++)
            {
                if (!confirmed[tree[now][i]])
                {
                    number[tree[now][i]] = k - 2 - tmp;
                    tmp += 1;
                    confirmed[tree[now][i]] = true;
                }
            }
        }

        if (!confirmed[now])
        {
            number[now] = k - 2;
            confirmed[now] = true;
        }
    }

    long long ans = 1;

    for (auto i = 0; i < n; i++)
    {
        if (number[i] <= 0)
        {
            cout << 0 << endl;
            return 0;
        }
        ans = (ans * number[i]) % MOD;
    }
    cout << ans << endl;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  int64 d;
  cin >> n >> d;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int64 x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        char[] chars = sc.next().toCharArray();
        if (N % 2 != 0) {
            System.out.println("No");
            return;
        }

        for (int i = 0; i < N / 2; i++) {
            if (chars[i] != chars[N / 2 + i]) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <regex>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 1145141919;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

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

int w, h;
vector<string> s;

int main()
{
	while (cin >> h >> w, w)
	{
		s.resize(h);
		REP(i, h) cin >> s[i];
		map<string,int> used;
		REP(i, h)
		{
			REP(j, w)
			{
				REP(k, 8)
				{
					string t; t+=s[i][j];
					int nx = i; int ny = j;
					while (1)
					{
						nx += dx[k]; ny += dy[k];
						if (nx == h) nx = 0;
						else if (nx < 0) nx = h - 1;
						if (ny == w) ny = 0;
						else if (ny < 0) ny = w - 1;
						if (nx == i&&ny == j)  break;
						t += s[nx][ny];
						used[t]++;
					} 

				}
			}
		}
		string ans = "0";
		for (auto ite = used.begin(); ite != used.end(); ite++)
		{
			if ((*ite).second >= 2)
			{
				auto tmp = (*ite).first;
				if (ans.size() < tmp.size()) ans = tmp;
				else if (ans.size() == tmp.size()) ans = min(ans, tmp);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 36028
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = min(C)
for i in range(N):
  s = 0
  m = [0 for i in range(N+1)]
  t = i
  step = 0
  while step < K:
    step += 1
    t = P[t] - 1
    s += C[t]
    m[step-1] = s
    if t == i:
      break
  #print(i, s, step, K // step)
  #Case_1 : [1,step]
  for j in range(step):
    ans = max(ans, m[j])
  #Case_2 : max(s, 0) * (K // step) + mod_max 1 ~ K//step : round
  if K % step == 0 and s > 0:
    mod_max = 0
    for j in range(step):
      mod_max = max(mod_max, m[j])
    ans = max(ans, mod_max + max(s, 0) * ((K // step)-1))
  elif s > 0:
    mod_max = 0
    for j in range(K % step):
      mod_max = max(mod_max, m[j])
    ans = max(ans, mod_max + max(s, 0) * (K // step))

print( ans )

Measured memory_bytes: 85624
#include <iostream>
#include <cstring>
#include<cstdio>
#include <algorithm>
#include <iostream>
#include <queue>
#include <ctime>
#include <cstring>
#include <cmath>
#include <stack>
#include <set>
#include <unordered_map>
#define INF 0x3f3f3f3f
#define ll long long
#define rep(i, n) for(ll i=0;i<n;i++)
#define per(i, n) for(int i=n;i>=0;i--)
#define rep2(i, n) for(ll i=1;i<=n;i++)
#define pb(x) push_back(x)
#define clint(x, n) memset(x,n,sizeof(x))
#define mp make_pair
#define fi first
#define se second
#define IO std::ios::sync_with_stdio(false)
#define ull unsigned long long
#define ud long double
#define pii pair<int,int>
using namespace std;
const int maxn = 1e6+5;
const ll inf = 100000000000;
const int mod =998244353;
const int MAX = 123123;
const int N =1005;
char a[55][55],b[55][55];
inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}
ll max(ll a,ll b){
    if(a>b) return a;
    return b;
}
ll min(ll a,ll b){
    if(a<b) return a;
    return b;
}
int main() {
    int m,n;
    cin>>n>>m;
    int flag=0,f=0;
    rep(i,n) rep(j,n) cin>>a[i][j];
    rep(i,m) rep(j,m) cin>>b[i][j];
    if(m>n) cout<<"No"<<endl;
    else{
        rep(i,n-m+1) {
            rep(j, n - m+1) {
                if (b[0][0] == a[i][j]) {
                    flag = 1;
                    for (ll x = 0; x < m; x++) {
                        for (ll y = 0; y < m; y++) {
                            if (b[x][y] != a[i + x][j + y]) {
                                flag = 0;
                            }
                        }
                    }
                    //cout<<i<<' '<<j<<' '<<f<<endl;
                    if (flag == 1) {
                        f = 1;
                        break;
                    }
                }
            }
            if(f) break;
        }
        if(f) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = []
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))

min_a = min(a)
ans = n // min_a
if n % min_a != 0:
    ans += 1
ans += 4


print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
int a,b,x;
x=0;
scanf("%d %d",&a,&b);
if(a>b){x=x+a;a--;}
else{x=x+b;b--;}
if(a>b){x=x+a;a--;}
else{x=x+b;b--;}
printf("%d",x);
return 0;
}

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

void dfs(ll i, bool *visited, ll n, vector<ll> *v){
	visited[i] = true;
	vector<ll> temp = v[i];
	for(int j=0;j<temp.size();j++){
		if(!visited[temp[j]]){
			dfs(temp[j],visited,n,v);
		}
	}
}

int main(){
	ll n,m;
	//set<int> s;
	cin>>n>>m;
	ll a,b;
	vector<ll> *v = new vector<ll>[n+1];
	ll count = 0;
	for(ll i=0;i<m;i++){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	bool *visited = new bool[n+1]();
	for (ll i=1; i<=n; i++) {
        if (visited[i] == false){
        	count++;
            dfs(i, visited, n, v); 
        } 
    }
    cout<<count-1<<endl;
	return 0;
}

Measured memory_bytes: 12108
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << (A*B < C*D ? C*D : A*B) << endl;
}

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

void Main() {
    // input
    string N;
    cin >> N;


    // translate
    for (int i = 0; i < 3; i++) {
        if (N[i] == '7') {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;

    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3608
//aea ctmr https://codeforces.com/contest/1271/submission/66946806
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
    
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define PI 3.14159265358979323846
 
typedef long double ld;
typedef long long ll;
const ll N = 105000;
const ll mod = 1e9 + 7;
using namespace std;
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
 
vector <pair <int, int>> xd;

int main(){

    ll a, b;
    cin >> a >> b;

    cout << a * b / __gcd(a, b) << endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, 0, n) cin >> s[i];
    int ac = 0, wa = 0, tle = 0, re = 0;
    rep(i, 0, n){
        if(s[i] == "AC") ac++;
        if(s[i] == "WA") wa++;
        if(s[i] == "TLE") tle++;
        if(s[i] == "RE") re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}


Measured memory_bytes: 6420
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		long num = 1000000007;
		long[] fact = new long[500001];
 		fact[0] = 1;
 		long ans1 = 1;
 		for(int i = 1;i<=500000;i++){
 			ans1= (ans1*i) % num;
 			fact[i] = ans1;
 		}
 		long[] inv = new long[500001];
 		inv[0] = 1;
 		for(int i = 1;i<=500000;i++){
 			inv[i] = power(fact[i], num-2, num)%num;
 		}
		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);

	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		int n = Integer.parseInt(st.nextToken());
	 		int m = Integer.parseInt(st.nextToken());
	 	
	 	long ans = fact[m] * inv[m-n] %num;
	 	
	 	long anss = 0;
	 	long pos = 1;
	 	for(int i = 1;i<=n;i++){
	 		long prod =1;
	 		prod*=fact[n];
	 		prod%=num;
	 		prod*=inv[i];
	 		prod%=num;
	 		prod*=inv[n-i];
	 		prod%=num;
	 		prod*=fact[m-i];
	 		prod%=num;
	 		prod*=inv[m-n];
	 		prod%=num;
	 		prod*=pos;
	 		anss+=prod;
	 		anss = (anss+num)%num;
	 		pos = -pos;
	 	}
	 	long actualans = 0;
	 	actualans+= ans*ans;
	 	actualans%=num;
	 	actualans-=anss*ans;
	 	actualans%=num;
	 	actualans = (actualans+num)%num;
	 	out.println(actualans);
 		out.close();
 		
 		
 		
 	}
	public static int power(long x, long y, long mod){
		long ans = 1;
		while(y>0){
			if (y%2==1)
				ans = (ans*x)%mod;
			x = (x*x)%mod;
			y/=2;
		}
		return (int)(ans);
	}
	
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 33844
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXL=200050;
char S[MAXL];

int main() {
	scanf("%s",S);
	vector<char> vec;
	for(int i=0;S[i];i++) {
		if(S[i]=='T' && SZ(vec)>0 && vec.back()=='S') vec.pop_back();
		else vec.PB(S[i]);
	}
	printf("%d\n",SZ(vec));
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());
using ll = long long;
using P = pair<int, int>;

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

vector<pair<long long, long long>> f(long long N)
{
  long long tempN = N;
  vector<pair<long long, long long>> dst;
  bool is_prime = true;

  for (long long i = 2; i * i <= N; i++)
  {
    if (tempN % i == 0)
    {
      dst.push_back(make_pair(i, 0));
      while (tempN % i == 0)
      {
        tempN /= i;
        dst.back().second++;
      }
      is_prime = false;
    }
  }
  if (is_prime)
    dst.push_back(make_pair(N, 1));

  bool is_none = true;
  rep(i, dst.size())
  {
    if (dst[i].first == tempN)
    {
      is_none = false;
      break;
    }
  }
  if (is_none && tempN != 1)
    dst.push_back(make_pair(tempN, 1));
  return dst;
}
vector<long long> calc_divisor(long long n)
{
  vector<long long> res;
  for (long long i = 1LL; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      res.push_back(i);
      long long j = n / i;
      if (j != i)
        res.push_back(j);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
int main()
{
  long long N;
  cin >> N;

  vector<pair<long long, long long>> f2 = f(N - 1);
  long long ans = 1;
  rep(i, f2.size())
  {
    long long n = f2[i].second + 1;
    ans *= n;
  }

  vector<long long> f1 = calc_divisor(N);
  for (long long n : f1)
  {
    if (n == 1)
      continue;

    long long tempN = N;
    while (tempN % n == 0)
    {
      tempN /= n;
    }

    if (tempN % n == 1)
      ans++;
  }

  ans--;
  if (N == 2)
    ans = 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
n = int(input())

x = 0
y = 0
z = 0
for i in range(n):
    a,b,c = map(int,input().split())
    nx = max(y,z) + a
    ny = max(x,z) + b
    nz = max(x,y) + c
    x = nx
    y = ny
    z = nz

print(max(x,y,z))


Measured memory_bytes: 3188
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n: usize,
        ass: [f64;n]
    }
    let ans = ass.iter().map(|x| 1.0 / x).sum::<f64>();
    let ans = 1.0 / ans;
    println!("{}", ans);
}


Measured memory_bytes: 4352
program prob5
    implicit none
    integer(8) i, L, m, change, up, down, j, ans
    integer(8), allocatable::s(:)
    character(len=5*10**5) N
    read(*,*) N
    L = len_trim(N)
    allocate(s(L+1))
    s = 0
    change = 0
    up = 0
    down = 0
    ans = 0

    do i = 1, L
        if(N(i:i) .eq. ">")then
            down = down + 1
            ans = ans + down
            s(i+1) = 0
            if((N(i+1:i+1) .eq. "<") .or. i == L)then
                if(s(i - down + 1) >= down)then
                    ans = ans - down
                else
                    ans = ans - up
                end if
                up = 0
            end if
        else
            up = up + 1
            ans = ans + up
            s(i+1) = s(i) + 1
            if(N(i+1:i+1) .eq. ">")then
                down = 0
            end if
        end if

    end do
    write(*,*) ans

    deallocate(s)

    stop
end program prob5

Measured memory_bytes: 5216
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    long[][long] G;
    foreach (_; 0 .. N - 1)
    {
        long a, b;
        scan(a, b);
        a--, b--;
        G[a] ~= b;
        G[b] ~= a;
    }
    auto C = aryread();
    C.sort!"b<a"();
    auto ans = new long[](N);
    auto Q = DList!long();
    Q.insertBack(0);
    foreach (i; 0 .. N)
    {
        long target = Q.front;
        Q.removeFront();
        ans[target] = C[i];
        foreach (child; G[target])
            if (ans[child] == 0)
                Q.insertBack(child);
    }
    C[1 .. $].sum().writeln();
    ans.map!text().join(' ').writeln();
}


Measured memory_bytes: 5372
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/*
 public class abc084 {

 }

 */
public class Main {
  int max = (int) 1e5;

  public void solve() throws FileNotFoundException {
    InputStream inputStream = System.in;

    InputHelper in = new InputHelper(inputStream);

    // actual solution
    int q = in.readInteger();

    boolean[] isp = new boolean[max + 1];

    for (int i = 2; i <= max; i++) {
      isp[i] = true;
    }

    for (int i = 2; i <= max; i++) {
      if (isp[i]) {
        for (int j = 2 * i; j <= max; j += i) {
          isp[j] = false;
        }
      }
    }

    int[] cum = new int[max + 1];

    cum[1] = 0;
    for (int i = 2; i <= max; i++) {
      if (i % 2 == 1)
        cum[i] = cum[i - 1] + ((isp[i] && isp[(i + 1) / 2]) ? 1 : 0);
      else
        cum[i] = cum[i - 1];
    }

    while (q-- > 0) {
      int l = in.readInteger();
      int r = in.readInteger();

      System.out.println(cum[r] - cum[l - 1]);
    }
    // end here
  }

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

  class InputHelper {
    StringTokenizer tokenizer = null;
    private BufferedReader bufferedReader;

    public InputHelper(InputStream inputStream) {
      InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
      bufferedReader = new BufferedReader(inputStreamReader, 16384);
    }

    public String read() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          String line = bufferedReader.readLine();
          if (line == null) {
            return null;
          }
          tokenizer = new StringTokenizer(line);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      return tokenizer.nextToken();
    }

    public Integer readInteger() {
      return Integer.parseInt(read());
    }

    public Long readLong() {
      return Long.parseLong(read());
    }
  }
}


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

#define ll long long
#define pb push_back
#define st first
#define sc second
#define mp make_pair

using namespace std;

const int e = 1e6 + 69;


int main()
{
    ll x, y;
    cin >> x >> y;
    if((y - 2*x)%2 == 0){
        ll b = (y - 2*x)/2;
        ll a = x - b;
        if(a >= 0 && b >= 0){
            cout <<"Yes";
            return 0;
        }
    }
    if((4*x - y)%2 == 0){
        ll a = (4*x - y)/2;
        ll b = x - a;
        if(a>=0 && b >= 0){
            cout <<"Yes";
            return 0;
        }
    }
    cout <<"No";
}



Measured memory_bytes: 3624
#include<iostream>

using namespace std;

int main(){
    int a, b;
    char op;
    
    while(1) {
        cin >> a >>  op >> b;
        if (op == '?') break;
        if (op == '+') {
            cout << a + b << endl;
        } else if (op == '-') {
            cout << a - b << endl;
        } else if (op == '*') {
            cout << a * b << endl;
        } else if (op == '/') {
            cout << a / b << endl;
        } 
        
    }
    
    
    return 0;
}

Measured memory_bytes: 1160
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    K, S = read().decode().split()
    K = int(K)
    if K < len(S):
        ans = S[:K] + '...'
    else:
        ans = S
    print(ans)
    return

if __name__ == '__main__':
    main()


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

typedef long long LL;

const double PI = acos(-1.0);

int n, a[100];

int work() {

    scanf("%d", &n);

    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);

    int k = 1;
    for ( ; k < n; ++k) {
        if (a[k] < a[k-1]) break;
    }
    if (k == n) {
        printf("YES");
        return 0;
    }

    for (int i = 0; i < n; ++i)
    for (int j = i+1; j < n; ++j) {
        swap(a[i], a[j]);
        for (k = 1; k < n; ++k) {
            if (a[k] < a[k-1]) break;
        }
        if (k == n) {
            printf("YES");
            return 0;
        }

        swap(a[i], a[j]);
    }
    printf("NO");
    return 0;
}

int main() {
    work();
    //while (~scanf("%d", &n)) work();
    //scanf("%d", &T); while (T--) work();

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var R int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &R)

	if R < 1200 {
		fmt.Println("ABC")
	} else if R < 2800 {
		fmt.Println("ARC")
	} else {
		fmt.Println("AGC")
	}
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int a, b, c; cin >> a >> b >> c;
    if(a+b>=c) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

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

int main() {
string N;
cin>>N;
long long ans=0;
for(int i=0;i<N.size();i++){
    ans+=N.at(i)-'0';
}
if(ans%9==0){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}

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

double dist(double x1,double y1,double x2,double y2){
	return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}
int main(){
	int n;
	cin>>n;
	rep(i,0,n){
		double xa,ya,ra,xb,yb,rb,d;
		cin>>xa>>ya>>ra>>xb>>yb>>rb;
		d=dist(xa,ya,xb,yb);
		if(ra>d+rb) o(2);
		else if(rb>d+ra) o(-2);
		else if(d>ra+rb) o(0);
		else o(1);
	}
}

Measured memory_bytes: 1232
n,z,w=map(int,input().split())
a=list(map(int,input().split()))
b=[abs(a[i]-a[-1]) for i in range(n-1)]
b=[abs(w-a[-1])]+b
if n==1:print(abs(w-a[0]));exit()
print(max(abs(w-a[-1]),abs(a[-2]-a[-1])))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

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

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main() {
  int n, m;
  cin >> n >> m;
  int h[n];
  map<int, set<int>> mp;
  set<int> all;
  rep (i, n) {
    cin >> h[i];
  }
  rep (i, m) {
    int a, b;
    cin >> a >> b;
    all.insert(a);
    all.insert(b);
    mp[a - 1].insert(b - 1);
    mp[b - 1].insert(a - 1);
  }
  int ans = 0;
  // for (auto itr = mp.begin(); itr != mp.end(); itr++) {
  //   cout << itr->first << ": " << endl;
  //   rep (i, itr->second.size()) {
  //     cout << "\t" << itr->second[i] << endl;
  //   }
  // }
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    int flag = 1;
    for (auto itr2 = itr->second.begin(); itr2 != itr->second.end(); itr2++) {
      if (h[itr->first] <= h[*itr2]) {
        flag = 0;
        break;
      }
    }
    if (flag == 1) ans++;
  }
  if (all.size() < n) ans += n - all.size();
  P(ans);

  return 0;
}

Measured memory_bytes: 25504
#include <iostream>
#define FORU(a, b, c) for (int a = b; a < c; ++a)
#define FORD(a, b, c) for (int a = b; a > c; --a)
#define ll long long
using namespace std;

int main() {
    int N = 0, W = 0;
    cin >> N >> W;
    int w[N], v[N];
    ll sw = 0;
    FORU(i, 0, N) {
        cin >> w[i] >> v[i];
        sw += v[i];
    }
    ll dp[N+1][sw+1];
    FORU(i, 0, N+1)
        dp[i][0] = 0;
    FORU(i, 1, sw+1)
        dp[0][i] = W+1;
    FORU(i, 1, N+1)
        FORU(V, 1, sw+1)
            if (V < v[i-1])
                dp[i][V] = dp[i-1][V];
            else
                dp[i][V] = min(dp[i-1][V], dp[i-1][V-v[i-1]]+w[i-1]);
    FORD(i, sw, -1)
        if (dp[N][i] <= W) {
            cout << i;
            break;
        }
    return 0;
}


Measured memory_bytes: 82300
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> vt(n, 0), va(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> vt[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> va[i];
    }
    vector<pair<int, int>> vp(n, make_pair(1, 0x3f3f3f3f));
    int last = 0;
    for (int i = 0; i < n; i++) {
        if (vt[i] > last) {
            vp[i].first = vt[i];
            vp[i].second = vt[i];
        }
        vp[i].second = vt[i];
        last = vt[i];
    }
    last = 0;
    for (int i = n - 1; i >= 0; i-- ) {

        if (va[i] > last) {   
            if (vp[i].first > va[i] || vp[i].second < va[i]) {
                cout << 0 << endl;
                return 0;
            }
            vp[i].first = va[i];
            vp[i].second = va[i];
        }
        vp[i].second = min(vp[i].second, va[i]);
        last = va[i];
    }
    long long int res = 1;
    const int mod = 1e9 + 7;
    for (int i = 0; i < n; i++) {
        res = res * (vp[i].second - vp[i].first + 1);
        res %= mod;
    }
    cout << res << endl;
}


Measured memory_bytes: 4852