akhauriyash/Code-Regression huggingface dataset:
<?php

$str = trim(fgets(STDIN));
$array = explode(' ', $str);
$A = (int)$array[0];
$B = (int)$array[1];
$C = (int)$array[2];

$array = [];
for($i = 1; $i < 100; $i++){
    $Anum = $A*$i;
    $sub = $Anum % $B;
    if (!in_array($sub, $array)) {
        $array[] = $sub;
        if ($C == $sub) {
            echo "YES";
            exit;
        }
    } else {
        break;
    }
}
echo "NO";


Measured memory_bytes: 4728
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
template<class T>
T gcd(T x, T y) {
	return y ? gcd(y, x % y) : x;
}
template<class T>
vector<T> enum_div(T n) {
	vector<T> ret;
	map<long long, bool> check;
	for (T i = 1; i * i < n; ++i) {

		if (n % i == 0) {
			ret.push_back(i);

			if (i != 1 && i * i != n) {
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}
template<class T>
map<T, int> prime_factorization(T n) {
	map<T, int> ret;

	for (long long i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1)ret[n] = 1;
	return ret;
}




int main() {
	long long A, B;
	cin >> A >> B;
	long long greatest_common_divisor = gcd(A, B);

	auto common_divisor = prime_factorization(greatest_common_divisor);

	cout << common_divisor.size() + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    if b[i] <= a[i]:
        ans += b[i]
    elif b[i] <= a[i] + a[i+1]:
        a[i+1] = a[i+1] + a[i] - b[i]
        ans += b[i]
    else:
        ans += a[i] + a[i+1]
        a[i+1] = 0
print(ans)


Measured memory_bytes: 18476
#include <cstdio>
#include <cstdint>
#include <utility>

intmax_t gcd(intmax_t m, intmax_t n) {
  while (n) std::swap(m %= n, n);
  return m;
}

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

int main() {
  intmax_t a, b;
  scanf("%jd %jd", &a, &b);

  printf("%jd\n", lcm(a, b));
}


Measured memory_bytes: 128
n, a, b = map(int, input().split())


def sum_digits(n):
    result = 0
    while (n > 0):
        result += n % 10
        n = int(n / 10)
    return result


total = 0
for i in range(1, n + 1):
    sum_d = sum_digits(i)
    total += i if a <= sum_d and sum_d <= b else 0
print(total)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <stdio.h>
#include <ios>     
#include <iomanip> 

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
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; }

int main()
{
  //input
  inputLong(N);
  vector<long> a(N),b(N);
  for(int i=0; i<N; i++){
    cin >> a[i];
    b[i] = a[i]-(i+1);
  }
  
  //main
  sort(b.begin(),b.end());
  
  long ans = 0;
  if(N % 2 == 1){
    for(int i=0; i<N; i++){//配列の要素はN個→中央値は奇数の時(N+1)/2個目・偶数の時N/2個目とN/2+1個目の間
       ans += abs(b[i]-b[ ((N+1)/2)-1 ]);
    }
  }else{
    for(int i=0; i<N; i++){//配列の要素はN個→中央値は奇数の時(N+1)/2個目・偶数の時N/2個目とN/2+1個目の間
       ans += abs(b[i]-ceil( (b[N/2-1]+b[N/2])/2 ) );
    }
  }

  // output
  output(ans);
  
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <string>
#include <iomanip>
#include <queue>

using namespace std;

int main() {
  int K;
  cin >> K;
  
  queue<long> q;
  for (int i = 1; i <= 9; i++ ){
    q.push(i);
  }

  int i = 1;
  long ans = 0;
  while (i <= K) {
    ans = q.front();
    q.pop();
    long checkVal = ans%10L;
    if (checkVal - 1L >= 0L ) q.push(ans*10L + checkVal-1L );
    q.push(ans*10L + checkVal);
    if (checkVal + 1L <= 9L ) q.push(ans*10L + checkVal+1L );
    
    i++;
  }
  

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
typedef long long int ll;
static const int MAX_N = 10000;

int N;
ll a[MAX_N];

int main(){
	cin >> N;
	for(int i = 0; i < N; i++) cin >> a[i];
	int ans = 0;
	for(int i = 0; i < N; i++){
		ll base = 2;
		for(;;){
			if(a[i] % base != 0) break;
			ans++;
			base *= 2;
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

using namespace std;

const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};

int H,W;
string fld[110];

void dfs(bool flg[110][110], int x, int y, char f){
	if(flg[y][x]){
		return;
	}
	if(f!=fld[y][x]){
		return;
	}

	flg[y][x] = true;
	rep(i,4){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(ny<0||ny>=H||nx<0||nx>=W){
			continue;
		}
		dfs(flg,nx,ny,f);
	}
}

int main(){
	while(cin >> H >> W, H){
		rep(i,H){
			cin >> fld[i];
		}

		bool flg[110][110] = {0};
		int ans = 0;
		rep(y,H){
			rep(x,W){
				if(flg[y][x]){
					continue;
				}
				ans++;
				dfs(flg,x,y,fld[y][x]);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  // 電光掲示板に書かれている数字
  int num = 1;
  for (int i=0; i<N; i++) num += min(num, K);
  cout << num << endl;
}

Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

struct edge {
	int from, to, cost;
};

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}


#pragma endregion 


/*****************************************************************************/
signed main(void) {
	int n, m;
	cin >> n >> m;
	vi x(m);
	f_vI(x, m);
	if (n >= m) {
		cout << 0;
	}
	else {
		sort(all(x));
		vi d(m - 1);
		f(i, 0, m - 1) {
			d[i] = x[i + 1] - x[i];
		}
		int ans = 0;
		sort(all(d));
		f(i, 0, m - n) {
			ans += d[i];
		}
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	ll N;
	cin >> N;
	vector<ll> T(N);
	rep(i, N) {
		cin >> T[i];
	}
	ll M;
	cin >> M;
	vector<ll> P(M), X(M);
	rep(i, M) {
		cin >> P[i] >> X[i];
		P[i]--;
	}

	ll sum = 0;

	rep(i, N) {
		sum += T[i];
	}

	rep(i, M) {
		cout << sum - T[P[i]] + X[i] << endl;
	}


	return 0;
}

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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	vector<long long> v(n);
	for(long long i=0;i<n;i++) cin>>v.at(i);

	long long ans=0;

	for(long long i=0;i<n;i++){
		for(long long j=i+1;j<n;j++){
			for(long long k=j+1;k<n;k++){
				if(max(max(v.at(i),v.at(j)),v.at(k))<v.at(i)+v.at(k)+v.at(j)-max(max(v.at(i),v.at(j)),v.at(k)) && v.at(i)!=v.at(j) && v.at(j)!=v.at(k) && v.at(k)!=v.at(i)) ans++;
//				cout<<i<<" "<<j<<" "<<k<<" "<<max(max(v.at(i),v.at(j)),v.at(k))<<" "<<v.at(i)+v.at(k)+v.at(j)-max(max(v.at(i),v.at(j)),v.at(k))<<endl;
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

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

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


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;

int ar[200500];
vector<pii> s;
void norm(int old_len, int new_len) {
    if (old_len < new_len) {
        if (s.empty()) {
            s.pb(new_len - old_len, 0);
            return;
        }
        if (s.back().second == 0)
            s.back().first += new_len - old_len;
        else
            s.pb(new_len - old_len, 0);
        return;
    }
    while (1) {
        int& l = s.back().first;
        if (old_len - l >= new_len) {
            s.pop_back();
            old_len -= l;
            continue;
        }
        l -= old_len - new_len;
        return;
    }
}
int check(int n, int p) {
    int cur_len = 0;
    s.clear();
    forn(i, n) {
        int old_len = cur_len;
        norm(cur_len, ar[i]);
        cur_len = ar[i];
        if (old_len < ar[i]) {
            continue;
        }
        while (s.size() && s.back().second == p - 1) {
            cur_len -= s.back().first;
            s.pop_back();
        }
        if (s.empty())
            return 0;
        s.back().first--;
        int c = s.back().second;
        if (!s.back().first)
            s.pop_back();
        s.pb(1, c + 1);
        norm(cur_len, ar[i]);
        cur_len = ar[i];
    }
    return 1;
}

int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    srand(time(NULL));
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    int n;
    cin >> n;
    forn(i, n)
        cin >> ar[i];
    int ans = n;
    int l = 1, r = n - 1;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (check(n, mid)) {
            ans = mid;
            r = mid - 1;
        } else
            l = mid + 1;
    }
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

int main(){

    int x,y,z;

    cin>>x>>y>>z;

    int ans=x/(y+z);
    
    if (x%(y+z)>=z)
        cout<<ans<<endl;
    else
        cout<<ans-1<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.9.5
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

bool prime(int n)  //  素数判定
{if(n<2)return false;else if(n==2)return true;else if(n%2==0)return false;
double s=sqrt(n);for(int i=3;i<=s;i+=2){if(n%i==0){return false;}}return true;}

signed main() {
  cout << fixed << setprecision(8);
  int n;
  cin >> n;
  int qw;
  set<int> kind;
  rep(i,0,n) {
    cin >> qw;
    kind.insert(qw);
  }
  int ans=kind.size();
  if(ans%2==0) ans--;
  cout << ans << endl;
  return 0;
}


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

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

	int posnum[k*4][k*4];
//	int accnum[4*k][4*k];
	int tempx=0;
	int tempy=0;
	while (tempx<k*4){
		tempy=0;
		while (tempy<k*4){
			posnum[tempx][tempy] = 0;
//			accnum[tempx][tempy] = 0;
			tempy++;
		}
		tempx++;
	}



	int x[n],y[n];
	string c[n];
	for (int i=0;i<n;i++){
		cin >> x[i];
		cin >> y[i];
		cin >> c[i];
		if (c[i]=="W"){
			x[i]=x[i]+k;
		}
		x[i]=x[i]%(k*2);
		y[i]=y[i]%(k*2);

		int xtemp = x[i];
		int ytemp = y[i];
		int flag = 0;

		while (xtemp<4*k){
			ytemp = y[i];
			while (ytemp<4*k){
				if (xtemp+1<4*k && ytemp+1+k*flag<4*k){
					posnum[xtemp+1][ytemp+1+k*flag]++;
				}
				if (xtemp+k+1<4*k && ytemp+k+1+k*flag<4*k){
					posnum[xtemp+k+1][ytemp+k+1+k*flag]++;
				}
				if (xtemp+1<4*k && ytemp+k+1+k*flag<4*k){
					posnum[xtemp+1][ytemp+k+1+k*flag]--;
				}
				if (xtemp+k+1<4*k && ytemp+1+k*flag<4*k){
					posnum[xtemp+k+1][ytemp+1+k*flag]--;
				}
				ytemp = ytemp+2*k;
			}
			xtemp = xtemp+k;
			if (flag==0){
				flag = 1;
			}else{
				flag = 0;
			}
		}
	}

	int maxans = 0;

	int xx = 1;
	int yy = 1;

	while(yy<4*k){
		xx = 1;
		while(xx<4*k){
			posnum[xx][yy]=posnum[xx][yy]+posnum[xx-1][yy];
			xx++;
		}
		yy++;
	}

	xx = 1;
	yy = 1;

	while(xx<4*k){
		yy = 1;
		while(yy<4*k){
			posnum[xx][yy]=posnum[xx][yy]+posnum[xx][yy-1];
			if(xx>=2*k && yy>=2*k && posnum[xx][yy] > maxans){
				maxans = posnum[xx][yy];
			}
			yy++;
		}
		xx++;
	}
	cout << maxans << endl;
}

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

// utility of stdin,stdout
#define INPS cin >>
#define BUFS cout << 
#define BUFE << endl 

int main(int argc, char const *argv[]){
	int n;
	cin >> n;
	BUFS(180 * (n - 2)) BUFE;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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;
};

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

  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  rep(i, 0, n-2) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
  }

  cout << ans << endl;

  return 0;
};


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

#define endl "\n"

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

    string input;
    cin >> input;
    if (input.length() != 6)
        cout << "No" << endl;
    else {
        if (input[0] != input[1]) {
            if (input[2] == input[3] && input[4] == input[5])
                cout << "Yes" << endl;
            else
                cout << "No" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
const int MAX_N=100010;
set<int> G[100000];
int N;
struct UF{
    int par[MAX_N];
    void init (int n){
        for (int i=0;i<n;i++){
            par[i]=i;
        }
    }
    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;
        par[y]=x;
    }
};
UF uf;
void merge(int x, int y){
    x=uf.find(x); y=uf.find(y);
    if(sz(G[x])<sz(G[y])) swap(x,y);
    set<P> que;
    for(auto &to :G[y]){
        if(to!=x){
            G[to].erase(y);
            if(G[to].count(x)) que.insert(P(to,x));
            G[to].insert(x);
            G[x].insert(to);
        }
    }
    G[x].erase(y);
    uf.unite(x,y);
    for(auto cur: que){
        merge(cur.fr, cur.sc);
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    uf.init(N);
    rep(i,0,N-1){
        int a,b;
        cin>>a>>b;
        a--; b--;
        G[a].insert(b); G[b].insert(a);
    }
    rep(i,0,N-1){
        int a,b;
        cin>>a>>b;
        a--; b--;
        a=uf.find(a); b=uf.find(b);
        if(!G[a].count(b)){
            G[a].insert(b);
            G[b].insert(a);
            continue;
        }
        merge(a,b);
    }
    int c=uf.find(0);
    bool t=true;
    rep(i,1,N){
        if(c!=uf.find(i)) t=false;
    }
    cout <<(t?"YES":"NO")<<"\n";
}

Measured memory_bytes: 24064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

void find_divisor(ll N, vector<ll>& divisor) {
  for(int i=1; i<=sqrt(N); i++) {
    if(N % i == 0)
      divisor.push_back(i);
  }
  int n = divisor.size();
  for(int i=n-1; i>=0; i--) {
    if(N != (ll)pow(divisor[i], 2))
      divisor.push_back(N / divisor[i]);
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n; cin >> n;
  vector<ll> div;
  find_divisor(n, div);
  int ans = inf;
  for(auto d: div) {
    ll e = n/d;
    chmin(ans, max((int)log10(d)+1, (int)log10(e)+1));
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3988
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let s:Vec<char> = read::<String>().chars().collect();

    for i in 0..3 {
        if s[i] == s[i+1] {
            println!("Bad");
            return ();
        }
    }

    println!("Good");

}


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

int main() {
   char buffer[100];
   char duffer[100];
    int number1;
    int number2;
    int a,b=0;
  	int i=0;
  	int pq=0;
  	int qtr=0;
    scanf("%s%s",buffer,duffer);
    number1=atoi(buffer);
  	number2=atoi(duffer);
    a=number1*3;
    qtr=a+number2;
	pq=qtr/2;
  printf("%d",pq);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

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

	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	
	vector<long long> dp(n+1);

	int a_i = 0;
	for (int i = 0; i < n+1; i++) {
		if (a_i < m && i == a[a_i]) {
			dp[i] = 0;
			a_i++;
			continue;
		}
		if (i == 0)dp[0] = 0;
		else if (i == 1)dp[1] = 1;
		else if (i == 2)dp[2] = dp[1] + 1;
		else  dp[i] = dp[i - 1] + dp[i - 2];
		dp[i] %= 1000000007;
	}

	cout << dp[n] << endl;

}

Measured memory_bytes: 1408
//
//  main.cpp
//  MST2ND
//
//  Created by Dong Truong on 7/13/19.
//  Copyright © 2019 Dong Truong. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
#define long long long

const long maxn = 1e6+2 , cm=1e9+7 , ba=31;
struct elem
{
    long id,gt;
};

double a[maxn];long n;
void nhap()
{
    cin>>n;
    double kq=0;
    for (int i=1;i<=n;++i)
    {
        double x;cin>>x;
        kq=kq+1/x;
    }
    kq=1/kq;
    cout<<setprecision(5)<<fixed<<kq;
}
int main(int argc, const char * argv[]) {
   // freopen("a.inp","r",stdin);
    nhap();
    return 0;
}


Measured memory_bytes: 256
import copy

s = input()
t = input()

sn = len(s)
tn = len(t)
a = [[] for i in range(26)]
for i in range(sn):
    num = ord(s[i]) - 97
    a[num].append(i)

table = [[0]*sn for i in range(26)]
for i in range(26):
    if a[i]:
        table[i][:] = [copy.deepcopy(a[i][0])]*sn
    f = 0
    for j in a[i]:
        table[i][f:j] = [copy.deepcopy(j)]*(j-f)
        f = copy.deepcopy(j)

flg = True
cnt = 0 # 今何週したか
x = -1 # 今何文字目か
for i in range(tn):
    num = ord(t[i]) - 97
    # sの中に対象の文字が存在しない
    if not a[num]:
        flg = False
        break
    # sの中に対象の文字が存在
    xx = copy.deepcopy(x)
    x = table[num][x]
    if xx >= x:
        cnt += 1
print(cnt*sn + x+1) if flg else print(-1)

Measured memory_bytes: 123748
L, R = map(int, input().split())

if R-L+1 >= 2019:
    print(0)
else:
    ans = 2018
    for i in range(L%2019, R%2019):
        for j in range(i+1, R%2019+1):
            ans = min(ans, (i*j)%2019)
    print(ans)

Measured memory_bytes: 2940
# -*- coding: utf-8 -*-

import sys
from itertools import combinations, accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,K=MAP()
A=LIST()

# 累積MAX
acc=list(accumulate(A, max))

ans=INF
for comb in combinations(range(N), K):
    sm=0
    for i, n in enumerate(comb):
        if i==0:
            # 1つめは累積MAXとの差分
            cost=max(acc[n]-A[n], 0)
            # 一番左じゃなくて、1つ手前の累積MAXより高くないなら+1
            if n!=0 and acc[n-1]==acc[n]:
                cost+=1
        else:
            # 2つめ以降は、max(1つ前に選んだやつ, 1つ手前の累積MAX)との差分+1でmax取る
            cost=max(max(prev, acc[n-1])-A[n]+1, 0)
        sm+=cost
        prev=A[n]+cost
    ans=min(ans, sm)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


const int N= 2e5+5;
int k,n;
vector<int>dist(N);






int32_t main()
{
	IOS;
	cin>>k>>n;
	dist.resize(n);
	int x=0, y=0, ind=0, begin=0, ans=0;
	
	for(int i=0;i<n;i++){
		cin>>x;
		if(i==0){
			y=x;
			begin=x;
		}
		else {
			
			dist[ind++]= x-y;
			y=x;
		}
	
	}

	dist[ind]= k-y+begin;
	
	sort(dist.begin(), dist.end());
	for(int i=0;i<n-1;i++){
		ans+= dist[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   ll sum = 1+2+3;
   ll a,b;
   cin>>a>>b;
   sum-=a+b;
   cout<<sum;
   
   return 0;        
}  
   

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using pll =  pair<long long, long long >;
int main(){
    int n;
    cin >> n;
    long long m;
    cin >> m;
    vector<pll> vec(n);
    for(int i=0; i<n; i++){
        cin >> vec[i].first >> vec[i].second;
    }
    sort(vec.begin(), vec.end());

    long long res=0;
    for(int i=0; i<n && m>0; i++){
        res += vec[i].first * min(m,vec[i].second);
        m -= min(m, vec[i].second);
    }
    cout << res << endl;
}



Measured memory_bytes: 4736
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n, m;
string a[55], b[55];
/**********************************************/

int main(){
    cin >> n >> m;
    REP(i, n) cin >> a[i];
    REP(i, m) cin >> b[i];
    bool flag = true;
    REP(i, n-m+1){
        REP(j, n-m+1){
            flag = true;
            REP(k, m){
                REP(l, m){
                    if(a[i+k][j+l] != b[k][l]) flag = false;
                }
            }
            if(flag){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int k, x;

int main(void) {

	cin >> k >> x;

	for (int i = x - k + 1; i < k + x; i++) {
		cout << i << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

struct Edge{
    // 始点, 終点, 重み, 最大量
    long long src, dst, weight, capacity;
    Edge(): src(0), dst(0), weight(0), capacity(0) {}
    Edge(long long s, long long d, long long w): src(s), dst(d), weight(w) {}
    Edge(long long s, long long d, long long w, long long c): src(s), dst(d), weight(w), capacity(c) {}
};

class Graph{
public:
    long long size;
    vector<vector<Edge>> node;
    Graph(long long n): size(n), node(n) {}
    // 無向辺の追加
    void addEdge(long long s, long long d, long long w = 1){
        node[s].emplace_back(s, d, w);
        node[d].emplace_back(d, s, w);
    }
};

// Dijkstra(Heap); 単一始点最短路（優先度付きキューを利用したダイクストラ法）
// ：負辺がある場合はループにハマる可能性があるため、Bellman-Fordを使うこと。[O((E+V)logV)]
vector<long long> Dijkstra(const Graph &g, long long src){
    const long long WeightINF = numeric_limits<long long>::max()/2-1;
    using state = pair<long long, long long>;
    priority_queue<state> que;
    vector<long long> d(g.size, WeightINF);
    d[src] = 0;
    que.emplace(0, src);
    while(!que.empty()){
        auto p = que.top(); que.pop();
        long long w = -p.first;
        long long v = p.second;
        if(d[v] < w) continue;
        for(auto &edge: g.node[v]){
            if(d[edge.dst] > d[v] + edge.weight){
                d[edge.dst] = d[v] + edge.weight;
                que.emplace(-d[edge.dst], edge.dst);
            }
        }
    }
    return d;
}

int main(){
    Init();
    // n人の参加者、m種類の言語
    ll n, m;
    cin >> n >> m;

    // 二部グラフ
    Graph g(n+m);

    rep(i, n){
        ll k;
        cin >> k;
        rep(j, k){
            ll lang;
            cin >> lang;
            lang--;
            g.addEdge(i, n+lang, 1);
        }
    }
    auto dij = Dijkstra(g, 0);
    const long long WeightINF = numeric_limits<long long>::max()/2-1;
    bool ok = true;
    for(ll i=0; i<n; i++) if(dij[i] == WeightINF) ok = false;
    ok ? YES() : NO();
}

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

typedef long long ll;

int main(void){
    int n;
    cin >> n;
    vector<vector<int>> vec(3, vector<int>(n));

    for(int i=0; i<3; i++){
        for(int j=0; j<n; j++){
            cin >> vec.at(i).at(j);
        }
        sort(vec.at(i).begin(), vec.at(i).end());
    }

    ll ans = 0;
    vector<ll> b(n), sum(n+1, 0);

    for(int i=n-1; i>=0; i--){
        b.at(i) = (vec.at(2).end() - upper_bound(vec.at(2).begin(), vec.at(2).end(), vec.at(1).at(i)));
        sum.at(i) = b.at(i) + sum.at(i+1);
    }

    for(int i=0; i<n; i++){
        int a = (upper_bound(vec.at(1).begin(), vec.at(1).end(), vec.at(0).at(i)) - vec.at(1).begin());
        ans += sum.at(a);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> a(n), sr;
	for(int i = 0; i < n; i++) cin >> a[i];
	sr = a;
	sort(sr.begin(), sr.end());
	if(sr == a) cout << "YES" << endl;
	else {
		for(int i = 0; i < n; i++){
			for(int j = i + 1; j < n; j++){
				vector<int> b = a;
				swap(b[i], b[j]);
				if(b == sr){
					cout << "YES" << endl;
					return 0;
				}
			}
		}
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sanket Makani
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader sc, PrintWriter w) {

            int n = sc.nextInt();
            int k = sc.nextInt();

            int curr = 1;

            while (n-- > 0) {
                if (curr <= k)
                    curr *= 2;
                else
                    curr += k;
            }
            w.println(curr);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
int f[110][10];
ll p[110][11];

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            cin>>f[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<11;j++){
            cin>>p[i][j];
        }
    }
    ll ans=-INF;
    for(int i=1;i<(1<<10);i++){
        ll sub=0;
        vector<int> q(n,0);
        for(int j=0;j<10;j++){
            for(int k=0;k<n;k++){
                if(1&(i>>j) && f[k][j]){
                    q[k]++;
                }
            }
        }
        for(int k=0;k<n;k++){
            sub+=p[k][q[k]];
        }
        ans=max(ans,sub);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	string s;
	cin >> s;
	bool isreturn = false;
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == 'A' && s.at(i + 1) == 'C') {
			isreturn = true;
			break;
		}
	}
	if (isreturn == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <queue>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
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; }

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

    int N, M; cin >> N >> M;
    vector<vector<int>> v(M, vector<int>(3));
    REP(i, M) {
        cin >> v[i][0] >> v[i][1];
        v[i][2] = i;
    }
    sort(ALL(v));
    int tmp = v[0][0], counter = 1;
    REP(i, M) {
        if (tmp != v[i][0]) {
            tmp = v[i][0];
            counter = 1;
        }
        v[i][1] = counter;
        swap(v[i][0], v[i][2]);
        counter++;
    }
    sort(ALL(v));
    REP(i, M) {
        cout << setfill('0') << right << setw(6) << v[i][2]
            << setfill('0') << right << setw(6) << v[i][1] << "\n";
    }

    return 0;
}



Measured memory_bytes: 7040
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc135/tasks/abc135_d
# 5あまるじゃなくてn余るできないかな？

'''
dp[i][j] ... [0,i)桁の数字で、余りがjに成る通りの総数
更新則
?じゃないとき
dp[i+1][(j+S[i]*pow(10,i,13))%13] = dp[i][j]
?のとき
dp[i+1][j] += dp[i][k] #すべてのjとkで
'''
mod = 13
S = list(reversed(read()[:-1]))

dp = [[0] * mod for _ in range(len(S) + 1)]
dp[0][0] = 1
pow10imod = 1
for i in range(len(S)):
    for j in range(mod):
        if S[i] != '?':
            dp[i + 1][(j + int(S[i]) * pow10imod) % mod] += \
                dp[i][j] % MOD
            # dp[i + 1][(j + int(S[i]) * pow(10, i, mod)) % mod] += \
            #     dp[i][j] % MOD
        else:
            for k in range(10):
                dp[i + 1][(j + k * pow10imod) % mod] += \
                    dp[i][j] % MOD
                # dp[i + 1][(j + k * pow(10, i, mod)) % mod] += \
                #     dp[i][j] % MOD
    pow10imod = pow10imod * 10 % mod

print(dp[-1][5] % MOD)
# print(*dp, sep='\n')


Measured memory_bytes: 66496
import math

N, A, B = map(int, raw_input().split())
h = [int(raw_input()) for _ in xrange(N)]

def judge(K):
    sums = 0
    for i in h:
        t = i-K*B
        if t > 0:
            sums += math.ceil(t*1.0/(A-B))
            if sums > K:
                return False;
    return True

high = int(1e9)
low = 0

while high > low:
    mid = int((high + low) / 2)
    if judge(mid):
        high = mid;
    else:
        low = mid+1;

print low


Measured memory_bytes: 5764
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  string s,t;
  cin >> s>>t;
  int diff=s.size()-t.size();
  for(int i=diff;i>=0;i--){
     int f=1;
     rep(j,t.size())
       if(s[i+j]!='?'&&s[i+j]!=t[j]){
          f=0;
          break; 
       }
     if(f){
        rep(j,i)
          cout<<(s[j]=='?'?'a':s[j]);
        cout<<t;
        for(int j=i+t.size();j<(int)s.size();j++)
          cout<<(s[j]=='?'?'a':s[j]);
        return 0;
     }
  }
  cout<<"UNRESTORABLE";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define in(x) cin >> x
#define out(x) cout << x << endl

#define PI acos(-1)
#define pp push_back

#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl

#define vec2(type) vector<vector<type>>
#define vec3(type) vector<vector<vector<type>>>

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

int main(){

	string s;

	cin >> s;

	if(s.size() == 2){
		out(s);
	}
	else{
		string t;
		for(i, 3){
			t.pp(s[2 - i]);
		}
		out(t);
	}

	return 0;
}

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

int main() {
        ios_base::sync_with_stdio(false) ;
        cin.tie(0) ;
	int N, K, Q ;
	cin >> N >> K >> Q ;
	
	vector<int> scores(N, K) ;
	int A ;
	for(int i = 0 ; i < Q ; i++) {
		cin >> A ;
		++scores[A-1] ;
	}

	for(const int &i : scores) {
		cout << ( i - Q > 0 ? "Yes" : "No" ) << endl ;
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N, M, K; cin >> N >> M >> K;
  string result = "No";
  rep(i,N+1) rep(j,M+1) {
    if (i*M+j*N-i*j*2==K) result = "Yes";
  }
  cout << result << endl;
  return 0;
}

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

int main()
{
	int a,b,c,x,i,j,k,s=0;
	cin>>a>>b>>c>>x;
	
	for(i=0;i<=a;i++)
	   for(j=0;j<=b;j++)
	      for(k=0;k<=c;k++)
	      {
	      	if(i*500+j*100+k*50==x)  s++;
	      }
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
   
int main() {
          int X;
          int A;
          int B;
          scanf("%d %d %d", &X, &A, &B);
 
   if(A - B >= 0){
    printf("delicious");
   } else if ((X + A) - B >= 0) {
    printf("safe");
   } else {
    printf("dangerous");
   }
   return 0;
   }
          
   

Measured memory_bytes: 128
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	long long q,h,s,d,n;
	scanf("%lld%lld%lld%lld%lld",&q,&h,&s,&d,&n);
	n*=4;
	vector<pair<long long,int>> p;
	p.push_back(make_pair(q*8,1));
	p.push_back(make_pair(h*4,2));
	p.push_back(make_pair(s*2,4));
	p.push_back(make_pair(d,8));
	sort(p.begin(),p.end());
	long long ans=0;
	for (int i=0;n;++i)
	{
		long long quan=n/p[i].second;
		ans+=quan*(p[i].first/(8/p[i].second));
		n%=p[i].second;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

string s;
int n;

int main(){
	cin >> n >> s;
	ll ans = 0, x = 0;
	REP(i, n){
		if (s[i] == 'I')x++;
		else x--;
		ans = max(ans, x);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256