akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

long long dsum(long long a) {
  long long res = 0;
  while (a) {
    res += a % 10;
    a /= 10;
  }
  return res;
}

int main() {
  vector<long long> candidates;
  for (int i = 1; i <= 10000; i++) {
    long long bs = i;
    while (bs <= 10000000000000000ll) {
      candidates.push_back(bs);
      bs *= 10;
      bs += 9;
    }
  }
  sort(candidates.begin(), candidates.end());
  candidates.resize(unique(candidates.begin(), candidates.end()) - candidates.begin());
  vector<bool> valid(candidates.size(), true);
  double bestValue = 1e60;
  for (int i = candidates.size() - 1; i >= 0; i--) {
    double cur = (double)candidates[i] / dsum(candidates[i]);
    valid[i] = (bestValue >= cur);
    bestValue = min(bestValue, cur);
  }
  int K;
  scanf("%d", &K);
  int cnt = 0;
  for (int i = 0; i < candidates.size() && cnt < K; i++) {
    if (!valid[i]) continue;
    printf("%lld\n", candidates[i]);
    cnt++;
  }
  return 0;
}


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

int main(){
  map<string, int> scores;

  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    string s_;
    cin >> s_;
    scores[s_]++;
  }

  int M;
  cin >> M;
  for(int i = 0; i < M; i++){
    string t_;
    cin >> t_;
    scores[t_]--;
  }

  int ans = 0;
  for(auto x: scores){
    ans = max(ans, x.second);
  }
  cout << ans << endl;
}


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

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

  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << endl;
    exit(0);
  }

  if (k % 7 == 0) {
    L = 9 * k / 7;
  } else {
    L = 9 * k;
  }

  bool flag = true;
  int i = 1;
  int amari = 10;
  while (flag) {
    if (i == k) {
      flag = false;
    }
    amari = amari % L;
    if (amari == 1) {
      flag = false;
      cout << i << endl;
    }
    i++;
    amari = amari * 10;
  }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
long long o[431];
int l[103331];
int j[3331];

long long x,y,z,mod=1000000007;
//string r;
char r[1];

P u[1];
priority_queue<P> q;
//stack<int> s;
set<int> s;
map<long long,int> p;

vector<int> v[100101];

bool as(P a,P b)
{
  //if(a.x!=b.x)
  //return a.x<b.x;
  return a.x<b.x;
}

long long f(long long x)
{
  int o[4],l[4];
  l[0]=o[0]=x/1000000000;
  l[1]=o[1]=x/1000000%1000;
  l[2]=o[2]=x/1000%1000;
  l[3]=o[3]=x%1000;
  for(int i=1;i<=3;i++)
  {
    for(int h=0;h<4;h++)
    if(o[(i+h)%4]>l[h]) break;
    else if(o[(i+h)%4]<l[h])
    {
      for(int p=0;p<4;p++)
        l[p]=o[(p+i)%4];
      break;
    }
  }
  long long z=0;
  for(int h=0;h<4;h++)
    z*=1000,z+=l[h];
  return z;
}

int g(long long x)
{
  int n=x/1000000000,m=x/1000000%1000,c=x/1000%1000,d=x%1000;
  if(n==m&&m==c&&c==d) return 4;
  if(n==c&&m==d) return 2;
  return 1;
}

int main()
{
  scanf("%d",&a);
  for(int t=1;t<=a;t++)
  {
    long long x=0;
    for(int i=0;i<4;i++)
    {
      x*=1000;
      scanf("%d",&n);
      x+=n;
    }
    o[t]=f(x);
  }
  for(int t=1;t<a;t++)
  for(int w=t+1;w<=a;w++)
  {
    map<long long,int> p;
    for(int i=t+1;i<=a;i++)
    if(i!=w) p[o[i]]++;
    long long l1[4],l2[4];
    long long s[4];
    l1[0]=o[t]/1000000000,l1[1]=o[t]/1000000%1000,l1[2]=o[t]/1000%1000,l1[3]=o[t]%1000;
    l2[2]=o[w]/1000000000,l2[1]=o[w]/1000000%1000,l2[0]=o[w]/1000%1000,l2[3]=o[w]%1000;
    for(int i=0;i<4;i++)
    {
      for(int h=0;h<4;h++)
      {
        s[h]=l1[(h+1)%4]*1000000000+l1[(h)%4]*1000000+l2[(h+i)%4]*1000+l2[(h+1+i)%4];
        s[h]=f(s[h]);
        //if(t==1&&w==5&&i==0)
        //printf("@@%lld %d\n",s[h],p[s[h]]);
      }
      long long y=1;
      for(int h=0;h<4;h++)
      {
        int e=0;
        for(int i=0;i<h;i++)
          if(s[i]==s[h])e++;
        y*=(p[s[h]]-e);
        y*=g(s[h]);
      }
      //if(t==1&&w==5)
      x+=y;
    }
  }
  printf("%lld",x);
}
//0
//21




Measured memory_bytes: 2688
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l  
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |   
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) reverse((a).begin(),(a).end())
#define REP(i, n) for(int i = 0; i < n; i++)
const int MOD = 1e9+7;
typedef long long ll;


int main(){
    int n; cin>>n;
    vector<int> x(n);
    vector<int> b(n);
    for(int i=0;i<n;i++){
        cin>>x[i];
        b[i]=x[i];
    }
    SORT(x);
    int ans1=x[n/2],ans2=x[n/2-1];
    for(int i=0;i<n;i++){
        if(b[i]<=ans2){
            cout<<ans1<<endl;
        }else{
            cout<<ans2<< endl;
        }
    }
}


Measured memory_bytes: 3712
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    h = list(map(int, input().split()))

    dp = [0] * N
    dp[1] = abs(h[1] - h[0])
    h1 = list(map(abs, [h[i] - h[i - 1] for i in range(2, N)]))
    h2 = list(map(abs, [h[i] - h[i - 2] for i in range(2, N)]))
    for i in range(N - 2):
        a = dp[i] + h2[i]
        b = dp[i + 1] + h1[i]
        if a < b:
            dp[i + 2] = a
        else:
            dp[i + 2] = b

    ans = dp[-1]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24964
#include<iostream>
#include<string>
using namespace std;
struct dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
  }
  int top() {
    return s[0];
  }
};
int main(){
  dice d;
  for(int i=0;i<6;i++)cin>>d.s[i];
  string s;cin>>s;
  for(int i=0;i<s.size();i++)d.roll(s[i]);
  cout<<d.top()<<endl;
  return 0;
}



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

int main(void) {
  int N;
  int d[110];
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }

  int num[110] = {0};
  for (int i = 0; i < N; i++) {
    num[d[i]]++;
  }

  int res = 0;
  for (int i = 1; i <= 100; i++) {
    if (num[i]) {
      res++;
    }
  }

  cout << res << endl;

  return 0;
}

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

const int sz = 2e5+10;




 
 
int main()
{
    
    int t;
    t=1;
    // cin>>t;
    for(int cs=1;cs<=t;cs++)
    {
 
        ll n;
        cin>>n;
        ll dis[n],val[n],val2[n-1];
        for(int i=0;i<n;i++)
        {
            cin>>dis[i];
            dis[i]--;
        }
        for(int i=0;i<n;i++)
        {
            cin>>val[i];
        }
        for(int i=0;i<n-1;i++)
        {
            cin>>val2[i];
        }
        ll res = val[dis[0]];
        for(int i=1;i<n;i++)
        {
            res+=val[dis[i]];
            if(dis[i]-dis[i-1]==1)
            {
                res+=val2[dis[i-1]];
            }

        }
        cout<<res;


 
    }
    return 0;
} 

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,ans,a;
double x[101],y[101];
int main(){
  while(cin>>n,n){
    ans=0;
    r(i,n)scanf("%lf,%lf",&x[i],&y[i]);
    r(i,1000)r(j,1000){a=0;
      double q=(double)i/100,w=(double)j/100;
      r(k,n)if((x[k]-q)*(x[k]-q)+(y[k]-w)*(y[k]-w)<=1)a++;
      ans=max(a,ans);
    }
    cout<<ans<<endl;
  }
}

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

int main()
{
    /*
    const double PI=3.14159265358979323846;
    double r;
    cin>>r;
    cout<<2.0*PI*r;
    */
    int n,m;
    cin>>n>>m;
    
    for(int i=0;i<m;i++)
    {
        int x;
        cin>>x;
        n-=x;
    }
    if(n<0)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<n<<endl;
    }

    return 0;
}

Measured memory_bytes: 3596
X = int(input())
if(400 <= X <= 599):
    lank = 8
elif(600 <= X <= 799):
    lank = 7
elif(800 <= X <= 999):
    lank = 6
elif(1000 <= X <= 1199):
    lank = 5
elif(1200 <= X <= 1399):
    lank = 4
elif(1400 <= X <= 1599):
    lank = 3
elif(1600 <= X <= 1799):
    lank = 2
elif(1800 <= X <= 1999):
    lank = 1

print(lank)

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

int main()
{
	int N;
	int x[110],y[110],h[110];
	
	cin >> N;
	for(int i=0;i<N;i++)
		cin >> x[i] >> y[i] >> h[i];
	
	for(int cx=0;cx<=100;cx++)
	{
		for(int cy=0;cy<=100;cy++)
		{
			int H;
			bool ok=true;
			for(int i=0;i<N;i++)
			{
				if(h[i]==0)continue;
				H=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
				break;
			}
			for(int i=0;i<N;i++)
			{
				if(h[i]!=max(H-abs(x[i]-cx)-abs(y[i]-cy),0))
				{
					ok=false;
					break;
				}
			}
			if(ok)
			{
				cout << cx << " " << cy << " " << H << endl;
				return 0;
			}
		}
	}
	return 0;
}


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

ll vec_y[8] = { 0, 0, -1, 1, -1, -1, 1, 1 };
ll vec_x[8] = {-1, 1, 0, 0, -1, 1, -1, 1 };

int main()
{
        ll H, W;
        cin >> H >> W;
        vector<vector<ll>> m(H, vector<ll>(W, 0));
        for (int i = 0; i < H; ++i) {
                string S;
                cin >> S;
                for (int j = 0; j < W; ++j) {
                        m[i][j] = S[j] == '#' ? -1 : 0;
                }
        }
        for (int i = 0; i < H; ++i) {
                for (int j = 0; j < W; ++j) {
                        if (m[i][j] == -1) continue;
                        ll bomb = 0;
                        for (int k = 0; k < 8; ++k) {
                                ll x = j + vec_x[k];
                                ll y = i + vec_y[k];
                                if (y < 0 || y >= H || x < 0 || x >= W) continue;
                                if (m[y][x] == -1) bomb++;
                        }
                        m[i][j] = bomb;
                }
        }

        for (int i = 0; i < H; ++i) {
                for (int j = 0; j < W; ++j) {
                        if (m[i][j] == -1) cout << "#";
                        else cout << m[i][j];
                }
                cout << endl;
        }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> 
#include <cmath> //pow

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

using namespace std;

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

    vector<vector<int>> table(c,vector<int>(100001,0));
	rep(i, n) {
	  int s,t,c;
		cin >> s >> t >> c;
        c--;
		table[c][s]++;
		table[c][t]--;
	}
  
	int sum = 0;
    vector<int> ans(100001,0);
  
    rep(j,100001) {
      rep(i,c) {
        if (table[i][j+1] > 0 && j+1 <= 100000) sum += table[i][j+1];
        if (table[i][j] < 0)   sum += table[i][j];
      }
      ans[j] = sum;
    }
    
	cout << *max_element(ans.begin(),ans.end()) << endl;
}


Measured memory_bytes: 12416
import itertools

N,M,X = [int(x) for x in input().split(' ')]

bookstore = []
total = float("inf")

for i in range(N):
    book = [int(x) for x in input().split(' ')]
    bookstore.append(book)


for n in range(2**N):
    c_cost = 0
    algos = [0] * M
    
    for i in range(n):
        if (1<<i)&n != 0:
            book = bookstore[i]
            c_cost += book[0]
            
            for x in range(1, M+1):
                algos[x-1] += book[x]
    
    valid = True
    for a in range(M):
        if algos[a] < X:
            valid = False
            break
    
    if valid == True:
        total = min(total, c_cost)

if total == float("inf"):
    print(-1)

else:
    print(total)



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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

vector<vector<int>> g;
vector<int> a;
vector<int> ans;

void dfs(int v, int p, vector<int> &en){
    auto it = lower_bound(en.begin(), en.end(), a[v]);
    ll pos = it - en.begin();
    ll temp = -1;
    if(it != en.end()) {
        temp = *it;
        *it = a[v];
    }
    else {
        en.push_back(a[v]);
    }
    ans[v] = en.size();

    for(auto u: g[v]){
        if(u == p) continue;
        dfs(u, v, en);
    }

    /// restore
    if(temp == -1){
        if(en.size())
            en.pop_back();
    } else {
        en[pos] = temp;
    }
}

void solve(){
    int n;
    cin>>n;
    g.resize(n+1);
    a.resize(n+1);
    ans.resize(n+1);
    rep(i, 1, n){
        cin>>a[i];
        /// coordinate compress to be done
    }

    int u, v;
    fr(i, n-1){
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    vector<int> el;
    dfs(1, 1, el);

    rep(i, 1, n) cout<<ans[i]<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



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

# a-bで割り切れるからa-bをXの約数になるようにする
# a-bはXの倍数、aとbはxで割ったときの余りは等しく

# aとbは-100~+100の中にあると思うので、総当たりしてしまう

flag = False
for a in range(1000):
    for b in range(-1000,1000):
        if a-b == 0:
            break
        if X%(a-b) == 0 and a**5 - b**5 == X:
                flag = True
        if flag:
            break
    if flag:
        break
print(str(a) + ' ' + str(b))


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

int main() {
    long long int n, x, a[100000], ans = 0;
    cin >> n >> x;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    // 左端がxを超えているか
    if(a[0] > x){
        ans += a[0] - x;
        a[0] = x;
    }
    // 左端から順に確定させる
    for(int i = 0; i < n-1; i++){
        if(a[i] + a[i+1] > x){
            long long int t = (a[i] + a[i+1]) - x;
            ans += t;
            a[i+1] -= t;
        }
    }
    cout << ans << endl;
    return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
// using mP = pair<modint, modint>;

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




void solve() {
    int n, x;
    while(1){
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        // int a1=1, a2=1, a3=1;
        int res = 0;
        rep1(i, n){
            Rep1(j, i+1, n){
                Rep1(k, j+1, n){
                    if(i+j+k == x && i!=j && j!=k && i!=k) res++;
                }
            }
        }
        cout << res << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}



Measured memory_bytes: 7236
#include<stdio.h>
int main(void){
	char s[11] = {'\0'};
	char t[11] = {'\0'};
	char u[11] = {'\0'};
	int a, b;
	scanf("%s", s);
	scanf("%s", t);
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%s", u);
	if(s[0] == u[0]){
		a--;
	} else if(t[0] == u[0]){
		b--;
	}
	printf("%d %d\n", a, b);
	return 0;
}


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

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    for(int i = 0; i < s.size(); i++) {
        int x = s[i] - 'A';
        x = (x + n) % 26;
        char c = x + 'A';
        cout << c;
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
/*----------------------------------------------------------------------------------*/

ll dp[100010][4];
const ll mod = 1e9+7;

int main() {
    string s; cin >> s;
    int len = s.size();

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    rep(i,len) {
        // カウントを進めない
        rep(j,4) {
            if (s[i] == '?') {
                (dp[i+1][j] += dp[i][j]*3) %= mod;
            } else {
                (dp[i+1][j] += dp[i][j]) %= mod;
            }
        }

        // 進める
        if (s[i] == '?' || s[i] == 'A') {
            (dp[i+1][1] += dp[i][0]) %= mod;
        }
        if (s[i] == '?' || s[i] == 'B') {
            (dp[i+1][2] += dp[i][1]) %= mod;
        }
        if (s[i] == '?' || s[i] == 'C') {
            (dp[i+1][3] += dp[i][2]) %= mod;
        }
    }

    cout << dp[len][3] << endl;
    return 0;
}


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

using namespace std;

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

	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;

	vector<int> p;
	p.resize(a);

	vector<int> q;
	q.resize(b);

	vector<int> r;
	r.resize(c);

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

	for(int i = 0; i < b; ++i) {
		cin >> q[i];
	}

	for(int i = 0; i < c; ++i) {
		cin >> r[i];
	}

	sort(p.begin(), p.end(), greater<int> ());
	sort(q.begin(), q.end(), greater<int> ());
	sort(r.begin(), r.end(), greater<int> ());

	long long ans = 0;

	vector<int> t;
	
	for(int i = 0; i < x; ++i) {
		t.emplace_back(p[i]);
	}

	for(int i = 0; i < y; ++i) {
		t.emplace_back(q[i]);
	}

	for(int i = 0; i < c; ++i) {
		t.emplace_back(r[i]);
	}

	sort(t.begin(), t.end(), greater<int> ());

	for(int i = 0; i < x + y; ++i) {
		ans += t[i];
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3572
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a, b;
  cin >> a >> b;
  if (b == 1) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 1;
  int tmp = a;
  while (tmp < b) {
    tmp+= a - 1;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
program main
integer :: x,y,z,m,n,i,j,k
integer,allocatable :: p(:),q(:),r(:)
character*16 :: a,b,c,d,e

read(*,*)n,x,y
if (n*x >= y) then
write(*,*)y
else 
write(*,*)n*x
end if

contains

end program main

Measured memory_bytes: 640
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE StrictData #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Char

main :: IO ()
main = do
    n <- readLn 
    s <- VU.unfoldrN n BS.uncons <$> BS.getLine
    print $ rgb n s 0 (0,0,0) - length [ () | i <- [0..n-3], j <- [1..(n-i-1)`div`2], s VU.! i /= s VU.! (i+j), s VU.! (i+j) /= s VU.! (i+2*j), s VU.! i /= s VU.! (i+2*j)]
    where rgb :: Int -> VU.Vector Char -> Int -> (Int,Int,Int) -> Int
          rgb n s cnt (r,g,b)
              | n == cnt          = r*g*b
              | s VU.! cnt == 'R' = rgb n s (cnt+1) (r+1,g,b)
              | s VU.! cnt == 'G' = rgb n s (cnt+1) (r,g+1,b)
              | s VU.! cnt == 'B' = rgb n s (cnt+1) (r,g,b+1)
              | otherwise         = undefined

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

int main(){
  vector<vector<int>> A(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>A.at(i).at(j);
    }
  }
  vector<vector<bool>> bingo(3,vector<bool>(3,false));
  int N;
  cin>>N;
  vector<int> b(N);
  for(int i=0;i<N;i++){
    cin>>b.at(i);
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(A.at(j).at(k)==b.at(i)){
          bingo.at(j).at(k)=true;
        }
      }
    }
  }

  bool flag=false;

  for(int i=0;i<3;i++){
    if(bingo.at(i).at(0)&&bingo.at(i).at(1)&&bingo.at(i).at(2)){
      flag=true;
      break;
    }else if(bingo.at(0).at(i)&&bingo.at(1).at(i)&&bingo.at(2).at(i)){
      flag=true;
      break;
    }
  }

  if(bingo.at(0).at(0)&&bingo.at(1).at(1)&&bingo.at(2).at(2)){
    flag=true;
  }
  if(bingo.at(0).at(2)&&bingo.at(1).at(1)&&bingo.at(2).at(0)){
    flag=true;
  }

  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string S, T; cin >> S >> T;
    cout << T << S << "\n";
}

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

int main() {
 int w,h,n;
 cin>>w>>h>>n;
 int x[n],y[n],a[n];
 int x1=0,y1=0;
 int siro=0;
 rep(i,n){
    cin>>x[i]>>y[i]>>a[i];
 }
 rep(i,n){
     if(a[i]==1&&x1<x[i])x1=x[i];
     if(a[i]==2&&w>x[i])w=x[i];
     if(a[i]==3&&y1<y[i])y1=y[i];
     if(a[i]==4&&h>y[i])h=y[i];
 }
 if(w>=x1&&h>=y1){
  siro=(w-x1)*(h-y1);
  cout<<siro<<endl;
 }
 else cout<<0<<endl;
 
}

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

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug( fmt, ... ) \
        fprintf( stderr, \
                  fmt "\n", \
                  ##__VA_ARGS__ \
        )

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

const int INF = 1 << 30;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}
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 (b<a) { a=b; return true; } return false; }
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

struct prepare {
	prepare() {
	    cout.setf(ios::fixed, ios::floatfield);
	    cout.precision(8);
	    ios_base::sync_with_stdio(false);
	}
} _prepare;

int main() {
	string str;
    cin >> str;
    vi per(4, 0);
    rep(i, str.size()) {
        if(str[i] == 'N')
            per[0]++;
        if(str[i] == 'S')
            per[1]++;
        if(str[i] == 'W')
            per[2]++;
        if(str[i] == 'E')
            per[3]++;
    }

    if( (per[0] == 0 && per[1] > 0) ||
            (per[1] == 0 && per[0] > 0) ||
            (per[3] == 0 && per[2] > 0) ||
        (per[2] == 0 && per[3] > 0) )
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
	
	
    return 0;
}


Measured memory_bytes: 768
N,C = map(int,input().split())
D = [list(map(int,input().split())) for i in range(C)]
CS = [list(map(int,input().split())) for i in range(N)]

from collections import Counter
cs = [Counter() for _ in range(3)]
for i,row in enumerate(CS):
    for j,c in enumerate(row):
        cs[(i+j)%3][c-1] += 1

ans = float('inf')
for i in range(C):
    d1 = 0
    for c,v in cs[0].items():
        d1 += D[c][i]*v
    for j in range(C):
        if i==j: continue
        d2 = 0
        for c,v in cs[1].items():
            d2 += D[c][j]*v
        for k in range(C):
            if k==i or k==j: continue
            d3 = 0
            for c,v in cs[2].items():
                d3 += D[c][k]*v
            ans = min(ans, d1+d2+d3)
print(ans)

Measured memory_bytes: 5876
from itertools import permutations


def main():
    grid = []
    num_sum = 0
    for _ in range(3):
        tmp = list(map(int, input().split(" ")))
        num_sum += sum(tmp)
        grid.append(tmp)
    num_sum //= 3
    index_list = permutations([0, 1, 2])
    answer = "Yes"
    for index in index_list:
        if not grid[0][index[0]] + grid[1][index[1]] + grid[2][index[2]] == num_sum:
            answer = "No"
            break
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#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 pb(a) push_back(a)
#define INF 999999999
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(){
    int a,b;
    cin >> a >> b;
    if (a+b == 15) {
        cout << "+";
    } else if (a*b == 15) {
        cout << "*";
    } else {
        cout << "x";
    }
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
	int n,x;
	int i,j,k;
	int count = 0;

	while (1) {
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0)
			break;

		for (i = 1; i <= n ; i++) {
			for (j = 1; j <= n; j++) {
				for (k = 1; k <= n; k++) {
					if (i + j + k == x) {
						if (i < j && j < k) {
					 		//printf("test %d %d %d\n", i, j, k);
							count++;
						}
					}
				}
			}
		}

		printf("%d\n", count);
		count = 0;

	}
	return 0;
}


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

using namespace std;

namespace {

#define VEVE(i, a, b) for (ll i = a, __##i = b; i < __##i; ++i)
#define DYDY(i, a, b) for (ll i = a, __##i = b; i > __##i; --i)
#define RARA(x, seq) for (auto &x : seq)
#define SIZE(x) ((ll)(x.size()))
#define ALL(x) x.begin(), x.end()

typedef int64_t ll;
typedef double dd;

void Solve(ll) {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll res = k % 2 ? -a + b : a - b;
  cout << res << endl;
}

void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}

int32_t main() {
#ifdef AZN
  freopen("input.txt", "r", stdin);
#endif
  Init();
  ll tests = 1;
  VEVE(test, 1, tests + 1) Solve(test);
  return 0;
}


Measured memory_bytes: 256
n, a, b = map(int,input().split())
s = input()
c = 0
d = 0
for i in range(len(s)):
    if s[i] == "a" and c < a+b:
        print("Yes")
        c += 1
    elif s[i] == "b" and d < b and c < a+b:
        print("Yes")
        d += 1
        c += 1
    else:
        print("No")

Measured memory_bytes: 53208
#include <bits/stdc++.h>
using namespace std;
/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}
/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*ここから*/
int main() {
    double W,H,x,y;
    cin >> W >> H >> x >> y;
    printf("%.6f ", W*H/2);
    if(W/2==x&&H/2==y){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

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

using namespace std;
#define int long long
const double PI=acos(-1.0);

signed main(){

  double a,b,m,n;
  cin>>a>>b>>m>>n;
  double temp=(m*30-n*5.5)*1.0;
  if(temp>=180)
    temp=360.0-temp;

  double ans=sqrt(a*a+b*b-2*a*b*cos(temp*PI*1.0/180.0));
  printf("%.20lf\n", ans);
  return 0;
}

Measured memory_bytes: 4212
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0ll;
    ll flag = 0ll;
    rep(i,n){
        if(a[i]!=0){
            flag += a[i];
        }
        else{
            ans += flag/2;
            flag = 0ll;
        }
    }
    cout << ans+flag/2 << endl;
}

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int maxn = 200050;

int n, h[maxn];
ll c, f[maxn];
struct line{int k; ll b;};

int main()
{
	#ifdef MPS
		fp("1.in","r",stdin);
		fp("1.out","w",stdout);
	#endif
	sf("%d%lld",&n,&c);
	fo(i,1,n) sf("%d",&h[i]);
	deque<line> hull;
	f[1] = 0;
	hull.pb((struct line){-2 * h[1], f[1] + h[1]*1ll*h[1]});
	fo(i,2,n)
	{
		while(SZ(hull) >= 2)
		{
			line l1 = hull.front(); hull.pop_front();
			line l2 = hull.front(); hull.push_front(l1);
			if(l2.b - l1.b <= h[i] * 1ll * (l1.k - l2.k)) 
				hull.pop_front();
			else
				break;
		}
		f[i] = hull.front().k * 1ll * h[i] + hull.front().b + c + h[i] * 1ll * h[i];
		line z = (struct line){-2 * h[i], f[i] + h[i] * 1ll * h[i]};
		while(SZ(hull) >= 2)
		{
			line y = hull.back(); hull.pop_back();
			line x = hull.back(); hull.pb(y);
			if((z.b - y.b) * (x.k - y.k) <= (y.b - x.b) * (y.k - z.k))
				hull.pop_back();
			else
				break;
		}
		hull.pb(z);
	}
	pf("%lld\n",f[n]);
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for(int m = 2; m < n; m+=2){
    int t = m/2;
    string a = s.substr(0, t);
    string b = s.substr(t, t);
    if(a == b) chmax(ans, m);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n >= 1000) {
			System.out.println("ABD");
		} else {
			System.out.println("ABC");
		}
	}
}


Measured memory_bytes: 22100
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        StringBuilder sb = new StringBuilder();
        int n = fs.nextInt();
        char[] s = fs.next().toCharArray();
        char[] t = fs.next().toCharArray();
        for(int i=0;i<n;i++){
            sb.append(s[i]);
            sb.append(t[i]);
        }
        System.out.println(sb.toString());
    }
    static class FastScanner{
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte(){
            if(ptr < buflen){
                return true;
            }else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen <= 0){
                    return false;
                }
            }
            return true;
        }

        private int readByte(){
            if(hasNextByte())return buffer[ptr++];
            else return -1;
        }

        private boolean isPrintableChar(int c){
            return 33<=c && c<=126;
        }

        public boolean hasNext(){
            while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;
            return hasNextByte();
        }

        public String next(){
            if(!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)){
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong(){
            if(!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if(b == '-'){
                minus = true;
                b = readByte();
            }
            if(b < '0' || '9' < b){
                throw new NumberFormatException();
            }
            while(true){
                if('0' <= b && b<='9'){
                    n*=10;
                    n+=b-'0';
                }else if(b==-1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt(){
            long nl = nextLong();
            if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)throw new NumberFormatException();
            return (int)nl;
        }
        public double nextDouble(){return Double.parseDouble(next());}
    }
}

Measured memory_bytes: 21332
#include <stdio.h>

int main(void){
    int N,card[100],i,temp,frag=1,sum_alice=0,sum_bob=0,ans=0;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&card[i]);
    }
    
    while(frag==1){
        frag = 0;
        for(i=0;i<N-1;i++){
            if(card[i]<card[i+1]){
                temp = card[i];
                card[i] = card[i+1];
                card[i+1] = temp;
                frag = 1;
            }
        }
    }
    
    for(i=0;i<N;i++){
        if(i%2==0){
            sum_alice += card[i];
        }else{
            sum_bob += card[i];
        }
    }
    ans = sum_alice - sum_bob;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    B = [(a, i) for i, a in enumerate(A, 1)]
    B.sort()

    ans = [i for a, i in B]
    print(' '.join(map(str, ans)))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 31812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,k,q;
  cin >> n >> k >> q;

	vector<ll> v(n,0);
  
  // de
  /*
  cout << "DE" << endl;
  for (int i = 0;i < n; i++)
    cout << v[i] << ' ';
  cout << endl;
  */
  // ede
  for (int i = 0;i < q; i++)
  {
	ll tmp;
    cin >> tmp;
    v[tmp-1]++;
  }
    // de
  /*
  cout << "DE" << endl;
  for (int i = 0;i < n; i++)
    cout << k - q + v[i] << ' ';
  cout << endl;
  */
  // ede
for (int i = 0;i < n;i++)
{
  if (k - q + v[i] <= 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}
}

Measured memory_bytes: 1408
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N; cin >> N;
    vl A(N); REP(i, N) cin >> A[i];
    set<ll> S;
    REP(i, N)
    {
        if(S.find(A[i]) != S.end())
        {
            cout << "NO" << endl;
            return 0;
        }
        S.insert(A[i]);
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 11264
N = int(input())
h = [int(i) for i in input().split()]

def chmin(a,b):
    if a > b:
        return b
    else:
        return a

dp = [float("inf") for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N):
    dp[i]=chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    dp[i]=chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
    
print(dp[N-1])

Measured memory_bytes: 13976
from collections import deque
n, m = map(int, input().split())
dir = [[] for _ in range(n+1)]

for i in range(m):
    ta, tb = map(int, input().split())
    dir[ta].append(tb)
    dir[tb].append(ta)

ans = [0]*(n+1)
flag = [False]*(n+1)
flag[1] = True
que = deque([1])
while que:
    #print('que: ', len(que), que)
    now = que.popleft()
    for to in dir[now]:
        if flag[to]:
            continue
        que.append(to)
        flag[to] = True
        ans[to] = now

print('Yes')
for i in range(2,n+1):
    print(ans[i])

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var N = r[0].ToInt();
            var K = r[1].ToInt();
            var ans = 0;
            var tmp = N;
            while (tmp > 0)
            {
                tmp = (int)(tmp / K);
                ans++;
            }
            WriteLine(ans);
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteLine(object str)
        {
            Console.WriteLine(str);
        }
    }
}

public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 11092
// fuck ratings, i am in love with learning process

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define tez ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
int main()
{
	string s;
	cin>>s;
	ll n = s.length();
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
		sum+= s[i]-'0';
	}
	if(sum%9==0)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
} 

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int K, X;

  while(cin >> K >> X){
    cout << (K*500 >= X ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 256