akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> C(N-1),S(N-1),F(N-1);
  for(int i=0;i<N-1;i++){
    cin >> C.at(i) >> S.at(i) >> F.at(i);
  }
  for(int i=0;i<N-1;i++){
    int64_t ans=0;
    ans+=S.at(i)+C.at(i);
    for(int j=i+1;j<N-1;j++){
      if(ans<=S.at(j)){
        ans=S.at(j);
      }else{
        if((ans-S.at(j))%F.at(j)!=0){
          ans+=(F.at(j)-((ans-S.at(j))%F.at(j)));
        }
      }
      ans+=C.at(j);
    }
    cout << ans << endl;
  }
  cout << 0 << endl;
  return 0;
}


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

struct Problem {

    void Solve() {
        UL N; cin >> N;
        set<string> SS;
        rep(i, N) {
            string S; cin >> S;
            SS.insert(S);
        }
        cout << SS.size() << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    //cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}


Measured memory_bytes: 19224
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
typedef long long ll;
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    string s,t;cin >> s >> t;
    int slen = s.length();int tlen = t.length();
    vector<vector<int>> lcm(slen+1,vector<int>(tlen+1,0));
    REP(i,slen)lcm[i+1][0]+=lcm[i][0]+1;
    REP(i,tlen)lcm[0][i+1]+=lcm[0][i]+1;
    REP(i,slen)REP(j,tlen){
        if(s[i]==t[j]){
            lcm[i+1][j+1]=min({lcm[i][j],lcm[i+1][j]+1,lcm[i][j+1]+1});
        }else{
            lcm[i+1][j+1]=min({lcm[i][j]+1,lcm[i+1][j]+1,lcm[i][j+1]+1});
        }
    }
    cout << lcm[slen][tlen] << endl;
}


Measured memory_bytes: 6836
N = int(input())
H = [[0]*N for _ in range(100)]
for j, h in enumerate(map(int, input().split())):
    for i in range(h):
        H[i][j] = 1
cnt = 0
for i in range(100):
    a0 = 0
    for a in H[i]:
        if a != a0 and a0==0:
            cnt += 1
        a0 = a
print(cnt)

Measured memory_bytes: 65912
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main() {
	// your code goes here
	ll n,a,b;
	cin>>n>>a>>b;
	if(a==0)
	cout<<0;
	else
	{
	    ll x=a+b;
	    ll z=n/x;
	    ll r=n%x;
	    ll ans=z*a;
	    ans+=min(r,a);
	    cout<<ans;
	}
	
}


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

const ll INF = 1e18;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int N, W;
	cin >> N >> W;
	const int V = 1000 * N;
	vector<int> v(N + 1), w(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> w[i] >> v[i];
	}
	vector<vector<ll>> dp(N + 1, vector<ll> (V + 1, INF));
	dp[1][0] = 0;
	dp[1][v[1]] = w[1];
	for (int i = 2; i <= N; i++) {
		for (int j = 0; j <= V; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j < v[i]) {
				continue;
			}
			dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
		}
	}
	int ans = 0;
	for (int i = 0; i <= V; i++) {
		if (dp[N][i] <= W) {
			ans = i;
		}
	}
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 83192
#include <iostream>

using namespace std;

int main(){
  int N;
  bool yn = false;
  
  cin >> N;
  
  if(N < 10){
    yn = true;
  }else{
    for(int n = 2; n < 10; n++){
      if(N % n == 0 && N / n < 10){
        
        yn = true;
      }
    }
  }
  
  if(yn == true){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}

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

typedef struct {
	int Up;
	int Sorth;
	int East;
	int West;
	int North;
	int Down;
}DICE;
DICE North(DICE *t);
DICE Sorth(DICE *t);
DICE East(DICE *t);
DICE West(DICE *t);
void assignment(DICE *d);
int main()
{
	unsigned int i;
	char word[100];
	DICE Dice1;
	assignment(&Dice1);
	scanf("%s", word);
	for (i = 0; i < strlen(word); i++){
		switch (word[i]){
		case 'N':Dice1 = North(&Dice1);
			break;
		case 'S':Dice1 = Sorth(&Dice1);
			break;
		case 'E':Dice1 = East(&Dice1);
			break;
		case 'W':Dice1 = West(&Dice1);
			break;
		}
	}
	printf("%d\n", Dice1.Up);

	return 0;
}

void assignment(DICE *d){
	int i, as, a[6];
	DICE temp;
	for (i = 0; i < 6; i++){
		scanf("%d", &as);
		a[i] = as;
	}
	d->Up = a[0], d->Sorth = a[1], d->East = a[2], d->West = a[3], d->North = a[4], d->Down = a[5] ;
}
DICE North(DICE *t){
	DICE temp = { t->Sorth, t->Down, t->East, t->West, t->Up, t->North };
	return temp;
}
DICE Sorth(DICE *t){
	DICE temp = { t->North, t->Up, t->East, t->West, t->Down, t->Sorth };
	return temp;
}
DICE East(DICE *t){
	DICE temp = { t->West, t->Sorth, t->Up, t->Down, t->North, t->East };
	return temp;
}
DICE West(DICE *t){
	DICE temp = { t->East, t->Sorth, t->Down, t->Up, t->North, t->West };
	return temp;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s;
    cin>>s;
    if(s[s.length()-1]=='s')
        s = s + "es";
    else
        s = s+"s";
    cout<<s<<endl;

    return 0;
}

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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

signed main() {
    int n, m;
    cin >> n >> m;
    vector<int> broken(1000000);
    vector<int> dp(n + 1);
    for (int i = 0; i < m; ++i) {
        int a;
        cin >> a;
        broken[a] = 1;
    }
    dp[0] = 1;
    if (broken[1] == 0) {
        dp[1] = 1;
    }
    for (int i = 2; i <= n; i++) {
        if (broken[i] == 0) {
            dp[i] = dp[i - 1] + dp[i - 2];
            dp[i] %= mod;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 4608
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8464
#include <bits/stdc++.h>
#include<vector>
using namespace std;
 
void merge(int arr[],int l, int m, int r) 
{ 
	int i, j, k; 
	int n1 = m - l + 1; 
	int n2 = r - m; 

	/* create temp arrays */
	int L[n1],R[n2];

	/* Copy data to temp arrays L[] and R[] */
	for (i = 0; i < n1; i++)
	{ 
		L[i] = arr[l + i];
	}
	for (j = 0; j < n2; j++) 
	{
		R[j] = arr[m + 1+ j]; 
	}
	/* Merge the temp arrays back into arr[l..r]*/
	i = 0; // Initial index of first subarray 
	j = 0; // Initial index of second subarray 
	k = l; // Initial index of merged subarray 
	while (i < n1 && j < n2) 
	{ 
		if (L[i] <= R[j]) 
		{ 
			arr[k] = L[i]; 
			i++; 
		} 
		else
		{ 
			arr[k] = R[j]; 
			j++; 
		} 
		k++; 
	} 

	/* Copy the remaining elements of L[], if there 
	are any */
	while (i < n1) 
	{ 
		arr[k] = L[i]; 
		i++; 
		k++; 
	} 

	/* Copy the remaining elements of R[], if there 
	are any */
	while (j < n2) 
	{ 
		arr[k] = R[j]; 
		j++; 
		k++; 
	} 
} 

/* l is for left index and r is right index of the 
sub-array of arr to be sorted */
void mergeSort(int arr[],int l, int r) 
{ 
	if (l < r) 
	{ 
		// Same as (l+r)/2, but avoids overflow for 
		// large l and h 
		int m = l+(r-l)/2; 

		// Sort first and second halves 
		mergeSort(arr,l, m); 
		mergeSort(arr, m+1, r); 

		merge(arr,l, m, r); 
	} 
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
      long long int k,n;
      cin>>k>>n;
      int *a=new int[n];
      for(int i=0;i<n;i++)
        cin>>a[i];
    mergeSort(a,0,n-1);
    int diff=a[0]+k-a[n-1];
    for(int i=1;i<n;i++)
    {
        if(diff<a[i]-a[i-1])
            diff=a[i]-a[i-1];
    }
    cout<<k-diff<<"\n";
      
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

struct node { int t,next; }a[200010];

int head[100010],bit[100010],f[100010],n,ans,tot;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void add(int x,int y) { a[++tot].t=y;a[tot].next=head[x];head[x]=tot; }

inline void dfs(int x,int y)
{
	bit[x]=f[x]=0;
	int hh=0;
	for (int i=head[x];i;i=a[i].next)
	{
		int t=a[i].t;
		if (t==y) continue;
		dfs(t,x);
		hh|=(bit[x]&bit[t]);
		bit[x]|=bit[t];
	}
	if (!bit[x]) bit[x]=1;
	else
	{
		while ((1<<f[x])<hh||((1<<f[x])&bit[x])) f[x]++;
		bit[x]=(bit[x]>>f[x]<<f[x])|(1<<f[x]);
	}
	ans=max(ans,f[x]);
}

int main()
{
	n=rd();tot=0;
	for (int i=1;i<n;i++)
	{
		int x=rd(),y=rd();
		add(x,y);add(y,x);
	}
	ans=0;dfs(1,0);
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<vector<int>> g(n);
    for(int i = 0; i < n - 1; ++i) {
        int a, b; cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    int dist = 0;
    vector<int> v(n);
    function<int(int, int)> dfs = [&] (int v, int p) {
        int res = 0;
        vector<int> ds;
        for(auto to : g[v]) {
            if(to == p) continue;
            ds.push_back(dfs(to, v) + 1);
        }
        sort(rbegin(ds), rend(ds));
        if(!ds.empty()) {
            res = ds[0];
            dist = max(dist, ds[0]);
        }
        if(ds.size() >= 2u) {
            dist = max(dist, ds[0] + ds[1]);
        }
        if(ds.size())
        dist = max(dist, res);
        return res;
    };
    dfs(0, -1);

    vector<int> dp(n + 1, -1);
    function<int(int)> solve = [&] (int x) {
        int& res = dp[x];
        if(x == 0) return res = 1;
        if(x == 1) return res = 0;
        if(res != -1) return res;
        return res = !solve(x - 1) || !solve(x - 2);
    };
    if(solve(dist) == 1) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
}

Measured memory_bytes: 36736
/*

    author : s@if

*/

#include<bits/stdc++.h>
using namespace std;
#define NIL -1
#define fi first
#define sec second
#define MAX INT_MAX
#define INF 99999999
#define ll long long
#define PI acos(-1.0)
#define MOD 1000000007
#define PLL pair<ll,ll>
#define PII pair<int,int>
#define ull unsigned long long
#define triplell pair<pair<ll,ll> , ll>
#define triple pair<pair<int,int> , int>
#define For(i,n) for(int i=0;i<(int)n;i++)
#define Forn(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define forba(i,a,b) for(int i=(int)b;i>=(int)a;i--)

bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>m>>n;

    cout<<m-n+1<<endl;

    return 0;
}


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

int main() {
    int n;
    char s[100000][4];
    char t[4][4]={"AC", "WA", "TLE", "RE"};
    int c[4]={0};
    int i, j;

    scanf("%d", &n);
    for (i=0;i<n;i++) scanf("%s", s[i]);
    
    for (i=0;i<n;i++) {
        for (j=0;j<4;j++) {
            if (strncmp(s[i],t[j],strlen(t[j]))==0) {
                c[j]++;
            }
        }
    }
    for (i=0;i<4;i++) {
        printf("%s x %d\n",t[i],c[i]);        
    }
    return 0;
}

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


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  
  rep(i,N) cin >> A.at(i);
  sort(A.begin(),A.end());
  
  bool ans = true;
  
  rep(i,N-1) if(A.at(i+1)-A.at(i)==0) ans = false;
  
  if(ans){cout << "YES" <<endl;}
  else{cout << "NO" << endl;}
  
  
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
	int N;
	int x=0;
	cin >> N;
	int a[100];
	for (int s = 0; s < N; s++) {
		cin >> a[s];
	}
	for (int i = 1; i <= N; i++) {
		if (a[i-1] % 2 != 0 && i % 2 != 0) {
				x++;
		}
	}
	cout << x;
	return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
	
	ld n;
	cin>>n;
	ld x=n/1.08;
	ll a = ll(x)*1.08;
	ll b = ll(x+1)*1.08;
	if(b==n) cout<<(ll)x+1;
	else cout<<":(";


}


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

typedef long long ll;

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    while (B <= A) {
        B += B;
        K--;
    }
    while (C <= B) {
        C += C;
        K--;
    }
    if (K >= 0) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];} 
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";} cout<<endl;
#define S second
#define F first
#define SZ(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const int  MOD = 1e9 + 7;
const int  N = 1e6 + 7;

ll rec(ll h){
    if(h == 1) return 1;
    return 1 + 2 * rec(h / 2);
}

void solve(){
    ll h;
    cin>>h;
    cout<<rec(h)<<endl;
}	
 
int main(){
    ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

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

int main(void) {
    string s;
    cin >> s;

    for(int i=0;i<4;i++)cout << s[i];
    cout << " ";
    for(int i=4;i<s.size();i++)cout << s[i];
    cout << endl;
    return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    vector<string> C(N);
    rep (i, N) {
        string tmp;
        cin >> C[i];
    }

    rep (i, 2*N) {
        cout << C[i/2] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def test
	a = gets.to_i
	b = gets.to_i
	c = gets.to_i
	d = gets.to_i
	e = gets.to_i
	k = gets.to_i
	return ':(' if b-a > k || c-a > k || d-a > k || e-a > k
	return ':(' if c-b > k || d-b > k || e-b > k
	return ':(' if d-c > k || e-c > k
	return ':(' if e-d > k
	return 'Yay!'
end

puts test


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    cout << floor((n-1) / 2.0) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val s = sc.nextInt()
  val w = sc.nextInt()

  println(abc164a(s, w))
}

private fun abc164a(s: Int, w: Int): String {
  if (s <= w) return "unsafe"
  return "safe"
}


Measured memory_bytes: 36396
K="1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
k=map(int,K.split(","))
A=list(k)
B=int(input())
print(A[B-1])

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
#include<stack>
using namespace std;
int main()
{
	stack<char>st;
	string str;
	cin>>str;
	for(int i=0;i<str.size();i++)
	{
		if(!st.size())
		st.push(str[i]);
		else
		{
			if(str[i]=='T'&&st.top()=='S')
			st.pop();
			else st.push(str[i]);
		}
	} cout<<st.size()<<endl;return 0;
}

Measured memory_bytes: 644
#include<iostream>
#include<algorithm>
 
using namespace std;
int main()
{
  	int h1, m1, h2, m2, k, ans;
  	cin >>  h1 >> m1 >> h2 >> m2 >> k;
    ans = (h2 * 60 + m2) - (h1 * 60 + m1) - k;
	if (ans < 0) ans = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
using System;
class Program{
  static void Main(){
    string[] NM = Console.ReadLine().Split(' ');
    int N = int.Parse(NM[0]);
    int M = int.Parse(NM[1]);
    
    int maxL = 0;
    int minR = int.MaxValue;
    for (int i = 0; i < M; i++){
      string[] LR = Console.ReadLine().Split(' ');
      int L = int.Parse(LR[0]);
      int R = int.Parse(LR[1]);
      maxL = Math.Max(L, maxL);
      minR = Math.Min(R, minR);
    }
    
    int ans;
    if (maxL > minR)
      ans = 0;
    else
      ans = minR - maxL + 1;
    
    Console.WriteLine(ans);
    
  }
}

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

#define ll long long 
int main() {
  
  ll N;
  cin >> N;

  
  ll x = 26;
  ll digit = 1;
  
  while (N - x > 0) {
    digit++;
    N -= x;
    x *= 26;
  }
  
//  cout << N << endl;
//  cout << digit << endl;

  N -= 1;
  vector<ll> p;
  ll count = 1; 
  while (count <= digit)
  {
    ll a = N % 26;
    p.push_back(a);
    N /= 26;
    count++;
  }
   
  ll num = p.size();

  for (int i = num-1; i >= 0; i--) {
    cout << char('a' + p[i]);
  } 
  cout << endl;
  
  
}

Measured memory_bytes: 3616
#include<cstdio>
#include<algorithm>
#include<vector>
#include<bitset>
using namespace std;
char p[8010];
bitset<16384>T;
int x, y, C[8010], ex, ey;
bool OK(int st, int d, int ed) {
	int t = abs(ed - st);
	if (t % 2 == d % 2 && t <= d)return true;
	return false;
}
bool Pos(int ck, int d) {
	if (abs(d) > 8000)return false;
	int i;
	T.reset();
	T[8192] = 1;
	for (i = ck; i <= 8000; i+=2) {
		if (C[i]) {
			T = (T >> C[i]) | (T << C[i]);
		}
	}
	if (T[8192 + d])return true;
	return false;
}
int main() {
	int i, c = 0;
	scanf("%s", p);
	for (i = 0; p[i]; i++) {
		if (p[i] == 'T')c++;
		else {
			if (c == 0)x++;
			else C[c]++;
		}
	}
	scanf("%d%d", &ex, &ey);
	if (Pos(0, ex - x) && Pos(1, ey))puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int ans = 0;

		for (int i = 1; i <= n; i++) {
			if (Integer.toString(i).length() % 2 == 1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 28500
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,t,a,ans;
    cin>>n>>t>>a;
    vector<int> h(n);
    double best=100000;
    rep(i,n){
        cin>>h[i];
        double idea=t-h[i]*0.006;
        if(best>abs(a-idea)){
            best=abs(a-idea);
            ans=i+1;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3532
/*
                                        //     //     //\\\\\\\\\
                                        \\    //      \\        \\
                                        //   //       //         \\
                                        \\  //        \\          \\
                                        // //         //           \\
                                        \\//          \\            \\       
                                        //\\          //            //
                                        \\ \\         \\           //
                                        //  \\        //          //
                                        \\   \\       \\         //
                                        //    \\      //        //
                                        \\     \\     \\/////////
*/

#include <bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vint vector <int>
#define vll vector <long long int>
#define endl cout<<'\n'
#define fre(i,l,n) for(long long int i=l;i<n;++i)
#define fr(i,l,n) for(long long int i=l;i<=n;i++)
#define rfre(i,n,l) for(long long int i=n-1;i>=l;i--)
#define rfr(i,n,l) for(long long int i=n;i>=l;--i)
#define tab '\t'
#define debug cout<<'*';
#define s(a) cin>>a
#define p(a) cout<<a
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
typedef pair<int,pair<int,int> > tii;
typedef vector<int> vec;
typedef vector<long long> vecll;
typedef vector<pair<int,int> > vec_pii;
typedef vector<pair<long long int,long long int> > vec_pll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<pair<int,int> > > vvpii;
typedef vector<vector<pair<ll,ll> > > vvpll;
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define Pi 3.14159265358979
#define gcd(a,b) __gcd(a,b)
#define sf(n) scanf("%lld",&(n))
#define pf(n) printf("%lld\n",(n))
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define w(t) while(t--)
#define flt(a) cout<<fixed<<setprecision(a)
#define cntSetBits(n) __builtin_popcountll(n)
/*****************************
*****************************/




void solve()
{
    ll n;
    s(n);
    ll cnt = 1;
    ll val = n;
    while(true)
    {
        if(n % 360 == 0)
        {
            break;
        }
        cnt += 1;
        n += val;
    }
    p(cnt);endl;
}



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll t=1;
    // s(t);
    w(t)
    {
        solve();
    }
    return 0;
}









Measured memory_bytes: 3608
#include <iostream>

using namespace std;
int A[500000];
int cnt;
void Merge(int A[],int left,int mid,int right){
    int n1 = mid-left+1;
    int n2 = right - mid;
    int L[n1+1],R[n2+1];
    for(int i=0;i<n1;i++){
        L[i] = A[left+i];
    }
    for(int i=0;i<n2;i++){
        R[i] = A[mid+1+i];
    }
    L[n1] = 2000000000;
    R[n2] = 2000000000;
    int i=0,j=0;
    for(int k=left;k<right+1;k++){
        cnt++;
        if(L[i]<=R[j]){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }
    }
}
void mergeSort(int A[],int left,int right){
    if(left<right){
        int mid = (left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid+1,right);
        Merge(A,left,mid,right);
    }
}
int main()
{
    int n;
    cnt = 0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    mergeSort(A,0,n-1);
    for(int i=0;i<n;i++){
        if(i>0) cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 6944
N, M = map(int,input().split())
a = list(map(int,input().split()))
check = []
for i in range(M):
    check.append(list(map(int,input().split())))
check.sort(key=lambda x : x[1],reverse = True)
a.sort()
ans = []
for b, c in check:
    ans += [c for i in range(b)]
    if len(ans) > N:
        break
else:
    ans+=[0 for i in range(N-len(ans))]
A=0
for i in range(N):
    A+=max(ans[i],a[i])
print(A)

Measured memory_bytes: 35028
#include <stdio.h>

int	main(void)
{
	int a,b,c,x;
	scanf("%d%d%d%d", &a,&b,&c,&x);
	int i,j,k;
	i = 0;
	int count = 0;
	while (i <= a)
	{
		j = 0;
		while (j <= b)
		{
			k = 0;
			while (k <= c)
			{
				if (x == (i * 500) + (j * 100) + (k * 50))
				{
					count++;
				}
				k++;
			}
			j++;
		}
		i++;
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder sbA = new StringBuilder();
		sbA.append(scan.nextLine());
		StringBuilder sbB = new StringBuilder();
		sbB.append(scan.nextLine());
		StringBuilder sbC = new StringBuilder();
		sbC.append(scan.nextLine());
		char tern = sbA.charAt(0);
		sbA.deleteCharAt(0);
		while (true) {

			switch (tern) {
			case 'a':
				if (sbA.length() == 0) {
					System.out.println("A");
					return;
				}
				tern = sbA.charAt(0);
				sbA.deleteCharAt(0);
				break;
			case 'b':
				if (sbB.length() == 0) {
					System.out.println("B");
					return;
				}
				tern = sbB.charAt(0);
				sbB.deleteCharAt(0);
				break;
			case 'c':
				if (sbC.length() == 0) {
					System.out.println("C");
					return;
				}
				tern = sbC.charAt(0);
				sbC.deleteCharAt(0);
				break;
			}
		}
	}

}


Measured memory_bytes: 9932
#include <bits/stdc++.h>
using namespace std;
int main(){
   long long a,b,c;
   cin >> a >> b >> c;
   long long x = a/c;
   long long y = b/c;
   long long z = y-x;
   if(a%c == 0)z++;
   cout << z << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int r;cin>>r;
    cout<<pow(r,2)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define MM <<" "<<
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setpercision(x)
using ll=long long;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using pl=pair<ll,ll>;
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;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    int H,W;cin>>H>>W;
    char info[H][W];
    rep(i,H)rep(j,W){
        cin>>info[i][j];
    }
    int ans=0;
    rep(i,H)rep(j,W){
        if(info[i][j]=='#')continue;
        int now=0;
        int count[H][W];
        rep(p,H)rep(q,W)count[p][q]=inf;
        count[i][j]=0;
        queue<pair<int,int>> que;
        que.emplace(i,j);
        while(que.size()){
            int p=que.front().fi,q=que.front().se;
            que.pop();
            rep(k,4){
                int np=p+dy[k],nq=q+dx[k];
                if(np<0 or np>=H or nq<0 or nq>=W)continue;
                if(info[np][nq]=='#')continue;
                if(count[np][nq]>count[p][q]+1){
                    count[np][nq]=count[p][q]+1;
                    que.emplace(np,nq);
                }
            }
        }
        rep(p,H)rep(q,W){
            if(count[p][q]==inf)continue;
            else now=max(now,count[p][q]);
        }
        ans=max(ans,now);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int x,k,d;
   cin>>x>>k>>d;
   if(x<0)
    x=-1*x;
   long long int n=x/d;
   //no .of moves to get the minimum pos. coordinate;
  // cout<<k*d<<"\n";
   if(k>n)
   {
       long long int mn=x%d;
  // if(mn>abs(mn-d))
   // mn=abs(mn-d);
   if((k-n)%2==0)
    cout<<mn;

   else
    cout<<d-mn;
   }
   else
   cout<<x-k*d;
}


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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

int main()
{
	int n;
	si(n);
	vector<vi> gr(n);  // {arista, peso}
	for(int i = 1; i < n; i++)
	{
		gr[i].push_back((i*10)%n);
		gr[i].push_back((i+1)%n);
	}

	vb visit(n);
	deque<pi> cola;
	cola.push_back({1, 1});

	while(!cola.empty())
	{
		pi curr = cola.front();
		cola.pop_front();
		if(visit[curr.fst])
			continue;
		//cout << curr.fst << endl;
		visit[curr.fst] = 1;
		if(curr.fst == 0)
		{
			printf("%d\n", curr.scn);
			return 0;
		}
		if(visit[gr[curr.fst][0]] == false)
			cola.push_front({gr[curr.fst][0], curr.scn});

		if(visit[gr[curr.fst][1]] == false)
			cola.push_back({gr[curr.fst][1], curr.scn+1});
	}

    return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B && B != C)
  {
    cout << "Yes" << endl;
  }
  else if (A == C && A != B)
  {
    cout << "Yes" << endl;
  }
  else if (B == C && A != B)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int a[3];
	int ans=0;
	
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	ans = a[0]+a[1];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	char k='a';
	string a,b,c;
	cin>>a>>b>>c;
	while(1){
		if(k=='a'){
			if(a.length()==0){
				cout<<'A'<<endl;
				return 0;
			}
			k=a[0];
			a=a.substr(1);
		}else if(k=='b'){
			if(b.length()==0){
				cout<<'B'<<endl;
				return 0;
			}
			k=b[0];
			b=b.substr(1);
		}else{
			if(c.length()==0){
				cout<<'C'<<endl;
				return 0;
			}
			k=c[0];
			c=c.substr(1);
		}
	}
}

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

class union_find {
 public:
  using tp = std::vector<size_t>::size_type;
  // 取り扱う型.

  explicit union_find(const tp n) : parent(n), rank(n, 0), cache() {
    for (tp i = 0; i < n; i++) {
      parent[i] = i;
    }
    cache.reserve(n);
  }

  tp root(tp n) {
    // 番号nの親を求める. ついでに経路圧縮を行う.

    while (parent[n] != n) {
      // 根になるまで親を探索. ついでにキャッシュ変数に追加.
      cache.push_back(n);
      n = parent[n];
    }
    for (const auto i : cache) {
      // キャッシュ変数に追加された子の親を経路圧縮.
      parent[i] = n;
    }
    cache.clear();
    return n;
  }

  bool same(tp x, tp y) {
    // xとyが同じグループに属しているか計算.
    return root(x) == root(y);
  }

  void unite(const tp x, const tp y) {
    // xとyを同じグループにする.
    const auto x_root = root(x);
    const auto y_root = root(y);

    if (x_root == y_root) {
      // 根が同じなら元から同じグループ.
      return;
    }

    if (rank[x_root] < rank[y_root]) {
      // rankの大きい方の根を統合後の根にする.
      parent[x_root] = y_root;
    } else if (rank[y_root] < rank[x_root]) {
      // rankの大きい方の根を統合後の根にする.
      parent[y_root] = x_root;
    } else {
      // rankが同じなら, どっちかを根にして根になったほうのランクを上げる.
      parent[x_root] = y_root;
      rank[x_root]++;
    }
  }

 private:
  std::vector<tp> parent;
  // 親の番号を格納. 自分が根なら parent[i] == i になる.
  std::vector<tp> rank;
  // 自分の下に何段分の子があるかを格納.
  std::vector<tp> cache;
  // root計算のときに経路圧縮を行うためのキャッシュ変数.
};

int main() {
  int64_t n;
  std::cin >> n;

  std::vector<std::pair<int64_t, int64_t>> x(n), y(n);

  for (int64_t i = 0; i < n; i++) {
    std::cin >> x[i].first >> y[i].first;
    x[i].second = i;
    y[i].second = i;
  }

  std::sort(x.begin(), x.end());
  std::sort(y.begin(), y.end());

  std::multimap<int64_t, std::pair<int64_t, int64_t>> m;

  for (int64_t i = 0; i < n - 1; i++) {
    m.emplace(x[i + 1].first - x[i].first,
      std::make_pair(x[i + 1].second, x[i].second));
    m.emplace(y[i + 1].first - y[i].first,
      std::make_pair(y[i + 1].second, y[i].second));
  }

  union_find uf(n);
  int64_t l = 0;

  for (const auto &i : m) {
    if (!uf.same(i.second.first, i.second.second)) {
      uf.unite(i.second.first, i.second.second);
      l += i.first;
    }
  }

  std::cout << l << std::endl;
  return 0;
}

Measured memory_bytes: 17792
#include <cstdio>
using namespace std;
const int N=100000+10;
int n;
int a[N];
void readData(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
}
inline int gcd(int x,int y){
	for(int z=x%y;z;x=y,y=z,z=x%y);
	return y;
}
void solve(){
	int g=a[1];
	for(int i=2;i<=n;i++) g=gcd(g,a[i]);
	printf("%d\n",g);
}
int main(){
	readData();
	solve();
	return 0;
}

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

#define ll long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

int main(){
	fastio
	int l,r,d;
	cin >> l >> r >> d;
	cout << r/d-l/d+(l%d==0 ? 1 : 0);
}

Measured memory_bytes: 3564
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (void)
{
    intmax_t A;
    intmax_t sum = 0;

    for (size_t i = 0; i < 3; i++) {
        scanf("%jd", &A);
        sum += A;
    }

    if (sum >= 22)
        puts("bust");
    else
        puts("win");

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a,b) (0<=a&&a<b)
using namespace std;
int w,h,c,ans,f[20][20];
bool crs(int y1,int x1,int y2,int x2){
	for(int y=y1;y<y2;y++)for(int x=x1;x<x2;x++)if(ck(y,h)&&ck(y+1,h)&&ck(x,w)&&ck(x+1,w)&&
		f[y][x]!=f[y][x+1]&&f[y][x]!=f[y+1][x]&&f[y][x]!=f[y+1][x+1]&&
		f[y][x+1]!=f[y+1][x]&&f[y][x+1]!=f[y+1][x+1]&&f[y+1][x]!=f[y+1][x+1])return 1;
	return 0;
}
void dfs(int y,int x){
	for(;y<h&&(x>=w||f[y][x]);x++)if(x>=w)x=-1,y++;
	if(y>=h&&c*2==w*h){
		ans++;return;
	}
	if(ck(x+1,w)&&!f[y][x]&&!f[y][x+1]){
		f[y][x]=f[y][x+1]=++c;
		if(!crs(y-1,x-1,y+1,x+2))dfs(y,x+2);
		f[y][x]=f[y][x+1]=0;--c;
	}
	if(ck(y+1,h)&&!f[y][x]&&!f[y+1][x]){
		f[y][x]=f[y+1][x]=++c;
		if(!crs(y-1,x-1,y+2,x+1))dfs(y,x+1);
		f[y][x]=f[y+1][x]=0;--c;
	}
}
int main(){
	while(cin>>w>>h,w){
		c=ans=0;
		rep(i,h)rep(j,w)f[i][j]=0;
		dfs(0,0);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 872
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i&-i
        return s
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i&-i
n, q = map(int, input().split())
c = list(map(int, input().split()))
last = [-1]*n
foradd = [[] for i in range(n)]
for i in range(n):
    if last[c[i]-1] != -1: foradd[last[c[i]-1]].append(i)
    last[c[i]-1] = i
forsum = [[] for i in range(n)]
for i in range(q):
    l, r = map(int, input().split()); l -= 1; r -= 1
    forsum[l].append([r, i])
bit = Bit(n); ans = [-1]*q
for i in range(n-1, -1, -1):
    for j in foradd[i]: bit.add(j, 1)
    for j in forsum[i]: ans[j[1]] = j[0]-i+1-bit.sum(j[0])
print(*ans, sep="\n")

Measured memory_bytes: 245164
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        m: u32,
        d: u32,
    }
    let mut ans = 0;
    for i in 1..(m + 1) {
        for j in 1..(d + 1) {
            let a = j % 10;
            let b = j / 10;
            if a >= 2 && b >= 2 && a * b == i {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}
 
 
int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, string>> a(m);
    set<int> ac;
    vector<int> wa(n);
    for(auto &p : a ) cin >> p.first >> p.second;
    for(auto &p : a) {
        if(p.second == "AC") ac.insert(p.first);
        else if (!ac.count(p.first)) wa[p.first - 1]++;
        else continue;
    }
    int pena = 0;
    rep(i, n) {
        if(ac.count(i + 1)) pena += wa[i];
    }
    cout << ac.size() << ' ' << pena << endl;
}

Measured memory_bytes: 12048
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
     
typedef long long ll;
typedef pair<int, int> P;
     
#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back
     
const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
     
int main(){
    int a, b; cin >> a >> b;
    if(b == 100) b = 101;
    if(a == 0){
    	cout << b << endl;
    }else if(a == 1){
    	cout << b * 100 << endl;
    }else{
    	cout << b * 10000 << endl;
    }
}

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

bool solve() {
  string S; cin >> S;
  set<char> st;
  map<char, int> ma;
  rep(i, 0, 4) {
    st.insert(S[i]);
    ma[S[i]]++;
    if(ma[S[i]] == 3) return false;
  }
  if(st.size() == 2) return true;
  return false;
}

int main() {
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a[100005],b,c,d,n,m,p,q,x,y,k,h,w,sum,mi,ma,ans,l,r,res;
string s;
typedef vector<int> VI;
typedef vector<pair<int,int> > VP;

ll dp[100005];

void solve(){
    rep(i,n+1){
        dp[i]%=mod;
        if(!a[i+1]){dp[i+1]+=dp[i];dp[i+1]%=mod;}
        if(!a[i+2]){dp[i+2]+=dp[i];dp[i+2]%=mod;}
    }
}

int main(){
    cin>>n>>m;
    rep(i,m){cin>>b;a[b]=1;}
    dp[0]=1;
    solve();
    rep(i,n+1)d(dp[i]);
    p(dp[n]%mod);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return sums.back();
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void build() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};

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

    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    sort(v.begin(), v.end());

    ll floor = 0, ceil = INF;
    auto check = [&](ll mid) -> bool {
        ll p = 0;
        for (ll b : v) {
            ll k = mid - b;
            auto it = lower_bound(v.begin(), v.end(), k);
            ll c = distance(it, v.end());
            p += c;
        }
        return p <= m;
    };

    while (floor + 1 < ceil) {
        ll mid = (floor + ceil) / 2;
        bool ok = check(mid);
        if (ok) ceil = mid;
        else floor = mid;
    }

    ll over_c = [&](ll mid) -> ll {
        ll p = 0;
        for (ll b : v) {
            ll k = mid - b;
            auto it = lower_bound(v.begin(), v.end(), k);
            ll c = distance(it, v.end());
            p += c;
        }
        return p;
    }(ceil);


    ll rem = m - over_c;

    ll over_h = [&](ll mid) -> ll {

        CumulativeSum cs(n);
        rep(i, n) cs.set(i, v[i]);
        cs.build();

        ll h = 0;
        for (ll b : v) {
            ll k = mid - b;
            auto it = lower_bound(v.begin(), v.end(), k);
            int c = distance(it, v.end());
            ll now = cs.getSectionSum(n - c, n) + (b * c);
            h += now;
        }
        return h;
    }(ceil);

    ll ans = over_h + (rem * floor);

    cout << ans << endl;
}


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

int main(){

	int n, k;
	string s;

	cin>> n;
	cin>> s;
	cin>> k;

	for(int i=0;i<n;i++){
		if(s[i]!=s[k-1]) s[i]='*';
	}

	cout<< s << endl;


}

Measured memory_bytes: 256
//To include everything you need
#include <bits/stdc++.h>
using namespace std;
typedef std::vector<int> vi;
typedef std::vector<std::pair<int, int> > vpi;
typedef std::vector<string> vs;
typedef std::vector<char> vc;

int main()
{
    string bingo = "No";
    int bingoGrid[3][3];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            int a;
            cin >> a;
            bingoGrid[i][j] = a;
        }
    }
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int b;
        cin >> b;
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (bingoGrid[i][j] == b)
                    bingoGrid[i][j] = 0;
            }
        }
    }

    if (bingoGrid[0][0] == 0 && bingoGrid[0][1] == 0 && bingoGrid[0][2] == 0)
        bingo = "Yes";
    if (bingoGrid[1][0] == 0 && bingoGrid[1][1] == 0 && bingoGrid[1][2] == 0)
        bingo = "Yes";
    if (bingoGrid[2][0] == 0 && bingoGrid[2][1] == 0 && bingoGrid[2][2] == 0)
        bingo = "Yes";

    if (bingoGrid[0][0] == 0 && bingoGrid[1][0] == 0 && bingoGrid[2][0] == 0)
        bingo = "Yes";
    if (bingoGrid[0][1] == 0 && bingoGrid[1][1] == 0 && bingoGrid[2][1] == 0)
        bingo = "Yes";

    if (bingoGrid[0][2] == 0 && bingoGrid[1][2] == 0 && bingoGrid[2][2] == 0)
        bingo = "Yes";

    if (bingoGrid[0][0] == 0 && bingoGrid[1][1] == 0 && bingoGrid[2][2] == 0)
        bingo = "Yes";
    if (bingoGrid[2][0] == 0 && bingoGrid[1][1] == 0 && bingoGrid[0][2] == 0)
        bingo = "Yes";

    cout<<bingo;
}

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

class Main{
        static ArrayDeque<Elem> dq;
        static int size;
        static int max;
        static int time = 0;

        static class Elem{
                String s;
                Integer i;
                public Elem(String s, Integer i){
                        this.s = s;
                        this.i = i;
                }
                public int minus(int i){
                        int j = this.i>=i ? i : this.i;
                        this.i -= j;
                        return j;
                }
        }
        static void runqueue(){
                while(!dq.isEmpty()){
                        Elem e = dq.pollFirst();
                        time += e.minus(max);

                        if(e.i>0)
                                dq.offerLast(e);
                        else
                                System.out.println(e.s + " " + time);
                }
        }

        public static void main(String[] args) throws IOException{
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                String[] line = br.readLine().split(" ");
                size = Integer.parseInt(line[0]);
                max = Integer.parseInt(line[1]);

                dq = new ArrayDeque<>();
                for(int i=0; i<size; i++){
                        line = br.readLine().split(" ");
                        Elem e = new Elem(line[0], Integer.parseInt(line[1]));
                        dq.offerLast(e);
                }
                runqueue();
        }
}

Measured memory_bytes: 63452