akhauriyash/Code-Regression huggingface dataset:
/*
*/

//#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 600031;

int n,m;
int cost[N];
vector<int> g[N];
int used[N];
vector<int> comp;
vector<vector<int> > comps;
int ptr[N];

void dfs(int v){
	used[v]=1;
	comp.push_back(cost[v]);
	for (int i=0;i<g[v].size();i++){
		int to=g[v][i];
		if (used[to])
			continue;
		dfs(to);
	}
}

int need_vertices;
int thold;
long long ans;

set<pair<int,int> > S;
set<pair<int,int> >::iterator it;

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

	cin>>n>>m;
	for (int i=0;i<n;i++){
		cin>>cost[i];
	}

	for (int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	for (int i=0;i<n;i++){
		if (used[i])
			continue;
		comp.clear();
		dfs(i);
		sort(comp.begin(),comp.end());
		comps.push_back(comp);
	}

	need_vertices=2*(comps.size()-1);
	// max from one
	thold=comps.size()-1;

	if (comps.size()>1){
	for (int i=0;i<comps.size();i++){
		ans+=comps[i][0];
		ptr[i]=1;
		if (ptr[i]<comps[i].size()&&ptr[i]<thold){
			S.insert(make_pair(comps[i][ptr[i]],i));
		}
		--need_vertices;
	}}

	//cout<<need_vertices<<endl;

	while (need_vertices>0){
		if (S.size()==0){
			cout<<"Impossible"<<endl;
			return 0;
		}
		it=S.begin();
		pair<int,int> p=(*it);
		S.erase(it);
		ans+=p.first;
		int id=p.second;
		++ptr[id];
		if (ptr[id]<comps[id].size()&&ptr[id]<thold){
			S.insert(make_pair(comps[id][ptr[id]],id));
		}
		--need_vertices;
	}

	cout<<ans<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 25908
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=1e5+5;



int main()
{ 

IOS;


ll n;cin>>n;

vl f(N);

ll ans=1;

for(int i=1;i<=n;i++){
  ll x;cin>>x;
  ll temp;
  if(!x){
    temp=3-f[0];
  }
  else {
    temp=f[x-1]-f[x];
  }
  if(temp<=0){
    cout<<0;
    return 0;
  }
  ans=ans*temp%M;
  f[x]++;
}

cout<<ans;

//end_routine();

return 0;
 
}


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

int main() {
    int d, t, s;
    double a;
    cin >> d >> t >> s;
    a = (double)d/s;
    if(a > (double)t){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long X, long long Y){
    for (int i = 0; i <= X; i++) {
        long long a2 = i;
        long long a4 = X - i;
        if (Y == a2 * 2 + a4 * 4) {
            cout << YES << endl;
            return;
        }
    }
    cout << NO << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
signed main() {
	int a,b;
	cin>>a>>b;
	if((a-b)%2)puts("IMPOSSIBLE");
	else cout<<(a+b)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdlib>

using namespace std;

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

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

#define INF 1e9
int N;
const int maxN=100100;
int h[maxN];
long long dp[maxN];


int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    fill(dp, dp+N,INF);
    dp[0]=0;    

    for(int i=1;i<N;i++){
        chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1) chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));

    }
    cout << dp[N-1] << endl;
    

}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main()
{
    string a,b;
    int i,j,k=0,f;
    cin >> a >> b;
    a=a+a;
    for(i=0;i<a.size();i++)
    {
        f=0;
        for(j=0;j<b.size();j++)
        {
            if(b[j]!=a[j+i])
            {
                f=1;
                break;
            }
        }
        if(f==0)
        {
            k=1;
            break;
        }
    }
    if(k)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> h(n);
  vector<int> p(n, 0);
  for (int i = 0; i < n; i++){
    cin >> h.at(i);
  }
  vector<int> a(m);
  vector<int> b(m);
  for (int i = 0; i < m; i++){
    cin >> a.at(i) >> b.at(i);
    a.at(i)--;
    b.at(i)--;
  }

  for (int i = 0; i < m; i++){
    p.at(a.at(i)) = max(p.at(a.at(i)), h.at(b.at(i)));
    p.at(b.at(i)) = max(p.at(b.at(i)), h.at(a.at(i)));
  }
  
  int ans = 0;
  for (int i = 0; i < n; i++){
    if (p.at(i) < h.at(i)){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4820
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	int a, b;
	cin >> a >> b;
	cout << a - b + 1 << rt;

	please AC;
}

Measured memory_bytes: 256
#!usr/bin/env python3

import sys


class Die:
    def __init__(self, pips):
        self.pips = pips

    def move_die(self, direction):
        tmp = int()
        if direction == 'N':
            tmp = self.pips[0]
            self.pips[0] = self.pips[1]
            self.pips[1] = self.pips[5]
            self.pips[5] = self.pips[4]
            self.pips[4] = tmp
            del tmp
        elif direction == 'S':
            tmp = self.pips[0]
            self.pips[0] = self.pips[4]
            self.pips[4] = self.pips[5]
            self.pips[5] = self.pips[1]
            self.pips[1] = tmp
            del tmp
        elif direction == 'E':
            tmp = self.pips[0]
            self.pips[0] = self.pips[3]
            self.pips[3] = self.pips[5]
            self.pips[5] = self.pips[2]
            self.pips[2] = tmp
            del tmp
        elif direction == 'W':
            tmp = self.pips[0]
            self.pips[0] = self.pips[2]
            self.pips[2] = self.pips[5]
            self.pips[5] = self.pips[3]
            self.pips[3] = tmp
            del tmp

    def spin_die_clockwise(self):
        tmp = self.pips[1]
        self.pips[1] = self.pips[2]
        self.pips[2] = self.pips[4]
        self.pips[4] = self.pips[3]
        self.pips[3] = tmp
        del tmp

    def get_upside(self):
        return self.pips[0]

    def get_frontside(self):
        return self.pips[1]

    def get_rightside(self):
        return self.pips[2]


def init_die():
    pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]
    die = Die(pips)
    return die


def roll_die(die):
    directions = list(sys.stdin.readline().strip('\n'))

    for direction in directions:
        die.move_die(direction)

    return die


def main():
    die = init_die()
    q = int(sys.stdin.readline().strip('\n'))

    for question in range(q):
        q_pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]

        if q_pips[0] == die.pips[0]:
            pass
        elif q_pips[0] == die.pips[1]:
            die.move_die('N')
        elif q_pips[0] == die.pips[2]:
            die.move_die('W')
        elif q_pips[0] == die.pips[3]:
            die.move_die('E')
        elif q_pips[0] == die.pips[4]:
            die.move_die('S')
        elif q_pips[0] == die.pips[5]:
            die.move_die('N')
            die.move_die('N')

        while die.get_frontside() != q_pips[1]:
            die.spin_die_clockwise()

        print(die.get_rightside())


if __name__ == '__main__':
    main()

Measured memory_bytes: 7840
#include <iostream>
#include <string>

using namespace std;

void C(string& str)
{
	string temp;
	for(int i = 1; i < str.size(); ++i)
	{
		temp += str[i];
	}
	temp += str[0];
	str = temp;
}

void J(string& str)
{
	string temp;
	temp += str[str.size() - 1];
	for(int i = 0; i < str.size() - 1; ++i)
	{
		temp += str[i];
	}
	str = temp;
}

void E(string& str)
{
	string temp;
	int n;
	if(str.size() % 2)
	{
		n = str.size() / 2 + 1;
	}
	else
	{
		n = str.size() / 2;
	}
	for(int i = n; i < str.size(); ++i)
	{
		temp += str[i];
	}
	if(str.size() % 2)
	{
		--n;
		temp += str[n];
	}
	for(int i = 0; i < n; ++i)
	{
		temp += str[i];
	}
	str = temp;
}

void A(string& str)
{
	string temp;
	for(int i = str.size() - 1; i >= 0; --i)
	{
		temp += str[i];
	}
	str = temp;
}

void M(string& str)
{
	for(int i = 0; i < str.size(); ++i)
	{
		if('0' <= str[i] && str[i] <= '8')
		{
			str[i] = str[i] + 1; 
		}
		else if(str[i] == '9')
		{
			str[i] = '0';
		}
	}
}

void P(string& str)
{
	for(int i = 0; i < str.size(); ++i)
	{
		if('1' <= str[i] && str[i] <= '9')
		{
			str[i] = str[i] - 1; 
		}
		else if(str[i] == '0')
		{
			str[i] = '9';
		}
	}
}

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		string command, input;
		cin >> command >> input;
		for(int i = command.size() - 1; i >= 0; --i)
		{
			switch(command[i])
			{
				case 'J':
				  J(input);break;
				case 'C':
				  C(input);break;
				case 'E':
				  E(input);break;
				case 'A':
				  A(input);break;
				case 'P':
				  P(input);break;
				case 'M':
				  M(input);break;
			}
		}
		cout << input << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

const int INF = 1e9;
const int MAX_N = 3010, MAX_E = 10000;
int n, m; //????????° ???????????¬??°
vector<pair<int, int> > G[MAX_N];//??°???????????¨?????£??\????????? fi:to se:cost
int d[MAX_N]; //s?????????????????????
typedef pair<int, int> P;//first??????????????¢,second??????????????????
int k; vector<int> shop;//???????¨????

void dijkstra(void){
	priority_queue<P, vector<P>, greater<P> > que;//first????°?????????????
    rep(i, n)d[i] = INF;//?????????
    
    //k????????????????????°????????????
    for(auto i : shop){
    	d[i] = 0;
    	que.push(make_pair(0, i));
    }
  
    while(!que.empty()){
       	auto p = que.top(); que.pop();
       	int v = p.second;
       	if(d[v] < p.first) continue;
       	for(auto e : G[v]){//e.fi:??£??\??????????????????????????? e.se:?????????????????§????????????
       		if(d[e.first] > d[v] + e.second){//???????????¢?????´??°???????????¨???
       			d[e.first] = d[v] + e.second;
       			que.push(make_pair(d[e.first], e.first));
       		}
       	}
    }
}

int main(void){
    cin >> n >> m >> k;
    rep(i, m){
        int a, b, l; cin >> a >> b >> l;
        a--; b--;
       	G[a].push_back(make_pair(b, l)); G[b].push_back(make_pair(a, l));
    }
    rep(i, k){
    	int s; cin >> s; s--;
    	shop.push_back(s);
    }
    dijkstra();//????????????????????????????°?????????????
    //?????????????????¶????????????????°?????????????
    int ans = 0;
    //??????????????????????????¢????????¨???????????????????????¶???????????´?????????????????????????????¢?????????
    // rep(i, n) printf("%d\n", d[i]);
   	for (int x = 0; x < n; ++x){
   		for(auto y : G[x]){
   			if(d[x] == 0 || d[y.first] == 0) continue;
   			int tmp = round((d[x] + d[y.first] + y.second + 1) / 2);//+1????????¨?????\??¨
   			ans = max(tmp, ans);
   		}
   	}
   	cout << ans << endl;
   	return 0;
}

Measured memory_bytes: 5932
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

string to_lower(string s)
{
	rep(i,sz(s))s[i] = tolower(s[i]);
	return s;
}

void solve()
{	
	string s; cin >> s;
	s = to_lower(s);
	int ans = 0;
	while (true)
	{
		string tmp; cin >> tmp;
		if(tmp == "END_OF_TEXT")break;
		tmp = to_lower(tmp);
		if(tmp == s)ans++;
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



Measured memory_bytes: 3232
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main(){
	
	long long n;
	cin >> n;
	
	if(n==1){
		cout << 0 << endl;
		return 0;
	}
	
	map<long long,int> mp;
	long long id=2;
	long long num=n;
	bool fin=false;
	while(n){
		if(n%id==0){
			mp[id]++;
			n/=id;
		}else{
			id++;
		}
		if(n<=1)break;
		if(fin){
			mp[n]++;
			break;
		}
		if(id*id>num)fin=true;
	}
		
	long long cnt=0;
	for(auto itr=mp.begin();itr!=mp.end();itr++){
		int now=itr->second;
		for(long long i=1;i<=itr->second;i++){
			now-=i;
			cnt++;
			if(now==0){
				break;
			}
			if(now<0){
				cnt--;
				break;
			}
		}
	}
	if(cnt==0)cnt++;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3632
rads=[]
h = 0
N,dum=gets.chomp.split(' ').map{|n| n.to_i}
1.upto(N){|i|
	r,dum=gets.chomp.split(' ').map{|n| n.to_i}
	if(! rads.include?(r))
		h+=1
		rads << r
	end
}
puts "#{h}"


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

int main() {
  int a,flag = 0;
  cin >> a;
  for (int i = 9; i > 0; --i) {if (a % i == 0 & a / i <= 9) {flag = 1;}}
  if (flag == 1) {cout << "Yes";} else {cout <<"No";}
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(){
    int x;
    cin >> x;
    if(x<1200)
        cout << "ABC" << endl;
    else
        cout << "ARC" <<endl;
}


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

using namespace std;
int N;
void dfs(string s,char m){
	if(s.size()==N){
		cout<<s.c_str()<<"\n";
	}
	else{
		for (char i='a';i<=m;++i){
			dfs(s+i,((i==m)?(char)(m+1):m));
		}
	}
}
int main(){
	cin>>N;
	dfs("",'a');
	return 0;
}


Measured memory_bytes: 3620
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let v: Vec<&str> = input.trim().split(" ").collect();

    let a = &v[0].parse::<i32>().unwrap();
    let b = &v[1].parse::<i32>().unwrap();
    let mut count = 1;

    loop {
        let a_abs = (a - count).abs();
        let b_abs = (b - count).abs();

        if a_abs == b_abs {
            println!("{}", count);
            break;
        }

        if count >= *a && count >= *b {
            println!("IMPOSSIBLE");
            break;
        }

        count = count + 1;
    }
}

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

int main()
{
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


N = ii()
s = {}
for _ in range(N):
    tmp = ii(str)
    try:
        s[tmp] += 1
    except KeyError:
        s[tmp] = 1

M = ii()
for _ in range(M):
    tmp = ii(str)
    try:
        s[tmp] -= 1
    except KeyError:
        s[tmp] = 0
print(max(max(s.values()), 0))


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

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

ll ans=1;
rep(i,n)
{
 int j=i+1;
 ans= ans*j% 1000000007;//%1000,000,007;
}



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

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

struct RMS {
	using type = int;
	static type id() { return 0; }
	static type op(const type& l, const type & r) { return l + r; }
};

struct seg_node {
	using M = RMS;
	using T = typename M::type;
	using U = int;

	T val;

private:
	int size;
	bool flag;
	U lazy;

public:
	seg_node() : val(), size(0), flag(false) {}
	void init_leaf(const T& v) {
		val = v;
		size = 1;
	}
	void init_non_leaf(const seg_node& l, const seg_node& r) {
		val = M::op(l.val, r.val);
		size = l.size + r.size;
	}
	void update(U v) {
		if (v) {
			val = size - val;
			lazy ^= v;
		}
		flag = true;
	}
	void push(seg_node& l, seg_node& r) {
		if (!flag) return;
		l.update(lazy);
		r.update(lazy);
		lazy = 0;
		flag = false;
	}
	bool is_updated() const {
		return flag;
	}

};

class segment_tree {
	using M = typename seg_node::M;
	using T = typename seg_node::T;
	using U = typename seg_node::U;
	const int h, n;
	vector<seg_node> data;
	void push(int node) {
		data[node].push(data[node << 1], data[(node << 1) | 1]);
	}
	void update(int node) {
		data[node].val = M::op(data[node << 1].val, data[(node << 1) | 1].val);
	}
public:
	segment_tree(int n_)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2) {}
	segment_tree(int n_, T v1)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2) {
		for (int i = 0; i < n_; i++)
			data[i + n].init_leaf(v1);
		for (int i = n - 1; i >= 1; i--)
			data[i].init_non_leaf(data[i << 1], data[(i << 1) | 1]);
	}
	segment_tree(const vector<T>& data_)
		: h(ceil(log2(data_.size()))), n(1 << h), data(n * 2) {
		for (int i = 0; i < (int)data_.size(); i++)
			data[i + n].init_leaf(data_[i]);
		for (int i = n - 1; i >= 1; i--)
			data[i].init_non_leaf(data[i << 1], data[(i << 1) | 1]);
	}
	void update(int l, int r, U val) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		int tl = l, tr = r;
		r++;
		while (l < r) {
			if (l & 1) data[l++].update(val);
			if (r & 1) data[--r].update(val);
			l >>= 1; r >>= 1;
		}
		while (tl >>= 1, tr >>= 1, tl) {
			if (!data[tl].is_updated()) update(tl);
			if (!data[tr].is_updated()) update(tr);
		}
	}
	T find(int l, int r) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		r++;
		T res1 = M::id(), res2 = M::id();
		while (l < r) {
			if (l & 1) res1 = M::op(res1, data[l++].val);
			if (r & 1) res2 = M::op(data[--r].val, res2);
			l >>= 1; r >>= 1;
		}
		return M::op(res1, res2);
	}
};

const int MAX = 1e5;

int it = 0;
int lv[MAX], rv[MAX];

void euler_tour(int v, const graph& G) {
	lv[v] = it++;
	for (auto to : G[v]) {
		euler_tour(to, G);
	}
	rv[v] = it - 1;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q; cin >> n >> q;
	graph G(n);
	for (int i = 1; i < n; i++) {
		int p;
		cin >> p; p--;
		G[p].push_back(i);
	}
	euler_tour(0, G);
	segment_tree lst(n, 0);
	for (int i = 0; i < n; i++) {
		char c;
		cin >> c;
		if (c == 'G') {
			lst.update(lv[i], lv[i], 1);
		}
	}
	for (int i = 0; i < q; i++) {
		int v;
		cin >> v; v--;
		lst.update(lv[v], rv[v], 1);
		puts(lst.find(0, n - 1) * 2 > n ? "broccoli" : "cauliflower");
	}
	return 0;
}



Measured memory_bytes: 18060
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
int r[MAXN], t[MAXN], a[MAXN];
int main()
{
    int X, k; scanf("%d%d", &X, &k);
    for (int i = 1; i <= k; i++) scanf("%d", &r[i]);
    r[k + 1] = 1e9 + 1;
    int q; scanf("%d", &q);
    for (int i = 1; i <= q; i++) scanf("%d%d", &t[i], &a[i]);
    int i = 0, j = 1;
    int low = 0, up = X, sig = -1, bound = 0;
    int det, res;
    while (j <= q)
    {
        if (i < k && t[j] >= r[i + 1])
        {
            i++;
            det = sig * (r[i] - r[i - 1]);
            low = max(min(low + det, X), 0);
            up = max(min(up + det, X), 0);
            bound += det;
            sig *= -1; 
        }
        else
        {
            det = t[j] - r[i];
            res = max(min(a[j] + bound, up), low);
            res = max(min(X, res + sig * det), 0);
            printf("%d\n", res);
            j++;
        }
    }
    return 0;
}

Measured memory_bytes: 2432
def g(n):
    for i in range(1, n+1):
        if i % 3 == 0:
            yield " {}".format(i)
            continue
        x = i
        while x != 0:
            if x % 10 == 3:
                yield " {}".format(i)
                break
            x //= 10

n = int(input())
print("".join(g(n)))

Measured memory_bytes: 7884
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(int i=0; i<n; i++);
int main() {
 int A,B;
 cin>>A>>B;
 int answer=-1;
 for(int i=1; i<1263; i++){
int g=i*8/100;
int h=i*10/100;
if(g==A&&h==B){
answer=i;
break;
}
 }
 cout<<answer<<endl;
 }


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k, ans = 0; cin >> n >> k;
    rep (m, k + 1, n + 1) {
        ans += ((n + 1) / m) * (m - k) + (n % m == m - 1 ? 0 : max(0LL, n % m + 1 - k));
        eprintf("%d: %lld %lld\n", m, ((n + 1) / m) * (m - k), max(0LL, n % m + 1 - k));
        if (k == 0) ans--;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    n = int(input())
    t = tuple(map(int, input().split()))
    total = sum(t)
    m = int(input())
    for i in sys.stdin:
        p,x = map(int, i.split())
        print(total - t[p - 1] + x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38396
import heapq
X, Y, A, B, C = map(int, input().split())

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort()

p = p[:X]
q = q[:Y]
heapq.heapify(p)
heapq.heapify(q)

jdg = True

while r and jdg:
    hp = heapq.heappop(p)
    hq = heapq.heappop(q)
    rr = r.pop()
    if hp > hq:
        heapq.heappush(p, hp)
        if rr > hq:
            heapq.heappush(q, rr)
        else:
            heapq.heappush(q, hq)
            r.append(rr)
            jdg = False            
    else:
        heapq.heappush(q, hq)
        if rr > hp:
            heapq.heappush(p, rr)
        else:
            heapq.heappush(p, hp)
            r.append(rr)
            jdg = False
print(sum(p) + sum(q))

Measured memory_bytes: 22848
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
const ll mod = 1e9+7;
#define INFL 0x3f3f3f3f3f3f3f3fLL
 
//-------------------------<MATH>-------------------------------------------------------//
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;
ll c = (a * b)%mod;
//cout << a << " " << b << endl;
return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(5e5 + 5)] , inv_fac[(int)(5e5 + 5)];
void precomp_factorial(int M){fac[0] = 1;for(int i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(int i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int lo[(int)(1e3 + 6)];
void sieve(int M){for(int i = 2 ; i < M ; i++){ if(lo[i]) continue; for(int j = i ; j < M ; j += i)lo[j] = i;}}
int max_expo_prime_n_fac(ll N , int prime){int ress = 0;while(N){ress += (N/prime);N /= prime;}return ress;}
//-------------------------</MATH>-------------------------------------------------------//
 
//-------------------------<STRING>-------------------------------------------------------//
string get_prefix(string x , int MAX){return x.substr(0 , min((int)x.size() , MAX));}
string get_suffix(string x,int MAX){int dn=1;for(int i=x.size()-1;i>=0;i--){if(dn==MAX)return x.substr(i);dn++;}return x;}
string convert_to_binary(int x,int len) {string ans=""; while(x){if(x&1){ans='1'+ans;}
    else{ans ='0'+ans;}x/=2;}int k = ans.size();while(k < len){ans = '0' + ans;k++;}return ans;}
//-------------------------</STRING>-------------------------------------------------------//
 
ull llrand() {ull r = 0;for(int i = 0; i < 5; ++i){r = (r << 15)|(rand() & 0x7FFF);}return r & 0xFFFFFFFFFFFFFFFFULL;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
 
const int SZ = 2345678;
 
 
 int main(){
   int a, b, c;
   cin >> a >> b >> c;
   int k;
   cin >> k;
   int cond = 0;
   for(int i = 0; i <= k; i++){
       int b1 = b<<i;
       int c1 = c<<(k-i);
       //cout << b1 << " " << c1 << " " << i << endl;
       if(a < b1 && b1 < c1){
         cond = 1; break;
       }
   }
   if(cond) cout << "Yes" << endl;
   else cout << "No" << endl;
 }


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] X = new int[M];

        for (int i = 0; i < M; i++) {
            X[i] = sc.nextInt();
        }

        Arrays.sort(X);

        int[] Y = new int[M-1];
        for (int i = 0; i < M-1; i++) {
            Y[i] = X[i+1] - X[i];
        }

        Arrays.sort(Y);

        int sum = 0;
        for (int i = 0; i < Y.length - (N-1); i++) {
            sum += Y[i];
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 51004
###############################################################################

from bisect import bisect_left as binl
from copy import copy, deepcopy

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n = intin()
    ablist = intinl(n-1)

    linklist = make_linklist(ablist)
    diameter = calc_tree_diameter(linklist)

    if diameter % 3 == 1:
        print('Second')
    else:
        print('First')


if __name__ == '__main__':
    main()


Measured memory_bytes: 155716
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long int> vec(2, 0);
    for(int n=0; n<N; n++) {
        long long int A;
        cin >> A;
        vec[A%2]++;
    }
    
    if(vec[1]%2) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }


    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
#define ll long long
#define W 1000000007
using namespace std;

int main(){
	int n,ans=0;
	cin>>n;
	if(n/100==9)ans += 100;
	else ans += 900;
	if((n/10)%10==9)ans+=10;
	else ans+=90;
	if(n%10==9)ans+=1;
	else ans+=9;
	cout<<ans<<endl;
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int s[n];
    rep(i,n) cin >> s[i];

    int c = 0;
    rep(i,n){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n;k++){
                if((s[i] != s[j]) && (s[j] != s[k]) && s[k] != s[i]){
                    if(abs(s[i] - s[j]) < s[k] && s[k] < s[i] + s[j]) {
                        c++;
                        //cout << s[i] << s[j] << s[k] << endl;
                    }
                }
            }
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);cout.tie(NULL);
      ll n,m;
      cin>>n>>m;
      cout<<(n*n - n + m*m - m)/2;
    }

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

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

vector<ll> factmemo, factmemoInv;
ll factmemoMod = -1;

ll factorial(int n, int M){
  if(factmemoMod == M) return factmemo[n];
  if(n <= 1) return 1;

  ll res = 1;
  for(int i=1; i<=n; i++) res = res * i % M;
  return res;
}

ll power(int k, int n, int M){
  if(n == 0) return 1;
  if(n == 1) return (ll)k;

  ll res = power(k, n/2, M);

  res = res * res % M;
  return n%2 == 1 ? res * k % M : res;
}

void initFactorial(int n, int M){
  factmemo.assign(n+1, 0);
  factmemoInv.assign(n+1, 0);
  factmemoMod = M;
  factmemo[0] = 1;
  for(int i=1;i<=n;i++) factmemo[i] = factmemo[i-1] * i % M;
  factmemoInv[n] = power(factmemo[n], M-2, M);
  for(int i=n;i>0;i--) factmemoInv[i-1] = factmemoInv[i] * i % M;
}

//nCm nPm nHm (mod M)

/*Combination*/
ll C(int n, int m, int M){
  if(n < m) return 0;
  if(m == 0 || n == m) return 1;

  if(factmemoMod == M)
    return factmemo[n] * factmemoInv[m] % M * factmemoInv[n-m] % M;

  ll numer = factorial(n, M);
  ll denom = factorial(m, M) * factorial(n-m, M) % M;

  denom = power((int)denom, M-2, M);

  return numer * denom % M;
}
/*Permutation*/
ll P(int n, int m, int M){
  if(n < m) return 0;
  if(m == 0) return 1;

  if(factmemoMod == M)
    return factmemo[n] * factmemoInv[n-m] % M;

  ll numer = factorial(n, M);
  ll denom = factorial(n-m, M);

  denom = power((int)denom, M-2, M);

  return numer * denom % M;
}
/*Combination with Repetitions*/
ll H(int n, int m, int M){
  if(n == 0 && m == 0) return 1;
  return C(n+m-1, m, M);
}



int main(){
  int B, W;

  cin >> B >> W;

  initFactorial(B+W, mod);

  ll a = 1, b = 0, c = 0;

  ll ans = 0;

  for(int i=0;i<B+W;i++){

    ans = (a + c * 2) % mod;

    ans *= power((a * 2 + b * 2 + c * 2) % mod, mod - 2, mod);

    debug(a);
    debug(b);
    debug(c);

    printf("%lld\n", ans % mod);

    int p = C(i, B-1, mod);
    int q = C(i, W-1, mod);

    debug(a); debug(p); debug(q);

    a = (a * 2) % mod;
    b = (b * 2 + p) % mod;
    c = (c * 2 + q) % mod;
    a = (a + mod * 2 - p - q) % mod;
  }

  return 0;
}


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

//a??????b??\?????§?????????
vector<int>V;
void saiki(int a, int b) {
	for (int c = b; c >= 1; c--) {
		if (a - c == 0) {
			for (int d = 0; d < V.size(); d++)cout << V[d] << " ";
			cout << c << endl;
			continue;
		}
		if (a - c > 0) {
			V.push_back(c);
			saiki(a - c, c);
			V.pop_back();
		}
	}
}
int main() {
	int a;
	while (cin >> a, a) {
		V.clear();
		saiki(a, a);
	}
}

Measured memory_bytes: 3124
a, b, c, x, y = [int(x) for x in input().split()]

c_list = list(range(max(x, y) * 2, -1, -2))
min_cost = max(x, y) * 2 * c

for index, numc in enumerate(c_list):
	numa = int(x - numc/2) if x > numc / 2 else 0
	numb = int(y - numc/2) if y > numc / 2 else 0
	cost = numa * a + numb * b + numc * c
	if cost < min_cost:
		min_cost = cost
		
print(min_cost)

Measured memory_bytes: 6900
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int a[100002];
int main() {
	int n, l, t;
	scanf("%d %d %d", &n, &l, &t);
	long long cur = 0;
	for (int i = 0; i < n; i++) {
		int temp;
		scanf("%d %d", a + i, &temp);
		if (temp == 1) {
			cur +=  (a[i] + t) / l;
			a[i] = (a[i] + t) % l;
		} else {
			cur +=  (a[i] - t) / l;
			a[i] = (a[i] - t) % l;
			if (a[i] < 0) { //mutiple circle (1 - 8) / 4 => cur = cur - 2 
				a[i] += l;
				cur--;
			}						
		}
	}
	sort(a, a + n);
	cur = cur % n;
	if (cur < 0)
		cur = cur + n;
	for (int i = 0; i < n; i++) {
		printf("%d\n", a[(i + cur) % n]);		
	}
	
	return 0;
}


Measured memory_bytes: 1536
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int i,j,n,x,flg,cnt;
	cnt=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		scanf("%d",&x);
		flg=1;
		for(j=2;j*j<=x;j++)	{
			if(x%j==0)	{
				flg=0;
				break;
			}
		}
		cnt+=flg;
	}
    printf("%d\n",cnt);
    return 0;
}


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

int as[26]; int bs[26];

int aa(){
  for (int i = 0; i < 26; i++){
    if (as[i] > 0){
      as[i]--;
      return i;
    }
  }
  return -1;
}

int bb(){
  for (int i = 0; i < 26; i++){
    if (bs[25 - i] > 0) {
      bs[25-i]--;
      return 25-i;
    }
  }
  return -1;
}

int main(){
  string a, b;
  cin >> a;
  cin >> b;
  int max = 0;
  for (int i = 0; i < 26; i++){
    as[i] = 0;
    bs[i] = 0;
  }
  for (int i = 0; i < a.size(); i++){
    as[a[i]-'a']++;
  }
  for (int i = 0; i < b.size(); i++){
    bs[b[i]-'a']++;
  }

  while(true){
    int u = aa();
    int v = bb();
    //printf("%d\t%d\n", u, v);
    if (u < v) {
      printf("Yes\n");
      return 0;
    }
    if (u > v) {
      printf("No\n");
      return 0;
    }
    if (u == -1 && v == -1){
      printf("No\n");
      return 0;
    }
  }

  return 0;
}

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

bool comp(const pair<int,int> a, const pair<int,int> b) {
    return a.second < b.second;
}

const int MAX = 510000;
const int MOD = 1000000007;

int main(){

    int N,D;

    cin >>N>>D;
    cout <<(N + ((2*D+1) - 1))/(2*D+1)<<endl;
    return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;

*/

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
flag = True
for i in range(N):
	if A[i] % 2 == 0:
		if A[i] % 3 == 0 or A[i] % 5 == 0:
			flag = True
		else:
			flag = False
			break
if flag == True:
	print("APPROVED")
else:
	print("DENIED")

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

int n;
int ax[5000],ay[5000];
int bx[5000],by[5000];

vector< ll > X,Y;

vector< int > Ga[5000];
vector< int > Gb[5000];
int f[5000];

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>ax[i]>>ay[i]>>bx[i]>>by[i];
    X.push_back(ax[i]);
    Y.push_back(ay[i]);
    X.push_back(bx[i]);
    Y.push_back(by[i]);
  }
  sort(X.begin(),X.end());
  sort(Y.begin(),Y.end());
  X.erase( unique( X.begin(), X.end()) , X.end() );
  Y.erase( unique( Y.begin(), Y.end()) , Y.end() );
  
  for(int i=0;i<n;i++){
    ax[i]=lower_bound(X.begin(),X.end(),ax[i])-X.begin();
    ay[i]=lower_bound(Y.begin(),Y.end(),ay[i])-Y.begin();
    bx[i]=lower_bound(X.begin(),X.end(),bx[i])-X.begin();
    by[i]=lower_bound(Y.begin(),Y.end(),by[i])-Y.begin();

    Ga[ ay[i] ].push_back( ax[i] );
    Ga[ ay[i] ].push_back( bx[i] );
    Gb[ by[i] ].push_back( ax[i] );
    Gb[ by[i] ].push_back( bx[i] );
  }
  ll ans=0;

  for(int y=0;y+1<(int)Y.size();y++){
    for(int i=0;i<(int)Ga[y].size();i+=2){
      int si=Ga[y][i];
      int ti=Ga[y][i+1];
      for(int x=si;x<ti;x++)f[x]++;
    }
    for(int i=0;i<(int)Gb[y].size();i+=2){
      int si=Gb[y][i];
      int ti=Gb[y][i+1];
      for(int x=si;x<ti;x++)f[x]--;
    }
    for(int x=0;x+1<(int)X.size();x++){
      if(f[x]==0)continue;
      ans+=(Y[y+1]-Y[y])*(X[x+1]-X[x]);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

bool win(int a, int b)
{
	if (a == 1) return true;
	if (b == 1) return false;
	if (a > b) return true;
	else return false;
}

int main(void)
{
	int a, b; cin >> a >> b;
	if (a == b) cout << "Draw" << endl;
	else if (win(a, b)) cout << "Alice" << endl;
	else cout << "Bob" << endl;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);

    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    REP(i,n)cin >> a[i];

    REP(i, k){
        bool flg=true;
        vector<int> b(n,0);

        REP(j,n){
            int l = max(0, j-a[j]);
            int r = min(n-1, j+a[j]);
            b[l]++;
            if(r+1<n) b[r+1]--;
        }
        a[0]=b[0];
        REAP(j,1,n){
            b[j]+=b[j-1];
            a[j]=b[j];
            if(a[j] != n)flg = false;
        }

        if(flg)break;
    }

    REP(i,n) {
        cout << a[i];
        if(i!=n-1)cout << " ";
        else cout << "\n";
    }

}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n, t, a, h;
  cin >> n >> t >> a;
  int ans = 0;
  double ans_t = 1e9;
  for(int i = 0; i < n; ++i)
  {
    cin >> h;
    double temp = abs(a - (t - h * 0.006));
    if (temp < ans_t)
    {
      ans_t = temp;
      ans = i + 1;
    }
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3628
def main
  n, m = gets.chomp.split(' ').map(&:to_i)
  jobs = []
  n.times do
    jobs << gets.split(' ').map(&:to_i)
  end
  schedule = (1..m).to_a
  jobs.sort! { |a, b| (b[1] <=> a[1]).nonzero? || b[0] <=> a[0] }
  sum = 0
  jobs.each do |day, reward|
    i = schedule.bsearch_index { |d| d >= day }
    next unless i
    sum += reward
    schedule.delete_at(i)
  end
  puts sum
end

main if $0 == __FILE__

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

void fnInput(int64_t& rnNum)
{
  cin >> rnNum;
}

int fnDigitsCheck(int64_t nDivisor)
{
  int nDigitCnt = 0;
  while (nDivisor)
  {
    nDigitCnt++;
    nDivisor /= 10;
  }

  return nDigitCnt;
}

int fnMultiplCheck(int64_t nNum)
{
  int nMinDigit = fnDigitsCheck(nNum);
                                           
  for (int64_t n = 2; n * n <= nNum; n++)  // int型 n では n * n が int型の範囲を
  {                                        // 超えて桁落ちが発生し 永久ループとなる
    if (nNum % n != 0)  continue;          // nNum の平方根を超えない整数 + 1 ～ nNum
    int64_t nOtr = nNum / n;               // の範囲でループさせると当然 TLE となる
    nMinDigit = min(nMinDigit, fnDigitsCheck(nOtr));
  }
  return nMinDigit;
}

int main()
{
  int64_t nNum;
  
  fnInput(nNum);
  cout << fnMultiplCheck(nNum) << endl;

  return 0;
}

Measured memory_bytes: 256