akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <cstdio>
#include<vector>

using namespace std;

int main(){
    int sum=0;
    int min=10;
    for (int i =0; i < 5; i++){
        int tmp = 0;
        int left = 0;
        cin >> tmp;
        left = tmp % 10;
        if (left==0){
            left = 10;
        }
        sum = sum + tmp + (10 - left);
        if (min > left){
            min = left;
        }
    }
    sum = sum - (10-min);
    cout << sum << endl;
}


Measured memory_bytes: 256
fun Power(base:Long, exponent:Long, prime:Long):Long{
    return when(exponent){
        0L -> 1
        1L -> base % prime
        else -> Power(base, exponent / 2, prime).let{(it * it % prime) * Power(base, exponent % 2, prime)} % prime
    }
}
fun FMemo(n:Int, prime:Long):Array<Long>{
    val g = Array(n + 1, {Array(it + 1, {0L})})
    for (i in 0 .. n){
        g[i][0] = 1
        for (j in 1 until i){
            g[i][j] = (g[i - 1][j] * (j + 1) + g[i - 1][j - 1]) % prime
        }
        g[i][i] = 1
    }
    val p = Array(n + 1){2L}.apply {
        for (idx in 1 .. n){
            this[idx] = this[idx - 1].let{it * it % prime}
        }
    }

    return Array(n + 1, {i ->
        var res:Long = 0
        var base = Power(2, n - i.toLong(), prime)
        var power = 1L
        for (j in 0 .. i){
            res += power * g[i][j] % prime
            res %= prime
            power = power * base % prime
        }
        res * p[n - i] % prime
    })
}
fun main(args:Array<String>):Unit{
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val combination = Array(n + 1, {0L}).apply{
        var res = 1L
        for (i in 0 .. n){
            this[i] = res
            res = res * (n - i) % m
            res = res * Power(i + 1L, m - 2L, m.toLong()) % m
        }
    }
    val f = FMemo(n.toInt(), m.toLong())
    println((0..n).map{i -> ((if (i % 2 == 0) 1 else (m - 1)) * combination[i] % m) * f[i] % m }.sum() % m)

}

Measured memory_bytes: 182200
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 100+100;
const ll mod = 1e9+7;
int b[maxn];
int main() {
    ios::sync_with_stdio(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>b[i];
    int ans = 100000000;
    for(int i=0;i<=100;i++){
        int num = 0;
        for(int j=1;j<=n;j++)
            num+=(i-b[j])*(i-b[j]);
        ans = min(ans,num);
    }
   cout<<ans<<endl;
}


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

#define rep(i,n) REP(i,0,n)
#define REP(i, a, n) for(int i = a; i < (int)n ; i++)

using namespace std;

string s;
string l[4];

signed main(){
  cin >> s;
  l[0] = "dream";
  l[1] = "dreamer";
  l[2] = "erase";
  l[3] = "eraser";
  
  int pos;
  bool flag = false;
  while(s.size()!=0){
    flag = false;
    rep(i, 4){
      if((pos = s.find(l[i], s.size()-l[i].size())) != string::npos){
	s.erase(pos, l[i].size());
	flag = true;
      }
    }
    if(!flag){
      cout << "NO" << '\n';
      exit(0);
    }
  }
  
  cout << "YES" << '\n';
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int a,n;
    while(~scanf("%d %d",&a,&n))
    {
        if(a<500)
        {
            if(n>=a)
                printf("Yes\n");
                else
            printf("No\n");
        }
        else if(a>=500)
        {
            while(a>=500)
            {
                a-=500;
            }
            if(n>=a)
                printf("Yes\n");
                else
            printf("No\n");
        }


    }
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

long long n,m;

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

    long long ans;

    if(n == 1 && m == 1) ans = 1;
    else if(n == 1 && m >= 2) ans = m-2;
    else if(n >= 2 && m == 1) ans = n-2;
    else{
        ans = (n-2)*(m-2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin>>n;
    vector<double> a(n);
    double sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sum/=n;
    double min=999999999;
    int k=0;
    for(int i=0;i<n;i++){
        if(fabs(sum-a[i])<min){
            min=fabs(sum-a[i]);
            k=i;
        }
    }
    cout<<k;
    
}

Measured memory_bytes: 256
a, b, m = map(int, input().split())
pa = list(map(int, input().split()))
pb = list(map(int, input().split()))

ans = min(pa) + min(pb)
for _ in range(m):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    ans = min(ans, pa[x] + pb[y] - c)

print(ans)


Measured memory_bytes: 18648
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

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

using namespace std;

typedef long long ll;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  int x, y, z; cin >> x >> y >> z;
  int ans = (x-z) / (y+z);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#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")
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}
int comb(int n, int k) {
	k = min(k, n - k);
	int x = 1, y = 1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

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

	int x;
	cin >> x;
	int ans = 0;
	ans += 1000 * (x / 500);
	ans += (x % 500) / 5 * 5;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x){
  while( x->left != NIL ) x = x->left;
  return x;
}

Node * find(Node *u, int k){
  while( u != NIL && k != u->key ){
    if( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x){
  if( x->right != NIL ) return treeMinimum(x->right);
  Node *y = x->parent;
  while( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y;
  Node *x;

  if( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(z);

  if ( y->left != NIL ){
    x = y->left;
  } else {
    x = y->right;
  }

  if( x != NIL ){
    x->parent = y->parent;
  }

  if( y->parent == NIL ){
    root = x;
  } else {
    if( y == y->parent->left ){
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if( y != z ){
    z->key = y->key;
  }

  free(y);
  
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if( y == NIL ){
    root = z;
  } else {
    if( z->key < y->key ){
      y->left =z;
    } else {
      y->right = z;
    }
  }
}


void inorder(Node *u){
  if( u == NIL ) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if( u == NIL ) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d",&n);

  for( i=0; i<n; i++ ){
    cin >> com;
    if( com[0] == 'f' ){
      scanf("%d",&x);
      Node *t = find(root,x);
      if( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if( com == "insert" ){
      scanf("%d",&x);
      insert(x);
    } else if( com == "print" ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if( com == "delete" ){
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }
  return 0;
}



Measured memory_bytes: 22036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    set<int> u;
    map<int,vector<int>> IN,OUT;
    rep(i,n){
        int s,t,x;
        scanf(" %d %d %d", &s, &t, &x);
        IN[s-x].pb(x);
        OUT[t-x].pb(x);

        // printf(" [%d %d)\n", s-x,t-x);
        u.insert(s-x);
        u.insert(t-x);
    }

    queue<int> ASK;
    rep(i,q){
        int d;
        scanf(" %d", &d);
        ASK.push(d);
        u.insert(d);
    }

    set<int> X;
    for(int i:u){
        for(int j:OUT[i]) X.erase(j);
        for(int j:IN[i]) X.insert(j);

        if(!ASK.empty() && ASK.front()==i){
            ASK.pop();
            int ans = -1;
            if(!X.empty()) ans = *X.begin();
            printf("%d\n", ans);
        }
    }
    return 0;
}


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

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<P> ab(n);
    rep(i, n) cin >> ab[i].first >> ab[i].second;
    sort(all(ab));
    ll b = 0;
    rep(i, n) {
        b += ab[i].second;
        if (b >= k) {
            cout << ab[i].first << endl;
            return 0;
        }
    }
}

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

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


int main() {
	int N;
	vector<long> H;
	long tmp;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		H.push_back(tmp);
	}
	long most = 0;
	long count = 0;
	H.push_back(10000100000);
	long past = H.at(0);
	for (int i = 1; i < N; i++) {
		past = H.at(i - 1);
		if (past >= H.at(i)) {
			count++;
		}
		else {
			if (most < count) {
				most = count;
			}
			count = 0;
		}
	}
	if (most < count) {
		most = count;
	}
	cout << most;
}


Measured memory_bytes: 1400
import collections

n = int(input())
a = [int(e) for e in input().split(" ")]

a_counter = collections.Counter(a)
ret = 0
for i in range(1,10**5+1):

    tmp = a_counter[i-1] + a_counter[i] + a_counter[i+1]
    ret = max(tmp,ret)

print(ret)

Measured memory_bytes: 14564
#include<bits/stdc++.h>
    using namespace std;
	
    int main(){
    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
		int n,k;
		cin>>n>>k;
		int arr[n];
		for(int i=0;i<n;i++){
			cin>>arr[i];
		}
		int cost[n]={};
		for(int i=0;i<n;i++)cost[i]=1000000007;
		cost[0]=0;
		cost[1]=abs(arr[1]-arr[0]);
		for(int i=2;i<n;i++){
			for(int j=i-1;j>=max(0,i-k);j--){
				if(abs(arr[i]-arr[j])+cost[j]<cost[i]){
					cost[i]=abs(arr[i]-arr[j])+cost[j];
				}
			}
		}
		cout<<cost[n-1]<<"\n";
        return 0;
    }

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

cost = [float('inf') ] * n
cost[0] = 0

for i in range(n):
	if i -1 >= 0:
		cost[i] = min(cost[i], cost[i-1] + abs(h[i] - h[i-1]))
	if i - 2 >=0:
		cost[i] = min(cost[i],cost[i-2] + abs(h[i] - h[i-2]))
print(cost[-1])



Measured memory_bytes: 13928
a = list(input())
b = list(input())
c = list(input())

import sys

turn = 'a'
while True:
    if len(a) == 0 and turn == 'a':
        print('A')
        sys.exit(0)
    elif len(b) == 0 and turn == 'b':
        print('B')
        sys.exit(0)
    elif len(c) == 0 and turn == 'c':
        print('C')
        sys.exit(0)

    if turn == 'a':
        turn = a[0]
        del a[0]
    elif turn == 'b':
        turn = b[0]
        del b[0]
    elif turn == 'c':
        turn = c[0]
        del c[0]


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(LL)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

#define INF 1LL << 50

const int MAX_V=103;

struct edge{int to,cost;};
typedef pair<int,int> P;//firstは最短距離,secondは頂点番号

int V;
vector<edge> G[MAX_V];
int d[MAX_V],prever[MAX_V];

void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P> > que;
    fill(d,d+V,INT_MAX);
    fill(prever,prever+V,-1);
    d[s]=0;
    que.push(P(0,s));
    
    while(!que.empty()){
        P p=que.top();que.pop();//仮の最短距離が短い順に取り出す
        int v=p.second;
        if(d[v]<p.first)continue;
        REP(i,G[v].size()){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                prever[e.to]=v;
                que.push(P(d[e.to],e.to));//仮の最短距離と頂点の組を更新が行われる度に追加していく
            }
        }
    }
}


int main(){
    int N,M;
    cin>>N>>M;
    V=N;
    REP(i,M){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        edge e={b,c};
        edge e2={a,c};
        G[a].PB(e);G[b].PB(e2);
    }
    set<PII>st;
    REP(i,N){
        dijkstra(i);
        FOR(j,i+1,N){
            int bef=j;
            int t=bef;
            while(1){
                t=prever[t];
                if(t==-1)break;
                //cout<<bef<<" "<<t<<endl;
                if(t<bef)st.insert(MP(t,bef));
                else st.insert(MP(bef,t));
                bef=t;
            }
        }
    }
    cout<<M-SZ(st)<<endl;
    return 0;
}


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

void solve(){
    int h1, s1, h2, s2;
    cin >> h1 >> s1 >> h2 >> s2;
    int turns1 = (int)ceil((double)h2/s1);
    int turns2 = (int)ceil((double)h1/s2);
    if(turns1 <= turns2) cout << "Yes";
    else cout << "No";
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
        cout << '\n';
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#define int long long
using namespace std;
signed main(){
    int n,x;
    cin>>n>>x;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int cnt=0;
    int sum;
    int def;
    for(int i=0;i<n-1;i++){
        sum=a[i]+a[i+1];
        def=sum-x;
        if(def<=0) continue;
        if(def<=a[i+1]){
            a[i+1]-=def;
        }else{
            a[i]=a[i]-def+a[i+1];
            a[i+1]=0;
        }
        cnt+=def;
    }
    cout<<cnt<<endl;
    return 0;
}

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

const int mod = 2019;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(),s.end());
    int x = 1, tot = 0;
    vector<int> cnt(mod);
    ll ans = 0;
    rep(i,n) {
        cnt[tot]++;
        tot += (s[i]-'0')*x;
        tot %= mod;
        ans += cnt[tot];
        x = x*10%mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3700
#include<stdio.h>
#include<stdlib.h>

int main(void){
    int i,ex1,ex2,ex3,ex4,a,b,q;
    int dice[7];
    int command;

    for(i = 1;i <= 6;i++){
        scanf("%d",&dice[i]);
    }

    scanf("%d",&q);

    for(i = 0;i < q;i++){
        scanf("%d%d",&a,&b);
        while(1){
            command = rand() % 4;
            if(command == 0){
                ex1 = dice[1];
                ex2 = dice[2];
                ex3 = dice[5];
                ex4 = dice[6];
                dice[1] = ex3;
                dice[2] = ex1;
                dice[5] = ex4;
                dice[6] = ex2;
            }else if(command == 1){
                ex1 = dice[1];
                ex2 = dice[2];
                ex3 = dice[5];
                ex4 = dice[6];
                dice[1] = ex2;
                dice[2] = ex4;
                dice[5] = ex1;
                dice[6] = ex3;
            }else if(command == 2){
                ex1 = dice[1];
                ex2 = dice[3];
                ex3 = dice[4];
                ex4 = dice[6];
                dice[1] = ex3;
                dice[3] = ex1;
                dice[4] = ex4;
                dice[6] = ex2;
            }else if(command == 3){
                ex1 = dice[1];
                ex2 = dice[3];
                ex3 = dice[4];
                ex4 = dice[6];
                dice[1] = ex2;
                dice[3] = ex4;
                dice[4] = ex1;
                dice[6] = ex3;
            }
            if(dice[1] == a && dice[2] == b)
                break;
        }
        printf("%d\n",dice[3]);
    }
    return 0;
}

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

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

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

int main(){
  ll n , k;
  mint ans;
  cin >> n >> k;
  vector<mint> d(k + 1);
  vector<mint> kosu(k + 1);
  for (ll i = k; i > 0; i--){
    ll a = k/i;
    kosu[i] = mint(a).pow(n);
    ll j = 2;
    while (j * i <= k){
        kosu[i] -= kosu[j * i];
        j++;
    }
    d[i] = mint(i) * kosu[i];
    ans += d[i];
  }
  cout << ans.x << endl;
}

Measured memory_bytes: 4816
n = int(input())
a = [int(x) for x in input().split()]
key = [0]*n
for i in range(n):
  if a[i]+i >= n:
    continue
  key[a[i]+i] += 1
ans = 0
for i in range(n):
  if i-a[i] < 0:
    continue
  ans += key[i-a[i]]
print(ans)

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

int main(){

    int is;
    int h, m, s;
    cin >> is;
    h = is / 3600;
    is = is - h*3600;
    m = is / 60;
    s = is % 60;
    cout << h << ":" << m << ":" << s << endl;

    return 0;
}

Measured memory_bytes: 1164
import heapq

def pcc(src, adj):
	pq = [(0,src)]
	dist = [float('inf')]*n
	dist[src] = 0
	heapq.heapify(pq)
	while pq:
		d, u = heapq.heappop(pq)
		for w, v in adj[u]:
			if dist[v] > dist[u] + w:
				dist[v] = dist[u] + w
				heapq.heappush(pq, (dist[v], v))
	return dist

n,m,s,t = map(int,input().split())
s,t = s-1,t-1
adjs = [[] for _ in range(n)]
adjt = [[] for _ in range(n)]
for _ in range(m):
	u,v,a,b = map(int, input().split())
	u,v = u-1,v-1
	adjs[u].append((a,v))
	adjs[v].append((a,u))
	adjt[u].append((b,v))
	adjt[v].append((b,u))

dist_s = pcc(s, adjs)
dist_t = pcc(t, adjt)

ans = [0]*n
ans[n-1] = 10**15 - dist_s[n-1]-dist_t[n-1]
for i in range(n-2,-1,-1):
	ans[i] = max(ans[i+1], 10**15 - dist_s[i] - dist_t[i])
print(*ans, sep = "\n")


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

using namespace std;

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

    vector<int> vec(N);

    for (int i = 0; i < N; i++)
    {
        cin >> vec.at(i);
    }

    sort(vec.rbegin(), vec.rend());

    int ans = 1;
    int nowMax = vec.at(0);

    for (int i = 1; i < N; i++)
    {
        if (vec.at(i) < nowMax)
        {
            nowMax = vec.at(i);
            ans++;
        }
        
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 384
fun main(args: Array<String>){
val str = readLine()!!
for (i in 'a'..'z'){
  if(str[0] == i){
    println("a")
  }else{
  }
}
  for (j in 'A'..'Z'){
    if(str[0] == j){
      println("A")
    }else{
    }
  }
}

Measured memory_bytes: 34440
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>

#define loop(i,st,en) for(int i=st;i<en;i++)
#define loop0n(i,n) for(int i=0;i<n;i++)


int main() {
  int K=0,A=0,B=0;
  scanf("%d",&K);
  scanf("%d %d",&A,&B);
  loop(i,A,B+1){
    if(i%K==0) {
      printf("OK\n");
      return 0;
    }
  }
  printf("NG\n");
  return 0;
}

Measured memory_bytes: 1640
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


struct SuffixArray{ 
  string s;
  vector<int> sa,rev;
  
  SuffixArray(){}
  SuffixArray(const string &S):s(S){
    int n=s.size();
    s.push_back('$');
    sa.resize(n+1);
    iota(sa.begin(),sa.end(),0);
    sort(sa.begin(),sa.end(),
         [&](int a,int b){
           if(s[a]==s[b]) return a>b;
           return s[a]<s[b];
         });
    vector<int> c(n+1,0),r(n+1),cnt(n+1);
    for(int i=0;i<=n;i++) r[i]=s[i];
    for(int len=1;len<=n;len*=2){
      for(int i=0;i<=n;i++){       
        c[sa[i]]=i;
        if(i>0 &&
           r[sa[i-1]]==r[sa[i]] &&
           sa[i-1]+len<=n &&
           r[sa[i-1]+len/2]==r[sa[i]+len/2]) c[sa[i]]=c[sa[i-1]];
      }
      iota(cnt.begin(),cnt.end(),0);
      copy(sa.begin(),sa.end(),r.begin());
      for(int i=0;i<=n;i++){
        int s1=r[i]-len;
        if(s1>=0) sa[cnt[c[s1]]++]=s1;
      }
      c.swap(r);
    }
    rev.resize(n+1);
    for(int i=0;i<=n;i++) rev[sa[i]]=i;    
  }
  int operator[](int i) const{return sa[i];}
  
  bool lt_substr(string &t,int si,int ti){
    int sn=s.size(),tn=t.size();
    while(si<sn&&ti<tn){
      if(s[si]<t[ti]) return 1;
      if(s[si]>t[ti]) return 0;
      si++;ti++;
    }    
    return si==sn&&ti<tn;
  }

  int lower_bound(string& t){
    int l=0,r=s.size();
    while(l+1<r){
      int m=(l+r)>>1;
      if(lt_substr(t,sa[m],0)) l=m;
      else r=m;
    }
    return r;
  }
  
  int upper_bound(string& t){
    t.back()++;
    int res=lower_bound(t);
    t.back()--;
    return res;
  }
  
  // O(|T|*log|S|)
  int count(string& T){
    return upper_bound(T)-lower_bound(T);
  }  
};

//INSERT ABOVE HERE
signed main(){
  int k;
  string s;
  cin>>k>>s;

  k++;
  if(k==1){
    cout<<s<<endl;
    return 0;
  }
  
  int n=s.size();
  int len=(n+k-1)/k;  
  SuffixArray sa(s);

  auto check=
    [&](int x){
      int pos=0;
      for(int i=0;i<k;i++){
        int idx=sa.rev[pos];
        if(idx<=x) pos+=len;
        else pos+=len-1;
        if(pos>=n) break;
      }      
      return pos>=n;
    };
  
  int l=0,r=n+1;
  while(l+1<r){
    int m=(l+r)>>1;
    if(check(m)) r=m;
    else l=m;
  }  
  cout<<s.substr(sa.sa[r],len)<<endl;
  return 0;
}


Measured memory_bytes: 2512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int a[] = new int[n+1];
		
		for(int i=1;i<=n;i++){
			a[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i=1;i<=n;i++){
			if(a[i] == i){
				ans++;
				i++;
			}
		}
		
		System.out.println(ans);
	}

}


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

using namespace std;

int n, a[500000];

void Process()
{
    int cou = 1, res = 0;       a[n+1] = 1000000001;

    for (int i=1; i<=n; i++)
        if (a[i] >= a[i+1]) cou++;
            else
            {
                res = max(res, cou - 1);
                cou = 1;
            }

    cout << res;
}

void Input()
{
    ios_base::sync_with_stdio(0);   cin.tie(0);

    //freopen("abc.txt", "r", stdin);

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

int main()
{
    Input();
    Process();
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        int b = 0;
        for(int i=0; i<n; i++) {
            b += sc.nextInt();
        }

        System.out.println(b>=h ? "Yes":"No");
    }



}


Measured memory_bytes: 48268
#include<iostream>
#include<string>
#include<vector>
#include<cctype>
int main(void) {
	std::string InputW, InputT;
	int count = 0;
	std::cin >> InputW;
	for (int i = 0; i < InputW.size(); ++i) {
		InputW[i] = std::tolower(InputW[i]);
	}
	while (1) {
		std::cin >> InputT;
		if (InputT == "END_OF_TEXT") { break; }
		for (int i = 0; i < InputT.size(); ++i) {
			InputT[i] = std::tolower(InputT[i]);
		}
	
		if (InputW == InputT) {
			++count;
		}
	}	
	std::cout << count << std::endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3212
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 2000000

struct Node{
  int data;
  struct Node *next, *prev;
};
/* typedef struct */
 
struct Node *node;


void init(void);
void Insert(int);
struct Node* listSearch(int);
void delete(struct Node *);
void deleteFirst(void);
void deleteLast(void);
void listprint(void);
void deletekey(int);

struct Node* nil;
void init(){
  nil = (struct Node *)malloc(sizeof(struct Node));
  nil->next = nil;
  nil->prev = nil;
}


struct Node* listSearch(int data){
  struct Node *a;
  a = nil->next;
  while(a!=nil && a->data!=data){
    a = a->next;
  }
  return a;
}



void Insert(int data){
  struct Node *x = (struct Node *)malloc(sizeof(struct Node));
  x->data = data;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}





void delete(struct Node *a){
  if(a == nil)return;
  a->prev->next = a->next;
  a->next->prev = a->prev;
  free(a);
}

void deleteFirst (){
  delete(nil->next);
}

void deleteLast(){
  delete(nil->prev);
}

void deletekey(int data){
  delete(listSearch(data));
}

void listprint(){
  struct Node *n;
  printf("%d",nil->next->data);
  for(n=nil->next->next;n!=nil;n=n->next){
    printf(" %d",n->data);
  }
  printf("\n");
}



int main(){
  int i,j,a,b;
  char c[20];
  struct Node *d;
  char e[] = "insert";
  char f[] = "delete";
  char g[] = "deleteFirst";
  char h[] = "deleteLast";
  
  scanf("%d",&a);
  init();
  for(i=0;i<a;i++){
    scanf("%s%d",c,&b);
    if(strcmp(c,e)==0) Insert(b);
    else if(strcmp(c,f)==0) deletekey(b);
    else if(strcmp(c,g)==0) deleteFirst();
    else if(strcmp(c,h)==0) deleteLast();
  }
  
  listprint();
  return 0;
}

Measured memory_bytes: 31796
/*
    Author : zzugzx
    Lang : C++
    Blog : blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod = 1e9+7;
//const int mod = 998244353;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int maxn = 1e6+10;
const ll inf = 0x3f3f3f3f;
const int dir[][2]={{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
    int n;
    cin >> n;
    cout << (1000 - n % 1000) % 1000;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// O(HW)
int H,W;
char maze[60][60];
int d[60][60];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void bfs(){
    queue<pair<int,int>> que;
    rep(i,H){
        rep(j,W){
            d[i][j]=INF;
        }
    }
    que.push(make_pair(0,0)); // (0,0)スタート
    d[0][0]=0;
    while(!que.empty()){
        pair<int,int> p=que.front();
        que.pop();
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx && nx<H && 0<=ny && ny<W && maze[nx][ny]!='#' && d[nx][ny]==INF){
                que.push(make_pair(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
}

int main() {
    cin>>H>>W;
    int cntb=0;
    rep(i,H){
        rep(j,W){
            cin>>maze[i][j];
            if(maze[i][j]=='#') cntb++;
        }
    }

    bfs();
    if(d[H-1][W-1]==INF){
        cout<<-1<<endl;
        return 0;
    }

    cout<<H*W-cntb-(d[H-1][W-1]+1)<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m,d;
  cin >> m >> d;
  int ans=0;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=d;j++){
      if(j/10==1||j%10==1){
        continue;
      }
      if(i==(j/10)*(j%10)){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    double a,b,x;
    cin>>a>>b>>x;
    double ans;
    double y=2*x/(a*b);
    if(y>a){
        double z=2*b-2*x/(a*a);
        ans=atan(a/z);
    }
    else{
        ans=atan(y/b);
    }

    ans*=180/acos(-1);
    ans=90-ans;
    cout<<setprecision(10)<<ans<<endl;
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			long h = sc.nextLong();

			long cnt = 0;
			long r = 1;
			while (h > 0) {
				h /= 2;
				cnt = cnt + r;
				r *= 2;
			}
			System.out.println(cnt);
		}
	}
}


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


int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    bool jud = true;

    rep(i,n){
        cin >> a[i];
    }

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

    rep(i,n-1){
        if(a[i] == a[i+1]){
            jud = false;
            break;
        }
    }

    if(jud) cout << "YES" << endl;

    else cout << "NO" << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ins insert
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rev(i,a,b) for(int i=b;i>=a;i--)
#define boost ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL)
#define nl '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;

const int N=200001;
const int MXN=1000001;
const int inf=1e9;
const ll INF=1e18;

int main(){
  boost;

  int x,y;
  cin>>x>>y;
  int ans=0;
  if(x==1)ans+=300000;
  else if(x==2)ans+=200000;
  else if(x==3)ans+=100000;
  if(y==1)ans+=300000;
  else if(y==2)ans+=200000;
  else if(y==3)ans+=100000;
  if(x==1&&y==1)ans+=400000;
  cout<<ans;
  return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node{
	int key;
	Node *prev, *next;
}; 

Node *nil;

void init(){
	nil=(Node*)malloc(sizeof(Node));
	nil->next=nil;
	nil->prev=nil;
}

void insert(int key)
{
	Node *x=(Node*)malloc(sizeof(Node));
	x->key=key;
	x->next=nil->next;
	nil->next->prev=x;
	nil->next=x;
	x->prev=nil;
}

Node *listSearch(int key)
{
	Node* cur=nil->next;
	while(cur!=nil&&cur->key!=key)
	cur=cur->next;
	return cur;
}

void deleteNode(Node *t){
	if(t==nil) return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deleteKey(int key)
{
	deleteNode(listSearch(key));
}

void printList(){
	Node *cur=nil->next;
	int isf=0;
	while(1)
	{
		if(cur==nil) break;
		if(isf++>0) printf(" ");
		printf("%d",cur->key);
		cur=cur->next;
	}
	printf("\n");
}

int main(){
	int key,n,i;
	int size=0;
	char com[20];
	scanf("%d",&n);
	init();
	for(i=0;i<n;i++)
	{
		scanf("%s %d",com,&key);
		if(com[0]=='i')
			insert(key);
		else if(com[0]=='d')
			{
				if(strlen(com)>6)
				{
					if(com[6]=='F')deleteFirst();
					else if(com[6]=='L')deleteLast();
				}
				else deleteKey(key);
			}
	}
	printList();
	return 0;
}


Measured memory_bytes: 33984
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(void){
    int A, B;
    cin >> A >> B;
    cout << A*B << endl;
    return 0;
}


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

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

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<cstdlib>
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
const int maxn=1e5+5;
int n,k;
ll a[maxn];
ll mp[maxn];
 
int main()
{
    int n;
    cin>>n;
    if(n==1) cout<<0<<endl;
    else cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
ll f(ll n,ll x){
    if(n==-1)
        return 0;
    else
        return (n/x)+1 ;
}
int main(){
    ll a,b,x;
    cin >> a >> b>>x;
    
    cout << f(b,x)-f(a-1,x) << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

input = sys.stdin.readline

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return tuple(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, Q, STX, D):
    E = []
    for i, (s, t, x) in enumerate(STX):
        E.append((s-x, 1, x, i))
        E.append((t-x, -1, x, i))
    E.sort(reverse=True)

    q = []
    done = set()
    ans = [-1] * Q
    for j, d in enumerate(D):
        while E and E[-1][0] <= d:
            t, e, x, i = E.pop()
            if e == 1:
                heapq.heappush(q, (x, i))
            else:
                done.add((x, i))

        while q and q[0] in done:
            done.remove(heapq.heappop(q))

        if q:
            ans[j] = q[0][0]

    for i in range(Q):
        print(ans[i])


def main():
    N, Q = read_int_n()
    STX = tuple(read_int_n() for _ in range(N))
    D = tuple(read_int() for _ in range(Q))
    (slv(N, Q, STX, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 128392
N=int(input())

red=[]
blue=[]

for i in range(N):
    a,b=map(int,input().split())
    red.append((a,b))

for i in range(N):
    c,d=map(int,input().split())
    blue.append((c,d))

red=sorted(red,key=lambda x:-x[1])
blue=sorted(blue,key=lambda x:x[0])

answer=0
for i,b in enumerate(blue):
    for j,r in enumerate(red):
        if r[0]<b[0] and r[1]<b[1]:
            answer+=1
            red.pop(j)
            break

print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;

int main()
{
    int N;
    cin >> N;
    vi A(N-1);
    rep(i, 0, N-1) {
        cin >> A[i];

    }
    srt(A);
    vi ans(N, 0);
    int cnt = 0;
    rep(i, 1, N - 1) {
        ++cnt;
        int diff = A[i] - A[i-1];
        if (diff != 0 || i == N-2) {
            ans[A[i-1]-1] = cnt;
            cnt = 0;
        }
    }
    int last = A[N-2];
    ++ans[last-1];


    rep(i, 0, N) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int aa = 0;
    int bb = 0;

    while (c > 0){
        aa++;
        c -= b;
    }
    while (a > 0){
        bb++;
        a -= d;
    }

    // cout << aa << " " << bb << endl;
    if (aa <= bb) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
 
int a[60], b[60];
int main(void)
{
    while (1) {
        int n, r, i;
        scanf("%d%d", &n, &r);
        if (n==0 && r==0) break;
        for(i=0;i<n;++i) a[n-i]=i+1;
        while (r--) {
            int p, c;
            scanf("%d%d", &p, &c);
            for(i=1;i<=n;++i) b[i]=a[i];
            for(i=1;i<=c;++i) a[i]=b[i+p-1];
            for(i=1;i<p;++i) a[i+c]=b[i];
        }
        printf("%d\n", a[1]);
    }
    return 0;
}

Measured memory_bytes: 600
//============================
// ABC136a Transfer
//
// 2019/08/13
//============================

#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  int A, B, C;
  cin >> A >> B >> C;

  if (C-(A-B) > 0)
  {
    cout <<  C-(A-B) << endl;
  }
  else
  {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=list(input())
    K=I()
    
    S3=S*3
    S2=S*2
    
    ans=0
    
    N=len(S)
    
    flag=0
    if S.count(S[0])==N:
        flag=1
    
    if N==1 or flag:
        ans=(K*N)//2
    else:
        ans2=0
        for i in range(N*2-1):
            if S2[i]==S2[i+1]:
                S2[i+1]="#"
                ans2+=1
                
        ans3=0
        for i in range(N*3-1):
            if S3[i]==S3[i+1]:
                S3[i+1]="#"
                ans3+=1
                
        ansd=ans3-ans2
        if K==2:
            ans=ans2
        else:
            ans=ans2+(K-2)*ansd

        
    print(ans)

main()


Measured memory_bytes: 38256
#!/usr/bin/env python3
#AGC16 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

s = sys.stdin.readline()
s = s[:-1]
if len(Counter(s)) == 1:
    print(0)
    quit()
n = len(s)
ans = float('inf')
for i in range(n):
    x = s[i]
    t = s
    cnt = 0
    while 1:
        t_ = ''
        for j in range(len(t)-1):
            if t[j] == x or t[j+1] == x:
                t_ += x
            else:
                t_ += t[j]
        t = t_
        cnt += 1
        if len(Counter(t)) == 1:
            ans = min(ans,cnt)
            break
print(ans)


Measured memory_bytes: 44836
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main
{
	private static Map<Integer,Integer> intMap = new HashMap<>();

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		int ans = solve(n);

		System.out.println(ans);
	}

	public static int solve(int n)
	{

		if(intMap.containsKey(n)){
			return intMap.get(n);
		}
		int ans = n;
		int n6 = getNext(n, 6);
		int n9 = getNext(n, 9);
		if (n < 6) {
			return n;
		} else if (n == 6 || n == 9) {
			return 1;
		} else if (n <9) {
			ans = Math.min(ans, solve(n6) + 1);
			ans = Math.min(ans, n + 1);
		} else {
			ans = Math.min(ans, solve(n6) + 1);
			ans = Math.min(ans, solve(n9) + 1);
		}
		intMap.put(n, ans);
		return ans;
	}

	private static int getNext(int n, int i)
	{
		int ans = n;
		int jp = 0;
		int j = i;
		while(true) {
			if (j > n) break;
			jp = j;
			j *=i;
		}
		return n - jp;
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
#define MOD 1e9+7

int main(){
    int n;
    cin >> n;
    vector<double> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int ans1=a[n-1];
    double temp=a[n-1]/2;
    a[n-1]=0;
    auto pos=lower_bound(a.begin(),a.end(),temp)-a.begin();
    int ans2=a[pos];
    rep(i,3){
        if(pos-i<0) break;
        if(abs(a[pos-i]-temp)<abs(ans2-temp)){
            ans2=a[pos-i];
        }
    }
    cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 4108
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,k;
cin>>n>>k;
int mx=pow(10,5)+5;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
int dp[mx]={};
sort(arr,arr+n);
for(int i=0;i<n;i++)
{
    dp[arr[i]]=1;
}
for(int i=1;i<mx;i++)
{int ok=1;
    for(int j=0;j<n;j++)
    {
        if(i>=arr[j])
        {
            if(!dp[i-arr[j]])
            {
                ok=0;
            }
        }
    }
    if(!ok)
        dp[i]=1;
    else
        dp[i]=0;
}
if(dp[k])
{
    cout<<"First"<<endl;
}
else
    cout<<"Second"<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    int  n,k;

    cin >> n;
    vector<int> v;
    int ma = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        ma = max(ma,a);
        v.push_back(a);
    }
    int ans = 1e9;
    for(int i = 1; i <= ma; i++){
        int tmp = 0;
        for(int j = 0; j < n; j++){
            tmp += (abs(v[j]-i)*abs(v[j]-i));
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl;

}


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

char s[205];
long long k;

int main()
{
	scanf("%s",s+1);
	cin>>k;
	for (int i=1;;++i){
		int p=s[i]-'0';
		if (p!=1) {cout<<s[i]<<endl;return 0;}
		else {
			k--;
			if (k==0) {cout<<1<<endl;return 0;}
		}
	}
	
}


Measured memory_bytes: 256