akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    while (true){
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0){
            return 0;
        }

        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if(i % 2 == 0 && j % 2 == 0){
                    printf("%c", '#');
                } else if(i % 2 == 0 && j % 2 == 1){
                    printf("%c", '.');
                } else if(i % 2 == 1 && j % 2 == 1){
                    printf("%c", '#');
                } else if(i % 2 == 1 && j % 2 == 0){
                    printf("%c", '.');
                }
            }
            printf("\n");
        }

        printf("\n");
    }
}



Measured memory_bytes: 3096
import sys
import math

def minSum(n):
    min_sum = 0
    for i in range(1, n):
        a = i
        b = n - i
        min_sum_a, min_sum_b = 0, 0
        while  a > 0:
            min_sum_a += a%10
            a = math.floor(a/10)
        while b > 0:
            min_sum_b += b%10
            b = math.floor(b/10)
        
        if i == 1:
            min_sum = min_sum_a + min_sum_b
        else:
            if min_sum > min_sum_a + min_sum_b:
                min_sum = min_sum_a + min_sum_b
    return min_sum

n = int(input())

print("{}".format(minSum(n)))



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

int main()
{
ll n ;
cin >> n ;
multiset<ll> a;
rep(i, n){
  ll b;
  cin >> b;
  a.insert(b);
}
auto itrmx=a.end();
itrmx--;
auto itrmi=a.begin();
bool ok=1;
if((*itrmx+1)/2!=*itrmi)ok=0;
if(*itrmx%2==0 && a.count(*itrmi)!=1)ok=0;
if(*itrmx%2==1 && a.count(*itrmi)!=2)ok=0;
for (ll i = *itrmi; i <= *itrmx; i++)
{
  if(a.count(i)==0)ok=0;
}


if(ok)cout << "Possible" << endl;
else cout << "Impossible" << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <cmath>
using namespace std;

#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647

int main() {
	long long N, M;
	cin >> N >> M;
	long long count = 0;
	if (N * 2 <= M) {
		count += N;
		M -= 2 * N;
		N = 0;
		count += M / 4;
	}
	else if(M < 2 * N){
		count += M / 2;
	}

	cout << count << endl;
	return 0;
}

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

a = []
for num in range(n):
  a.append(int(input()))

maxn = max(a)


if (a.count(maxn) ==1):
  sortedset = sorted(set(a))
  max2n = max(a)
  if len(sortedset) > 1:
    max2n = sortedset[-2]
  for num in a:
    if num != maxn:
      print (maxn)
    else:
      print (max2n)
else:
  for num in a:
    print(maxn)

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

const int MAX = 1000001;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*x+yは3の倍数になる*/
int main(){
  int x, y;
  cin >> x >> y;
  if ((x + y) % 3) {
    cout << 0 << endl;
    return 0;
  }
  int n = (x + y) / 3;
  x -= n, y -= n;
  if (x < 0 || y < 0) {
    cout << 0 << endl;
    return 0;
  }
  COMinit();
  cout << COM(x + y, x)  << endl;
  return 0;
} 

Measured memory_bytes: 23680
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define F first
#define S second
using namespace std;
int r;
int f[555][555];
bool used[555][555];
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
vector< pair<int,int> > v[2];
int main(void){
  while(cin >> r && r){
    for(int k = 0; k < 2; k++){
      v[k].clear();
      int w,h,ox,oy;
      cin >> w >> h >> ox >> oy;
      for(int y = 1; y <= h; y++){
	for(int x = 1; x <= w; x++){
	  cin >> f[x][y];
	}
      }

      priority_queue< pair<int,pair<int,int> > , vector< pair<int,pair<int,int> > > , greater< pair<int,pair<int,int> > > > que;
      que.push(make_pair(1,make_pair(ox,oy)));
      memset(used,false,sizeof(used));
      used[ox][oy] = true;
      int best = 0;
      int cr = 0;
      while(!que.empty()){
	int x = que.top().S.F;
	int y = que.top().S.S;
	int l = que.top().F;
	que.pop();
	if(best < l){
	  v[k].push_back(make_pair(cr,best));
	  best = l;
	}
	cr++;
	if(cr >= r){
	  v[k].push_back(make_pair(cr,best));
	  break;
	}
	for(int i = 0; i < 4; i++){
	  int nx = x + dx[i];
	  int ny = y + dy[i];
	  if(0 >= nx || 0 >= ny || w < nx || h < ny || used[nx][ny]) continue;
	  used[nx][ny] = true;
	  que.push(make_pair(f[nx][ny],make_pair(nx,ny)));
	}
      }
      v[k].push_back(make_pair(cr,best));
    }

    int res = 1<<28;
    for(int i = 0; i < (int)v[0].size(); i++){
      int p = r - v[0][i].F;
      int t = 0,e = (int)v[1].size();
      while(t < e){
	int h = (t+e)/2;
	if(p <= v[1][h].F) e = h;
	else t = h+1;
      }
      if(e == (int)v[1].size()) continue;
      res = min(res,v[0][i].S+v[1][e].S);
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3604
# -*- coding:utf-8 -*-

n, y = map(int, input().split())
a = 10000
b = 5000
c = 1000
list = []
for i in range(n+1):
        for j in range((n+1)-i):
                #for k in range((n+1)-(i+j)):
                        total = a*i + b*j + c*(n-(i+j))
                        if total == y:
                                new_list = [i, j, (n-(i+j))]
                                list.append(new_list)
                                print("{} {} {}".format(i, j, (n-(i+j))))
                                exit()
if not list:
        print("-1 -1 -1")

Measured memory_bytes: 3064
#include <stdio.h>
int main() {
	char s[4];
	scanf("%s", s);
	if (s[0] != s[1] && s[1] != s[2] && s[2] != s[0]) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
N1, N2, N3, N4 = map(int, input().split())
N1, N2, N3, N4 = sorted([N1, N2, N3, N4])
if [N1, N2, N3, N4] == [1, 4, 7, 9]:
  print("YES")
else:
  print("NO")


Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	int date[300][3] = { 0 };
	int i, j, k, q;
	int n = 0;

	while (1) {
		scanf("%d %d", &date[n][0], &date[n][1]);

		if (date[n][0] == 0 && date[n][1] == 0) {
			break;
		}
		else {
			n++;
		}
	}

	for (i = 0; i < n; i++) {
		for (j = 1; j <= date[i][0]; j++) {
			for (k = j + 1; k <= date[i][0]; k++) {
				for (q = k + 1; q <= date[i][0]; q++) {
					if (j + k + q == date[i][1]) {
						date[i][2]++;
					}
				}
			}
		}
	}

	for (i = 0; i < n; i++) {
		printf("%d\n", date[i][2]);
	}
	
	return 0;
}


Measured memory_bytes: 2096
#include<stdio.h>

void trace(int A[], int N) {
    int i;
    for(i = 0; i < N; i++)
    {
        if(i > 0) {
            printf(" ");
        }
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N) {
    int j, i, v;
    for(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;
        trace(A, N);        
    }   
}

int main() {
    int N, i, j;
    int A[100];

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

    trace(A, N);
    insertionSort(A, N);

    return 0;
}




Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int K;
  cin >> N;
  cin >> K;
  int A;
  for ( int i = 0 ; i < N ; i++ ) {
    int x;
    cin >> x;
    if ( x <= ( K - x ) ) {
      A = A + x;
    }
    else {
      A = A + K - x;
    }
  }
  cout << A * 2 << endl;
}

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int N, K;
  cin >> N >> K;
  combination c(N);
  for(int i=1; i<=K; i++) {
    if(i == 1 || i == K) printf("%d\n", c(N-K+1, i));
    else printf("%d\n", c(N-K+1, i)*c(K-1, i-1));
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


int main() {
int N; cin >> N;
VI A(N); rep(i, 0, N) scanf("%d", &A[i]);

int cnt=0;

rep(i, 0, N) {
    if (A[i]%2 == 1) ++cnt;
}
if (cnt%2 == 1) {
    cout << "NO" << "\n";
    return 0;
}

cout << "YES" << "\n";
return 0;
}

// 境界，出力文字列 チェック
// int は ± 2*10⁹.


Measured memory_bytes: 640
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 2000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
	int m;
	cin >> m;
	cout << 48 - m << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);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 ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
int main() {
    IN(int,n);
    VIN(int, a, n);
    vi s(n);
    int sum = a[0];
    for (int i = 1; i < n; i++) {
        sum = sum^a[i];
    }
    REP(i, n){
        cout << (sum^a[i]);
        if (i<n-1) {
            cout << " ";
        }
    }
    ENDL;
}


Measured memory_bytes: 4788
N, K = map(int, input().split())
a = list(map(int,input().split()))

b = [0]
A = []
m = 40
for e in a:
    b.append(b[-1]+e)
for i in range(1,N+1):
    for j in range(1,N+1):
        if i <= j:
            A.append(b[j]-b[i-1])
xp = 0
for t in reversed(range(1,m+1)):
    count = 0
    for e in A:
        if e & (xp+2**(t-1)) == (xp+2**(t-1)):
            count += 1
    if count >= K:
        xp += 2**(t-1)
print(xp)

    


Measured memory_bytes: 66940
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;

string itos(int t){
    string ret = "";
    stack<int> v;
    while(t>0){
        v.push(t%10);
        t /= 10;
    }
    while(v.size()){
        ret.push_back(v.top()+'0'); v.pop();
    }
    return ret;
}

int main(){
    while(1){
        int m,n;
        scanf("%d%d",&m,&n);
        if(!m)break;

        vector<bool> p(m,true);
        vector<string> str(n);
        for(int i=0;i<n;i++){
            cin >> str[i];
        }

        int out_num = 0;
        int player_i = 0;
        for(int i=0;i<n;i++){
            if((i+1)%15==0){
                if(str[i]!="FizzBuzz"){
                    p[player_i] = false;
                    out_num++;
                }
            }else if((i+1)%3==0){
                if(str[i]!="Fizz"){
                    p[player_i] = false;
                    out_num++;
                }
            }else if((i+1)%5==0){
                if(str[i]!="Buzz"){
                    p[player_i] = false;
                    out_num++;
                }
            }else{
                if(str[i]!=itos(i+1)){
                    p[player_i] = false;
                    out_num++;
                }
            }

            if(out_num==m-1){
                break;
            }

            player_i = player_i==m-1 ? 0 : player_i+1;
            while(!p[player_i]) player_i = player_i==m-1 ? 0 : player_i+1;
        }

        bool first = true;
        for(int i=0;i<m;i++){
            if(p[i]){
                if(first){cout << i+1;first=false;}
                else cout << " " << i+1;
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1768
#include<cstdio>
#include<cstring>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn=200010,MOD=1000000007;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
struct cyc{
    int z0,z1,z2;
};
cyc operator + (cyc a,cyc b){
    cyc c;
    c.z0=1ll*a.z0*b.z0%MOD;
    c.z1=(1ll*a.z0*b.z1+1ll*a.z1*b.z0)%MOD;
    c.z2=(1ll*a.z0*b.z2+1ll*a.z2*b.z0+1ll*a.z1*b.z1+1ll*a.z2*b.z2+1ll*a.z1*b.z2+1ll*a.z2*b.z1)%MOD;
    return c;
}
vector<cyc>a[maxn];
int n,fa[maxn],first[maxn],cnt=0,tot=0,b[maxn];
struct edge{int v,from;}e[maxn*2];
void insert(int u,int v){cnt++;e[cnt].v=v;e[cnt].from=first[u];first[u]=cnt;}
int MO(int x){return x>=MOD?x-MOD:x;}
void merge(int &x,int y){
    if(a[x].size()<a[y].size())swap(x,y);
    for(int i=0;i<(int)a[y].size();i++){
        a[x][a[x].size()-i-1]=a[x][a[x].size()-i-1]+a[y][a[y].size()-i-1];
    }
}
int main(){
    n=read()+1;
    for(int i=2;i<=n;i++)fa[i]=read()+1,insert(fa[i],i);
    for(int i=n;i>=1;i--){
        int mx=0;
        if(!first[i]){
            a[b[i]=++tot].push_back((cyc){(MOD+1)/2,(MOD+1)/2,0});
        }
        else{
            b[i]=b[e[first[i]].v];
            for(int j=e[first[i]].from;j;j=e[j].from){
                mx=max(mx,(int)a[b[e[j].v]].size());
                merge(b[i],b[e[j].v]);
            }
            a[b[i]].push_back((cyc){(MOD+1)/2,(MOD+1)/2,0});
        }
        for(int j=(int)a[b[i]].size()-1-1;j>=(int)a[b[i]].size()-mx-1;j--)a[b[i]][j].z0+=a[b[i]][j].z2,a[b[i]][j].z2=0;
    }
    int ans=0,N=1;
    for(int i=1;i<=n;i++)N=(N<<1)%MOD;
    for(int i=0;i<(int)a[b[1]].size();i++)ans=MO(ans+1ll*a[b[1]][i].z1*N%MOD);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 16128
M = 60
def topbit(n):
    res = -1
    for i in range(M,-1,-1):
        if n&2**i!=0:
            res = i
            break
    return res

def solve():
    N = int(input())
    A = list(map(int,input().split()))
    S = input()
    base = {}
    ans = '0'
    for i in range(N-1,-1,-1):
        if S[i]=='0':
            s = A[i]
            while s != 0:
                n = topbit(s)
                if n not in base:
                    base[n] = s
                    break
                else:
                    s ^= base[n]
        else:
            s = A[i]
            while s != 0:
                n = topbit(s)
                if n not in base:
                    ans = '1'
                    break
                else:
                    s ^= base[n]
    print(ans)

T = int(input())
for t in range(T):
    solve()

Measured memory_bytes: 69200
#include <bits/stdtr1c++.h>
// typedef __int128 int128;
// typedef __float128 float128;

using namespace std;
using namespace rel_ops;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ld> vd;
typedef vector<vd> vvd;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;
#define pb push_back


ll minCost(ll N, vi& h, vi& prev){

  if(N == 2)
    return abs(h[1] - h[0]);
  if(N == 3)
    return abs(h[2] - h[0]);

  if(prev[N-1] != -1)
    return prev[N-1];

  ll res = min(minCost(N - 1, h, prev) + abs(h[N - 1] - h[N-2]),
               minCost(N - 2, h, prev) + abs(h[N - 1] - h[N-3]));

  prev[N-1] = res;

  return res;




}

int main(){

  // freopen("A.in", "r", stdin);

  ll N;
  cin >> N;

  vi h;
  for (ll i = 0; i < N; i++) {
    ll hi;
    cin >> hi;
    h.pb(hi);
  }

  vi prev(N, -1);
  cout << minCost(N, h, prev) << endl;


}


Measured memory_bytes: 4340
n= int(input())
for i in range(1,3501):
    for j in range(1,3500):
        if (4*i*j-n*i-n*j)>0:
         w= (n*i*j)/(4*i*j-n*i-n*j)
         if w.is_integer():
            print(str(i)+" "+str(j)+" "+str(int(w)))
            exit()


Measured memory_bytes: 40668
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x, y;
  cin >> x >> y;
  rep(i, x + 1) {
    ll j = x - i;
    if(i * 2 + j * 4 == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

int main(){
  int N;
  cin>>N;
  if(N%10==3)
    cout<<"bon"<<endl;
  else if(N%10==0||N%10==1||N%10==6||N%10==8)
    cout<<"pon"<<endl;
  else
    cout<<"hon"<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int N;
vector<ll> H;

void solve() {
  ll res = 0, cnt = 0;
  for (int i = 1; i < N; i++) {
    if (H[i - 1] >= H[i]) {
      cnt++;
    } else {
      cnt = 0;
    }
    res = max(res, cnt);
  }
  cout << res << '\n';
}

int main() {
  cin >> N;
  H.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#include <stdio.h>
#include <cstdlib>

using namespace std;

int main() {
    int a = 0;
    int b  = 0;
    cin >> a;
    if (a % 10 == 7){
        b = 1;
    }
    a = a / 10;
    if (a % 10 == 7){
        b = 1;
    }
    a = a / 10;
    if (a == 7){
        b = 1;
    }
    if (b == 1){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}



Measured memory_bytes: 3676
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a,x,b) (a<=x && x<=b)
#define WS std::cout<<" ";
#define NL std::cout<<"\n"
#define OUT(dist) std::cout<<(dist);
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;

int N;
V<LL> a, b;

int main(){
    INIT;
    cin >> N;
    a.resize(N+1); b.resize(N);
    REP(i,N+1) {
        cin >> a[i];
    }
    REP(i,N) {
        cin >> b[i];
    }

    LL cnt = 0;
    REP(i,N) {
        if(a[i] < b[i]) {
            cnt += a[i];
            b[i] -= a[i];
            if(a[i+1] < b[i]) {
                cnt += a[i+1];
                a[i+1] = 0;
            } else {
                cnt += b[i];
                a[i+1] -= b[i];
            }
        } else {
            cnt += b[i];
        }
    }
    cout << cnt;
}

Measured memory_bytes: 1792
<?php
	$stdin = trim(fgets(STDIN));
	$arr = explode(' ', $stdin);
    $rslt = 'NO';
	$five_cnt = 0;
	$sevn_cnt = 0;
	foreach($arr as $val){
      if($val === '5'){
        $five_cnt++;
      }
      if($val === '7'){
        $sevn_cnt++;
      }
    }
	if($five_cnt === 2 && $sevn_cnt === 1){
    	$rslt = 'YES';  
    }
    echo $rslt;
?>

Measured memory_bytes: 4728
n = int(input())
h = list(map(int, input().split()))

ans = 0
while sum(h) != 0:
    cnt = 0
    for i in range(n):
        if sum(h) == 0:
            break
        if h[i]:
            cnt += 1
        if h[i]!= 0 and i == n-1:
            for j in range(cnt):
                h[i-j] -= 1
            ans += 1
        elif h[i] != 0 and h[i+1] == 0:
            for j in range(cnt):
                h[i-j] -= 1
                cnt = 0
            ans +=1

print(ans)

Measured memory_bytes: 3188
#include <stdio.h>

int main(void)
{
	int L,R,d,total=0;
	scanf("%d",&L);
	scanf("%d",&R);
	scanf("%d",&d);
	total+=R/d;
	if(L%d==0)total-=L/d-1;
	else total-=L/d;
	printf("%d",total);
	return 0;
}

Measured memory_bytes: 1732
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    string T;
    cin >> T;
    ll N = T.length();
    string S = T;
    rep(i,N){
        if(T[i]=='?'){
            if(i==N-1) S[i] = 'D';
            else if(i==0){
                if(T[i+1]=='P') S[i] = 'D';
                else S[i] = 'P';
            }
            else if(S[i-1]=='P') S[i] = 'D';
            else if(T[i+1]=='P') S[i] = 'D';
            else S[i] = 'P';
        }
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 3920
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            int num1 = int.Parse(Console.ReadLine());
            double result = 2 * num1 * Math.PI;

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 27620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = (m); i < (n); i++)
#define rrep(i,n) for (int i = (n); i >= 0; i--)
using namespace std;
typedef long long ll;

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  
  int res = 0;
  int cc = 1<<30;
  rep1(i,N) {
    int X;
    cin >> X;
    int d = (T*1000-X*6) - A*1000;
    if (d < 0) d = -d;
    if (cc > d) cc = d, res = i;
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000000;
int main(){
  int K;
  cin >> K;
  vector<int> A(K);
  for (int i = 0; i < K; i++){
    cin >> A[i];
  }
  long long tv1 = INF;
  long long fv1 = 0;
  while (tv1 - fv1 > 1){
    long long mid = (tv1 + fv1) / 2;
    long long N = mid;
    for (int i = 0; i < K; i++){
      N = N / A[i] * A[i];
    }
    if (N >= 2){
      tv1 = mid;
    } else {
      fv1 = mid;
    }
  }
  long long tv2 = 0;
  long long fv2 = INF;
  while (fv2 - tv2 > 1){
    long long mid = (tv2 + fv2) / 2;
    long long N = mid;
    for (int i = 0; i < K; i++){
      N = N / A[i] * A[i];
    }
    if (N <= 2){
      tv2 = mid;
    } else {
      fv2 = mid;
    }
  }
  if (tv2 < tv1){
    cout << -1 << endl;
  } else {
    cout << tv1 << ' ' << tv2 << endl;
  }
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll x;
    cin >> x;
    ll ans = 0;
    ans += (x/11)*2;
    if (x%11>6) ans+=2;
    else if (x%11>0) ans++;

    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

int main() 
{
    int n; cin >> n; 
    string s; cin >> s;
    int w_cnt = 0;
    int e_cnt = 0;
    int ans = -1; 
    rep(i,n) {
        if(s[i] == 'W') { w_cnt++; }  
        else            { e_cnt++; }
    }
    
    vector<pair<int,int> > l(n), r(n);

    int r_w = w_cnt, r_e = e_cnt;
    int l_w = w_cnt, l_e = e_cnt;

    rep(i,n) {
        if(s[i] == 'W') {
            r[i] = make_pair(--r_w, r_e);
        } else {
            r[i] = make_pair(r_w, --r_e);
        }

        if(s[n-i-1] == 'W') {
            l[n-i-1] = make_pair(--l_w, l_e);
        } else {
            l[n-i-1] = make_pair(l_w, --l_e);
        }
    }

    rep(i,n) {
        ans = max(ans, r[i].first + l[i].second);
    }

    cout << n-ans-1 << endl;
    return 0;
}



Measured memory_bytes: 5380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  int l,r;
  cin >> l >> r ;
  ll ans=2020;
  if((r-l)>=2019) ans=0;
  else{
    for(int i=l;i<=r-1;i++){
		for(int j=i+1;j<=r;j++){
          ll mx=((i%2019)*(j%2019))%2019;
          ans=min(ans,mx);
        }
    }
  }
    cout << ans << endl;
    
  
}
  

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c := nextInt(), nextInt(), nextInt()
	var ans int
	if c <= a+b {
		ans = b + c
	} else {
		ans = b + (a + b) + 1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define INF 2e9
#define ll long long


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

    string s;
    cin>>s;

    if(n>=3200){
        cout<<s<<endl;
    }
    else{
        cout<<"red"<<endl;
    }
}

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

using ll = long long;
using P = pair<int, int>;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

bool prime[60000];

void erathos() {
  for (int i = 2; i * i <= 60000; i++) {
    for (int j = 2; i * j <= 60000; j++) {
      prime[i*j] = true;
    }
  }
}

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

  erathos();
  int cnt = 0;
  for (int i = 11; i < 55555; i++) {
    if (!prime[i] && i % 5 == 1) {
      cout << i;
      if (cnt < N - 1) cout << " ";
      cnt++;
    }
    if (cnt == N) break;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
"use strict";

function main(input)
{
    const args = input.split(' ');

    let 変数 = new Array(5);
    変数[0] = parseInt(args[0], 10);
    変数[1] = parseInt(args[1], 10);
    変数[2] = parseInt(args[2], 10);
    変数[3] = parseInt(args[3], 10);
    変数[4] = parseInt(args[4], 10);

    const インデックス = 変数.findIndex(中身 => 中身 == 0) + 1;
    console.log("%d", インデックス);
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29540
#include <bits/stdc++.h>
using namespace std;
string s1,s2;
int main(void){
    array<int,26> nums,nums2;
    cin.tie(0);
    ios::sync_with_stdio(false);
    int i,j;
    while(cin>>s1>>s2){
        for(i=0;i<s1.size();++i){
            s1[i]-='a';
        }
        for(i=0;i<s2.size();++i){
            s2[i]-='a';
        }
        if(s1.size()>s2.size()){
            swap(s1,s2);
        }
        int mx=0;
        for(i=s1.size();i>=1;--i){
            set<array<int,26>> dic;
            for(j=0;j<26;++j){
                nums[j]=nums2[j]=0;
            }
            for(j=0;j<i;++j){
                ++nums[s1[j]];
                ++nums2[s2[j]];
            }
            dic.insert(nums);
            for(j=i;j<s1.size();++j){
                ++nums[s1[j]];
                --nums[s1[j-i]];
                dic.insert(nums);
            }
            if(dic.find(nums2)!=dic.end()){
                mx=i;
                break;
            }
            for(j=i;j<s2.size();++j){
                ++nums2[s2[j]];
                --nums2[s2[j-i]];
                if(dic.find(nums2)!=dic.end()){
                    mx=i;
                    goto end;
                }
            }
        }
        end:
        ;
        cout<<mx<<'\n';
    }
}



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

int main() {
  int K, S;
  cin >> K >> S;

  int ans = 0;
  for (int x = 0; x <= K; x++) {
    for (int y = 0; y <= K; y++) {
      int z = S - x - y;
      if (0 <= z && z <= K)
        ans++;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 100000000001
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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


int main()
{
    double t, x;
    cin >> t >> x;
    cout << double(t / x) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define anD &&
#define oR ||
#define max(a,b) ((a)>=(b))?(a):(b)
#define min(a,b) ((a)<=(b))?(a):(b)
#define rep(i,n) for((i)=0;(i)<(n);(i)++)

int main(void) {
	int point_Taro = 0, point_Hanako = 0, i, st_T, st_H;
	int n,j;
	char t[101], h[101];
	scanf("%d", &n);
	rep(i, n) {
		scanf("%s %s", t, h);
		st_T = strlen(t); st_H = strlen(h);
		for (j = 0; j < min(st_T, st_H); j++) {
			if (t[j] > h[j]) {
				point_Taro += 3;
				break;
			}
			if (h[j] >t[j]) {
				point_Hanako +=3;
				break;
			}
			if (h[j] == t[j]) {
				if (j ==( min(st_T, st_H) - 1)) {
					if (st_T < st_H) {
						point_Hanako += 3;
						break;
					}
					if (st_H < st_T) {
						point_Taro += 3;
						break;
					}
					if (st_H == st_T) {
						point_Taro += 1;
						point_Hanako += 1;
						break;
					}
				}
			}

		}

	}
	printf("%d %d\n", point_Taro, point_Hanako);
	return 0;
}

Measured memory_bytes: 596
X = int(input())

MAX_INT = 201

res = 0

for i in range(MAX_INT):
  for j in range(MAX_INT):
    if i**5 - j**5 == X:
      print(i,j)
      exit()

    if i**5 + j**5 == X:
      print(i,-j)
      exit()

Measured memory_bytes: 64508
#include<iostream>
using namespace std;
int main()
{
    long long int m,n,o,t=1,p;
    cin>>m>>n;
    o=max(m,n);
    p=min(m,n);
    while(t)
    {
        if((o*t)%p==0)
        {
            cout<<o*t;
            break;
        }
        t++;
  }
    return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  ll s;cin>>s;
  ll sh=s/1000000000;
  ll mar=s%1000000000;
  if(mar!=0)
  {
    sh++;
    mar=1000000000-mar;
  }
  printf("0 0 1000000000 1 %lld %lld\n", mar, sh);
} 


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			System.out.println(solve(N) ? "Yes" : "No");
		}
	}

	static boolean solve(int N) {
		int[] R = new int[N];
		int[] C = new int[N];
		for (int i = 0; i < N; ++i) {
			R[i] = Integer.parseInt(sc.next());
		}
		for (int i = 0; i < N; ++i) {
			C[i] = Integer.parseInt(sc.next());
		}
		boolean[] doneR = new boolean[N];
		boolean[] doneC = new boolean[N];
		int onR = 0;
		int onC = 0;
		int offR = 0;
		int offC = 0;
		while (true) {
			if (onR + offR == N && onC + offC == N) return true;
			boolean update = false;
			for (int i = 0; i < N; ++i) {
				if (doneR[i]) continue;
				if (R[i] == onC) {
					offR++;
					doneR[i] = true;
					update = true;
					continue;
				}
				if (R[i] == N - offC) {
					onR++;
					doneR[i] = true;
					update = true;
					continue;
				}
			}
			for (int i = 0; i < N; ++i) {
				if (doneC[i]) continue;
				if (C[i] == onR) {
					offC++;
					doneC[i] = true;
					update = true;
					continue;
				}
				if (C[i] == N - offR) {
					onC++;
					doneC[i] = true;
					update = true;
					continue;
				}
			}
			if (!update) break;
		}
		return false;
	}

}

Measured memory_bytes: 50544
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

vector<ll> two;
vector<ll> f(ll N){
    vector<ll> ret(two.size());
    ll cnt = 0;
    ll t = 1;
    while(true){
        ll T = N-(t-1);
        if(T <= 0) break;
        
        ret[cnt] = (T/(2*t))*t;
        
        T -= T/(2*t)*(2*t);
        ret[cnt] += min(T,t);
        
        cnt++;
        t *= 2;
    }
    return ret;
}
template<class Type>
Type solve(Type res = Type()){
    ll A,B; cin >> A >> B;
    ll t = 1;
    while(t <= 1e12+10){
        two.push_back(t);
        t *= 2;
    }
    auto ret1 = f(B);
    vector<ll> ans = ret1;

    if(A >= 2){
        auto ret2 = f(A-1);
        for(int i = 0; i < two.size();i++){
            ans[i] -= ret2[i];
        }
    }
    
    for(ll i = 0; i < two.size();i++){
        if(ans[i]%2==1){
            res += 1LL<<i;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
x,y=map(int,input().split())

ans=abs(x)-abs(y)
#print(ans)
if ans==0:
    if x==y:
        print(ans)
    else:
        print(1)
elif ans<0:
   # print("SDFGH")
    if x<0 and y<0 :
        print(abs(ans)+2)
    elif 0<=x and 0<=y:
        print(abs(ans))
    else:
        print(abs(ans)+1)
else:
    if x<=0 and y<=0:
        print(abs(ans))
    elif 0<x and 0<y:
        print(abs(ans)+2)
    else: 
        
        print(abs(ans)+1)



Measured memory_bytes: 3064
import Text.Printf (printf)

pat :: Int -> Int -> [(Int, Int, Int)]
pat n y = [(a,b,c)| a <- [0..n], b <- [0..n-a], let c = n - a - b, 10000*a+5000*b+1000*c == y]

main :: IO ()
main = do
  [n,y] <- (map read . words) <$> getLine
  let ps = pat n y
  let (a,b,c) = if null ps then (-1,-1,-1) else head ps
  printf "%d %d %d\n" a b c


Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;
vector<int> vis;
int total = 1;
void dfs(vector<vector<int>>& g, int v) {
	
	total++;
	vis[v] = 1;
	//int tot = 0;
	for (int e : g[v]) {
		if (vis[e] == 0) dfs(g, e);
	}
	return;

}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	vis.resize(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int ans = 0;
	
	for (int i = 0; i < n; i++) {
		total = 0;
		if (vis[i] == 0) dfs(g,i);
		
		ans = max(ans, total);
		
	}
	cout << ans;

}



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

int main(){
  string L;
  cin >> L;
  int N = 0, E = 0, W = 0, S = 0;
  for(int i = 0;i < L.size(); i++){
    if(L.at(i) == 'N'){
      N++;
    }
    if(L.at(i) == 'E'){
      E++;
    }
    if(L.at(i) == 'W'){
      W++;
    }
    if(L.at(i) == 'S'){
      S++;
    }
  }
  if((N != 0 && S != 0)||(N == 0 && S == 0)){
    if ((W != 0 && E != 0)||(W == 0 && E == 0)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>

#define INC(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define DEC(i, a, b) for(int (i) = (a); (i) > (b); --(i))
#define REP(i, n)    INC(i, 0, n)
#define comp(a, b) int comp(const void *(a), const void *(b))

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}

int abs(int x){
    return x > 0? x : -x;
}

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

int min(int a, int b){
    return a < b? a : b;
}


int main(){
    int Acost, Bcost, ABcost;
    int needA, needB;
    cin >> Acost >> Bcost >> ABcost >> needA >> needB;
    int ans = 0;
    int AandAB, BandAB, AandB;

    AandAB = 2 * ABcost * needB + max(0, needA - needB) * Acost;
    BandAB = 2 * ABcost * needA + max(0, needB - needA) * Bcost;
    AandB = Acost * needA + Bcost * needB;
    cout << min(AandAB, min(BandAB, AandB)) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        a: while(true){
            int N = sc.nextInt();
            if(N==0)break;
            TreeMap<Integer, Integer> map = new TreeMap<>();
            for(int i=0;i<N;i++){
                int a = sc.nextInt();
                int b = sc.nextInt();
                if(map.get(b)!=null){
                	map.put(b,a+map.get(b));
                }else{
                	map.put(b, a);
                }
            }
            int c=0;
            for (Entry<Integer, Integer> m : map.entrySet()) {
                c+=m.getValue();
                if(c>m.getKey()){
                    System.out.println("No");
                    continue a;
                }
            }
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 32796
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

class data{
public:
	int year;
	string name;
};

int main(){
	int N,Q;
	cin>>N>>Q;
	data dt[N];
	rep(i,N){
		cin>>dt[i].year>>dt[i].name;
	}	
	if(Q<dt[0].year){
		cout<<"kogakubu10gokan"<<endl;
	}else if(dt[N-1].year<=Q){
		cout<<dt[N-1].name<<endl;
	}else{
		rep(i,N-1){
			if(dt[i].year<=Q && Q<dt[i+1].year){
				cout<<dt[i].name<<endl;
				break;
			}
		}
	}
	return 0;
}

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

typedef long long int ll;

#define MAX 1000000007

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

    ll a[m];

    for (ll i=0 ; i<m ; i++) {
        cin >> a[i];
    }

    ll dp[n+1];

    for (ll i=0 ; i<n+1 ; i++) {
        dp[i] = 0;
    }

    sort(a, a+m);

    dp[0]=1;

    if (a[0]!=1) {
        dp[1] = 1;
    }

    if (a[0]!=2 && a[1]!=2) {
        dp[2] = dp[1] + dp[0];
    }

    for (ll i=0 ; i<m ; i++) {
        dp[a[i]] = -1;
    }


    ll m1=0, m2=0;

    for (ll i=3 ; i<=n ; i++) {

        ll flag=0;

        if (dp[i]!=-1) {


        m1 = (i-1);
        m2 = (i-2);

        flag=0;

        

        if (dp[i-1] != -1) {
            dp[i] = ((dp[i]%MAX) + (dp[i-1]%MAX))%MAX;
        }



        if (dp[i-2] != -1) {
            dp[i] = ((dp[i]%MAX) + (dp[i-2]%MAX))%MAX;
        }
        }
    }

    // cout << "dp array is " << endl;

    // for (ll i=0 ; i<n+1 ; i++) {
    //     cout << dp[i] << " ";
    // }
    // cout << endl;

        cout << (dp[n]%MAX) << endl;
    

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int s,w;
  cin>>s>>w;
  string ans="safe";
  if(w>=s){
    ans="unsafe";
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<string.h>

int main()
{
    int i, l, ind=0, count=0;
    char s[50];
    scanf("%s", s);
    l=strlen(s);
    if(s[0]!='A')
        ind=1;
    for(i=2;i<l-1;i++)
    {
        if(s[i]=='C')
            count++;
    }
    if(count!=1)
        ind=1;
    if(s[1]=='C'||s[l-1]=='C')
        ind=1;
    for(i=1;i<l;i++)
    {
        if('A'<=s[i]&&'Z'>=s[i]&&s[i]!='C')
        {
            ind=1;
            break;
        }
    }
    if(ind==0)
        printf("AC\n");
    else
        printf("WA\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int ans=0;
		int[] f = new int[a];
		for(int i=0;i<a;i++){
			f[i]=scan.nextInt();
		}
		Arrays.sort(f);
		int count=0;
		int p=0;
		while(true){
			while(true){
				if(f[p]==0){p++;}else{break;}
			}
			for(int l=p+1;l<a;l++){
				f[l]=f[l]%f[p];
				if(f[l]==0){count++;}
			}
			if(count==a-1-p){break;}
			Arrays.sort(f);
			count=0;
		}
		System.out.println(f[p]);
	}
}

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

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll a, b;
	cin >> a >> b;
	
	
	for(ll x = 1; x <= 100000; x++){
		ll A = x * 8 / 100;
		ll B = x * 10 / 100;
		
		if(A == a && B == b){
			cout << x << endl;
			return 0;
		}
	}
	
	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256