akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    A.extend(A)
    mod1 = 10**9+7
    mod2 = 10**9+9
    b1 = 1007
    b2 = 2009
    H1 = H2 = 0
    for i in range(N-1):
        tmp = B[i] ^ B[i+1]
        #print(tmp)
        H1 = (H1 + pow(b1, N-i-2, mod1) * tmp)%mod1
        H2 = (H2 + pow(b2, N-i-2, mod2) * tmp) % mod2

    h1 = h2 = 0
    for i in range(N-1):
        tmp = A[i] ^ A[i+1]
        #print(tmp)
        h1 = (h1 + pow(b1, N-i-2, mod1) * tmp)%mod1
        h2 = (h2 + pow(b2, N-i-2, mod2) * tmp) % mod2
    #print(H1, h1, H2, h2)
    if h1 == H1 and h2 == H2:
        print(0, A[0]^B[0])
    for k in range(1, N):
        tmp_plus = A[N+k-2] ^ A[N+k-1]
        tmp_minus = A[k-1] ^ A[k]
        #print(k, tmp_plus, tmp_minus)
        h1 = ((h1 * b1)%mod1 + tmp_plus - (tmp_minus * pow(b1, N-1, mod1))%mod1) % mod1
        h2 = ((h2 * b2) % mod2 + tmp_plus - (tmp_minus * pow(b2, N-1, mod2)) % mod2) % mod2
        #print(H1, h1, H2, h2)
        if h1 == H1 and h2 == H2:
            print(k, A[k] ^ B[0])


if __name__ == '__main__':
    main()


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

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

template <typename T>
void printArr(const T * arr, int s, int fn) {
    for (int i = s; i <= fn; ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <typename T>
long long minArr(const T * arr, int s, int fn) {
    ll res = 1e16 + 1;
    for (int i = s; i <= fn; ++ i) {
        res = min(res, arr[i]);
    }
    return res;
}

template <typename T>
void printVec(const T * arr) {
    for (int i = 0; i < sz(arr); ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <class T>
bool uax(T&a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool uin (T&a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

#define ll int

int dp[N];

bool u[N];

int main () {
    to_pray();
    
    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= m; ++ i) {
        int x;
        cin >> x;
        u[x] = true;
    }

    dp[0] = 1;

    for (int i = 0; i < n; ++ i) {
        if (!u[i + 1]){
            dp[i + 1] += dp[i];
            dp[i + 1] %= MOD;
        }
        if (!u[i + 2]) {
            dp[i + 2] += dp[i];
            dp[i + 2] %= MOD;
        }
    }

    cout << dp[n];
    
    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);

    cerr << '\n';
    
    return 0;
}

Measured memory_bytes: 4480
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    vi a(n), b(n), c(n-1);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n-1; i++) cin >> c[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += b[a[i]-1];
        if(i > 0)
            if(a[i - 1] + 1 == a[i]) ans += c[a[i-1]-1];
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
const ll mod = 1000000007;
const ll INF = 1000000000000000;
ll bit[100010], num;
ll par[100010], sz[100010];
ll n, m, a, b, cnt;
vector<ll> road[100010];
map<ll, ll> mp;
bool flg[100010];

struct edge { ll to, cost; };
ll V;
vector<edge> G[300010];
ll d[300010];

ll root(int x) { // �f�[�^x��������؂̍����ċA�œ���Froot(x) = {x�̖؂̍�}
	if (par[x] == x) return x;
	return par[x] = root(par[x]);
}

void unite(int x, int y) { // x��y�̖؂𕹍�
	int rx = root(x); //x�̍���rx
	int ry = root(y); //y�̍���ry
	if (rx == ry) return; //x��y�̍�������(=�����؂ɂ���)���͂��̂܂�
	par[rx] = ry; //x��y�̍��������łȂ�(=�����؂ɂȂ�)���Fx�̍�rx��y�̍�ry�ɂ���
}

bool same(int x, int y) { // 2�̃f�[�^x, y��������؂������Ȃ�true��Ԃ�
	int rx = root(x);
	int ry = root(y);
	return rx == ry;
}

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= num)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll po(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return po(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = po(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll pow_mod(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y % 2 == 1)
		{
			(res *= x) %= mod;
		}
		(x *= x) %= mod;
		y /= 2;
	}
	return res;
}

ll div(ll x)
{
	return po(x, mod - 2);
}

void dfs(ll x, ll y)
{
	flg[x] = true;
	if (x == y)
	{
		return;
	}
	else if (road[x].size() == 4)
	{
		cnt++;
		return;
	}
	else
	{
		for (int i = 0; i < 2; i++)
		{
			if (flg[road[x][i]]) continue;
			dfs(road[x][i], y);
		}
	}
}

int main(void)
{
	cin >> n >> m;
	bool judge = true;
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		road[a].push_back(b);
		road[b].push_back(a);
	}
	for (int i = 1; i <= n; i++)
	{
		mp[road[i].size()]++;
		if (road[i].size() % 2 == 1)
		{
			judge = false;
		}
	}
	if (n == 1 || n == 2)
	{
		cout << "No" << endl;
	}
	else if (mp[2] == n)
	{
		cout << "No" << endl;
	}
	else if (mp[2] == n - 1 && mp[4] == 1)
	{
		cout << "No" << endl;
	}
	else if (mp[2] == n - 2 && mp[4] == 2)
	{
		for (int i = 1; i <= n; i++)
		{
			if (road[i].size() == 4)
			{
				for (int j = 0; j < 4; j++)
				{
					for (int k = 1; k <= n; k++)
					{
						flg[k] = false;
					}
					flg[i] = true;
					dfs(road[i][j], i);
				}
				break;
			}
		}
		if (cnt == 4)
		{
			cout << "No" << endl;
		}
		else
		{
			cout << "Yes" << endl;
		}
	}
	else if (!judge)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}
	int www;
	cin >> www;
}


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

#define var auto
#define ll long long
//#define APPLY(a, f) f(a.begin(), a.end())
#define APPLY(a, f, ...) f(a.begin(), a.end(), __VA_ARGS__)
#define FUN1(x, f) [&](auto& x){return f;}
#define FUN2(x, y, f) [&](auto& x){return f;}
using namespace std;

int main() {
    while(true){
        int n, l, r;
        cin >> n >> l >> r;
        if (n == 0) break;
        vector<int> a(n);
        for (int i = 0; i < n; i++) cin >> a[i];
        int res = 0;
        for (int y = l; y <= r; y++){
            for (int i = 0; i < n; i++){
                if (y % a[i] != 0) continue;
                if (i % 2 == 0) res++;
                goto end;
            }
            if (n % 2 == 0) res++;
            end:;
        }
        cout << res << endl;
    }
}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
void A()
{
    // 入力
    string N;
    cin >> N;
    
    // 出力
    if( N.find("7") != string::npos )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
 
void B()
{
    // 入力
    int N;
    cin >> N;
    
    long long int ans = 0;
    
    // "Fizz", "Buzz", "FizzBuzz"のいずれでもない場合を合算する
    for( int i = 1; i < N+1; ++i )
        if( (i % 3 != 0) && (i % 5 != 0) )
            ans += i;
    
    // 出力
    cout << ans << endl;
}
 
long long int gcd(long long int a, long long int b)
{
    long long int ret;
     
    if( a < b ){
        long long int tmp = a;
        a = b;
        b = tmp;
    }
     
    if( b == 0 ) return a;
     
    ret = a % b;
    ret = gcd(b, ret);
     
    return ret;
}
 
void C()
{
    // 入力
    int K;
    cin >> K;
    
    int ans = 0;
    
    // 2重GCDで解ける
    for( int a = 1; a < K+1; ++a )
        for( int b = 1; b < K+1; ++b )
            for( int c = 1; c < K+1; ++c )
                ans += gcd(gcd(a, b), c);
    
    // 出力
    cout << ans << endl;
}
 
void D()
{
    // 入力
    int N;
    string S;
    cin >> N >> S;
    
    // SをR, G, Bに分割する
    //unsigned long long int R = 0, G = 0, B = 0;
    long long int R = 0, G = 0, B = 0;
    for( int i = 0; i < N; ++i )
        switch( S[i] ){
            case 'R': ++R; break;
            case 'G': ++G; break;
            case 'B': ++B; break;
        }
    
    // {R, G, B}の組合せの数
    // 必ずR, G, Bそれぞれひとつずつの組合せになるが、i < j < k順に並びかえればいいので、それぞれの個数をかけた値になる
    //unsigned long long int ans = R * G * B;
    long long int ans = R * G * B;
    
    // (j − i) == (k − j)の組合せの数を引く
    // i, jが決まればkを求められる
    for( int i = 1; i < N+1; ++i )
        for( int j = i+1; j < N+1; ++j ){
            int k = 2*j - i;
            if( k < j || N < k ) continue;
            if( S[i-1] != S[j-1] && S[j-1] != S[k-1] && S[k-1] != S[i-1] )
                --ans;
        }
    
    // 出力
    cout << ans << endl;   
}
 
int main()
{
    //A();
    //B();
    //C();
    D();
    
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	int ans=a+b+c+d+e;
	int maxx; 
	if(a%10)ans+=10-a%10,maxx=max(10-a%10,maxx);
	if(b%10)ans+=10-b%10,maxx=max(10-b%10,maxx);
	if(c%10)ans+=10-c%10,maxx=max(10-c%10,maxx);
	if(d%10)ans+=10-d%10,maxx=max(10-d%10,maxx);
	if(e%10)ans+=10-e%10,maxx=max(10-e%10,maxx);
	//cout<<maxx;
	ans-=maxx;
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n;
long long ans;
char s[200002];
map<int,int>v;
inline int ksm(re int x,re int y){
	re int an=1;
	while(y){
		if(y&1)an=an*x%2019;
		x=x*x%2019;
		y>>=1;
	}
	return an;
}
inline void work(re int l,re int r){
	if(l==r)return;
	re int mid=l+r>>1;
	v.clear();
	re int pw=1,m=0;
	for(re int i=mid;i>=l;--i){
		m=m+(s[i]-'0')*ksm(10,mid-i);
		m%=2019;
		++v[m];
	}
	m=0;
	for(re int i=mid+1;i<=r;++i){
		m=m*10+s[i]-'0';
		m%=2019;
		pw*=10;
		pw%=2019;
		for(re int j=0;j<=2018;++j)if((j*pw+m)%2019==0){
			ans+=v[j];
			break;
		}
	}
	work(l,mid),work(mid+1,r);
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	work(1,n);
	printf("%lld\n",ans);
}


Measured memory_bytes: 4032
#include <stdio.h>
#define N 100000
#define inf 2000000
#define WHITE 1
#define BLACK 2 
void dij();

int n,u,e,v,c[100][N],d[N],pi[N],color[N],q[100];
int main(){
  int i,k,j;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      c[i][j]=inf;}}
  for(i=0;i<n;i++){
    scanf("%d%d",&e,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&c[i][v]);
    }
    
  }
  dij();
  
  for(i=0;i<n;i++)
    printf("%d %d\n",i,d[i]);

  return 0;
}

void dij(){
  int mincost,k,h,i,y;
  for(u=0;u<n;u++){
    d[u]=inf;
    pi[u]=-1;
    color[u]=0;
  }
  d[0]=0;

  while(1){
    mincost=inf;
    
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==inf){
      break;
    }
    color[u]=BLACK;
    for(k=0;k<n;k++){
      if(color[k]!=BLACK && d[u]+c[u][k]<d[k]){
	pi[k]=u;

       d[k]=d[u]+c[u][k];

      }
      
    }
   
  }
  
    
      
    
  }

Measured memory_bytes: 37496
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),m=sc.nextInt(),x=sc.nextInt();
        boolean[] a = new boolean[n+1];
        for(int i = 0;i<m;i++){
            a[sc.nextInt()]=true;
        }
        int ans0 = 0;
        int ansN = 0;
        for(int i = x;i<=n;i++){
            if(a[i]){
                ansN ++;
            }
        }
        for(int i =x;i>=0;i--){
            if(a[i]){
                ans0 ++;
            }
        }
        System.out.println(Math.min(ansN,ans0));
    }
}

Measured memory_bytes: 21844
import math

n = int(input())

zeinuki = math.floor(n / 1.08)
zeikomi = math.floor(zeinuki * 1.08)

if zeikomi == n:
    print(zeinuki)
elif zeikomi > n:
    if math.floor((zeinuki-1) * 1.08) == n:
        print(zeinuki-1)
    else:
        print(":(")
elif zeikomi < n:
    if math.floor((zeinuki+1) * 1.08) == n:
        print(zeinuki+1)
    else:
        print(":(")


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

Measured memory_bytes: 580
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	int A,B;
	scanf("%d %d",&A,&B);

	if(A <= 2*B){

		printf("0\n");

	}else{

		printf("%d\n",A-2*B);
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
	int i,temp;
	string S,T;
	char tem;
	cin>>S>>T;
	for(i=0;i<S.size();i++){
		if(S==T){
			cout<<"Yes";
			break;
		}
		tem=S.at(0);
		S.erase(S.begin());
		S.push_back(tem);
	}
	if(i==S.size()){
		cout<<"No";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=998244353;
const int MAX=1000010;



signed main(){
    ll r,c;cin>>r>>c;
    ll k;cin>>k;
    vector<vector<ll> >v(r,vector<ll>(c));
    rep(i,k){
        ll x,y,z;cin>>x>>y>>z;
        x--;y--;
        v[x][y]=z;
    }
    vector<vector<vector<ll> > >dp(r+1,vector<vector<ll> >(c+1,vector<ll>(4)));
    rep(i,r){
        rep(j,c){
            rep(l,3){
                if(i<r){
                    if(v[i][j]){
                        dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][l]+v[i][j]);
                    }
                    dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][l]);
                }
                if(j<c){
                    if(v[i][j]){
                        dp[i][j+1][l+1]=max(dp[i][j+1][l+1],dp[i][j][l]+v[i][j]);
                    }
                    dp[i][j+1][l]=max(dp[i][j+1][l],dp[i][j][l]);
                }
            }
            if(i<r-1){
                dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][3]);
            }
            if(j<c-1){
                dp[i][j+1][3]=max(dp[i][j+1][3],dp[i][j][3]);
            }
        }
    }
    ll ans=0;
    rep(j,4){
        ll res=dp[r-1][c-1][j];
        if(v[r-1][c-1]&&j<3)res+=v[r-1][c-1];
        ans=max(res,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 706540
// ahokusa.cpp
#include <iostream>
using namespace std;

void insertionSort(int a[],int n){
	int v;
	int j;
	for(int i=1;i<n;i++){
		v = a[i];
		j = i-1;
		while( j >= 0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		for(int i=0;i<n;i++){
			if(i>0){cout << " ";}
			cout << a[i];
		}
		cout << endl;
	}
}
int main(){
	int n;
	int a[100];
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		if(i>0){cout << " ";}
		cout << a[i];
	}
	cout << endl;
	insertionSort(a,n);
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(void){
 	 int n;
 	 int sum=0;
 	 int temp;
 	 scanf("%d",&n);
 	 temp=n;
 	 while(n){
 	 
	  	sum=sum+(n-n/10*10);
	  	n/=10;
	  }
	  if(temp%sum==0)
	  printf("Yes");
	  else
	  	printf("No");
	 return 0;
 }

Measured memory_bytes: 128
n,m,k;a[99],b[99],c[99];
void push(x,y,z){a[m]=x;b[m]=y;c[m]=z;m++;}
main(i){
	scanf("%d",&k);
	while((1<<n)<=k)n++;
	for(i=n;--i;){
		push(i,i-1,0);
		push(i,i-1,1<<(i-1));
	}
	for(i=n-2;~i;i--){
		if((1<<i)&k){
			push(n-1,i,(k>>(i+1))<<(i+1));
		}
	}
	printf("%d %d\n",n,m);
	for(i=m;i--;){
		printf("%d %d %d\n",n-a[i],n-b[i],c[i]);
	}
	return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s; cin >> s;

    if(s <= "2019/04/30" ) cout << "Heisei" << ln;
    else cout << "TBD" << ln;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    ll out=1;
    ll lim=1000000000000000000;
    ll n=nxt();
    ll arr[n];
    REP(i,n){
        ll in;
        scanf("%lld",&in);
        arr[i]=in;
        if(in==0){
            printf("0");
            return 0;
        }
    }
    REP(i,n){
        if(arr[i]>lim/out){
            printf("-1");
            return 0;
        } else{
            out*=arr[i];
        }
    }
    printf("%lld",out);
    return 0;
}



Measured memory_bytes: 4508
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int h,w;cin >> h >> w;
    vvi bo(h,vi(w,-1));
    queue<P> que;
    rep(i, h) {
        rep(j, w) {
            char c;cin >> c;
            if(c=='#') {
                que.push({i,j});
                bo[i][j]=0;
            }
        }
    }
    vi ans;
    ans.pb(0);
    while(!que.empty()) {
        P p = que.front();
        que.pop();
        rep(i, 4) {
            int x = p.first+dx[i],y = p.second+dy[i];
            if(x<0||x>=h||y<0||y>=w||bo[x][y]!=-1) continue;
            bo[x][y]=bo[p.first][p.second]+1;
            ans.pb(bo[x][y]);
            que.push({x,y});
        }
    }
    cout << ans.back() << endl;
    return 0;
}

Measured memory_bytes: 27404
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int>> p(n);
    int i;
    for(i = 0;i < n;++i){
        cin >> p.at(i).first.first;
        cin >> p.at(i).first.second;
      	p.at(i).first.second *= -1;
        p.at(i).second = i+1;
    }
    sort(p.begin(),p.end());
    for(i = 0;i < n;++i){
        cout << p.at(i).second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N;
ll A[200010];

signed main(){
    cin >> N;
    bool z = false;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(A[i] == 0){
            z = true;
        }
    }
    if(z){
        PRINT("0");
        return 0;
    }
    ll ans = 1;
    for(int i = 0; i < N; i++){    
        if(ans > (ll)(1e18) / A[i]){
            PRINT("-1");
            return 0;
        }
        ans *= A[i];
    }
    PRINT(ans);
    return 0;
}

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

int main() 
{
   string A, B, C;
   cin >> A >> B >> C;

   if (A.at(A.size() - 1) == B.at(0) && B.at(B.size() - 1) == C.at(0))
      cout << "YES" << endl;
   else
      cout << "NO" << endl;
}


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

using namespace std;

bool check(int m, int d) {
    bool res = (d % 10 >= 2) && (d / 10 >= 2);
    return (d % 10) * (d / 10) == m && res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int M, D;
    cin >> M >> D;
    int C = 0;
    for (int m = 1; m <= M; m++) {
        for (int d = 10; d <= D; d++) {
            if (check(m, d)) {
                C++;
            }
        }
    }
    cout << C;
    return 0;
}


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

using namespace std;
long long pluspref[1000000];
long long minuspref[1000000];
int n, k;
long long niz[1000000];
int main()
{
    cin >>n >>k;
    pluspref[0] = 0;
    minuspref[0] = 0;
    for (int i = 1; i <= n; ++i){
        cin >>niz[i];
        if (niz[i] > 0){
            pluspref[i] = pluspref[i-1] + niz[i];
            minuspref[i] = minuspref[i-1];
        }else{
            minuspref[i] = minuspref[i-1] + niz[i];
            pluspref[i] = pluspref[i-1];
        }
    }

    long long sol = 0;
    for (int i = 0; i <= n-k; ++i){
        long long score = 0;
        score += pluspref[i]-pluspref[0];
        score += pluspref[n]-pluspref[i+k];
        long long midsc = (pluspref[i + k]-pluspref[i])+(minuspref[i + k]-minuspref[i]);
        ///cout <<i <<" " <<i+k <<" " <<score <<" " <<pluspref[i-1]-pluspref[0] <<" " <<pluspref[n]-pluspref[i+k-1] <<midsc <<endl;
        if (midsc>0)score+=midsc;
        if (score>sol)sol = score;
    }
    cout <<sol;
return 0;
}
/*
10 5
  5 -4 -5 -8  -4   7   2   -4  0  7
0 5  5  5  5   5   12  14  14  14 21
0 0 -4 -9 -17 -21 -21 -21 -25 -25 -25
*/


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

using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  if (a <= 0 && b >= 0) {
    cout << "Zero\n";
  } else if (b < 0 && (b - a) % 2 == 0) {
    cout << "Negative\n";
  } else {
    cout << "Positive\n";
  }
  return 0;
}



Measured memory_bytes: 256
using System;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate {
    class Program {
        static void Main (string[] args) {
            string[] index = Console.ReadLine().Split(' ');
            int a = int.Parse(index[0]);
            int b = int.Parse(index[1]);

            if((a*b)%2 == 0)
            {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            };
        }
    }

    class MyLibrary {

    }
}

Measured memory_bytes: 11092
#include <stdio.h>
int main(void) {
  int N;
  int M;
  int sum = 0;

  scanf("%d", &N);
  scanf("%d", &M);

  int A[M];
  for (int i = 0; i < M; i++) {
    scanf("%d", &A[i]);
    sum += A[i];
  }
  if (N < sum) {
    printf("%d\n", -1);
  } else {
    printf("%d\n", N - sum);
  }
  return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
 using namespace std;
 int mod(int n)
 {
     int div=ceil(n/-2)*-2;

     return n-div;
 }

 int main()
 {

    long long n;
    cin >> n;
    int cnt=0;

    string str;
    if(n==0){
        cout << 0 << endl;
    }
    else{
    while(n)
    {

        int temp=mod(n);
        if(temp==0)
            str+='0';
        else
            str+='1';
        n=ceil(n*1.0/-2);

    }
    reverse(str.begin(),str.end());
    cout << str << endl;
    }



 }


Measured memory_bytes: 256
// In the name of Allah
// #Isart

#include<bits/stdc++.h>

#define pii pair<int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double

using namespace std;

const int MAXN = 1e5 + 10;
vector<int> d[MAXN], q[MAXN];
int cnt[MAXN], fen[MAXN], ans[MAXN];

void add(int p, int val){
	for(++ p; p < MAXN; p += p & (-p))
		fen[p] += val;
}

int get(int p){
	int res = 0;
	for(; p > 0; p -= p & (-p))
		res += fen[p];
	return res;
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m; cin >> n >> m;
	for(int i = 0; i < n; i ++){	
		int l, r; cin >> l >> r;
		q[r].pb(l);
		cnt[l] ++;
	}
	for(int i = 1; i <= m; i ++){
		for(int j = i; j <= m; j += i){
			d[j].pb(i);
		}
	}
	for(int i = 1; i <= m; i ++){
		add(i, cnt[i]);
		for(auto u : d[i]){
			int j = i - u;
			ans[u] += get(i + 1) - get(j + 1);
		}
		for(auto u : q[i]){
			add(u, -1);
		}
	}
	for(int i = 1; i <= m; i ++)
		cout << ans[i] << endl;
	
	return 0;	
}

Measured memory_bytes: 18048
#include <bits/stdc++.h>
     //https://www.codechef.com/viewsolution/28454497
    // https://medium.com/hackernoon/manachers-algorithm-explained-longest-palindromic-substring-22cb27a5e96f
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define int long long
vector < ll> primes;
 int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int n;
bool isvalid(int x,int y){
  return (x>=0 and x<n and y>=0 and y<n);
}
void Sieve(ll n) 
{ 
    bool prime[n+1];
	for(ll i=0;i<n+1;++i)
		prime[i]=true;
    for (ll p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (ll i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(ll p=2; p<=n; p++) 
       if (prime[p]) 
		primes.push_back(p);  
}
 const int N = 5e5 + 5;
 	int connected;
	int par[N], sz[N];
 
struct DSU
{

	void init(int n) 
	{
		for(int i=1;i<=n;i++)
		{
			par[i]=i;
			sz[i]=1;
		}
		connected=n;
	}
 
	int getPar(int k)
	{
		while(k!=par[k])
		{
			par[k]=par[par[k]];
			k=par[k];
		}
		return k;
	}
 
	int getSize(int k)
	{
		return sz[getPar(k)];
	}
 
	void unite(int u, int v)
	{
		int par1=getPar(u), par2=getPar(v);
 
		if(par1==par2)
			return;
 
		connected--;
 
		if(sz[par1]>sz[par2])
			swap(par1, par2);
 
		sz[par2]+=sz[par1];
		sz[par1]=0;
		par[par1]=par[par2];
	}
};
 
 

DSU dsu;
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
        return gcd(b % a, a); 
} 
ll powermod(ll x, ll y){
    if(y==0)
    return 1;
        
    if(y%2==0)
    return (powermod(x,y/2)*powermod(x,y/2))%mod;
    else
    return (((powermod(x,y/2)*powermod(x,y/2))%mod)*x)%mod;
}
// vector<vector<int>>dp(3500,vector<int>(3500));

 
 
int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);

string s;
cin>>s;
int n=s.size();
for(int i=0;i<n;i++)cout<<'x';
    
    
    
    
}

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

int main() {
    using vi = vector<int>;
    
    int n,m;
    cin >> n >> m;
    vi a(m);
    rep(i,m){
        cin >> a[i];
    }
    int s = 0;
    rep(i,m){
        s+=a[i];
    }
    if(n-s>=0){
        cout << n-s << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
s = list(input())
n = len(s)-1
trueans = []
for i in range(2**n):
    bag = []
    for j in range(n):
        bag.append(s[j])
        if (i>>j) & 1:
            bag.append("+")
    bag.append(s[-1])
    bag.append("+")
    kai = ""
    ans = []
    if "+" in bag:
        for j in bag:
            if j != "+":
                kai += j
            else:
                ans.append(int(kai))
                kai = ""
    trueans.append(sum(ans))
print(sum(trueans))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cmath>

#define REP(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;

class node {
public:
	int key;
	node *left, *right, *parent;
	node() :key(0), left(NULL), right(NULL), parent(NULL) {};
	node(int n) :key(n), left(NULL), right(NULL), parent(NULL) {};
};

class tree {
public:
	node *root;
	tree() :root(NULL) {};
	tree(node *n) :root(n) {};
	void insert(int n) {
		node N(n);
		this->insert(N);
	};
	void insert(node n) {
		node *y = NULL;
		node *x = root;
		while (x != NULL) {
			y = x;
			if (n.key<x->key) x = x->left;
			else x = x->right;
		}
		n.parent = y;
		if (y == NULL) root = new node(n);
		else if (n.key < y->key) y->left = new node(n);
		else y->right = new node(n);
	};
	void Pre() {
		tree t1(root->left), t2(root->right);
		cout << " " << root->key;
		if (t1.root != NULL) t1.Pre();
		if (t2.root != NULL) t2.Pre();
	};
	void Ino() {
		tree t1(root->left), t2(root->right);
		if (t1.root != NULL) t1.Ino();
		cout << " " << root->key;
		if (t2.root != NULL) t2.Ino();
	};
	void Pos() {
		tree t1(root->left), t2(root->right);
		if (t1.root != NULL) t1.Pos();
		if (t2.root != NULL) t2.Pos();
		cout << " " << root->key;
	};
};

int main() {
	int n, nd;
	string str;
	tree T;
	cin >> n;
	REP(i, n) {
		cin >> str;
		if (str == "insert") {
			cin >> nd;
			T.insert(nd);
		}
		else {
			T.Ino();cout << endl;
			T.Pre();cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 26556
n=int(input())
ml=list(map(int,input().split()))
sl=list(map(int,input().split()))
ans,a1=0,ml[0]
for a2,b in zip(ml[1:],sl):
  x=min([a1,b])#first left saver's kill
  y=b-min([a1,b])#left saver's left power
  z=min([y,a2])#second left saver's kill
  a1=a2-z#middle monster's left power
  ans+=(x+z)#all kill
print(ans)

Measured memory_bytes: 18476
#include <iostream>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, n, m) for (int i = (n); i < (m); ++i)

int N, K;

void answer (int a[], int n) {
  cout << a[0];
  FOR (i, 1, n) cout << " " << a[i];
  cout << endl;
}

int main() {

  cin >> K >> N;

  if (K%2 == 0) {
    cout << K/2;
    REP (i, N-1) cout << " " << K;
    cout << endl;
    return 0;
  }

  int ans[N];
  REP (i, N) ans[i] = (K+1)/2;
  int n = N;

  REP (q, N/2) {
    if (ans[n-1] == 1) n--;
    else {
      ans[n-1] -= 1;
      if (n != N) 
        FOR (i, n, N) ans[i] = K;
      n = N;
    }
  }

  answer(ans, n);
  return 0;

}

Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);rep(i,0,n)cin>>var[i];
#define linit(type,var,n) list<type> var;rep(i,0,n){type _v;cin>>_v;var.push_back(_v);}
#define range(container) container.begin(),container.end()
#define rep(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull INF = (ull)(-1LL);

typedef ull ntype;

typedef vector<ntype> vntype;
typedef list<ntype> lntype;

int main(void)
{
	init(string, s);

	bool ans = true;
	for (uint i = 0; i < s.size(); i += 2){
		if ((s[i] != 'h') || (s[i + 1] != 'i'))ans = false;
	}

	outl(ans ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  ll n;
  cin>>n;
  if(n%2 == 0) {
    n /= 2;
    ll ans = 0;
    while (n) {
      n /= 5;
      ans += n;
    }
    cout<<ans<<endl;
  }else{
    cout<<0<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math
a,b,c,d = map(int,input().split())

#cで割り切れる数+dで割り切れる数-gcd(c,d)で割り切れる数を求めればよい
ans=(b//c+b//d-b//(c*d//math.gcd(c,d)))-((a-1)//c+(a-1)//d-(a-1)//(c*d//math.gcd(c,d)))

print(b-a+1-ans)


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

using namespace std;

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

  int ans = 0;
  for(int i = 1; i <= n; i += 2) {
    int count = 0;
    for(int j = 1; j <= i; j++) {
      if(i % j == 0) {
	count += 1;
      }
    }
    if(count == 8) {
      ans += 1;
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int drawy(string s,int &t){
	//cout <<s[t]<<"\n";
	int x=t;
	t++;
	return (int)s[x]-97;
}

int main(){
	string s[3];
	cin >>s[0]>>s[1]>>s[2];
	int a[3]={0,0,0};
	int y=0;
	while(1){
		if(a[y]>=s[y].length()) break;
//		cout <<a[0] <<" "<<a[1]<<" "<<a[2]<<" "<<y<<"\n";
		y=drawy(s[y],a[y]);
	}
	
	cout <<(char)(y+65);
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3652
def resolve():
    from math import gcd
    _, X = [int(i) for i in input().split()]
    xx = [int(i) for i in input().split()]
    ans = abs(X - xx[0])
    for x in xx:
        ans = gcd(ans, abs(X - x))
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 20424
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s;
    cin >> s;
    sort(all(s));
    string x = "abc";
    if(s == x) {
        out("Yes");
    }
    else {
        out("No");
    }
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int a, b, h; cin >> a >> b >> h;
	cout << (a+b)*h/2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s,t;
    cin >> s >> t;

    map<char, vector<int>> mp;
    rep(i, s.length())
    {
        mp[s[i]].push_back(i);
    }
    int now_at = -1;
    ll hanten = 0;

    bool sippaiflag = false;
    rep(i, t.length())
    {
        if (mp[t[i]].size() == 0){
            sippaiflag = true;
            break;
        }
        // now_at縺ｧ縺ｫ縺ｶ縺溘ｓ
        auto itr = upper_bound(mp[t[i]].begin(), mp[t[i]].end(), now_at);
        if (itr == mp[t[i]].end())
        {
            hanten++;
            now_at = mp[t[i]][0];
        }
        else
        {
            now_at = *itr;
        }
        
        // bool flag = 0;
        // rep(j, mp[t[i]].size())
        // {
        //     if (now_at < mp[t[i]][j])
        //     {
        //         flag = 1;
        //         now_at = mp[t[i]][j];
        //         break;
        //     }
        // }
        // if (flag)
        // {
        //     continue;
        // }
        // else
        // {
        //     hanten++;
        //     now_at = mp[t[i]][0];
        // }
        
    }
    if (sippaiflag)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << hanten * s.length() + now_at + 1 << endl;
    }
    
}


Measured memory_bytes: 1228
from fractions import gcd

a, b, c, d = map(int, input().split())
a= a-1
a_c = a // c
b_c = b // c
a_d = a // d
b_d = b // d
e = c*d // gcd(c, d)

print((b - b_c - b_d + b//e) - (a - a_c - a_d + a//e))

Measured memory_bytes: 64108
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> w(n);
    
    for(int i=0;i<n;i++){
        cin>>w.at(i);
    }
    int answer=100000000;
    for(int i=0;i<n;i++){
        int high=0;
        int low=0;
        int pre=0;
        for(int k=0;k<n;k++){
            if(k<=i)low+=w.at(k);
            else    high+=w.at(k);
        }
        if(low<=high)pre=high-low;
        else         pre=low-high;
        if(pre<answer)answer=pre;
    }
    cout<<answer;
}

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

using namespace std;

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

    vector<long long> a(n + 1);
    vector<long long> b(n);
    for (int i = 0; i <= n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i];

    long long total = 0;
    for (int i = 0; i < n; ++i) {
        int c1 = min(a[i], b[i]);
        b[i] -= c1;
        int c2 = min(a[i + 1], b[i]);
        a[i + 1] -= c2;
        total += c1 + c2;
    }
    cout << total << '\n';
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
typedef tuple<int, int, int> T;

int n;
string s[1000000];

bool allSearch() {
	int i;
	
	vector<int> p;
	rep(i, n) p.push_back(i);
	
	do {
		string t;
		rep(i, n) {
			t += s[p[i]];
		}
		
		int cnt = 0;
		rep(i, t.length()) {
			if (t[i] == '(') cnt++;
			else cnt--;
			if (cnt < 0) break;
		}
		if (i == t.length() && cnt == 0) {
			return true;
		}
	} while (next_permutation(p.begin(), p.end()));
	return false;
}

bool solve(bool debug = false) {
	int i, j;
	
	int sumCnt = 0;
	vector<T> vec1, vec2, vec3;
	rep(i, n) {
		int cnt = 0;
		int minCnt = 0;
		rep(j, s[i].length()) {
			if (s[i][j] == '(') cnt++;
			if (s[i][j] == ')') cnt--;
			minCnt = min(minCnt, cnt);
		}
		sumCnt += cnt;
		
		if (cnt >= 0 && minCnt >= 0) {
			vec1.push_back(T(0, cnt, minCnt));
		}
		else if (cnt >= 0 && minCnt < 0) {
			vec2.push_back(T(-minCnt, cnt, minCnt));
		}
		else {
			vec3.push_back(T(-(cnt - minCnt), cnt, minCnt));
		}
	}
	if (sumCnt != 0) {
		return false;
	}
	
	sort(vec2.begin(), vec2.end());
	sort(vec3.begin(), vec3.end());
	
	if (debug) {
	}
	
	int ccnt = 0;
	rep(i, vec1.size()) {
		ccnt += get<1>(vec1[i]);
	}
	
	rep(i, vec2.size()) {
		if (get<2>(vec2[i]) + ccnt >= 0) {
			ccnt += get<1>(vec2[i]);
		}
		else {
			return false;
		}
	}
	
	rep(i, vec3.size()) {
		if (get<2>(vec3[i]) + ccnt >= 0) {
			ccnt += get<1>(vec3[i]);
		}
		else {
			return false;
		}
	}
	return true;
}

signed main() {
	int i, j, k;
	
	/*n = 5;
	for (i = 0; i < 10000; i++) {
		rep(j, n) {
			int len = 1 + rand() % 5;
			s[j] = "";
			rep(k, len) {
				if (rand() % 2) s[j] += "(";
				else s[j] += ")";
			}
		}
		bool res1 = allSearch();
		bool res2 = solve();
		if (res1 != res2) {
			cout << "Wrong Answer[" << i << "]" << endl;
			cout << "allSearch = " << res1 << endl;
			cout << "solve = " << res2 << endl;
			cout << "n = " << n << endl;
			rep(j, n) {
				cout << s[j] << endl;
			}
			cout << endl;
			cout << "solve.debug" << endl;
			solve(true);
			return 0;
		}
	}*/
	
	cin >> n;
	rep(i, n) cin >> s[i];
	if (solve()) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 57972
<?php
  $a = [];
  list($a[]) = explode(" ", trim(fgets(STDIN)));
  list($a[]) = explode(" ", trim(fgets(STDIN)));
  list($a[]) = explode(" ", trim(fgets(STDIN)));
  list($a[]) = explode(" ", trim(fgets(STDIN)));
  list($a[]) = explode(" ", trim(fgets(STDIN)));
  list($k) = explode(" ", trim(fgets(STDIN)));

  for ($i=0; $i<count($a)-1; $i++) {
    for ($j=$i+1; $j<count($a); $j++) {
      if(abs($a[$i]-$a[$j]) > $k) {
        echo ":(";
        exit;
      }
    }
  }
    echo "Yay!";

Measured memory_bytes: 16048
#include<stdio.h>
#include<stdlib.h>

void bubbleSort(int num[],int com,int *count);

int main(void)
{
  int *num;
  int com;
  int i;
  int count=0;

  scanf("%d",&com);

  num=calloc(com,sizeof(int));

  for(i=0;i<com;i++)
    {
      scanf("%d",&num[i]);
    }

  bubbleSort(num,com,&count);

  for(i=0;i<com;i++)
    {
      printf("%d",num[i]);

      if(i!=com-1)
	printf(" ");
    }
  
  putchar('\n');

  printf("%d\n",count);
  
  free(num);
  
  return 0;
}


void bubbleSort(int num[],int com,int *count)
{
  int i,j,tmp;


  for(i=0;i<com-1;i++)
    {
      for(j=com-1;j>i;j--)
	{
	  if(num[j-1]>num[j])
	    {
	      tmp=num[j-1];
	      num[j-1]=num[j];
	      num[j]=tmp;
	      (*count)++;
	    }
	}
    }
}



Measured memory_bytes: 2128
a = int(input())
b = int(input())
c = int(input())
x = int(input())

atta = 0
for i in range(a+1):
  for j in range(b+1):
    if 0 <= x-500*i-100*j and x-500*i-100*j <= 50*c:
      #print(i,j,(x-500*i-100*j)//50)
      atta +=1

print(atta)
        

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

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF = 1e12+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}



int main() {
    int N;
    cin >> N;
    vector<ll> A(N), T(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i] >> A[i];
    }
    ll t = T[0], a = A[0];
    for (int i = 1; i < N; i++) {
        ll td = (t + T[i]-1)/ T[i];
        ll ad = (a + A[i]-1)/ A[i];
        t = T[i] * max(td,ad);
        a = A[i] * max(td,ad);
    }
    cout << t+a << endl;
}


Measured memory_bytes: 384
N=int(input())
c={1:0,2:0,4:0}
for a in map(int,input().split()):
	if a % 2 == 0:
		if (a // 2) % 2 == 0:
			c[4] += 1
		else:
			c[2] += 1
	else:
		c[1] += 1

if c[2] > 0:
	c[1] += 1

print("No" if c[1] >= c[4] + 2 else "Yes")


Measured memory_bytes: 11224