akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
  int N;
  cin >> N;
  for(int i=1; i<=9; i++){
    for(int j=1; j<=9; j++){
      if(i*j==N){
        cout << "Yes" <<endl;
        return 0;
      }
    }
  }
  cout << "No" <<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class aoj
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int m = int.Parse(Console.ReadLine());
        int[,] go = new int[n, n];
        int[,] back = new int[n, n];
        int[,] go2 = new int[n, n];
        int[] a;
        int[] b = new int[n];
        bool[,] d = new bool[n, n];
        int c, v, p, e, f;
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                go[i, j] = 10000;
                back[i, j] = 10000;
                go2[i, j] = 10000;
            }
            b[i] = 10000;
        }
        for(int i = 0; i < m; i++)
        {
            a = Console.ReadLine().Split(',').Select(int.Parse).ToArray();
            go2[a[0]-1, a[1]-1] = a[2];
            go2[a[1]-1, a[0]-1] = a[3];
        }
        a = Console.ReadLine().Split(',').Select(int.Parse).ToArray();
        b[a[0] - 1] = 0;
        c = a[1]-1;
        v = a[2];
        p = a[3];
        for(int i = 0; i < n; i++)
                go[a[0]-1, i] = go2[a[0]-1, i];
        while (b[c] == 10000)
        {
            int sum = 10000;
            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < n; j++){if (sum > go[i, j] + b[i] && d[i, j] == false)sum = go[i, j] + b[i];}
            }
            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < n; j++)
                {
                    if (go[i,j] + b[i] == sum && d[i,j] == false)
                    {
                        if (b[i] + sum < b[j]) b[j] =  sum;
                        d[i, j] = true;
                        for (int z = 0; z < n; z++)
                            go[j, z] = go2[j, z];
                    }
                }
            }
        }
        e = b[c];
        for (int i = 0; i < n; i++)
        {
            b[i] = 10000;
            for (int j = 0; j < n; j++)
                d[i, j] = false;
        }
        b[c] = 0;
        for (int i = 0; i < n; i++)
            back[c, i] = go2[c, i];
        while (b[a[0]-1] == 10000)
        {
            int sum = 10000;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++) { if (sum > back[i, j] + b[i] && d[i, j] == false) sum = go[i, j] + b[i]; }
            }
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (back[i, j] + b[i] == sum && d[i, j] == false)
                    {
                        if (b[i] + sum < b[j]) b[j] = sum;
                        d[i, j] = true;
                        for (int z = 0; z < n; z++)
                            back[j, z] = go2[j, z];
                    }
                }
            }
        }
        f = b[a[0]-1];
        int g = p + e + f;
        Console.WriteLine(v - g);
    }
}

Measured memory_bytes: 9468
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=1000000007;
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
struct node
{
	int x,y,next;
}a[400010];int len,last[200010];
inline void ins(int x,int y)
{
	len++;
	a[len].x=x;a[len].y=y;
	a[len].next=last[x];last[x]=len;
}
int n,f[200010],g[200010],tot[200010];
int fac[200010],inv[200010];
inline void dfs(int x,int fa)
{
	tot[x]=f[x]=1;
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		if(y==fa)continue;
		dfs(y,x);
		tot[x]+=tot[y];
		f[x]=1LL*f[x]*f[y]%mod*inv[tot[y]]%mod;
	}f[x]=1LL*f[x]*fac[tot[x]-1]%mod;
}
inline void solve(int x,int fa)
{
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		if(y==fa)continue;
		g[y]=1LL*f[x]*inv[tot[x]-1]%mod*power(f[y],mod-2)%mod*fac[tot[y]]%mod*g[x]%mod*inv[n-tot[x]]%mod*fac[n-tot[y]-1]%mod;
		solve(y,x);
	}
}
inline int C(int n,int m){return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    fac[0]=1;
    for(int i=1;i<=200000;i++)fac[i]=1LL*fac[i-1]*i%mod;inv[200000]=power(fac[200000],mod-2);
    for(int i=200000;i>=1;i--)inv[i-1]=1LL*inv[i]*i%mod;
    n=read();
    for(int i=1;i<n;i++)
    {
    	int x=read(),y=read();
    	ins(x,y),ins(y,x);	
    }dfs(1,0);
    g[1]=1,solve(1,0);
    for(int x=1;x<=n;x++)pr2(1LL*f[x]*g[x]%mod*C(n-1,n-tot[x])%mod);
    return 0;
}

Measured memory_bytes: 11520
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define int long long

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言
int H,W,K;
int I,J;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



int n;

cin>>n;
string ans;

while(n){
	n--;
	ans+='a'+n%26;
	n/=26;
}
reverse(ans.begin(),ans.end());

cout<<ans<<endl;









return 0;

}

Measured memory_bytes: 3564
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define out(x) cerr<<#x<<" = "<<x<<" "
#define outln(x) cerr<<#x<<" = "<<x<<endl
#define outarr(x,l,r) cerr<<#x"["<<l<<"-"<<r<<"] = "; for (int _i=l;_i<=r;++_i) cerr<<x[_i]<<" ";cerr<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll,int> pii;
#define gc() getchar()
//char buf[1<<23],*p1=buf,*p2=buf;
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x)
{
    x=0; char c=gc(); int flag=0;
    while (c<'0'||c>'9') flag|=(c=='-'),c=gc();
    while (c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=gc();
    if (flag) x=-x;
}
template <class T> T _max(T a,T b){return a>b ? a : b;}
template <class T> T _min(T a,T b){return a<b ? a : b;}
template <class T> bool checkmax(T &a,T b){return b>a ? a=b,1 : 0;}
template <class T> bool checkmin(T &a,T b){return b<a ? a=b,1 : 0;}
const int N=200005;
int n;
ll negative,positive,zero;
ll k,a[N];
ll v[N],w[N];
void init()
{
    read(n); read(k);
    for (int i=1;i<=n;++i)
    {
        read(a[i]);
    }
    sort(a+1,a+n+1);
    for (int i=1;i<=n;++i)
    {
        if (a[i]<0) negative++,v[negative]=-a[i];
        else if (a[i]>0) positive++,w[positive]=a[i];
        else zero++;
    }
    sort(v+1,v+negative+1);
    sort(w+1,w+positive+1);
    /*outarr(v,1,negative);
    outarr(w,1,positive);
    outarr(a,1,n);*/
}

int check(ll x)
{
    ll cnt=0;
    for (int i=1;i<=n;++i)
    {
        if (a[i]>0)
        {
            if (x==0) 
            {
                cnt+=negative+zero;
            }
            else if (x>0)
            {
                cnt+=negative+zero;
                ll tmp=upper_bound(w+1,w+positive+1,x/a[i])-w-1;
                if (tmp>0) cnt+=tmp;
            }
            else
            {
                ll tmp=lower_bound(v+1,v+negative+1,(-x+a[i]-1)/a[i])-v;
                if (tmp<=negative) cnt+=(negative-tmp+1);
            }
        }
        else if (a[i]==0)
        {
            if (x>=0) 
            {
                cnt+=n;
            }
        }
        else
        {
            if (x==0)
            {
                cnt+=positive+zero;
            }
            else if (x<0)
            {
                ll tmp=lower_bound(w+1,w+positive+1,(-x-a[i]-1)/(-a[i]))-w;
                if (tmp<=positive) cnt+=(positive-tmp+1);
            }
            else if (x>0)
            {
                cnt+=positive+zero;
                ll tmp=upper_bound(v+1,v+negative+1,(x/(-a[i])))-v-1;
                if (tmp>0) cnt+=tmp;
            }
        }
        if (a[i]*a[i]<=x) --cnt;
    }
    if (cnt/2>=k) return 1;
    return 0;
}

void solve()
{
    ll l=-1e18,r=1e18,mid,best;
    while (l<=r)
    {
        mid=(l+r)/2;
        if (check(mid))
        {
            best=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    printf("%lld\n",best);
}

int main()
{
    init();
    solve();
    return 0;
}

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;

  if ((N - A) <= N / 500 * 500) {
    cout << "Yes" << endl;
  }
  
  else  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  1e9
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d); BR;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))


signed main(){ INIT;
    VAR(ll, n);
    MAT(int, f, n, 10);
    MAT(int, p, n, 11);

    int ans = -INF;
    FOR(i, 1, 1<<10){
        int sum = 0;
        REP(s, n){
            int o = 0;
            REP(t, 10) o += (i>>t&1) & f[s][t];
            sum += p[s][o];
        }
        ans = max(sum, ans);
    }
    OUTL(ans);
RET;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n,m;
    cin >> n >> m;
    rep(i,m){
        int a;
        cin >> a;
        n -= a;
    }

    ll ans = max((ll)-1, n);
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}

void MAIN() {
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]) {
		cout<<"Yes";
	}else cout<<"No";
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

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

int h[105];

int func(int l, int r, int m) {
    if (l >= r) return 0;

    int i;
    for (i = l; i < r; i++) {
        if (h[i] == m) {
            return func(l, i, m) + func(i + 1, r, m);
        }
    }
    if (i == r) {
        return func(l, r, m + 1) + 1;
    }
}

int main() {
    int n;

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

    printf("%d\n", func(0, n, 0));

    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;

int h;
int n;
int dp[10004];
int w[10002],v[10003];

inline int maxx(int a,int b)
{
	return a>b?a:b;
}

inline int minn(int a,int b)
{
	return a>b?b:a;
}

inline int qr()
{
	int w=1,x=0;char a=0;
	while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar();}
	while(a>='0'&&a<='9'){x=(x<<3)+(x<<1)+(a^48);a=getchar();}
	return x*w;
}

int main()
{
	h=qr();
	n=qr();
	for(register int i=1;i<=n;i++)
		v[i]=qr(),w[i]=qr();
	for(register int j=1;j<=h;j++)
		dp[j] = 999999999;
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=h;j++)
		{
			if(j>=v[i])
				dp[j] = minn( dp[j] , dp[j-v[i]] + w[i] );
			else
				dp[j] = minn( dp[j] , w[i] );
		}
	cout<<dp[h]<<endl;
	return 0;
} 

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

int main() {
    cout.tie(0)->sync_with_stdio(0);
    int N; cin >> N;
    map<string, bool> mapa;
    for (int i = 0; i < N; ++i) {
        string kind;
        cin >> kind;
        mapa[kind] = true;
    }
    cout << mapa.size() << '\n';
}


Measured memory_bytes: 19224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i;
string s;
cin >> s;
int m=0;
map<char,int>mp;
for(i=0;i<s.length();i++)
{mp[s[i]]++;
}
if(mp.size()==2)
    cout << "Yes" << endl;
else
    cout << "No" << endl;



}


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

int main(){
  unsigned long int A, B, i, Amari, Ans;
  cin >> A >> B;
  if(A > B){
  	for(i = 1; ; i++){
      Amari = A * i % B;
      if(Amari == 0){
        Ans = A * i;
        break;
      }
  	}
  }
  else if(A < B){
  	for(i = 1; ; i++){
      Amari = B * i % A;
      if(Amari == 0){
        Ans = B * i;
        break;
      }
  	}
  }
  cout << Ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
from math import gcd

def main():
    n = int(input())
    a = list(map(int, input().split()))

    forward = [0] * (n+1)
    forward[0] = a[0]
    for i in range(n):
        forward[i+1] = gcd(forward[i], a[i])

    backward = [0] * (n+1)
    backward[n] = a[n-1]
    for i in range(n-1, -1, -1):
        backward[i] = gcd(backward[i+1], a[i])

    ans = max(forward[n-1], backward[1])
    for i in range(1, n-1):
        candidate = gcd(forward[i], backward[i+1])
        if ans < candidate:
            ans = candidate

    print(ans)

main()

Measured memory_bytes: 86392
import sys

def get_min_value_in_row(data):
    if(len(data) < 1):
        return 0
    min = 0
    for i in range(0,len(data)):
        if(data[i] < data[min]):
            min = i
    return min

def is_max(Min,index,data):
    max = data[index][Min]
    for i in range(index,-1,-1):
        if(data[i][Min] > max):
            max = data[i][Min]
    for i in range(index,len(data)):
        if(data[i][Min] > max):
            max = data[i][Min]
    return True if max == data[index][Min] else False

def print_both(data):
    for i in range(0,len(data)):
        indexmin = get_min_value_in_row(data[i])
        if(is_max(indexmin,i,data) == True):
            print(data[i][indexmin])
            return
    print(0)
    

l = []
for i in sys.stdin:
    l.append(i)

i = 0
while(i < len(l)):
    if(len(l[i]) == 2):
        Matrix = []
        for j in range(i+1,int(l[i])+i+1):
            temp = [l[j].split()]
            for k in range(0,len(temp[0])):
                temp[0][k] = int(temp[0][k])
            Matrix.append(temp[0])
        i += int(l[i]) + 1
        print_both(Matrix)
    else:
        i += 1


Measured memory_bytes: 5612
s=input()
i=0;j=len(s)-1
ans=0
while i<j:
  if s[i]==s[j]:
    i+=1
    j-=1
  elif s[i]=='x':
    ans+=1
    i+=1
  elif s[j]=='x':
    ans+=1
    j-=1
  else:
    print(-1)
    exit()
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define mod 1000000007 
#define check exit(0)
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;

int main()
{
    jaldi
    int n1,n2,m;
    cin>>n1>>n2>>m;
    vector<int> v1(n1),v2(n2);
    for(int &x:v1) cin>>x;
    for(int &x:v2) cin>>x;
    int minu=*min_element(v1.begin(),v1.end());
    int minv=*min_element(v2.begin(),v2.end());
    ll ans=minu+minv;
    while(m--)
    {
        int u,v,d;
        cin>>u>>v>>d;
        ll cost=v1[u-1]+v2[v-1]-d;
        ans=min(ans,cost);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
fun main() {
    val ints = rspint()
    val ints2 = rspint()
    val n = (ints2.sum() - 1) / (ints[1] * 4) + 1
    printYN(ints2.filter { it >= n }.size >= ints[1])
}

fun rl() = readLine()!!
fun rsp() = readLine()!!.split(" ")
fun rint() = readLine()!!.toInt()
fun rspint() = readLine()!!.split(" ").map { it.toInt() }
fun printYN(isYes: Boolean) = println(if (isYes) "Yes" else "No")

fun main(args: Array<String>) = main()

Measured memory_bytes: 36060
import java.util.*;
public class Main{
	public static void main(String[] args){
      	Scanner scan = new Scanner(System.in);
    	int a = scan.nextInt();
      	int b = scan.nextInt();
      	if( ((a*b) % 2) == 0){
        	System.out.println("Even");
        }else{
        	System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 23124
def prime_factorize(N): #素因数分解
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization

N = int(input())

pr = prime_factorize(N)


l = len(pr)
s = sum((i for _,i in pr))
ans = 0

ans = 0
for p,e in pr:
    tmp = 1
    ttmp = e
    res = 0
    for i in range(100000):
        if ttmp - tmp < 0:
            break
        res += 1
        ttmp -= tmp
        tmp += 1
    ans += res

print(ans)

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

using namespace std;

vector<string> res(2);
int ok=0;
string up=".##.",down="##..";
bool lr=0;

bool lft()
{
    for(int i=0;i<4;++i)
    {
        cout<<res[0]+up[i]<<'\n';
        cout<<res[1]+down[i]<<'\n';
        cout.flush();
        char c;
        cin>>c;
        if(c=='T')
        {
            res[0]+=up[i];
            res[1]+=down[i];
            return 1;
        }
    }
    return 0;
}

bool rgt()
{
    for(int i=0;i<4;++i)
    {
        cout<<up[i]+res[0]<<'\n';
        cout<<down[i]+res[1]<<'\n';
        cout.flush();
        char c;
        cin>>c;
        if(c=='T')
        {
            res[0]=up[i]+res[0];
            res[1]=down[i]+res[1];
            return 1;
        }
    }
    return 0;
}

void thing()
{
    if(!lr&&!lft())
        lr=1;
    if(lr&&!rgt())
        lr=0;
}

int main()
{
    int n;
    cin>>n;
    getchar();
    bool yee=0;
    for(int i=0;i<n;++i)
        thing();
    cout<<res[0]<<'\n';
    cout<<res[1]<<'\n';
    cout.flush();
}


Measured memory_bytes: 724
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include <ctime>
#include<list>
#include <numeric>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include <array>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(int i = 0; i < n; i++)
#define FORAB(i, a, b) for(int i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))
#define AIN(A, B, C) assert(IN(A, B, C))

typedef long long int LL;
//typedef __int128 LLL;
typedef long long LLL;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PLL> VPL;
typedef vector<PII> VP;
typedef vector<double> VD;
typedef vector<vector<int>> VVI;
typedef vector<string> VS;
typedef long double ld;

#define MAXN 1000006
//#define MAXN 1006

const LL MOD = 1000000007;
//const LL MOD = 998244353;
const LL INF = 2000000000000000001LL; //2e18 + 1

LL gcd(LL a, LL b) {
	if (b == 0 || a == 0) return a + b;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

LL w, h, k;
LL Calc(LL w, LL h) {
	LL ans = 0;
	for (LL x = 1; x < w; x++) {
		for (LL y1 = 1; y1 < h; y1++) {
			LL R = 2 * k - 2 - y1 * (w - x) + gcd(x, y1);
			if (R + w * 2 < 0) break;
			// xy2 - g(w - x, y2) - g(w, y2 - y1) <= R
			LL mn = R / x;
			mn = MAX(mn, 0);
			LL mx = (R + 2 * w) / x;
			mx = MIN(mx, h - 1);
			ans += MIN(mn, h - 1);
			for (LL y2 = mn + 1; y2 <= mx; y2++) {
				LL L = x * y2 - gcd(w - x, y2) - gcd(w, ABS(y2 - y1));
				ans += (L <= R);
			}
		}
	}
	return ans;
}

void solve(int ks) {
	scanf("%lld %lld %lld", &w, &h, &k);
	LL ans = 2 * (Calc(w, h) + Calc(h, w));
	printf("%lld\n", ans);
}

void gen() {
}

int main()
{
	double start_time = clock();
#ifdef LOCAL
	freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
	// freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
	//	freopen("out.out", "w", stdout);
#endif

	gen();

	if (0) {
		int T;
		scanf("%d", &T);
		//AIN(T, 1, 5000);
		for (int ks = 1; ks <= T; ks++) {
			solve(ks);
			if (ks % 1 == 0) fprintf(stderr, "%d done\n", ks);
		}
	}
	else {
		solve(0);
	}

	double end_time = clock();
	fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);

	return 0;
}


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

using namespace std;

int arr1[256];
int arr2[256];

int main() {
	string s, t;
	int ans = 0;

	cin >> s >> t;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) ans++;
	}

	cout << ans;
}


Measured memory_bytes: 3868
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

used = [[False] * 3 for i in range(3)] 
for num in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b[num]:
                used[i][j] = True

for i in range(3):
    if used[i][0] and used[i][1] and used[i][2]:
        print("Yes")
        exit()
for i in range(3):
    if used[0][i] and used[1][i] and used[2][i]:
        print("Yes")
        exit()
if used[0][0] and used[1][1] and used[2][2]:
    print("Yes")
    exit()
if used[0][2] and used[1][1] and used[2][0]:
    print("Yes")
    exit()
print("No")


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

using namespace std;
using ll = long long;
using ld = long double;

struct UnionFind{
    vector<int> d;
    UnionFind(int n): d(n,-1) {}
    int find(int x){
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(d[x] < d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return -d[find(x)];
    }
};

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<int> fr(n);
    for(int i = 0; i < m; i++) {
        int a,b;
        cin >> a >> b;
        fr[a-1]++;
        fr[b-1]++;
        uf.unite(a-1,b-1);
    }
    vector<int> ans(n,0);
    for(int i = 0; i < n; i++) {
        ans[i]=uf.size(i)-1-fr[i];
    }
    for(int i = 0; i < k; i++) {
        int c,d;
        cin >> c >> d;
        if(!uf.same(c-1,d-1)) continue;
        ans[c-1]--;
        ans[d-1]--;
    }
    for(int i = 0; i < n; i++) {
        cout << ans[i] << " ";
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 2816
#include<string>
#include<iostream>
#include<cctype>
using namespace std;
int b[26];
int main(){
    string a;
    char c[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    while(getline(cin,a)){
    for(int i=0;i<a.size();i++){
        for(int j=0;j<26;j++){
            if(a[i]==c[j] || a[i]==toupper(c[j])){
                b[j] += 1;
            }
        }
    }
    }
    for(int i=0;i<26;i++){
        cout<<c[i]<<" : "<<b[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3172
n = gets.to_i
ns = (1..n).to_a.select{|i| i % 2 == 1}

cnt = 0
ns.each do |num|
    tmp = 0
    for i in (1..num)
        tmp = tmp + (num % i == 0 ? 1 : 0)
    end
    cnt = cnt + (tmp == 8 ? 1 : 0)
end

puts cnt

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
int main(){
    int a,b;
    cin >> a >> b;
    if(b == 100) b += 1000*a;
    else if(b >= 10) b += 100*a;
    else b += 10*a;
    for(int i=0; i<1000; i++){
        if(i*i == b){
            cout << "Yes" << endl;
            break;
        }
        if(i*i > b){
            cout << "No" << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(h)]

for k in range(10):
  for i in range(10):
    for j in range(10):
      c[i][j] = min(c[i][j], c[i][k]+c[k][j])
      
ans = 0
for i in range(h):
  for j in range(w):
    if A[i][j]!=-1:
      ans += c[A[i][j]][1]
      #print(A[i][j])

print(ans)

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

int main() {
  ll N, K; cin >> N >> K;
  cout << min(N%K, abs((N%K)-K)) << endl;
  return 0;
}


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

int main() {
    int N, M, a[51], b[51];
    cin >> N >> M;
    for (int i = 1; i <= M; ++i) cin >> a[i] >> b[i];

    int counter[51] = {0};
    for (int i = 1; i <= M; ++i) {
        ++counter[a[i]];
        ++counter[b[i]];
    }

    for (int i = 1; i <= N; ++i) cout << counter[i] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

const int mod = 1000000007;

int mod2pow(int k){
  if(k == 0) return 1;
  if(k & 0x1) return (mod2pow(k-1) << 1) % mod;
  else {
    long long int x = mod2pow(k/2);
    return x * x % mod;
  }
}

int a[100000];

int main(){
  int i;
  int n;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    int x;
    scanf("%d", &x);
    a[x]++;
  }
  if(n & 0x1){
    if(a[0] != 1){
      putchar('0');
      return 0;
    }
    for(i=1;i<n;i+=2){
      if(a[i] != 0 || a[i+1] != 2){
        putchar('0');
        return 0;
      }
    }
  }
  else {
    for(i=0;i<n;i+=2){
      if(a[i] != 0 || a[i+1] != 2){
        putchar('0');
        return 0;
      }
    }
  }
  printf("%d", mod2pow(n/2));
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N),count(1e6+1,0);
  int ma=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    ma=max(ma,A.at(i));
    count.at(A.at(i))++;
  }
  sort(A.begin(),A.end());
  set<int> s;
  int ans=0;
  for(int i=0;i<N;i++){
    if(!s.count(A.at(i))){
      if(count.at(A.at(i))==1){
        ans++;
      }
      for(int x=A.at(i);x<=ma;x+=A.at(i)){
        s.insert(x);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 54640
import java.util.Scanner;

public class Main {
    static long q;
    static String s;
    static String t; //反転する文字列

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = sc.next();
        q = sc.nextInt();
        t = "";

        StringBuffer sbs = new StringBuffer(s);
        StringBuffer sbt = new StringBuffer(t);
        StringBuffer tmp;

        for (int i = 0; i < q; i++) {
            if (sc.nextInt() == 1) {
                tmp = sbs;
                sbs = sbt;
                sbt = tmp;
            } else {
                if (sc.nextInt() == 1) {
                    sbt.append(sc.next());
                } else {
                    sbs.append(sc.next());
                }
            }
        }
        System.out.println(sbt.reverse().append(sbs));
    }
}

Measured memory_bytes: 151816
import java.util.*;

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

        int a = scan.nextInt();
        String b = scan.next();
        String ans = "No";
        if(a%2==0){
            a=a/2;
            if(b.substring(0,a).equals(b.substring(a)) ){
                ans="Yes";
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
def main():
    H, W = map(int, input().split())
    c = []
    c.append(['.'] * (W + 2))
    for _ in range(H):
        c.append(['.'] + list(input()) + ['.'])
    c.append(['.'] * (W + 2))
    for h in range(1, H + 2):
        for w in range(1, W + 2):
            if c[h][w] == '#':
                if c[h - 1][w] == c[h + 1][w] == c[h][w - 1] == c[h][w + 1] == '.':
                    print('No')
                    return
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n = int(input())
d = 1
c = 0

for x in range(1, n + 1):
  l = x % 10
  
  if l == 0:
    continue
    
  r = x // d
  k = 10
    
  if l == r:
    c += 1
  
  while k <= n:
    y = l * k + r
    z = n - y
    
    if k <= z:
      c += k // 10
    elif 0 <= z:
      a  = z % k // 10 + 1
      c += a if a != 0 else 1
      
    k *= 10
  
  if       9 == x: d =     10
  elif    99 == x: d =    100
  elif   999 == x: d =   1000
  elif  9999 == x: d =  10000
  elif 99999 == x: d = 100000

print(c)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();

		int ans = 0;
		for (int i = 1; i <= N; i++) {
			int cnt = 0;

			if (i % 2 == 1) {
				for (int j = 1; j <= i; j++) {
					if (i % j == 0) {
						cnt++;
					}
				}
			}

			if (cnt == 8) {
				ans++;
			}
		}

		System.out.println(ans);
	}
}

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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 310;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

char s[maxn][maxn];

int main(){
	read(n);
	REP(i,0,n-1)scanf("%s",s[i]);
	int ans=0;
	REP(x,0,n-1){
		bool ok=1;
		REP(i,0,n-1)REP(j,0,n-1)if(s[(i+x)%n][j]!=s[(j+x)%n][i])ok=0;
		if(ok)ans+=n;
	}
	iout(ans);
	return 0;
}


Measured memory_bytes: 512
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

import numpy as np

#0: g, R
#1: c, S
#2: p, P

ans = 0
L = [[] for _ in range(K)]
for i in range(K):
    L[i] = T[i:N:K]
for l in L:
#    print()
#    print(l)
    lenl = len(l)
    Dp = np.zeros([lenl+1, 3], dtype=int)
    Dp[:][:] = -1
    Dp[0][:] = 0
#    print(Dp)
    ll = l[0]
    if ll == 'r':
        Dp[1][0] = 0
        Dp[1][1] = 0
        Dp[1][2] = P
    elif ll == 's':
        Dp[1][0] = R
        Dp[1][1] = 0
        Dp[1][2] = 0
    elif ll == 'p':
        Dp[1][0] = 0
        Dp[1][1] = S
        Dp[1][2] = 0

    for i in range(1, lenl):
        ll = l[i]
        if ll == 'r':
            Dp[i+1][0] = max(Dp[i][1], Dp[i][2])
            Dp[i+1][1] = max(Dp[i][2], Dp[i][0])
            Dp[i+1][2] = max(Dp[i][0], Dp[i][1]) + P
        elif ll == 's':
            Dp[i+1][0] = max(Dp[i][1], Dp[i][2]) + R
            Dp[i+1][1] = max(Dp[i][2], Dp[i][0])
            Dp[i+1][2] = max(Dp[i][0], Dp[i][1])
        elif ll == 'p':
            Dp[i+1][0] = max(Dp[i][1], Dp[i][2])
            Dp[i+1][1] = max(Dp[i][2], Dp[i][0]) + S
            Dp[i+1][2] = max(Dp[i][0], Dp[i][1])
#    print(Dp)
    ans += max(Dp[-1][:])
print(ans)

Measured memory_bytes: 23768
import java.util.Scanner;

public class Main{

    public static void main(String argv[])
    {
	Scanner scan = new Scanner(System.in);

	int num1 = scan.nextInt();
	int num2 = scan.nextInt();
	int num3 = scan.nextInt();

	if( num1 <= num2 )
	    {
		if( num2 <= num3)
		    System.out.println(num1+" "+num2+" "+num3);
		else if( num3 <= num1)
		    System.out.println(num3+" "+num1+" "+num2);
		else if( num1 <= num3 && num3 <= num2 )
		    System.out.println(num1+" "+num3+" "+num2);
		
	    }
	else if( num2 <= num1 )
	    {

		if( num1 <= num3)
		    System.out.println(num2+" "+num1+" "+num3);
		else if( num3 <= num2)
		    System.out.println(num3+" "+num2+" "+num1);
		else if( num2 <= num3 && num3 <= num1 )
		    System.out.println(num2+" "+num3+" "+num1);
	    }
 

    }
	

}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> A(N);
    REP(i,N) cin >> A.at(i).first >> A.at(i).second;
    sort(A.begin(), A.end());

    ll count = 0;
    ll ans = 0;
    REP(i,N){
        if(count + A.at(i).second <= M){
            ans += A.at(i).first * A.at(i).second;
            count += A.at(i).second;
        }
        else{
            ans += (M - count) * A.at(i).first;
            break;
        }
    }
    cout << ans << endl;
}

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

#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL)
// #define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 77, mod = 1e9 + 7;
int vis[N];
vector<int> g[N];

void dfs(int x, int d){
    if(vis[x]!=1e9) return;
    vis[x] = d;
    if(x==2){
        cout << d << endl;
        exit(0);
    }
    for(auto i : g[x]) dfs(i,d+1);
}

int32_t main()
{
    fast;
    fill(vis,vis+N,1e9);
    int n ; cin >> n ;
    for(int i = 1 ; i <= n ; ++i){
        int a ; cin >> a;
        g[i].push_back(a);
    }
    dfs(1,0);
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 16776
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    string s,t,u;
    cin >> s >> t >> u;
    cout << "A" << t[0] << "C" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

struct Node {
    int parent = -1, left = -1, right = -1;
};

void printPreOrderWalk(int i, Node T[]) {
    Node c = T[i];
    cout << " "<< i;
    if (c.left != -1) {
        printPreOrderWalk(c.left, T);
    }
    if (c.right != -1) {
        printPreOrderWalk(c.right, T);
    }
}

void printInOrderWalk(int i, Node T[]) {
    Node c = T[i];
    if (c.left != -1) {
        printInOrderWalk(c.left, T);
    }
    cout << " "<< i;
    if (c.right != -1) {
        printInOrderWalk(c.right, T);
    }
}

void printPostOrderWalk(int i, Node T[]) {
    Node c = T[i];
    if (c.left != -1) {
        printPostOrderWalk(c.left, T);
    }
    if (c.right != -1) {
        printPostOrderWalk(c.right, T);
    }
    cout << " "<< i;
}

int main() {
    int n;
    cin >> n;
    Node T[n];
    for (int i = 0; i < n; i++) {
        int id, l, r;
        cin >> id >> l >> r;
        T[id].left = l;
        T[id].right = r;
        T[l].parent = id;
        T[r].parent = id;
    }
    int p = -1;
    for (int i = 0; i < n; i++) {
        Node n = T[i];
        if (n.parent == -1) {
            p = i;
        }
    }

    cout << "Preorder" << endl;
    printPreOrderWalk(p, T);
    cout << endl;
    cout << "Inorder" << endl;
    printInOrderWalk(p, T);
    cout << endl;
    cout << "Postorder" << endl;
    printPostOrderWalk(p, T);
    cout << endl;

    return 0;
}


Measured memory_bytes: 3088
import sys

# utils
def read_numbers():
    return [int(num) for num in sys.stdin.readline().split()]
def read_string():
    return sys.stdin.readline().rstrip('\r\n')
def list2str(*array):
    return ' '.join([str(i) for i in array])

def main(N, K, xs):
    result = 0
    for x in xs:
        result += 2*min(K-x, x)
    return result

def parse_stdin():
    # N = read_numbers()
    # data = []
    # for i in range(N):
    #    data.append(read_numbers())
    N = read_numbers()[0]
    K = read_numbers()[0]
    xs = read_numbers()
    return N, K, xs

def test_main():
    """run pytest stdin.py to test"""
    assert main(2, 9, [3, 6]) == 12

if __name__ == '__main__':
    N, K, xs = parse_stdin()
    result = main(N, K, xs)
    print(result)

Measured memory_bytes: 3064
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import division, print_function
import sys


def main():
    n, m, k = map(int, sys.stdin.readline().strip().split(" "))
    nums = {0}
    for i in range(0, n + 1):
        for j in range(0, m + 1):
            i_ = n - i
            nums.add(m * i + i_ * j - i * j)
    # print(nums)
    print("Yes" if k in nums else "No")


if __name__ == '__main__':
    main()


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

public class Main {

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

        int n=sc.nextInt();
        int[] a=new int[n];
        int count=0;
        int r=1;
        boolean aaaa=false;

        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }

        while(true){
            r=a[r-1];
            count++;
            if(r==2){
                aaaa=true;
                break;
            }
            if(count>n){
                break;
            }
        }

        if(aaaa){
            System.out.println(count);
        }else{
            System.out.println("-1");
        }


    }



}

Measured memory_bytes: 50632
#include <iostream>
using namespace std;
 
int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (x >= r && x + r <= W && y >= r && y + r <= H ) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
}



Measured memory_bytes: 3116
#include <stdio.h>

int n;

int solve(int a,int b)
{
	int i,sum=0;

	if(a==4) {
		return b==n;
	}
	for(i=0;i<=9;i++) {
		if(b+i<=n) {
			sum+=solve(a+1,b+i);
		}
	}
	return sum;
}

int main(void)
{
	while(scanf("%d",&n)!=EOF) {
		printf("%d\n",solve(0,0));
	}
	return 0;
}

Measured memory_bytes: 596
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.pop();
    return_
}

fn main() {
    let inp = read_line().parse::<u64>().unwrap();
    let mut a = 2;
    while a <= inp {
        a = a << 1;
    }
    println!("{}", a >> 1);
}


Measured memory_bytes: 5032
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

int main(){
	FAST;

	int N, K;
	int h;
	int ans = 0;
	cin >> N >> K;
	rep(i,N) {
		cin >> h;
		if (h>=K) ans++;
	}

	cout << ans << LF;

	return 0;
}

Measured memory_bytes: 256
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io
	string x;
	cin>>x;
	ll s2=(x[2]-'0')*10+(x[3]-'0');
	ll s1=(x[0]-'0')*10+(x[1]-'0');
	// cout<<s1<<s2;
	ll c1=0,c2=0;	
	if(s1>=0 && s2>0 && s2<=12)
	{
		c1++;
	}
	if(s2>=0 && s1>0 && s1<=12 )
	{
		c2++;
	}
	if(c1&&c2)
	{
		cout<<"AMBIGUOUS";
		exit(0);
	}
	if(c1)
	{
		cout<<"YYMM";
		exit(0);
	}
	if(c2)
	{
		cout<<"MMYY";
		exit(0);
	}
	cout<<"NA";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 3005;
#define ff first
#define ss second

pair<int, pair <int, int> > dp[MAXN][MAXN];
int main()
{
    string s, t;
    cin >> s >> t;
    for (int i = 1; i <= s.size(); i++)
    {
        for (int j = 1; j <= t.size(); j++)
        {
            char cs = s[i-1], ct = t[j-1];
            if (cs == ct)
            {
                dp[i][j].ff = dp[i-1][j-1].ff + 1;
                dp[i][j].ss.ff = i; dp[i][j].ss.ss = j;
            }
            else
            {
                int it = i-1, jt = j;
                if (dp[i][j-1].ff > dp[i-1][j].ff) {it = i; jt = j-1;}
                dp[i][j].ff = dp[it][jt].ff;
                dp[i][j].ss.ff = dp[it][jt].ss.ff;
                dp[i][j].ss.ss = dp[it][jt].ss.ss;
            }
        }
    }
    string ans;
    int i = s.size(), j = t.size();
    while (dp[i][j].ff > 0)
    {
        int it = dp[i][j].ss.ff;
        int jt = dp[i][j].ss.ss;
        ans.push_back(s[it-1]);
        i = it-1; j = jt-1;
    }
    for (int i = ans.size()-1; i>=0; i--) cout << ans[i];
    cout << endl;
}


Measured memory_bytes: 105984