akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){

  int i,n,sum=0,min=1000,max=0,ave=0,x,l;
  int score[101];

  for(;;){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    for(i=1;i<=n;i++){

      scanf("%d",&score[i]);

      if(max<score[i]){
	max=score[i];
	x=i;
      }

      if(min>score[i]){
	min=score[i];
	l=i;
      }
    }


    score[l]=0;
    score[x]=0;


    for(i=1;i<=n;i++){
      sum+=score[i];
    }
    ave=sum/(n-2);

    printf("%d\n",ave);

    ave=0;
    sum=0;
    min=1000;
    max=0;

  }
  return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long int ll;

#define rep(x, a, b) for (int x = a; x < b; x++)

int
main()
{
  string str;

  cin >> str;

  rep (i, 0, 4) putchar(str[i]);
  putchar(' ');
  rep (i, 4, 12) putchar(str[i]);
  putchar('\n');
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int n; scanf("%d", &n);
	int ans = 0;
	REP(i, n){
		int a; scanf("%d", &a);
		if(i%2==0 && a%2==1) ans++;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
//Start from Here
int main(){
    int X;
    cin>>X;
    for(int i=-200;i<=200;i++){
        for(int j=-200;j<i;j++){
            if(mod(quick_pow(i, 5)-quick_pow(j, 5), M)==X){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int inf = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	string s, t;
	cin >> s >> t;
	rep(i, N) {
		bool flag = true;
		rep(j, N) {
			if (s[i + j] != t[j]) {
				flag = false;
				break;
			}
			if (i + j == N - 1) {
				cout << N + (N - j - 1) << endl;
				return 0;
			}
		}
		if (flag) {
			cout << i + N << endl;
			return 0;
		}
	}
	cout << N + N << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <time.h>

int main(void) {
	int r, g, b, x;

	scanf("%d %d %d", &r, &g, &b);

	x = r * 100 + g * 10 + b;

	if (x % 4 == 0) {
		printf("YES");
	}
	else {
		printf("NO");
	}
}

Measured memory_bytes: 1680
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
 
const ll INF=1e9+7;

int main(){
    ll n,z,w;
    cin >> n >> z >> w;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    vector<ll> dp1(n);
    vector<ll> dp2(n,INF);
    for(ll i=n-1;i>=0;i--){
        if(i==0){
            dp1[i]=max(dp1[i],abs(a[n-1]-w));
        }
        else{
            dp1[i]=max(dp1[i],abs(a[n-1]-a[i-1]));
            dp2[i]=min(dp2[i],abs(a[n-1]-a[i-1]));
        }
        for(ll j=n-1;j>=i+1;j--){
            dp1[i]=max(dp1[i],dp2[j]);
            dp2[i]=min(dp2[i],dp1[j]);
        }
    }
    cout << dp1[0] << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
L,R=map(int,input().split())
modifyed=[]
flag=0
for i in range(L,R+1):
    modifyed.append(i%2019)
    if i%2019==0:
        print(0)
        sys.exit()
ans=[]
for m in range(len(modifyed)):
    for j in range(m+1,len(modifyed)):
        ans.append(modifyed[m]*modifyed[j]%2019)
print(min(ans))
            

Measured memory_bytes: 75440
/*
    Sk arman Hossain
    University of Barisal

    Problem name :
    Algorithm :
 */

#include<bits/stdc++.h>
#define nl printf("\n");
#define N 200001
#define PR pair<int,int>
#define sf(n) scanf("%d", &n)
#define sff(n, m) scanf("%d %d",&n,&m)
#define sfl(n) scanf("%lld", &n)
#define sfu(n) scanf("%llu", &n)
#define sffl(n, m) scanf("%lld %lld",&n,&m)
#define pfn(n) printf("%d\n",n)
#define pf(n) printf("%d ",n)
#define pfl(n) printf("%lld ",n)
#define pfln(n) printf("%lld\n",n)
#define pfu(n) printf("%llu\n",n)
#define pfs(s) printf("%s",s)
#define YES printf("YES\n")
#define NO printf("NO\n")
#define PB push_back
#define PI 3.1415926536
#define VST(v) sort(v.begin(),v.end())
#define fori(i,n) for(;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define MP make_pair
#define first ff
#define second ss
int dx[]= {0,0,1,-1};
int dy[]= {1,-1,0,0};
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
vector<ll>V,V2,V3;
vector<ll> :: iterator it1,it2;
void CLEAR(){
    V.clear();
    V2.clear();
    V3.clear();
}
int main()
{
    ///freopen("1input.txt","r",stdin);
    int tcase=1;
    //sf(tcase);
    for(int test=1;test<=tcase;test++)
    {
        int n,ans=1;
        sf(n);
        for(int i=1;i<=3;i++){
            ans*=n;
        }

        printf("%d\n",ans);
    }
///*****************************  ALHAMDULILLAH  *****************************/
}



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

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int x[3];
  cin >> x[0] >> x[1] >> x[2];
  sort(x, x+3);
  int ans = 0;
  ans += x[2]-x[1];
  x[0] += x[2]-x[1];
  if((x[2] - x[0]) %2 == 1){
    ans++;
    x[2]++;
  } 
  ans += (x[2]-x[0])/2;
  cout << ans << "\n";
}  

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

struct Card {
    char suite;
    int value;
    bool operator==(const Card& rhs) const
    {
        return suite == rhs.suite && value == rhs.value;
    }
};

void bubbleSort(vector<Card>& v)
{
    for (size_t i = 0; i < v.size(); ++i) {
        for (size_t j = v.size() - 1; j >= i + 1; --j) {
            if (v[j].value < v[j - 1].value) {
                swap(v[j], v[j - 1]);
            }
        }
    }
}

void selectionSort(vector<Card>& v)
{
    for (size_t i = 0; i < v.size(); ++i) {
        auto mini = i;
        for (size_t j = i; j < v.size(); ++j) {
            if (v[j].value < v[mini].value) {
                mini = j;
            }
        }
        swap(v[i], v[mini]);
    }
}

bool isStableSort(const vector<Card>& raw, const vector<Card>& sorted)
{
    for (size_t i = 0; i < sorted.size() - 1; ++i) {
        auto&& a = sorted[i];
        auto&& b = sorted[i + 1];
        if (a.value == b.value) {
            int a_pos;
            int b_pos;
            for (size_t j = 0; j < raw.size(); ++j) {
                if (raw[j] == a) {
                    a_pos = j;
                }
                else if (raw[j] == b) {
                    b_pos = j;
                }
            }
            if (!(a_pos < b_pos)) {
                return false;
            }
        }
    }
    return true;
}

int main()
{
    int N;
    scanf("%d\n", &N);

    vector<Card> vc;
    for (auto i = 0; i < N; ++i) {
        char c;
        int n;
        scanf("%c%d ", &c, &n);
        vc.push_back(Card{c, n});
    }

    auto p = [](const vector<Card>& v) {
        for (size_t i = 0; i < v.size(); ++i) {
            printf("%c%d", v[i].suite, v[i].value);
            if (i != v.size() - 1) {
                putchar(' ');
            }
        }
        putchar('\n');
    };

    {
        auto t = vc;
        bubbleSort(t);
        p(t);
        if (isStableSort(vc, t)) {
            printf("Stable\n");
        }
        else {
            printf("Not stable\n");
        }
    }
    {
        auto t = vc;
        selectionSort(t);
        p(t);
        if (isStableSort(vc, t)) {
            printf("Stable\n");
        }
        else {
            printf("Not stable\n");
        }
    }
}

Measured memory_bytes: 2804
#include <stdio.h>
int main(void) {
    int num,time,eps,sand[100],i,flag=0;
    scanf("%d %d %d",&num,&time,&eps);
    for (i=0; i<num; i++) {
        scanf("%d",&sand[i]);
        if (flag==0) {
            if (sand[i]>=time&&sand[i]-time<=eps) {
                flag=i+1;
            } else if (sand[i]<time) {
                if (time%sand[i]<=eps||(((time/sand[i])+1)*sand[i])%time<=eps) {
                    flag=i+1;
                }
            }
        }
    }
    if (flag!=0) {
        printf("%d\n",flag);
    } else {
        printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 596
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-05-03 21:05:00
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000000

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
    }

    vector<int> nog(n, 0);
    for (int i = 0; i < m; i++) {
        int h_a, h_b;
        h_a = h[a[i]-1];
        h_b = h[b[i]-1];

        if (h_a < h_b) {
            nog[a[i]-1] = 1;
        } else if (h_a == h_b) {
            nog[a[i]-1] = nog[b[i]-1] = 1;
        } else {
            nog[b[i]-1] = 1;
        }
    }

    int ans = n;
    for (int i = 0; i < n; i++) {
        ans -= nog[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4840
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        
        int T = Integer.parseInt(sc.next());
        int A = Integer.parseInt(sc.next());
        
        int res = 0;
        double cnt = Integer.MAX_VALUE;
        
        for(int i = 0; i < N; i++){
            String s = sc.next();
            
            double d = Math.abs(A - (T - Integer.parseInt(s) * 0.006));
            
            if(cnt > d){
               cnt = d;
               res = i+1;
            }
        }
        
        System.out.println(res);
    }
}


Measured memory_bytes: 25300
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int x[4] = {0, 1, 0, -1};
    int y[4] = {1, 0, -1, 0};
    int nd = 0;
    int h,w; cin >> h >> w;
    int n; cin >> n;
    vector<int> a(n);
    rep(k,n) {
        cin >> a[k];
        if (k!=0) a[k]+=a[k-1];
    }
    int v[105][105] = {0};
    int now =1 ,i = 0,j = 0;
    for (int cnt =0;cnt <h*w;cnt++){
        if(cnt >= a[now-1]) ++now;
        v[i][j] = now;
        if ( j+y[nd] < 0){
            i++;
            nd = 0;
            j--;
        }
        else if (j + y[nd] > w-1 ){
            i++;
            nd = 2;
            j++;
        }
        j += y[nd];
    }
    rep(i,h){
        rep(j,w){
            cout << v[i][j];
            if (j != w-1) cout << " ";
    }
    cout << endl;
    }
    }


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

ll powMod(ll a, ll b, ll mod) {
	ll res = 1;
	while(b > 0) {
		if(b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}
int main() {
	ll N, P;
	string S;
	cin >> N >> P >> S;
	ll ans = 0;
	if(P == 2 or P == 5) {
		// 末尾がPで割り切れる場合無条件にPの倍数
		// 理由: それ以外は, a * 10の形で表され, これはPで割り切れるから
		for(int i=0;i<N;i++) {
			int tmp = S[i] - '0';
			if(tmp % P == 0) {
				ans += (i+1);
			}
		}
		cout << ans << endl;
		return 0;
	}
	map<int,ll> mp;
	vector<ll> imos(N+1, 0);
	for(int i=N-1;i>=0;i--) {
		int tmp = S[i] - '0';
		imos[i] = tmp % P;
	}
	for(int i=N-2;i>=0;i--) {
		imos[i] = (imos[i] * powMod(10, N-i-1, P) + imos[i+1]) % P;
	}
	for(int i=0;i<=N;i++) mp[imos[i]]++;
	for(auto &now : mp) {
		ans += (now.second) * (now.second -1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2564
ABC=list(map(int,input().split()))
coin=0
date=0
days=0

while(1):
    days+=1
    
    if not date==6:
        coin=coin+ABC[0]
    else:
        coin=coin+ABC[1]
        coin=coin+ABC[0]

    if coin>=ABC[2]:
        print(days)
        break
    date=(date+1)%7


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll in()
{
    ll re=0,f=1;char x=getchar();
    while(x<'0'||x>'9'){if(x=='-')f=-1;x=getchar();}
    while(x>='0'&&x<='9')re=re*10+x-48,x=getchar();
    return re*f;
}
void out(ll x)
{
    if(x<0)putchar('-'),x=-x;
    if(!x){putchar('0');return;}
    char z[21],ct=0;
    while(x){z[++ct]=x%10+48,x/=10;}
    while(ct){putchar(z[ct]);--ct;}
}
int n;
char ss[500000];
int s[100010],pt;
int len[100010],tlen;
char t[100010];
int ptr=1;
const ll mod=1e9+7;
struct node{
    int ch[26],fa;
    char v;
    vector<int>cnt;
}nd[200010];
void ins(int l,int len)
{
    int cur=1;
    for(int i=l;i<l+len;++i)
    {
        char c=ss[i];
        if(!nd[cur].ch[c-'a'])
        {
            nd[cur].ch[c-'a']=++ptr;
            nd[ptr].fa=cur;
            nd[ptr].v=c;
        }
        cur=nd[cur].ch[c-'a'];
    }
    nd[cur].cnt.push_back(len);
}
int fail[200010];
void bfs()
{
    queue<int>q;
    fail[1]=1;
    for(int i=0;i<26;++i)
    if(nd[1].ch[i])
    {
        fail[nd[1].ch[i]]=1;
        q.push(nd[1].ch[i]);
    }
    else nd[1].ch[i]=1;
    while(!q.empty())
    {
        int h=q.front();q.pop();
        for(int i=0;i<26;++i)
        if(nd[h].ch[i])
        {
            fail[nd[h].ch[i]]=nd[fail[h]].ch[i];
            q.push(nd[h].ch[i]);
        }
        else nd[h].ch[i]=nd[fail[h]].ch[i];
    }
}
ll dp[200010];
int main()
{
    scanf("%d\n",&n);
    for(int i=1;i<=n;++i)
    {
        scanf("%s",ss+pt);
        s[i]=pt;
        len[i]=strlen(ss+pt);
        pt=pt+len[i]+1;
    }
    for(int i=1;i<=n;++i)
        ins(s[i],len[i]);
    bfs();
    scanf("%s",t+1);
    tlen=strlen(t+1);
    dp[0]=1;
    int cur=1;
    for(int i=1;i<=tlen;++i)
    {
        cur=nd[cur].ch[t[i]-'a'];
        int now=cur;
        while(now>1)
        {
            vector<int>&v=nd[now].cnt;
            for(int j=0;j<v.size();++j)
                dp[i]=(dp[i]+dp[i-v[j]])%mod;
            now=fail[now];
        }
    }
    cout<<dp[tlen]<<'\n';
}


Measured memory_bytes: 32360
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  vector<ll> sum(N);
  sum[0] = A[0] % M;
  repp(i, 1, N - 1) {
    sum[i] = sum[i - 1] + A[i];
    sum[i] %= M;
  }
  // rep(i, N) {
  //   cout << sum[i] << ' ';
  // }
  // cout << endl;
  map<ll, int> m;
  vector<ll> dupl;
  rep(i, N) {
    if (m[sum[i]] == 1)
      dupl.pb(sum[i]);
    m[sum[i]]++;
  }

  ll ans = 0;
  ans += m[0];
  rep(i, dupl.size()) {
    ll d = m[dupl[i]];
    ans += d * (d - 1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
long long int n,x,ans;
long long int a[100000];

int main(){
  scanf("%lld %lld",&n,&x);
  for(int i=0;i<n;i++){
    scanf("%lld",&a[i]);
  }
  for(int i=1;i<n;i++){
    if(a[i]+a[i-1]>x){
      long long int tmp=a[i]+a[i-1]-x;
      ans+=tmp;
      if(a[i]<tmp){
        tmp-=a[i];
        a[i]=0;
        a[i-1]-=tmp;
      }else{
        a[i]-=tmp;
      }
    }
  }
  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  vi inv(3);
  cin >> N >> inv;

  v(string) S(N);
  cin >> S;

  v(char) ans;

  rep(i, N)
  {
    string p = S[i];
    if (inv[p[0] - 'A'] == 0 and inv[p[1] - 'A'] == 0){
      cout << "No\n";
      return;
    }
    if (inv[p[0] - 'A'] > inv[p[1] - 'A'])
    {
      ans.emplace_back(p[1]);
      inv[p[0] - 'A']--;
      inv[p[1] - 'A']++;
    }
    else if (inv[p[0] - 'A'] < inv[p[1] - 'A'])
    {
      ans.emplace_back(p[0]);
      inv[p[0] - 'A']++;
      inv[p[1] - 'A']--;
    }
    else if (inv[p[0] - 'A'] > 1 or i == S.size() - 1)
    {
      ans.emplace_back(p[1]);
      inv[p[0] - 'A']--;
      inv[p[1] - 'A']++;
    }
    else{
      if (S[i + 1][0] == p[0] or S[i + 1][1] == p[0])
      {
        ans.emplace_back(p[0]);
        inv[p[0] - 'A']++;
        inv[p[1] - 'A']--;
      }
      else
      {
        ans.emplace_back(p[1]);
        inv[p[0] - 'A']--;
        inv[p[1] - 'A']++;
      }
    }
  }

  cout << "Yes\n";
  rep(i,ans.size()){
    cout << ans[i] << "\n";
  }

}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

int main(){
  int n;
  cin >> n;
  
  ll power = 1;
  for(int i = 1; i <= n; i++){
    power *= i;
    power %= 1000000007;
  }
  cout << power << endl;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()


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

  int X,A;
  cin>>X>>A;
  if(X<A)cout<<0<<endl;
  else cout<<10<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main()
{
  int x,i,j,k,key;
  int y[N];
  scanf("%d",&x);
  for(i=0;i<x;i++)
    {
      scanf("%d",&y[i]);
    }
  for(i=0;i<x;i++)
    {
      printf("%d",y[i]);
      if(i != x-1)
	{
	  printf(" ");
	}
    }
  printf("\n");
  for(i=1;i<x;i++)
    {
      key = y[i];
      j = i - 1;
      while((j >= 0) && (y[j] > key))
	{
	  y[j+1] = y[j];
	  j--;
	}
      y[j+1] = key;
      for(k=0;k<x;k++)
	{
	  printf("%d",y[k]);
	  if(k != x-1)
	    {
	      printf(" ");
	    }
	}
      printf("\n");
    }
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
int ans;
int n, m, q;
int A[100];
int a[100], b[100], c[100], d[100];
void dfs(int dep, int v) {
	A[dep] = v;
	if (dep == n) {
		int tmp = 0;
		for (int i = 1; i <= q; i++) {
			if (A[b[i]] - A[a[i]] == c[i]) {
				tmp += d[i];
			}
		}
		ans = max(ans, tmp);
		return;
	}
	for (int i = v; i <= m; i++) {
		dfs(dep + 1, i);
	}
}
int main(){
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 1; i <= q; i++)scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
	for (int i = 1; i <= m; i++)dfs(1, i);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3828
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)
		{
			ans+=i;
		}
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 1732
def solve(string):
    n, m, *ab = map(int, string.split())
    ans = 0
    for a, b in sorted([(a, b) for a, b in zip(ab[::2], ab[1::2])]):
        if m <= b:
            ans += a * m
            break
        ans += a * b
        m -= b
    return str(ans)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 26748
#include<bits/stdc++.h>
using namespace std;
int main (){
    int x,p,n;cin>>x>>n;
    bool vs[1005];
    memset(vs,0,sizeof vs);

    for(int i=0;i<n;i++){
        cin >> p;
        vs[p+200] = 1;
    }

    int mn = 1e9,res=0;
    for(int i=-200;i<=200;i++){

        if(vs[i+200])continue;

        int df = abs(x-i);
        if(df<mn){
            mn = df;
            res = i;
        }
    }
    cout<<res;
    //main();
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n;
    cin >> n;

    int A, B;
    cin >> A >> B;

    int w = 0;
    for (int i = 0; i < n-2; ++i) {
        int x;
        cin >> x;
        w ^= x;
    }

    vector <int> l,r ;

    {
    int al = A >> 20;
    int bl = B >> 20;
    int wl = w >> 20;
    for (int i = 0; i <= al; ++i) {
        if (((al - i) ^ (bl + i)) == wl) {
            l.app(i);
        }   
        if (i + 1 <= al && ((al - i - 1) ^ (bl + i)) == wl) {
            l.app(i);
        }   
        if (i + 1 <= al && ((al - i) ^ (bl + i + 1)) == wl) {
            l.app(i);
        }   
        if (i + 1 <= al && ((al - i - 1) ^ (bl + i + 1)) == wl) {
            l.app(i);
        }   
    }
    }   

    {
    int ar = A & ((1 << 20) - 1);
    int br = B & ((1 << 20) - 1);
    int wr = w & ((1 << 20) - 1);
    for (int i = 0; i < (1 << 20); ++i) {

        int a1 = ar - i;
        if (a1 < 0)
            a1 += 1 << 20;

        int t = a1 ^ (br + i);
        t &= (1 << 20) - 1;
        if (t == wr) {
            r.app(i);
        }   
    }
    }

    #ifdef HOME
    for (auto e : l)
        cout << e << ' ';
    cout << endl;
    for (auto e : r)
        cout << e << ' ';
    cout << endl;
    #endif

    const int INF = 1e18;
    int p = INF;
    for (int x : l) {
        for (int y : r) {

            int ans = (x << 20) + y;
            if (ans < A && ((A - ans) ^ (B + ans)) == w) {
                p = min(p, ans);
            }   

        }   
    }   

    if (p == INF)
        cout << -1 << endl;
    else
        cout << p << endl;
}

Measured memory_bytes: 3748
#include <cstdio>
long long n, n2, s, k, d, a[100005];
int main() {
	int i;
	scanf("%d", &n);
	for (i=0; i<n; i++) scanf("%d", &a[i]), s += a[i];
	n2 = n * (n+1) / 2;
	if (s%n2) {puts("NO"); return 0;}
	k = s / n2;
	for (i=s=0; i<n; i++) {
		d = a[(i+1)%n] - a[i];
		if (k<d || (k-d)%n) {puts("NO"); return 0;}
		s += (k-d) / n;
	}
	puts(s==k ? "YES":"NO");
	return 0;
}

Measured memory_bytes: 896
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
m+='@'*w,
I=h*w
d=[I]*I
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j;p=d[s]+1
   if'.'!=m[i][j]or d[t]<p:break
   if d[t]>p:q+=t,;d[t]=p
print(d[~w+f*w+g]%I-1)

Measured memory_bytes: 129588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
	int N,i,j;
	scanf("%d",&N);
	char W[N][11];
	for(i=0;i<N;i++){
		scanf("%s",W[i]);
		for(j=0;j<i;j++){
			if(strcmp(W[i],W[j]) == 0){
				printf("No");
				return 0;
			}
		}
	}
	for(i=0;i<N-1;i++){
		int len = strlen(W[i]);
		char e = W[i][len-1];
		if(e != W[i+1][0]){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n, err := strconv.Atoi(stdin.Text())
	if err != nil {
		fmt.Println("err", err)
		os.Exit(1)
	}

	var rmax = 1000000000
	var diffMax = -rmax

	stdin.Scan()
	r, err := strconv.Atoi(stdin.Text())
	if err != nil {
		fmt.Println("err", err)
		os.Exit(1)
	}
	var rmin = r

	for i := 1; i < n; i++ {
		stdin.Scan()
		r, err := strconv.Atoi(stdin.Text())
		if err != nil {
			fmt.Println("err", err)
			os.Exit(1)
		}

		diff := r - rmin
		if diff > diffMax {
			diffMax = diff
		}

		if r < rmin {
			rmin = r
		}
	}

	fmt.Println(diffMax)
}

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

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

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

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

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	
	int ans = 0, num = 1;
	
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		
		if(x == num){
			ans++;
			num++;
		}
	}
	
	if(ans == 0)
		cout << -1 << endl;
	else
		cout << n - ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    string S;
    cin >> S;
    int ans = 0;
    rep(i, 4) {
        if (S[i] == '+') ans++;
        else ans--;
    }
    cout << ans << "\n";
}

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

#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)

void recursive_debug(string) { cerr << endl; }

template<class H,class... T>
void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}

template<class T,class U>
ostream& operator<<(ostream& ost, const pair<T,U> &p) {
    ost << "(" << p.first << ", " << p.second << ")";
    return ost;
}

template<class T>
ostream& operator<<(ostream &ost, const vector<T> &v) {
    ost << "[";
    for(T t : v) ost << t << ",";
    ost << "]";
    return ost;
}

struct State {
    ll score;
    vector<int> types;
    bool operator<(const State& rhs) const {
        return (score < rhs.score);
    }
    bool operator>(const State& rhs) const {
        return (score > rhs.score);
    }
};


int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int D, M = 26;
    cin >> D;
    vector<ll> c(M);
    rep(i,M) cin >> c[i];
    vector<vector<ll>> s(D, vector<ll>(M));
    rep(d,D) rep(i,M) cin >> s[d][i];

    set<State> cur_states = {{0, {}}};
    size_t SIZE = 1050;

    rep(d,D) {
        set<State> nxt_states;
        for (auto &cur_itr : cur_states) {
            State state = cur_itr;
            vector<int> last(M, -1);
            rep(i,state.types.size()) {
                last[state.types[i]] = i;
            }
            ll minus_score = 0;
            rep(i,M) {
                minus_score -= c[i] * (d - last[i]);
            }
            rep(i,M) {
                State nxt_state;
                nxt_state.score = state.score + s[d][i] + minus_score + c[i] * (d - last[i]);
                nxt_state.types = state.types;
                nxt_state.types.push_back(i);
                
                nxt_states.insert(nxt_state);
                if (nxt_states.size() > SIZE) {
                    nxt_states.erase(nxt_states.begin());
                }
            }
        }

        cur_states = std::move(nxt_states);
    }

    for (int t : cur_states.begin()->types) {
        cout << t+1 << endl;
    }
    // debug(cur_states[0].score);

    return 0;
}


Measured memory_bytes: 7320
import re
import decimal

def main():
    decimal.getcontext().rounding = decimal.ROUND_DOWN
    n = int(input())
    for i in range(n):
        s = input()
        s = re.sub(r'(\d+)', r'decimal.Decimal(\1)', s).replace('=', '').replace('/', '//')
        print(int(eval(s)))

main()


Measured memory_bytes: 6936
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::collections::HashMap;

fn main() {
    let s = get!(String).chars().collect::<Vec<_>>();
    let mut m = HashMap::new();
    for c in s.into_iter() {
        let v = m.entry(c).or_insert(0);
        *v += 1;
    }
    for (_, v) in m {
        if v > 1 {
            println!("no");
            return;
        }
    }
    println!("yes");
}

Measured memory_bytes: 4352
@d=$t=1;
$/=\1;
for(;$t+=($j=ord<>)>10?($c+=$j%3,1):-1;$d[$c<$t?$t:$c-$t]=0){
	for($j=$c;$j;){
		$d[$j+1]-=998244353if($d[$j]+=$d[--$j])>119<<23
	}
}
print$d[$c]+0

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
int main() {
  string S; cin >> S;
  if(S == "RRS" || S == "SRR") cout << 2 << endl;
  else if (S == "RRR") cout << 3 << endl;
  else if (S == "SSS") cout << 0 << endl;
  else cout << 1 << endl;
  
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

typedef pair<int, int> pii;
vector<int> v[MAX];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt",  "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    int n, m, p,  y;
    vector<pii> vp;

    cin>>n>>m;

    for(int i = 0; i < m; i++){
        cin>>p>>y;
        v[p].push_back(y);
        vp.push_back(make_pair(p, y));
    }

    for(int i = 1; i <= n; i++){
        sort(v[i].begin(), v[i].end());
    }
    for(int i = 0; i < vp.size(); i++){
        int idx = lower_bound(v[vp[i].first].begin(), v[vp[i].first].end(), vp[i].second) - v[vp[i].first].begin();
        cout<<setw(6)<<setfill('0');
        cout<<vp[i].first;
        cout<<setw(6)<<setfill('0');
        cout<<(idx + 1)<<endl;
    }

    return 0;
}

Measured memory_bytes: 7796
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005 
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
  scanf("%d",&head);
  RI(tail...);
}
using namespace std;
typedef long long LL;
int in[M], dp_pre[M], dp_pos[M];
int gcd(int a, int b) {
	if(b > a) gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> in[i];
	dp_pre[0] = in[0], dp_pos[n-1] = in[n-1];
	for(int i = 1; i < n; i++) {
		dp_pre[i] = gcd(in[i], dp_pre[i-1] );
	}
	
	for(int i = n-2; i >= 0; i--) {
		dp_pos[i] = gcd(in[i], dp_pos[i+1] );
	}
	int ans = -1e9;
	for(int i = 1; i < n-1; i++) {
		ans = max(ans, gcd(dp_pre[i-1], dp_pos[i+1] ) );
	}
	if(n > 1) ans = max(max(ans, dp_pos[1]), dp_pre[n-2] );
	if(ans == -1e9) ans = in[0];
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    int l = 0, r = n;
    cout << l << endl;
    string sex; cin >> sex;
    if (sex == "Vacant") return 0;
    else {
        while (true) {
            int mid = (l+r)/2;
            cout << mid << endl;
            string sex_ ; cin >> sex_;
            if (sex_ == "Vacant") return 0;
            if (mid&1) {
                if (sex_ == sex) r = mid;
                if (sex_ != sex) l = mid;
            } else {
                if (sex_ == sex) l = mid;
                if (sex_ != sex) r = mid;
            }
        }
    }
}

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

int main()
{
    int n;
    cin>>n;
    int h[n],dp[n];
    for(int i=0;i<n;i++)
    cin>>h[i];
    dp[0]=0;
    dp[1]=dp[0]+abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    dp[i]=min( dp[i-1]+abs(h[i]-h[i-1]) , dp[i-2]+abs(h[i]-h[i-2]) );
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    string s;
    cin >> s;
    int c_0=count(s.begin(),s.end(),'0');
    int c_1=count(s.begin(),s.end(),'1');
    cout << min(c_0,c_1)*2 <<endl;


    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int main() {
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  int y=c-a-b;
  if(y<=0){
    return cout<<"No\n",0;
  }else{
    if(4ll*a*b<1ll*y*y)cout<<"Yes\n";
    else cout<<"No\n";
  }
  return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int y = scan.nextInt();
        
            
        for(int crane = 0 ; crane <= 100 ; crane++) {
            for(int turtle = 0 ; turtle <= 100 ; turtle++ ) {
                if((crane+turtle == x) && (crane*2 + turtle*4 == y)) {
                                 System.out.println("Yes");
                                 return;
                }
            }
        }
            System.out.println("No");
    }
    
}

Measured memory_bytes: 35692
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define	       MEM(a,b)         memset(a,(b),sizeof(a))
#define	       CLR(p)           memset(p,0,sizeof(p))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
#define	       ff               first
#define	       sc              second
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//memset(ar,-1,sizeof(ar));
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
#define MAX 1000005
#define precision(a) fixed << setprecision(a)

#define mod 1000000007



int main()
{
 //O_O ;
   ll a,b,c;
   cin>>a>>b>>c;
   ll ans=a%b,ans2=a/b;
   if(ans)
    ans2++;
   cout<<ans2*c<<nn;


    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
#include <numeric>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define PB push_back
#define INF 100000000000000000

bool IsPrime(int num)
{
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
    {
      // 素数ではない
      return false;
    }
  }

  // 素数である
  return true;
}

/*********************************************************/
// 最大公約数（Greatest Common Divisor）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************/
ll gcd( ll m, ll n )
{
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) )
    return 0;

  // ユークリッドの方法
  while( m != n )
  {
    if ( m > n ) m = m - n;
    else         n = n - m;
  }
  return m;
}//gcd

//*********************************************************
// 最小公倍数（Least Common Multiple）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
ll lcm( ll m, ll n )
{
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) )
    return 0;

  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

/********************************************************/

int main() {
  ll N,A,B,i,problem1,problem2,problem3,ans;
  ans=0;
  problem1=0;
  problem2=0;
  problem3=0;
  cin >> N >> A >> B;
  vector<ll> P(N);
  for(i=0;i<N;i++){
    cin >> P.at(i);
  }
  for(i=0;i<N;i++){
    if(P.at(i)<=A){
      problem1++;
    }
    if((A+1) <=P.at(i) &&  P.at(i) <=B){
      problem2++;
    }
    if((B+1) <=P.at(i) && P.at(i)!=0){
      problem3++;
    }
  }
  ans=min(problem1,min(problem2,problem3));
  cout <<ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){

char ch[1001];
int sum='0';
while (1)
{
    
    scanf("%s", ch);
    if ( ch[0] == '0' ){ break; }

    for (int i = 0; i < 1001; i++)
    {
        sum+=ch[i]-'0';
        if ( ch[i] == '\0' )
            {   
                printf("%d\n",sum);
                sum='0';
                break;
            }
    }
}

return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> m >> n;
  ll u[m],c[m],x=0,y=0;
  mem(u);mem(c);
  rep(i,n) {
    int a;
    string s;
    cin >> a >> s;
    a--;
    if(u[a]) continue;
    if(s=="AC") {
      x++;
      y+=c[a];
      u[a]=1;
    } else c[a]++;
  }
  pr(x,y);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1792
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});

process.stdin.on('end', () => {
  let [size, ...lines] = content.trim().split('\n');
  const [matA, matB] = lines.map(line =>
    line.split(' ').map(n => parseInt(n, 10))
  );

  for (let i = 1; i <= 3; i++) {
    console.log(getDistance(matA, matB, i));
  }
  console.log(getDistance(matA, matB, Infinity));
});

const getDistance = (matA, matB, p) => {
  if (p === Infinity) {
    return Math.max(...matA.map((num, i) => Math.abs(num - matB[i])));
  } else {
    const sum = matA.reduce((prev, cur, i) => prev + Math.pow(Math.abs(cur - matB[i]), p), 0);
    return Math.pow(sum, 1 / p);
  }
};


Measured memory_bytes: 16588
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
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;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int a[102];

ll dp[105][21];

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

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

    dp[1][a[1]] = 1;

    for (int i = 2; i <= n - 1; ++i) {
        for (int j = 0; j <= 20; ++j) {
            if (j + a[i] <= 20) dp[i][j + a[i]] += dp[i - 1][j];
            if (j - a[i] >= 0) dp[i][j - a[i]] += dp[i - 1][j];
        }
    }

    cout << dp[n - 1][a[n]] << endl;
}

Measured memory_bytes: 3116
ss = input().split()
n,k,c = map(int, ss)
s = input()

L = {}
R = {}

# forward
i = 0
fk = 0
while i < n and fk < k:
  if s[i] == 'x':
    i += 1
  else:
    L[fk+1] = i
    i += (c + 1)
    fk += 1
    

# backward
n -= 1
while 0 <= n and 0 < k:
  if s[n] == 'x':
    n -= 1
  else:
    R[k] = n
    n -= (c + 1)
    k -= 1


keys = set(L.keys()) | set(R.keys())
for k in sorted(keys):
  if k in R and k in L:
    if R[k] == L[k]:
      print(R[k]+1)


Measured memory_bytes: 100872