akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
  if(S.size()%2==1){
    cout<<NO<<endl;
    return;
  }
  REP(S.size()/2){
    if(S[2*i]!='h'||S[2*i+1]!='i'){
      cout<<NO<<endl;
      return;
    }
  }
  cout<<YES<<endl;
}

int main(){
  cout<<setprecision(1000);
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));
  list($t) = explode(" ", trim(fgets(STDIN)));

  $n=strlen($s);
  for($i=0;$i<$n;$i++){
    $ok=true;
    for($j=0;$j<$n;$j++){
      if($s[($j+$i)%$n]!==$t[$j]){
        $ok=false;
        break;
      }
    }
    if($ok){
      echo "Yes";
      exit;
    }
  }

  echo "No";

Measured memory_bytes: 16168
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

typedef long long int ll;
const int E_MAX = 102;
const int K_MAX = 4;

string n;
int k;

ll Choice(int l, int t){
    if (t < 0)return 0;
    ll ans = 1;
    for(int i = 0; i < t; i++)ans *= (l-i);
    for(int j = 1; j <= t; j++)ans /= j;
    return ans;
}

ll pow(int l, int t){
    ll ans = 1;
    for(int i = 0; i < t; i++)ans *= l;
    return ans;
}

int main(){
    cin >> n >> k;
    int e = n.length();
    ll ans = 0;
    for(int i = k; i >= 0; i--){
        int res = i;
        int now = 0;
        while(res > 0 && now < e){
            if (n[now] != '0')res--;   
            now++;         
        }
        while(n[now] == '0' && now < e)now++;
        if (now == e && res != 0)continue;
        else if (now == e){
            if (i == k)ans++;
            continue;
        }
        int num = n[now] - '0';
        ans += ((ll)num - 1) * Choice(e-1-now, k-i-1) * pow(9, k-i-1) + Choice(e-1-now, k-i) * pow(9, k-i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long X = input.nextLong();
		long yokin = 100;
		int i=0;
		
		for(i=0;yokin<X;i++) {
			yokin+= (long)(yokin*0.01);
		}
		System.out.println(i);
	}
}


Measured memory_bytes: 35576
def c_coloring_colorfully(S):
    ans1 = S[::2].count('0') + S[1::2].count('1')  # 1010...と一致しない数字の数
    ans2 = S[::2].count('1') + S[1::2].count('0')  # 0101...と一致しない数字の数
    return min(ans1, ans2)

S = input()
print(c_coloring_colorfully(S))

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

int64_t gcd(int64_t X, int64_t Y){
  int64_t X0=max(X, Y);
  int64_t Y0=min(X, Y);
  if(X0%Y0==0){
    return Y0;
  }
  else{
    return gcd(Y0, X0%Y0);
  }
}

int64_t isprime(int64_t X){
  int64_t S=(int64_t)sqrt(X);
  int64_t Ans=1;
  for(int64_t i=2; i<=S; i++){
    if(X%i==0){
      Ans=0;
      break;
    }
  }
  return Ans;
}

int main(){
  int64_t Ans=0;
  int64_t A, B;
  cin >> A >> B;
  int64_t L=gcd(A, B);
  for(int64_t i=2; i<=min(L, (int64_t)1000000); i++){
    if(isprime(i)==1 && L%i==0){
      Ans++;
      while(L%i==0){
        L=L/i;
      }
    }
  }
  for(int64_t i=L; i>1000000; i--){
    if(isprime(i)==1 && L%i==0){
      Ans++;
      while(L%i==0){
        L=L/i;
      }
      i=L+1;
    }
  }
  cout << Ans+1 << endl;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

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

    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    int now = 0, ans1 = 0, ans2 = 0;

    while(now < N)
    {
        ans1 += B;
        now += A;
    }

    now = 0;

    while(now < N)
    {
        ans2 += D;
        now += C;
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    int a[n], b[n];
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        cin >> b[i];
    }
    int ans = 0;
    int ma[n], mb[n];
    for (int i = 0; i < 30; i++) {
        int T = 1 << i;
        rep(i, n) {
            ma[i] = a[i] % (2 * T);
        }
        rep(i, n) {
            mb[i] = b[i] % (2 * T);
        }
        sort(mb, mb + n);
        ll sum = 0;
        rep(i, n) {
            sum += lower_bound(mb, mb + n, 2 * T - ma[i]) -
                   lower_bound(mb, mb + n, T - ma[i]);
            sum += lower_bound(mb, mb + n, 4 * T - ma[i]) -
                   lower_bound(mb, mb + n, 3 * T - ma[i]);
        }
        if (sum % 2 == 1) {
            ans += T;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6688
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r,idx;
ll x[500005],y[500005],z[500005];
char s[500005],t[500005];
//bool used[500005];
bool flag,dame;


int main(){
	for(i=0;i<3;i++){
        cin >> x[i];
    }
    sort(x,x+3);
    p(x[0] + x[1]);

	return 0;
}

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

using namespace std;

typedef long long ll;

//{{{ Fast IO
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

const int MAXN = 200010;
const int mod = 924844033;

inline int fsp(int x, int k = mod - 2) {
	int s = 1;
	while(k) {
		if(k & 1) s = 1LL * s * x % mod;
		x = 1LL * x * x % mod, k >>= 1;
	} return s;
}

vector<int>to[MAXN];
int sz[MAXN];
int c[MAXN];

int ifac[MAXN];
int fac[MAXN];

inline int C(int n, int m) { return n < m ? 0 : 1LL * fac[n] * ifac[m] % mod * ifac[n - m] % mod; }
inline void binom_init(int n) {
	ifac[0] = fac[0] = 1;
	for(int i = 1; i <= n; i++)
		ifac[i] = fsp(fac[i] = 1LL * fac[i - 1] * i % mod);
}

inline void dfs(int x, int la) {
	sz[x] = 1;
	for(auto u : to[x])
		if(u != la)
			dfs(u, x), sz[x] += sz[u];
}

int f[540000];
int g[540000];
int p[540000];
int N, invN;

inline void NTT_init(int n) {
	N = 1; while(N < (n << 1)) N <<= 1; invN = fsp(N);
	for(int i = 1; i < N; i++) p[i] = (p[i >> 1] >> 1) | (i & 1 ? N >> 1 : 0);
}

inline void NTT(int a[], int k) {
	for(int i = 1; i < N; i++)
		if(i < p[i]) swap(a[i], a[p[i]]);
	for(int l = 2; l <= N; l <<= 1) {
		int len = l >> 1;
		int delta = fsp(5, (mod - 1) / l);
		for(int i = 0; i < N; i += l) {
			int g = 1;
			for(int j = i; j < i + len; j++) {
				int tmp = 1LL * g * a[j + len] % mod;
				a[j + len] = (a[j] + mod - tmp) % mod;
				a[j] = (a[j] + tmp) % mod;
				g = 1LL * g * delta % mod;
			}
		}
	} if(~k) return ; reverse(a + 1, a + N);
	for(int i = 0; i < N; i++) a[i] = 1LL * a[i] * invN % mod;
}

int main() {
#ifdef LOCAL
	FILE("");
#endif
	int n = ri; binom_init(n), NTT_init(n);
	for(int i = 1; i < n; i++) {
		int u = ri, v = ri;
		to[u].push_back(v);
		to[v].push_back(u);
	} dfs(1, 0), c[n] = -1;
	for(int i = 1; i <= n; i++) c[sz[i]]++, c[n - sz[i]]++;
	for(int i = 0; i <= n; i++) f[i] = 1LL * c[i] * fac[i] % mod;
	for(int i = 0; i <= n; i++) g[i] = ifac[n - i];
	NTT(f, 1), NTT(g, 1);
	for(int i = 0; i < N; i++) f[i] = 1LL * f[i] * g[i] % mod;
	NTT(f, -1);
	for(int i = 1; i <= n; i++) {
		int res = (1LL * C(n, i) * n + 1LL * (mod - ifac[i]) * f[i + n]) % mod;
		printf("%d\n", res);
	} return 0;
}

Measured memory_bytes: 28160
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    ll r, d, x_2000;
    cin >> r >> d >> x_2000;
    for (int i = 2001; i <= 2010;i++)
    {
        x_2000 = r * x_2000 - d;
        cout << x_2000 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using ld = long double;
int main()
{
	int N;
	cin >> N;
	ld res = (N + 1) / 2;
	res /= N;
	cout << fixed << setprecision(12) << res << endl;
	return 0;
}


Measured memory_bytes: 764
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  int a[2][N];
  int bottom_total = 0;
  for (int i = 0; i < N; ++i)
    cin >> a[0][i];
  for (int i = 0; i < N; ++i) {
    cin >> a[1][i];
    bottom_total += a[1][i];
  }

  int total_top[N];
  int total_bottom_back[N];
  for (int i = 0; i < N; ++i) {
    total_top[i] = a[0][i];
    total_bottom_back[i] = a[1][i];
    if (i > 0) {
      total_top[i] += total_top[i - 1];
      total_bottom_back[i] += total_bottom_back[i - 1];
    }
  }

  int total_bottom[N];
  for (int i = 0; i < N; ++i) {
    total_bottom[i] = bottom_total - total_bottom_back[i] + a[1][i];
  }

  int max_candies = 0;
  for (int i = 0; i < N; ++i) {
    max_candies = max(max_candies, total_top[i] + total_bottom[i]);
  }

  cout << max_candies << endl;
}

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

// 頂点の状態を管理する。pair<最短距離, pair<頂点番号、到達時間のMOD3>>
using P = pair<int, pair<int, int>>;
using Graph = vector<vector<int>>;

int mod = 3;

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

    Graph G(N);
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        // G[v].push_back(u);
    }

    int S, T;  // start, end
    cin >> S >> T;
    S--; T--;

    // dist[v][k] ... 頂点vにp(mod)回で到達する際の最短距離
    vector<vector<int>> dist(N, vector<int>(mod, INT_MAX));

    // 初期値のセット
    dist[S][0] = 0;

    // 最短頂点候補を保持するキュー
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, {S, 0}));

    // 拡張ディクストラ
    while (!que.empty()) {
        auto p = que.top();
        que.pop();

        int v = p.second.first;
        int k = p.second.second;

        if (dist[v][k] < p.first) continue;

        for (auto nv : G[v]) {
            int nk = (k + 1) % mod;
            if (dist[nv][nk] > dist[v][k] + 1) {
                dist[nv][nk] = dist[v][k] + 1;
                que.push(P(dist[nv][nk], {nv, nk}));
            }
        }
    }

    if (dist[T][0] != INT_MAX) cout << dist[T][0] / 3 << endl;
    else cout << -1 << endl;
}

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

vector <int> xaxis;
vector <int> yaxis;
bool dpx[8001][16001];
bool dpy[8001][16001];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	int gx,gy;
	int x=0,y=0;

	cin >> s;
	cin >> gx >> gy;

	int flag = 0;
	int cnt = 0;
	bool num = 0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='F')
		{
			cnt++;
		}
		else
		{
			if(flag==0)
			{
				if(num!=0)
				{
					if(cnt!=0)
					{
						xaxis.push_back(cnt);
						cnt = 0;
					}
				}
				else
				{
					if(cnt!=0)
					{
						x += cnt;
						cnt = 0;
					}
				}
				flag = 1;
				num++;
			}
			else
			{
				if(cnt!=0)
				{
					yaxis.push_back(cnt);
					cnt = 0;
				}
				flag = 0;
				num++;
			}
		}
	}

	if(cnt!=0)
	{
		if(flag==0)
		{
			if(num==0)
			{
				x+=cnt;
			}
			else
			{
				xaxis.push_back(cnt);
			}
		}
		else
		{
			yaxis.push_back(cnt);
		}
	}

	memset(dpx,false,sizeof(dpx));
	memset(dpy,false,sizeof(dpy));
	//cout << xaxis[0] << '\n';

	dpx[0][x+8000] = true;
	dpy[0][y+8000] = true;

	for(int i=0;i<xaxis.size();i++)
	{
		for(int j=0;j<=16000;j++)
		{
			if(dpx[i][j]==false)
			{
				continue;
			}

			if(j-xaxis[i]>=0)
			{
				dpx[i+1][j-xaxis[i]] = true;
			}
			if(j+xaxis[i]<=16000)
			{
				dpx[i+1][j+xaxis[i]] = true;
			}
		}
	}

	for(int i=0;i<yaxis.size();i++)
	{
		for(int j=0;j<=16000;j++)
		{
			if(dpy[i][j]==false)
			{
				continue;
			}

			if(j-yaxis[i]>=0)
			{
				dpy[i+1][j-yaxis[i]] = true;
			}
			if(j+yaxis[i]<=16000)
			{
				dpy[i+1][j+yaxis[i]] = true;
			}
		}
	}	


	if(dpx[xaxis.size()][gx+8000] && dpy[yaxis.size()][gy+8000])
	{
		cout << "Yes" << '\n';
	}
	else
	{
		cout << "No" << '\n';
	}

	return 0;	
}	

Measured memory_bytes: 250496
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define N 2005
#define mod 924844033
using namespace std;
inline int read()
{
    char c=getchar(); int num=0,f=1;
    while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
    while (c<='9'&&c>='0') { num=num*10+c-'0'; c=getchar(); }
    return num*f;
}
int n,k,jc[N],tot,f[N<<1][N][2],ans;
bool lk[N<<1];
int main()
{
    n=read(); k=read();
    jc[0]=1; for (int i=1;i<=n;i++) jc[i]=1ll*jc[i-1]*i%mod;
    for (int i=1;i<=k;i++)
    {
        tot++; for (int j=i+k;j<=n;j+=k) lk[++tot]=true; 
        tot++; for (int j=i+k;j<=n;j+=k) lk[++tot]=true; 
    }
    f[0][0][0]=1;
    for (int i=0;i<n<<1;i++)
     for (int j=0;j<=min(i,n);j++)
     {
         f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%mod;
         if (lk[i+1]) f[i+1][j+1][1]=f[i][j][0];
     }
    for (int i=0;i<=n;i++)
    {
        int tmp=1ll*(f[2*n][i][0]+f[2*n][i][1])*jc[n-i]%mod;
        if (i&1) ans=(ans-tmp+mod)%mod;
         else ans=(ans+tmp)%mod;
    }
    printf("%d",ans);
    return 0;
}


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

int n;
string s;
bool ok(vector<bool> &is_sheep, bool s1, bool s2) {
  is_sheep[0] = s1;
  is_sheep[1] = s2;
  for (int i=1; i<n-1; i++) {
    if (is_sheep[i]) {
      if (s[i] == 'o') {
        is_sheep[i+1] = is_sheep[i-1];
      } else {
        is_sheep[i+1] = !is_sheep[i-1];
      }
    } else {
      if (s[i] == 'o') {
        is_sheep[i+1] = !is_sheep[i-1];
      } else {
        is_sheep[i+1] = is_sheep[i-1];
      }
    }
  }
  if (is_sheep[n-1]) {
    if (s[n-1] == 'o' ^ is_sheep[0] == is_sheep[n-2]) {
      return false;
    }
  } else {
    if (s[n-1] == 'x' ^ is_sheep[0] == is_sheep[n-2]) {
      return false;
    }
  }
  if (is_sheep[0]) {
    return s[0] == 'o' ^ is_sheep[n-1] != is_sheep[1];
  } else {
    return s[0] == 'x' ^ is_sheep[n-1] != is_sheep[1];
  }
}
int main() {
  cin>>n;
  cin>>s;
  vector<bool> is_sheep(n);
  bool state[2] = {true, false};
  for (bool s1: state) {
    for (bool s2: state) {
      if (ok(is_sheep, s1, s2)) {
        for (bool b: is_sheep) {
          if (b) {
            cout<<"S";
          } else {
            cout<<"W";
          }
        }
        cout<<endl;
        return 0;
      }
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 512
// abc169_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif
    
    int A, B;
    cin >> A >> B;
    
    print(A*B);


    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		string s;
		while(n){
			s=s+char('0'+n%8);
			n/=8;
		}
		reverse(allof(s));
		rep(i,s.size()){
			if(s[i]=='4')
				s[i]++;
			else if('5'<=s[i])
				s[i]+=2;
		}
		cout<<s<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
vector<vector<char>> cell;
vector<vector<long long>> dp;
long long mod = 1000000007;

int main()
{
	int H, W;
	cin >> H >> W;
	cell.resize(H);
	dp.resize(H);
	for (int i = 0; i < cell.size(); i++) {
		string tmp;
		cin >> tmp;
		cell[i].resize(W);
		for (int j = 0; j < tmp.size(); j++) {
			cell[i][j] = tmp[j];
			dp[i].push_back(0);
		}
		
	}

	dp[0][0] = 1;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i == 0 && j == 0) continue;
			long long tmp =0;
			if (i-1 >= 0 && cell[i - 1][j] != '#') {
				tmp +=  dp[i - 1][j];
			}
			
			if(j-1 >= 0 && cell[i][j-1] != '#') {
				tmp +=  dp[i][j - 1];
			}
			dp[i][j] = tmp%mod;
		}
	}
	cout << dp[H - 1][W - 1]<< endl;

	return 0;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1e7+5,Mod=998244353;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,Fac[MAXN],iFac[MAXN],Fpow[MAXN];
inline int Fp(int x,int k){int ans=1;for(;k;k>>=1,x=1ll*x*x%Mod)if(k&1)ans=1ll*ans*x%Mod;return ans;}
inline int C(int n,int m){return n<0||m<0||n<m?0:1ll*Fac[n]*iFac[m]%Mod*iFac[n-m]%Mod;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();
	Fac[0]=Fpow[0]=1;Rep(i,1,n)Fac[i]=1ll*Fac[i-1]*i%Mod,Fpow[i]=(Fpow[i-1]<<1)%Mod;
	iFac[n]=Fp(Fac[n],Mod-2);Red(i,n,1)iFac[i-1]=1ll*iFac[i]*i%Mod;
	int ans=0;Rep(i,n/2+1,n)ans=(ans+1ll*C(n,i)*Fpow[n-i])%Mod;ans=ans*2%Mod;
	ans=(Fp(3,n)-ans+Mod)%Mod,cout<<ans<<'\n';
	return 0;
}




Measured memory_bytes: 120716
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    ll n;
    cin >> n;
    vector <ll> a(n+1);
    rep(i,1,n+1) {
        cin >> a[i];
    }
    vector <ll> dp(n+1);
    dp[1] = 1000;
    rep(i,2,n+1) {
        dp[i] = dp[i-1];
        rep(j,1, i) {
            ll c = dp[j] / a[j];
            ll m = dp[j] + (a[i] - a[j]) * c;
            dp[i] = max(dp[i], m);
        }
    }
    cout << dp[n] << endl;;
    return 0;
}

Measured memory_bytes: 3176
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=1000000007;
inline int ad(int x){return x>=mod?x-mod:x;}
inline int dec(int x){return x<0?x+mod:x;}
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
int cnt[510],f[510][510][510];
int fac[510],inv[510];
inline int C(int n,int m){return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	fac[0]=1;
	for(int i=1;i<=500;i++)fac[i]=1LL*fac[i-1]*i%mod;inv[500]=power(fac[500],mod-2);
	for(int i=500;i>=1;i--)inv[i-1]=1LL*inv[i]*i%mod;
	int n=read(),m=read();
	for(int i=1;i<=n;i++)cnt[read()]++;
	f[m+1][0][0]=1;
	for(int i=m;i>=1;i--)
	{
		for(int j=0;j<=m;j++)
		{
			for(int k=0;k-1+j<=m;k++)
			{
				if(!f[i+1][j][k])continue;
				for(int u=0;u*i+j+u+k-1<=m;u++)
				{
					int w1=u*i+j,w2=u+k;
					f[i][w1][w2]=ad(f[i][w1][w2]+1LL*f[i+1][j][k]*power(w1-w2*(i-1),cnt[i])%mod*inv[u]%mod);
				}
			}
		}
	}
	int ans=0;
	for(int i=0;i<=m;i++)
	{
		int sum=0;
		for(int j=1;j-1+i<=m;j++)sum=ad(sum+1LL*f[1][i][j]*C(m-i+1,j)%mod*fac[j]%mod);
		if((m-i)&1)ans=dec(ans-sum);
		else ans=ad(ans+sum);
	}
	pr2(ans);
	return 0;
}

Measured memory_bytes: 509056
N = int(input())
S = input()

str_dict = {}
for i in range(26):
    s = (i + N) % 26 + ord('A')
    str_dict[chr(ord('A') + i)] = chr(s)

new_str = []
for i in S:
    new_str.append(str_dict[i])

s = ''.join(new_str)

print(s)




Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

signed main(){
  int a,b,c;
  string s;
  int n;
  int A,B;
  cin>>A>>B>>a>>b;
  cout<<max(0LL,A*B-(a*B)-((b)*(A-a)))<<endl;
}

Measured memory_bytes: 256
class Array
  def score_abc140
    n = size
    self << 0
    res = 0
    n.times{|i| res += 1 if self[i+1] == self[i] }
    res
  end
end

n, k = gets.to_s.split.map{|t| t.to_i }
s = gets.chomp.bytes

puts [ s.score_abc140 + 2 * k, n - 1].min 

Measured memory_bytes: 2812
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

// int main() {
//     int N;
//     string s, t;
//     cin >> N >> s >> t;
//     string tmp = s + t;
//     int idx = 1, sep = s.size();
//     bool flag = false;
//     int ans = 0;
//     while (true) {
//         string right = tmp.substr(sep, idx);
//         string left = tmp.substr(sep - idx, idx);
//         if (right == left) flag = true;
//         if (flag && right != left) {
//             cout << tmp.size() - ans << endl;
//             return 0;
//         }
//         if (sep - idx < 0 || sep + idx >= tmp.size()) {
//             if (flag) ans += 1;
//             cout << tmp.size() - ans << endl;
//             return 0;
//         }
//         idx += 1;
//         ans += 1;
//     }
//     cout << tmp.size() << endl;
//     return 0;
// }

int main() {
    int N;
    string s, t;
    cin >> N >> s >> t;
    int cnt = 0;
    rep(i, N) {
        string left = s.substr(N - i - 1, i + 1);
        string right = t.substr(0, i + 1);
        if (right == left) cnt = i + 1;
    }
    cout << 2*N - cnt << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;
using mat2d_t = std::vector<std::vector<int64_t>>;



int main(int argc, char **argv) {
    int a, b, m, small_a{int_max}, small_b{int_max};
    cin >> a >> b >> m;
    std::vector<int> as(a), bs(b);
    for (int i=0; i<a; ++i) {
        int a;
        cin >> a;
        as[i] = a;
        small_a = min(a, small_a);
    }
    for (int i=0; i<b; ++i) {
        int b;
        cin >> b;
        bs[i] = b;
        small_b = min(b, small_b);
    }
    int ans = small_a + small_b;

    for (int i=0; i<m; ++i) {
        int x, y, c;
        cin >> x >> y >> c;
        --x;
        --y;
        int sum = as[x] + bs[y] - c;
        ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;
map<int,int>t;
int n,a,s;
main(){
    cin>>n;
    while(cin>>a){
        s+=t[a]*-2+1;
        t[a]=!t[a];
    }
    cout<<s<<endl;
}

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

int main () {
  int N;
  cin >> N;
  
  if (N == 1){
    cout << 1 << endl;
    return 0;
  }
  
  vector<int>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  int count = 1;
  int sum = 0;
  for (int i = 0; i < N-1; i++) {
    if (A.at(i) == A.at(i+1)){
      count++;
      if (i == N-2){
        if (count % 2 == 1){
          sum++;
        }
      }
    }
    else {
      if (count % 2 == 1){
        sum++;
      }
      if (i == N-2){
        sum++;
      }
      count = 1;
    }
  }
  cout << sum << endl;
}
      
      

Measured memory_bytes: 3744
from math import sqrt

while True:
    e = int(raw_input())

    if e == 0: break
    z, ans = 0, e

    while z ** 3 <= e:
        y = int(sqrt(e - z**3))
        x = e  - y**2 - z**3
        ans = min(ans, x + y + z)
        z += 1

    print ans



Measured memory_bytes: 4708
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

int main() {
  
  long long n,a,b;
  cin >> n >> a >> b;

  
const int MAX = 200100;
vector<long long> fac(MAX,1),finv(MAX,1),inv(MAX,1);
for(int i = 2;i < MAX;i++) {
    fac.at(i) = fac.at(i-1) * i % MOD;
    inv.at(i) = MOD - inv.at(MOD%i) * (MOD/i) % MOD;
    finv.at(i) = finv.at(i-1) * inv.at(i) % MOD;
}

vector<long long> com(200010,1);
for(int i = 0;i <= b;i++) {
    com[i+1] = com[i]*((n-i)*inv.at(i+1)%MOD)%MOD;
}

long long r = modpow(2,n,MOD);
if(n == 2 && a == 1 && b == 2) cout << 0 << endl;
else cout << mod(r%MOD-(1+com[a]+com[b])%MOD,MOD) << endl;


}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    int n;cin >> n;vector<char> v(n);int w = 0, r = 0;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        if (v[i] == 'R')r++;
        if (v[i] == 'W')w++;
    }
    int s = 0;
    for (int i = 0; i < r; i++)if(v[i] == 'W')s++;
    cout << min(r, min(w, s));
}

Measured memory_bytes: 3536
# -*- coding: utf-8 -*-
import sys

def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))
    

    A_list.sort(key=lambda x: -abs(x))
    A_plus = []
    A_minus = []
    mod = 10**9 + 7

    for val in A_list:
        if val >= 0:
            A_plus.append(val)
        else:
            A_minus.append(val)
    

    if (not A_plus):
        if (K % 2 == 0):
            target_range = range(K)
        else:
            target_range = range(len(A_minus)-K, len(A_minus))

        ans = 1

        for i in target_range:
            ans *= A_minus[i]
            ans %= mod
        
        print(ans)
        return


    if (not A_minus):
        ans = 1

        for i in range(K):
            ans *= A_plus[i]
            ans %= mod
        
        print(ans)
        return


    select = []
    i_p = 0  # index of A_plus
    i_m = 0  # index of A_minus


    while (len(select) < K):
        if (K - len(select)) == 1:
            if i_p < len(A_plus):
                select.append( A_plus[i_p] )
                i_p += 1
                break
            
            else:
                ans = 1

                for i in range( len(A_list)-K, len(A_list) ):
                    ans *= A_list[i]
                    ans %= mod

                print(ans)
                return


        if (i_m + 1) < len(A_minus):
            if (i_p + 1) < len(A_plus):
                if abs( A_plus[i_p] * A_plus[i_p + 1] ) > abs( A_minus[i_m] * A_minus[i_m + 1] ):
                    select.append( A_plus[i_p] )
                    i_p += 1
                else:
                    select.extend( [ A_minus[i_m] , A_minus[i_m + 1] ] )
                    i_m += 2

            else:
                select.extend( [ A_minus[i_m] , A_minus[i_m + 1] ] )
                i_m += 2
            
        else:
            select.append( A_plus[i_p] )
            i_p += 1
    

    ans = 1
 
    for i in range(K):
        ans *= select[i]
        ans %= mod
    
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 31912
#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define NIL -1
const int MOD = 1e9+7;
const int INF = 1 << 29;
int n,m;
int main(){
    cin>>n>>m;
    ll count=(1900*m+100*(n-m))*pow(2,m);
    cout<<count<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    cout << "A" << b[0] << "C" << endl;

    return 0;
}

Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

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

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int h,w;
int table[81][81], t;

set<int> pos[81][81];
bitset<26000> dp[81], pv[81];
signed main(){
    I(h); I(w);
    REP(i,h) REP(j,w) I(table[i][j]);
    REP(i,h) REP(j,w){
        I(t);
        table[i][j] = abs(table[i][j] - t);
    }
    dp[0][13000] = 1;
    REP(i,h){
        REP(j,w){
            dp[j+1] |= (dp[j] << table[i][j]);
            dp[j+1] |= (dp[j] >> table[i][j]);
            dp[j+1] |= (pv[j+1] >> table[i][j]);
            dp[j+1] |= (pv[j+1] << table[i][j]);
            // cerr << i << " " << j << endl;
        }
        REP(j,w) pv[j+1] = dp[j+1];
        REP(j,w+1) dp[j] ^= dp[j];
    }
    int ret = INT64_MAX;
    REP(ind,26000) if(pv[w][ind]) ret = min(ret, abs(13000-ind));
    cout << ret << endl;
}

Measured memory_bytes: 1152
import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,m = map(int,readline().split())

if n == m:
    print("Draw")
elif n==1 or m == 1:
    if n ==1:
        print("Alice")
    else:
        print("Bob")
else:
    if n > m:
        print("Alice")
    else:
        print("Bob")

Measured memory_bytes: 38256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

LL dp[30000000];
int gsb[2][3];

LL f(int p, int q, int n) {
	REP(i, n + 1)dp[i] = i;
	REP(i, n+1) {
		REP(j, 3) {
			if (i >= gsb[p][j])dp[i] = max(dp[i], dp[i - gsb[p][j]] + gsb[q][j]);
		}
	}
	return dp[n];
}

int main() {
	LL n;
	scanf("%lld", &n);
	REP(i, 2)REP(j, 3)scanf("%d", &gsb[i][j]);
	n = f(0, 1, n);
	n = f(1, 0, n);
	printf("%lld\n", n);
	return 0;
}

Measured memory_bytes: 196864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N;
ll dp[3000+5][3000+5][2];
ll arr[3000+5];

/* (i, j) -> max(A[i]+(i+1, j), A[j]+(i,j-1))
solve(i, j, c) -> c*max(arr[i] + solve(i+1, j, 1-c), arr[j] + solve(i, j-1, 1-c)) +
			(1-c)*min(arr[i] + solve(i+1, j, 1-c), arr[j] + solve(i, j-1, 1-c));
				
ll solve(ll i, ll j, ll c, ll X, ll Y){
	if (i > j) return X-Y;
	
	//if(dp[i][j][c] != -1) return dp[i][j][c];
	
	ll ans;
	if (c)
		ans = max(solve(i+1, j, 1-c, X+arr[i], Y), solve(i, j-1, 1-c, X+arr[j], Y));
	else
		ans = min(solve(i+1, j, 1-c, X, Y+arr[i]), solve(i, j-1, 1-c, X, Y+arr[j]));
	return ans;
}*/

ll solve(ll i, ll j, ll c){
	if (i > j) return 0;
	
	if(dp[i][j][c] != -1) return dp[i][j][c];
	if (c)
		dp[i][j][c] = max(arr[i]+solve(i+1, j, 1-c), arr[j]+solve(i, j-1, 1-c));
	else
		dp[i][j][c] = min(solve(i+1, j, 1-c)-arr[i], solve(i, j-1, 1-c)-arr[j]);
	return dp[i][j][c];
}
			

int main(){
	cin>>N;
	for(ll i = 0;i<N;i++)cin>>arr[i];
	
	memset(dp, -1, sizeof dp);
	
	cout<<solve(0,N-1, 1)<<endl;
}	

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

namespace ABC046A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            if (a == b && b == c)
                Console.WriteLine("1");
            else if (a == b || a == c || b == c)
                Console.WriteLine("2");
            else
                Console.WriteLine("3");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int n; cin >> n;
   V<int> C(n);
   for (int i = 0; i < n; i++) {
      cin >> C[i];
   }

   V<int> prev(n, -1);
   map<int,int> last;
   for (int i = 0; i < n; i++) {
      last[C[i]] = -1;
   }
   for (int i = 0; i < n; i++) {
      prev[i] = last[C[i]];
      last[C[i]] = i;
   }

   V<int> dp(n+1);
   dp[0] = 1;
   for (int i = 0; i < n; i++) {
      dp[i+1] = (dp[i] + (prev[i] != -1 && prev[i] != i-1 ? dp[prev[i]+1] : 0)) % MOD;
   }
   cout << dp[n] << endl;

   return 0;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
 
long ryuka(int N){
  vector<long> L(N + 1);
  L.at(0) = 2; L.at(1) = 1;
  if(N > 1){
    for (int i = 2; i < N + 1; i++){
      L.at(i) = L.at(i-2) + L.at(i-1);
    }
  }
  return L.at(N);
}
 
int main() {
  long N;
  cin >> N;
  cout << ryuka(N) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,a[1000],i,count,j,s=0;
   cin>>n;
   for(i=0;i<n;i++)
        cin>>a[i];
   for(i=1;i<n;i++)
   {
       count=0;
        for(j=0;j<i;j++)
            if(a[i]>=a[j])
                count++;
        if(count==i)
            s++;
   }
   cout<<s+1<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
ans = 0
f = True
while f:
    f = False
    e = True
    for i in range(n):
        if h[i] > 0:
            h[i] -= 1
            if e:
                ans += 1
            f = True
            e = False
        else:
            e = True
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define pb push_back
#define all(a) a.begin(),a.end()
#define i64 long long int
const double pi = 2*acos(0) ;
const int maxn = (i64)2e5+5;

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int i ,sum = 0;
    for(i = 0 ; i<3 ; i++)
    {
        if(s1[i] == s2[i]) sum++;
    }
    cout<<sum;


return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
l = []
for i in range(m):
    l.append([i] + list(map(int, input().split())))
l.sort(key=lambda x: (x[1], x[2]))
ans = []
pref = -1
for i in l:
    if pref != i[1]:
        cnt = 1
    pref = i[1]
    ans.append((i[0], i[1], cnt))
    cnt += 1
ans.sort()
for _, a, b in ans:
    print(str(a).zfill(6)+str(b).zfill(6))

Measured memory_bytes: 40832
h,w=map(int,input().split())
s=[list(input())for _ in range(h)]
score=[[0]*w for _ in range(h)]
ans=0
range_w=range(w)
range_h=range(h)
for i in range_h:
  tmp_1=0
  tmp_2=0
  for j in range_w:
    if s[i][j]=="#":
      tmp_1=0
    else:
      tmp_1+=1
    score[i][j]+=tmp_1
    
    if s[i][-j-1]=="#":
      tmp_2=0
    else:
      tmp_2+=1
    score[i][-j-1]+=tmp_2
    
for j in range_w:
  tmp_3=0
  tmp_4=0
  for i in range_h:
    if s[i][j]=="#":
      tmp_3=0
    else:
      tmp_3+=1
    score[i][j]+=tmp_3
    
    if s[-i-1][j]=="#":
      tmp_4=0
    else:
      tmp_4+=1
    score[-i-1][j]+=tmp_4-3
for i in range(h):
  for j in range(w):
    ans=max(ans,score[i][j])
print(ans)

Measured memory_bytes: 214920
package main

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

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

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	s := scanText()
	if []byte(s)[0]-'a' > 26 {
		fmt.Println("A")
	} else {
		fmt.Println("a")
	}
}


Measured memory_bytes: 1772