akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
struct UnionFind{
public:
	vector<int> par;
	vector<int> rank;
	vector<int> s;
	int cnt;
 
	UnionFind(int n){
		rep(i,n){
			par.push_back(i);
			rank.push_back(0);
			s.push_back(1);
		}
		cnt=n;
	}
 
	int find(int x){
		if(par[x]==x) return x;
		else return par[x]=find(par[x]);
	}
 
	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			par[x]=y;
			s[y]+=s[x];
		}else{
			par[y]=x;
			s[x]+=s[y];
			if(rank[x]==rank[y]) rank[x]++;
		}
		cnt--;
	}

	bool same(int x,int y){
		return find(x)==find(y);
	}

	int size(int x){
		return s[find(x)];
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	UnionFind uf(n);
	vector<ll> a(m),b(m);
	rep(i,m){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
	}
	ll ans=n*(n-1)/2;
	vector<ll> now;
	for(int i=m-1;i>=0;i--){
		now.push_back(ans);
		if(uf.same(a[i],b[i])) continue;
		ll sz1=uf.size(a[i]),sz2=uf.size(b[i]);
		ans-=sz1*sz2;
		uf.unite(a[i],b[i]);
	}
	reverse(begin(now),end(now));
	cout<<now<<endl;
}

Measured memory_bytes: 4968
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, k, max, sum=0;
    cin >> a >> b >> c >> k;
    if(a>=b && a>= c) max = a;
    else if(b>=a && b>=c) max =b;
    else max = c;
    sum = a+b+c - max;
    for(int i=0; i<k; i++)
    {
        max = max * 2;
    }
    cout << sum+max << endl;
     return 0;   
}

Measured memory_bytes: 256
/*Program from Luvwgyx*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define int long long
using namespace std;
char s[10];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(int x){print(x);puts("");}
void query(int x){printf("? %lld\n",x);fflush(stdout);scanf("%s",s);}
signed main()
{
    int x=1e9;query(x);
    if (s[0]=='Y')
    {
        for (int i=8;~i;i--)
        {
            query(x-1);
            if (s[0]=='N') break;
            x/=10;
        }
        printf("! %lld\n",x);
        return 0;
    }
    for (int i=8;~i;i--)
    	{
        x/=10;
        query(x);
        if (s[0]=='Y')
        {
            break;
        }
    }
    int l=x+1,r=x*10-1,ans;
    while(l<=r)
    {
        ll mid=(l+r)>>1;
        query(mid*10);
        if (s[0]=='Y') ans=mid,r=mid-1;
        else l=mid+1;
    }
    printf("! %lld\n",ans);
    return 0;
}


Measured memory_bytes: 504
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int n;
	int i,j,count;
	cin >> n;
	int ans = 0;
	REP(i, 1, n + 1) {
		count = 0;
		if (i % 2 == 1) {
			REP(j, 1, n + 1) {
				if (i % j == 0) {
					count++;
				}
			}
		}
		if (count == 8) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

#define uint unsigned int

uint zerobit(uint bin, uint D){
    int d = D - 1;
    while(d >= 0){
        if(((bin >> d) & 1) == 0)
            break;
        else
            d--;
    }
    return d;
}

uint calc_bin(uint D, uint p[], uint c[], uint bin, uint *num){
    if(bin == 0)
        return 0;
    uint sum = 0;
    int d = D - 1;
    while(d >= 0){
        if((bin >> d) & 1){
            sum += 100*(1+d)*p[d] + c[d];
            *num += p[d];
        }
        d--;
    }
    return sum;
}

int main(){
    uint D, G;
    cin >> D >> G;
    uint p[10], c[10];
    for(int i = 0; i < D; i++){
        cin >> p[i] >> c[i];
    }

    uint sum = 0;
    uint num = 0;
    uint min_num = 1000000;
    for(int b = 0; b < pow(2,D); b++){
        int most = zerobit(b, D); 
        num = 0;
        sum = calc_bin(D, p, c, b, &num);
        if(most >= 0){
            int tmp_p = p[most];
            while(sum < G){
                if(tmp_p == 0){
                    num += 100000000;
                    break;
                }
                num++;
                sum += 100*(1+most);
                tmp_p--;
            }
        }
        if(min_num > num)
            min_num = num;
    }
    cout << min_num << endl;
    return 0;
}



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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<int> st;
	int ans=1;
	int x;
	cin>>x;
	st.emplace_back(x);
	for(int i=2;i<=n;i++){
		cin>>x;
		if(st.back()==x)	continue;
		if(st.size()==1)
			st.emplace_back(x);
		else if(st.size()>=2){
			if((st.back()>st[st.size()-2])^(x>st.back())){
				ans++;
				st.clear();
				st.emplace_back(x);
			}
			else
				st.emplace_back(x);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 892
n, m = gets.split.map(&:to_i)

as = gets.split.map(&:to_i)

def f(x)
  c = 0
  while x % 2 != 1
    x /= 2
    c += 1
  end
  c
end

as2 = as.map {|a|
  if a.odd?
    puts 0
    exit
  end
  a / 2
}

if as2.map {|a| f(a) }.uniq.size > 1
  puts 0
  exit
end

lcm = as2.inject(&:lcm)

puts (m / lcm + 1) / 2

Measured memory_bytes: 14212
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
using ll = long long; using ld = long double; const char nl = '\n';
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */
 
#include <bits/extc++.h>
namespace pbds =  __gnu_pbds;
template <typename key, typename val=pbds::null_type, typename comp=less<key>>
using ostree=pbds::tree<key,val,comp,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
using vi = vector< int >; using vll = vector< ll >;
#define all(x) std::begin(x), std::end(x)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&);
string to_string(string const&s){return '"'+s+'"';}
string to_string(char const &c) {return to_string(string(1,c));}
string to_string(char const *c) {return to_string(string(c));}
string to_string(bool const &b) {return (b ? "T" : "F");}
template<typename... Args> string to_string(pair<Args...> const&p)
{return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&S)
{string s = "{"; for(auto const& e: S)s+=" "+to_string(e);s+=" }"; return s;}
template<typename Tail> void debug_out(Tail t) {cerr<<" "<<to_string(t)<<" ]"<<endl;}
template<typename Head, typename... Tail> void debug_out(Head h, Tail... t)
{cerr << " " << to_string(h) << ","; debug_out(t...);}
#define pr(...) cerr<<"["<<(#__VA_ARGS__)<<"] : [", debug_out(__VA_ARGS__)
template <typename T> void dbr(T lb, T ub)
{cerr<<'{';for(auto it=lb; it!=ub; it++)cerr<<' '<<to_string(*it); cerr<<" }"<<endl;}
template<typename T, typename Comp=less<T>> bool smin(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(v, mem) ? mem = v, true : false;}
template<typename T, typename Comp=less<T>> bool smax(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(mem, v) ? mem = v, true : false;}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

using Point = pair<ld,ld>;

Point operator+(Point const&p, Point const&q)
{ return Point(p.ff+q.ff, p.ss+q.ss); }

Point operator-(Point const&p, Point const&q)
{ return Point(p.ff-q.ff, p.ss-q.ss); }

inline ld norm(Point const&p)
{ return sqrt(p.ff*p.ff+p.ss*p.ss); }

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

  int n; cin >> n;
  Point a[n+n+n];
  for(int i=0; i<n; i++) {
    ld x, y; cin >> x >> y;
    a[i] = Point(x, y);
  }
  sort(a, a+n, [&](auto const&p, auto const&q)
       { return atan2(p.ss,p.ff) < atan2(q.ss,q.ff); });

  for(int i=0; i<n+n; i++) a[i+n] = a[i];
  // dbr(a, a+n+n);

  ld ans = 0.0;
  for(int len=1; len<=n; len++) {
    Point F(0,0);
    for(int i=0, j=0; i<n+n; i++) {
      for(; j<i+len; j++) F = F + a[j];
      // pr(i,j,F,norm(F));
      smax(ans, norm(F));
      F = F - a[i];
    }
  }
  cout << fixed << setprecision(50) << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	string S,T;
	cin>>S>>T;
	int N=(int)S.length();
	int f=0;
	rep(i,N){
		if(S==T)f=1;
		char x=S.front();
		S.erase(S.begin());
		S.push_back(x);
	}
	if(f)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
b=0
n=input()

for i in range(1, int(n)+1):

    if i%3==0 and i%5==0:
      a="FizzBuzz"
    elif i%3==0:
        a="Fizz"
    elif i%5==0:
      a="Buzz"
    else:
      b=b+i

print(b)






Measured memory_bytes: 9040
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 100000
using namespace std;
typedef long long ll;
struct card
{
	char suit;
	int num;
};
struct card L[50002],R[50002];
void Merge(struct card a[],int left,int mid,int right)
{
	int len,len1,len2,i,j;
	len1=mid-left;
	len2=right-mid;
	len=len1+len2;
	for( i=0;i<len1;i++) L[i]=a[left+i];
	for( i=0;i<len2;i++) R[i]=a[mid+i];
	L[len1].num=R[len2].num=2000000001;
	i=j=0;
	for(int k=0;k<len;k++)
	{
		if(L[i].num<=R[j].num){
			a[left+k]=L[i++];
		}else{
			a[left+k]=R[j++];
		}
	}
}
void mergeSort(struct card a[],int left,int right)
{
	int mid=(left+right)/2;
	if(left+1<right){
		mergeSort(a,left,mid);
		mergeSort(a,mid,right);
		Merge(a,left,mid,right);
	}
}
int partition(struct card a[],int left,int right)
{
	struct card stan=a[right],t;
	int j=left-1;
	for(int i=left;i<right;i++)
	{
		if(a[i].num<=stan.num){
			++j;
			t=a[i];
			a[i]=a[j];
			a[j]=t;
		}
	}
	t=a[j+1];
	a[j+1]=a[right];
	a[right]=t;
	return j+1;
}
void quickSort(struct card a[],int left,int right)
{
	int q;
	if(left<right)
	{
		q=partition(a,left,right);
		quickSort(a,left,q-1);
		quickSort(a,q+1,right);
	}
}
int main()
{	
	int n,tmp;
	char S[5];
	bool judge=true;
	struct card a[100001],b[100001];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%s %d",S,&tmp);
		a[i].suit=b[i].suit=S[0];
		a[i].num=b[i].num=tmp;
	}
	mergeSort(a,0,n);
	quickSort(b,0,n-1);
	for(int i=0;i<n;i++)
	{
		if(a[i].suit!=b[i].suit) {
			judge=false;
			break;
		}
	}
	if(judge){
		cout<<"Stable"<<endl;
	}else{
		cout<<"Not stable"<<endl;
	}
	
	for(int i=0;i<n;i++){
		printf("%c %d\n",b[i].suit,b[i].num);
	}
	return 0;
}


Measured memory_bytes: 5536
#include <iostream>
#include <cmath>

using namespace std;

bool input(int* l, int* v)
{
	char dummy;
	for (int i=0; i<10; i++) {
		if ( !(cin >> l[i]) ) return false;
		cin >> dummy;
	}
	for (int i=0; i<2; i++) {
		if ( !(cin >> v[i]) ) return false;
		if (i==0) cin >> dummy;
	}
	return true;
}

int main()
{
	int l[10];
	int v[2];
	while ( input(l, v) ) {
		int L = 0;
		for (int i=0; i<10; i++) L += l[i];
		float rate = static_cast<float>(v[0]) / static_cast<float>(v[0] + v[1]);
		int meet_pos = ceil(L * rate);
		
		//cout << "rate = " << rate << " meet_pos = " << meet_pos << endl;
		
		int meet_rail_num;
		int sum_of_length = 0;
		for (meet_rail_num = 0; sum_of_length < meet_pos; meet_rail_num++) {
			sum_of_length += l[meet_rail_num];
		}
		
		cout << meet_rail_num << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3076
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var S = LnStr();
        print(Palindrome(S) ? Palindrome(S.Substring(0, (S.Length - 1) / 2)) ? Palindrome(S.Substring((S.Length + 3) / 2-1)) ? "Yes" : "No" : "No" : "No");
    }

    static bool Palindrome(string s)
    { 
        for(int i = 0; i < s.Length / 2; i++)
        {
            if (s[i] != s[s.Length - i-1])
            {
                return false;
            }
        }
        return true;
    }

    public static void print(object obj) { Console.WriteLine(obj); }
    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}



Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)

int main(){
    //input
    char s[105];
    scanf("%s", s);
    int k;
    scanf("%d", &k);

    //solve
    ll ans = 0;
    int n = strlen(s);
    char t[205];
    rep(i, 2*n) t[i] = s[i%n];
    int allsame = 1;
    rep(i, n-1) if(s[i] != s[i+1]) allsame = 0;
    if(allsame){
        ans = (ll)n * k / 2;
    }else{
        rep(i, n){
            if(t[i] == t[i+1]){
                if(i+1 < n) ans += k;
                else{
                    int tmp = i+1;
                    while(tmp + 1 < 2*n && t[tmp] == t[tmp+1]) tmp++;
                    if((tmp - i) % 2 == 1) ans += k-1;
                    break;
                }
                i++;
            }
        }
    }
    
    //output
    printf("%lld", ans);
}

Measured memory_bytes: 1688
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = 2000000000;
// const ll MOD = 1000000007;

int N;
string s;

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

  int r = 0, b = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'R') {
      r++;
    } else if (s[i] == 'B') {
      b++;
    }
  }

  if (r > b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
N = int(input())
P = [int(x) for x in input().split()]

ans = 0
for i in range(N-1):
    if P[i] == i+1:
        temp = P[i]
        P[i] = P[i+1]
        P[i+1] = temp
        ans += 1
if P[N-1] == N:
        ans += 1
print(ans)

Measured memory_bytes: 20100
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    vector<int> ans(N);
    for (int i = 0; i < N; i++) {
        ans[A[i] - 1] = i + 1;
    }
    for (auto a : ans) cout << a << ' ';
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX_N = 1<<17;
ll n,dat[2*MAX_N-1];

void init(int n_){
  n=1;
  while(n<n_)n*=2;
  for(int i=0;i<2*n-1;i++)dat[i]=0;
}

void update(ll k,ll a){
  k+=n-1;
  dat[k]=a;
  while(k>0){
    k=(k-1)/2;
    dat[k]=max(dat[k*2+1],dat[k*2+2]);
  }
}

ll query(ll a,ll b,ll k,ll l,ll r){
  if(r<=a||b<=l)return 0;
  if(a<=l&&r<=b)return dat[k];
  else{
    ll v1=query(a,b,k*2+1,l,(l+r)/2);
    ll vr=query(a,b,k*2+2,(l+r)/2,r);
    return max(v1,vr);
  }
}

int main(){
  cin>>n;
  ll nn=n;
  ll ans=0;
  init(n);
  for(ll i=0,x;i<nn;i++){
    cin>>x;
    ll p=query(0,x,0,0,n);
    update(x-1,p+x);
    ans=max(ans,p+x);
  }
  cout<<nn*(nn+1)/2-ans<<endl;
  return 0;
}

Measured memory_bytes: 5116
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);	
	double lo=10000,hi=0;
	while(sc.hasNextDouble()){
		double high=sc.nextDouble();
		lo=Math.min(lo,high);
		hi=Math.max(hi,high);
		}
	System.out.println(hi-lo);
    }
 }

Measured memory_bytes: 18640
N = int(input())
L = sorted([list(input().split()) + [i + 1] for i in range(N)], key = lambda x: x[0])
while len(L) > 0:
    c = sum([x[0] == L[0][0] for x in L])
    M = sorted(L[0: c], key = lambda x : int(x[1]), reverse = True)
    for x in M:
        print(x[2])
    L = L[c:]

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    char s;
    int win = 0;
    int count = 0;
    while(cin>>s){
        if(s == 'o') win++;
        count++;

    }
    win += 15-count;
    if(win >= 8) cout<<"YES"<<endl;
    if(win<=7) cout<<"NO"<<endl;
    
}

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

int N;
int C[510], S[510], F[510];

signed main() {
    cin >> N;
    rep(i, N-1) cin >> C[i] >> S[i] >> F[i];
    rep(i, N) {
        int now = 0;
        for (int j=i; j<N-1; j++) {
            now = max(S[j], (now+F[j]-1)/F[j]*F[j]);
            now += C[j];
        }
        cout << now << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>

#include <vector>
#include <stack> // s.top()
#include <queue> // s.front()
using namespace std;

typedef long long llong;
typedef vector<int> vecint;
typedef vector<llong> vecllong;
typedef pair<llong, llong> P;

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10

bool pairComp(const P& firstElof, const P& secondElof) {
	return firstElof.second > secondElof.second;
}

// ========================================================

int sc[5];

int main() {
	int a[5];
	int b[5];
	stack<int> s;
	for (int i = 0; i < 3; i++) {
		cin >> a[i + 1] >> b[i + 1];
		s.push(a[i + 1]);
		s.push(b[i + 1]);
	}

	while (s.size() > 0) {
		int point = s.top();
		s.pop();
		sc[point]++;
	}
	if (sc[1] != 3 && sc[2] != 3 && sc[3] != 3 && sc[4] != 3) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;

	



	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func main() {
	var s string
	fmt.Scan(&s)
	ans, k := int(s[0]-'0'), len(s)

	if len(s) > 1 {
		if s[1:k] == strings.Repeat("9", k-1) {
			ans += 9 * (k - 1)
		} else {
			ans += 9*(k-1) - 1
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import collections

n = int(input())
A = list(map(int, input().split()))
ans = sum(A)
ANS = []
q = int(input())
T = collections.Counter(A)
for i in range(q):
    b, c = map(int, input().split())
    t = T[b]
    ans -= t * b
    ans += t * c
    T[b] = 0
    T[c] += t
    ANS.append(ans)
for i in ANS:
    print(i)

Measured memory_bytes: 26932
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  int i=(a+b)%2;
  int k=(a+b)/2;
  if(i==0)
  {
    cout<<k<<endl;
  }else{
    cout<<k+1<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
  long int n;
  std::cin>>n;
  for(long int i=pow(n,0.5);i>0;i--){
    if(n%i==0){
      std::cout<<(i-1)+(n/i-1)<<"\n";
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]

ab_hash = {}
count = 0
price_sum = 0
for x in range(len(ab)):
    ab_hash[x] = [ab[x][0], ab[x][1]]
ab_key_sorted = sorted(ab_hash.items(), key=lambda x: x[1][0])

for y in ab_key_sorted:
    if M > y[1][1]:
        price_sum += y[1][0] * y[1][1]
    else:
        price_sum += y[1][0] * M
    M -= y[1][1]
    if M <= 0:
        break

print(price_sum)


Measured memory_bytes: 84564
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    
    int ans = H*W - (h*W+w*H-h*w);
    cout1(ans)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long ar1[n],ar2[n],ar3[n];
	for(int i=0;i<n;i++){
		cin>>ar1[i];
	}
	for(int i=0;i<n;i++){
		cin>>ar2[i];
	}
	for(int i=0;i<n;i++){
		cin>>ar3[i];
	}
	sort(ar1,ar1+n);
	sort(ar2,ar2+n);
	sort(ar3,ar3+n);
	long long cnt=0;
	for(int i=0;i<n;i++){
		long long index2=lower_bound(ar1,ar1+n,ar2[i])-ar1;
		int index3=upper_bound(ar3,ar3+n,ar2[i])-ar3;
		cnt+=(n-index3)*(index2);
	}
	cout<<cnt<<endl;
}

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

int main()
{
int A,B,C,X;scanf("%d\n%d\n%d\n%d",&A,&B,&C,&X);
int count=0;
for(int a=0;a<A+1;a++)for(int b=0;b<B+1;b++)if(X-a*500-b*100>=0&&C*50>=X-a*500-b*100)count++;
printf("%d\n",count);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int AB_area = A * B, CD_area = C * D;
	if (AB_area > CD_area) {
		cout << AB_area;
	}else {
		cout << CD_area;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff(i,n) for(i=0;i<n;i++)
#define pb push_back
ll bg =  998244353;
ll fac[300000];
ll power(ll x,ll y)
{
    if(y==0)
	    return 1;
	ll d = power(x,y/2)%bg;
	ll f = (d*d)%bg;
	if(y%2==0)
	  return f;
	else
	  return (f*x)%bg;	 	
}
ll modinv(ll m)
{
	return power(m,bg-2);	
}
ll ncr(ll n,ll r)
{
	ll s1 = fac[n],s2 = fac[r],s3 = fac[n-r];
	ll d1 = (s1*modinv(((s2*s3)%bg)))%bg;
	return d1;
}
int main()
{
	fac[0]=1;
	for(ll j=1;j<300000;j++)
	  fac[j] = (j*fac[j-1])%bg;
	ll t;
	t=1;
	while(t--)
	{
		set<ll>set1;
		ll i,j,n,m;
		cin>>n;
		ll arr[n];
		ff(i,n)
		   cin>>arr[i];
		map<ll,ll>map1;
		ll ans=0,a=1;
		for(i=0;i<n;i++)
		{
			if(map1.find(i-arr[i])!=map1.end())
			   ans+=map1[i-arr[i]];
			if(map1.find(i+arr[i])==map1.end()) 
			   map1.insert(make_pair(i+arr[i],a));
			else     
				map1[i+arr[i]]++;	
		}  
		cout<<ans; 
	}
	 return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  int count = 0;
  for(int i = a; i <= b; i++){
    if (i % c == 0) {
      count++;
    }
  }
  cout << count << endl;
} 

Measured memory_bytes: 3588
// Aizu Vol0 0021: Parallelism
// 2017.7.30

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char *gets(char *);

#define LLONG long long

#define MAX 500
char buf[MAX + 5], *p;

int GetInt(void)
{
	int minus = 0, len = 0, n = 0;

	while (isspace(*p)) p++;
	if (*p == '-') p++, minus = 1;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	if (*p == '.') p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0'), len++;
#define MAGIC 5
	while (len < MAGIC) n = 10 * n, len++;
	if (minus) n = -n;
	//	printf("%10d\n", n);
	return n;
}

int main()
{
	int i, n;
	int ax1, ay1, ax2, ay2;
	int bx1, by1, bx2, by2;

	gets(buf);
	n = atoi(buf);
	for (i = 0; i < n; i++) {
		gets(p = buf);
		ax1 = GetInt(), ay1 = GetInt();
		ax2 = GetInt(), ay2 = GetInt();
		bx1 = GetInt(), by1 = GetInt();
		bx2 = GetInt(), by2 = GetInt();

		if (ax1 == ax2 && ay1 == ay2) goto NO;
		if (bx1 == bx2 && by1 == by2) goto NO;

		if (ax1 == ax2) {
			if (bx1 == bx2) goto YES;
			goto NO;
		}

		if (bx1 == bx2) {
			if (ax1 == ax2) goto YES;
			goto NO;
		}

		if ((LLONG)(ay2 - ay1)*(LLONG)(bx2 - bx1) != (LLONG)(ax2 - ax1)*(LLONG)(by2 - by1)) {
NO:			puts("NO");
		}
		else {
YES:		puts("YES");
		}
	}
	return 0;
}

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

int main(){
    int64_t n, ans = 0;
    cin >> n;
    vector<int64_t> a(n + 1);
    vector<int64_t> b(n);
    for(int64_t i = 0; i < n + 1; i++) cin >> a[i];
    for(int64_t i = 0; i < n; i++) cin >> b[i];
    for(int64_t i = 0; i < n; i++){
        if(b[i] < a[i]){
            ans += b[i];
        }
        else{
            ans += a[i];
            b[i] -= a[i];
            if(b[i] < a[i + 1]){
                ans += b[i];
                a[i + 1] -= b[i];
            }
            else{
                ans += a[i + 1];
                a[i + 1] = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
n,a,b=map(int,input().split())
mod=10**9+7
ans=pow(2,n,mod)-1+mod*2
def c(x,y):
	p=1
	for i in range(x-y+1,x+1):
		p*=i
		p%=mod
	for i in range(2,y+1):
		p*=pow(i,mod-2,mod)
		p%=mod
	return p
r=ans-c(n,a)-c(n,b)
print(r%mod)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++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(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int h, w, n;
int a[10005];
vector<int> sum[10005];
int dat[105][105];
int num[10005];

int main(){
	scanf("%d %d %d ", &h, &w, &n);
	rep(i, n) {
		scanf("%d ", &a[i]);
	}
	int cnt = 0;
	rep(i, n) {
		rep(j, a[i]) {
			num[cnt++] = i + 1;
		}
	}
	cnt = 0;
	rep(i, h) {
		if (i % 2) {
			FORR(j, w-1, 0) {
				dat[i][j] = num[cnt++];
			}
		}
		else {
			FOR(j, 0, w - 1) {
				dat[i][j] = num[cnt++];
			}
		}

	}
	rep(i, h) {
		rep(j, w) {
			printf("%d%c", dat[i][j], (j==(w-1))?'\n':' ');
		}
		
	}

	return 0;
}


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

#define ll long long
const ll MAX = 1000050;
const ll MOD = 1e9 + 7;

ll fac[MAX],invfac[MAX],f[MAX];
ll n;
ll pow_mod(ll a,ll n){
	ll ans = 1;
	a %= MOD;
	while(n){
		if(n&1)ans = (ans * a) % MOD;
		a = (a * a) % MOD;
		n>>=1;
	}
	return ans;
}
ll inv(ll a){
	return pow_mod(a,MOD-2);
}
void init(){
	fac[0] = 1;
	for(int i = 1;i <= n; i++)
		fac[i] = fac[i - 1]*i%MOD; 
		
	invfac[n] = inv(fac[n]);
	
	for(int i=n-1;i>=0;--i)
		invfac[i] = invfac[i+1]*(i+1)%MOD;
	
}


ll C(ll n,ll m){
	if(n < m || m <0)return 0;
	return fac[n] * invfac[n-m] %MOD * invfac[m] % MOD;
}
int main(){
	cin>>n;
	init();
	for(int i=1;i<n;i++)
		f[i] = C(i-1,n-1-i) * fac[i]%MOD * fac[n-1-i]%MOD;
	
	int ans = 0;
	for(int i=1;i<n;i++)
		ans = (ans + (f[i] - f[i-1] + MOD)%MOD * i)%MOD;
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)

int main(){
    int N;
    cin>>N;
    ll A[100000];
    rep(i,N) cin>>A[i];
    vector<ll> vec;
    vec.push_back(A[0]);
    Rep(i,1,N-1){
        auto itr = lower_bound(vec.begin(), vec.end(),A[i]);
        if(itr == vec.begin()) vec.insert(vec.begin(),A[i]);
        else{
            --itr;
            *itr = A[i];
        }
    }
    cout<<vec.size()<<endl;

    return 0;
}

Measured memory_bytes: 2168
#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include <queue>
#include <cstring>

#define mp make_pair
#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"
#define sag (sol|1)
//#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) ((1e5+5))
#define K 25
#define  ALPHABET_SIZE  26
#define N (int)(1e5+10)
#define int ll
using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;



int n, C;
int value[100005], weight[100005];
vpi vec(100005,{MAXN,MAXN});
int dp[100005];
signed main() {

    int a,b;
    cin >>a>>b;
    int res= a/b;
    if(a%b)res++;
    cout <<res;


}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;


int main(){
	int n;
	cin >> n;
	vl a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0LL;
	sort(rall(a));
	while(1) {
		ll cnt = 0LL;
		// rep(i, n) if(a[i] >= n) {
		// 	cnt = a[i] / n;
		// 	rep(j, n) if(i != j) a[j] += cnt;
		// 	a[i] %= n;
		// 	break;
		// } 
		// if(cnt) ans += cnt;
		// else break;
		sort(rall(a));
		if(a[0] < n) break;
		cnt = a[0] / n;
		a[0] %= n;
		REP(i, 1, n) a[i] += cnt;
		ans += cnt;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T> &v) {
    for(auto it=v.begin();it != v.end();it++) {
        cout << *it << " ";
    }
    cout << endl;
    return out;
}

int main() {
    int n,m;
    string s;
    cin >> n >> m;
    cin >> s;
    vector<vector<int>> v(n);
    vector<int> aok(n, 0);
    vector<int> bok(n, 0);
    for(int i=0;i<m;i++) {
        int a, b;
        cin >> a >> b;
        if (s[a-1] == 'A') {
            aok[b-1]++;
        } else {
            bok[b-1]++;
        }
        v[a-1].push_back(b-1);
        if (a == b) {
            //continue;
        }
        if (s[b-1] == 'A') {
            aok[a-1]++;
        } else {
            bok[a-1]++;
        }
        v[b-1].push_back(a-1);
    }
    queue<int> q;
    for(int i=0;i<n;i++) {
        if (aok[i] == 0 || bok[i] == 0) {
            q.push(i);
        }
    }
    while(q.size() > 0) {
        int t = q.front();
        q.pop();
        //cout << t << endl;
        for(auto it = v[t].begin();it != v[t].end();it++) {
            if (aok[(*it)] == 0 || bok[(*it)] == 0) {
                continue;
            }
            if (s[t] == 'A') {
                aok[(*it)]--;
            } else {
                bok[(*it)]--;
            }
            if (aok[(*it)] == 0 || bok[(*it)] == 0) {
                q.push(*it);
            }
        }
    }
    //cout << aok << bok;
    for(int i=0;i<n;i++) {
        if(min(aok[i],bok[i])>0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main(){
  int h,w,k;
  cin >> h >> w >> k;
  vector<string> s(h);
  for (int i = 0; i < h; i++)
  {
    cin >> s[i];
  }

  int ans = 1000000;
  vector<int> id(h);
  for (int bit = 0; bit < (1<<(h-1)); bit++)
  { 
    int g = 0;
    for (int i = 0; i < h; i++)
    {
      id[i] = g;
      if(bit & (1<<i)) g++;
    }
    g++;

    vector<vector<int>> c(g,vector<int>(w));
    for (int i = 0; i < h; i++)
    {
      for (int j = 0; j < w; j++)
      {
        c[id[i]][j] += s[i][j]-'0';
      }
    }

    bool ok = true;
    for (int i = 0; i < g; i++)
    {
      for (int j = 0; j < w; j++)
      {
        if(c[i][j]>k) ok = false;
      }
    }
    if(!ok) continue;

    vector<int> now(g);
    int cnt = g-1;
    for (int j = 0; j < w; j++)
    {
      for (int i = 0; i < g; i++)
      {
        now[i]+=c[i][j];
        if(now[i]>k) ok = false;
      }
      if(!ok){
        ok = true;
        cnt++;
        now = vector<int>(g);
        for (int i = 0; i < g; i++)
        {
          now[i]+=c[i][j];
        }
      }
    }
    ans = min(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N =20;
int A[N],x[N][N],y[N][N];

int counter(int x)
{
    if(x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=0; i<n; i++)
        {
            scanf("%d",&A[i]);
            for(int j=0; j<A[i]; j++)
            {
                scanf("%d%d",&x[i][j],&y[i][j]);
            }
        }
        int ans =0;
        for(int bits=1; bits<(1<<n); bits++)
        {
            bool ok =true;
            for(int i=0; i<n; i++)
            {
                if(!(bits&(1<<i)))
                    continue;
                for(int j=0; j<A[i]; j++)
                {
                    if((bits&(1<<(x[i][j]-1))) ^ (y[i][j]<<(x[i][j]-1)))
                        ok = false;
                }
            }

            if(ok)
            {
                ans =max(ans,counter(bits));
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 384
N = int(input())
A = [int(i) for i in input().split()]
A_sum = sum(A)

s = 0
i = 0
while i < N:
    s += A[i]
    if A_sum - s < s:
        t = s
        u = s - A[i]
        break
    i += 1
      
print(min(t-A_sum+t, A_sum-u-u))

Measured memory_bytes: 26764
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

string s;
int k;

char nxt(char t){
	if(t == 'z') return 'a';
	return t+1;
}

int main(){
	cin >> s >> k;
	for(int i=0; i<s.size(); i++){
		char v = s[i];
		int cnt = 0;
		while(v != 'a') v = nxt(v), cnt++;
		if(cnt > k){
			continue;
		}
		k -= cnt;
		s[i] = 'a';
	}
	k %= 26;
	for(int i=0; i<k; i++) s.back() = nxt(s.back());
	cout << s << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
 
int main(){
  string s,t;
  cin>>s>>t;
  
  ll ans=0;
  rep(i,s.size()){
    if(s[i]!=t[i]){
      ans++;
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3924
#include <iostream>
#include <vector>
#include <list>
#include <utility>
using namespace std;

int main() {
    int n, q;
    cin >> n >> q;
    vector<list<int> > lst(n);

    for(int i = 0; i < q; i++) {
        int p;
        cin >> p;
        if(p == 0) {
            int t, x;
            cin >> t >> x;
            lst[t].push_back(x);
        }
        else if(p == 1) {
            int t;
            cin >> t;
            list<int>::iterator itr = lst[t].begin();
            if(itr != lst[t].end()){
                cout << *itr;
            }
            while(++itr != lst[t].end()){
                cout << " " << *itr;
                //itr++;
            }
           
            cout << endl;   
        }
        else {
            int s, t;
            cin >> s >> t;
            /*
            if(lst[s].size() == 0){
                continue;
            }
            */
            lst[t].splice(lst[t].end(), lst[s]);
            //lst[s].clear();
        }
    }

}


Measured memory_bytes: 18720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;

int main(){
  ll N;cin>>N;
  vector<int> A(N);rep(i,N)cin>>A[i];
  map<int,int> m;
  ll ans = 1;
  rep(i,N){
    m[A[i]]++;
    if(A[i]==0){
      ans *= 4 - m[0];
    }
    else{
      ans *= (m[A[i]-1] - m[A[i]] + 1);
    }
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8188
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
const int INF=1000000000000000;

//ABC131
signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int n,l; cin>>n>>l;
    int sum=(l+l+n-1)*n/2;
    int ans=INF;
    int ans1;
    rep(i,n){
        int now=l+i;
        if(chmin(ans,abs(sum-(sum-now)))){
            ans1=sum-now;
        }
    }
    cout<<ans1<<endl;

}

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

int main() {
    int a, b;
    cin >> a >> b;
    int c = 1;
    for(int i = 2; i <= 999; i++) {
        int d = c + i;
        if(c - a > 0 and c - a == d - b) return !printf("%d\n", d - b);
        c = d;
    }
}

Measured memory_bytes: 256
#include <cstdio>


int n;

void solve(){
    bool f = false;

    while(n){
        if(n % 10 == 9){
            f = true;
            break;
        }

        n /= 10;
    }

    if(f) printf("Yes\n");
    else printf("No\n");
}

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

    solve();

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

vector<pair<ll, int>> Pfact(ll num) {
    vector<pair<ll, int>> res;
    for (ll i = 2; i * i <= num; i++) {
        int cnt = 0;
        while (num % i == 0) {
            cnt++;
            num /= i;
        }
        if (cnt) res.emplace_back(i, cnt);
    }
    if (num != 1) res.emplace_back(make_pair(num, 1));
    return res;
}

class Combi {
private:
  v(ll) fac, inv, finv;
  void init(int N) {
    fac[0] = fac[1] = 1; inv[1] = 1; finv[0] = finv[1] = 1;
    for (int i = 2; i < N; i++) {
      fac[i] = fac[i - 1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
      finv[i] = finv[i - 1] * inv[i] % MOD;
    }
  }
public:
  Combi(int N) : fac(N + 1), inv(N + 1), finv(N + 1) { init(N + 1); }
  ll Cmod(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
  }
  ll Pmod(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k] % MOD;
  }
};
  
int main() {
  int N,M;
  cin >> N >> M;
  vector<pair<ll, int>> f = Pfact(M);
  Combi C = Combi(1000000);
  ll ans = 1;
  rep(i,sz(f)) {
    int num = f[i].second;
    ans *= C.Cmod(N+num-1,num);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#include<iostream>
#include <stdio.h>
#define f(i,a,b) for(int i=a; i<b; ++i)
#define f2(j,a,b) for(int j=a; j<b; ++j)
#define F first
#define S second
#define pi 3.1415926536
#define Faast ios_base::sync_with_stdio(0);       cin.tie(0);      cout.tie(0);
#define SIZE 10
#define IN freopen("records.in","r",stdin);
const int MOD = 1e9 + 7;
const int MAX_VAL=1e6+2;
const int INF = 0x3f3f3f3f;
typedef long long ll;
using namespace std;

void file()
{
    #ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
    #else
  // online submission
    #endif
}

int main()
{
     int n,s,cnt=0; cin>>n;
     f(i, 1, n+1) 
     { 
       cin>>s; if((i&1)&&(s&1)) cnt++;
     }
     cout<<cnt<<endl;
      return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <iterator>
#include <algorithm>

#define print_vector(os,v) do{      \
  os << #v ":{";                    \
  if(v.size()) os << v[0];          \
  for(int i=1 ; i<v.size() ; ++i){  \
    os << "," << v[i];              \
  }                                 \
  os << "}\n";                      \
}while(0)

#define input_vector(is,type,vec) do{               \
  std::string str;                                  \
  std::getline(is, str);                            \
  std::istringstream iss(str);                      \
  std::copy(std::istream_iterator< type >(iss), {}, \
      vec.begin());                     \
}while(0)

using namespace std;

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

  vector<int> L(2*N);
  input_vector(std::cin,int,L);
  
  std::sort(L.begin(),L.end());

  int ans=0;
  for(int i=0 ; i<2*N ; i+=2){
    ans += std::min(L[i],L[i+1]);
  }

  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) for(auto x:obj)cout<<x<<' ';cout<<endl;
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

double a,b,x;
const double pi = 3.141592653589793238;

int main(){
	cin>>a>>b>>x;
	double ans ;
	if(a*a*b/2<x){
		double rest = a*a*b-x;
		double h = rest/a*2/a;
		ans = atan(h/a)*180/pi;
	}else{
		double h = x/a*2/b;
		ans = 90 - atan(h/b)*180/pi;
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
typedef pair<ll,ll> LL_LLP;
#define INF 1e9+7
#define MOD 1000000007


int main(){

    int n;
    cin >> n;
    vector<double> a(n);
    double sum = 0;
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    }
    double mean = sum/double(n);
    REP(i,n){
        a[i] = abs(a[i]-mean);
    }

    double mini = INF;
    int ans;
    REP(i,n){
        if(a[i] < mini){
            ans = i;
            mini = a[i];
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k,n=0;
	cin>>a>>b>>c>>k;
	if(k>a){
		n+=a;
		k-=a;
		if(k>=b){
			k-=b;
			if(k!=0){
				n-=k;
			}
		}
	}
	else{
		n+=k;
	}
	cout<<n;
}


Measured memory_bytes: 3620