akhauriyash/Code-Regression huggingface dataset:
n,k=[int(i) for i in input().split()]
word=input()
if word[k-1]=="A":
    print(word[:k-1]+"a"+word[k:])
if word[k-1]=="B":
    print(word[:k-1]+"b"+word[k:])
if word[k-1]=="C":
    print(word[:k-1]+"c"+word[k:])
    

Measured memory_bytes: 38256
//
// Created on 2020/03/28.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {

    int n,x,y;
    cin>>n>>x>>y;
    n--;
    x--;
    y--;

    map<int,int>mp;

    for (int i = 0; i < n; ++i) {
        vector<int>edge(n+1);
        for (int j = 0; j <= n; ++j) {
            edge[j] = abs(j-i);
        }
        edge[y] = min(edge[y],edge[x]+1);

        for (int m = y+1; m <= n; ++m) {
            edge[m] = min(edge[m],edge[m-1]+1);
        }
        for (int k = y-1; k >=0 ; --k) {
            edge[k] = min(edge[k],edge[k+1]+1);
        }
        for (int l = i; l <= n; ++l) {
            mp[edge[l]] += 1;
        }

    }
    for (int m = 1; m <= n; ++m) {
        cout<<mp[m]<<endl;
    }
}


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

// returns a permutation pK of K elements such that if 
// it has a increasing sequence of K elements concataned
// after it, the total of good subsequences will be 'size',
// considering that an empty subsequence is a good one.
vector<int> roll(ll size) {
	if(size == 1) {
		return vector<int>();
	}
	vector<int> v;
	if(size & 1) {
		v = roll(size - 1);
		v.insert(v.begin(), v.size() + 1);
	}
	else {
		v = roll(size / 2);
		v.push_back(v.size() + 1);
	}
	return v;
}

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

	ll n;
	cin >> n;
	
	vector<int> p = roll(n + 1);
	int total = p.size();
	fori(i, 1, total + 1) {
		p.push_back(i);
	}

	cout << p.size() << '\n';
	for(auto &each : p) {
		cout << each << " ";
	}
	cout << '\n';

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
int N, H, f[401], g[401], w[401];
std::vector < int > V[401];
int F(int x)
{
	return f[x] == x ? x : f[x] = F(f[x]);
}
int main()
{
	scanf("%d%d", &N, &H);
	for (int i = 1; i <= H + H; i++)
		f[i] = i;
	for (int i = 1; i <= N; i++)
	{
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		int u = c ? H + c : a, v = d ? d : H + b;
		g[u]++, g[v]--;
		w[u]++, w[v]++;
		u = F(u), v = F(v);
		if (u != v)
			f[u] = v;
	}
	for (int i = 1; i <= H; i++)
		if (g[i] < 0 || g[H + i] > 0)
		{
			puts("NO");
			return 0;
		}
	for (int i = 1; i <= H + H; i++)
		V[F(i)].push_back(i);
	for (int i = 1; i <= H + H; i++)
		if (F(i) == i && !std::all_of(V[i].begin(), V[i].end(), [] (int x) { return w[x] == 0; }) && std::all_of(V[i].begin(), V[i].end(), [] (int x) { return g[x] == 0; }))
		{
			puts("NO");
			return 0;
		}
	puts("YES");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<double,double> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;




int main(){
    int n,d,x;
    cin >> n >> d >> x;
    int dp[100001];
    int p[n][n];
    for(int i=0;i<d;i++){
        for(int j=0;j<n;j++){
            cin >> p[i][j];
        }
    }
    int maxi=x;
    for(int i=0;i<d-1;i++){
        memset(dp,0,sizeof(dp));
        int tmp=0;
        for(int j=0;j<n;j++){
            for(int k=p[i][j];k<=maxi;k++){
                if(!dp[k-p[i][j]]&&k-p[i][j]!=0) continue;
                dp[k]=max(dp[k],dp[k-p[i][j]]+p[i+1][j]);
                tmp=max(dp[k]+maxi-k,tmp);
            }
        }
        maxi=max(maxi,tmp);
    }
    cout << maxi << endl;
    return 0;
}



Measured memory_bytes: 3504
def calc_gcd(a, b):
    if a < b:
        s, l = [a, b]
    else:
        s, l = [b, a]
    
    while True:
        r = l % s
        if r == 0:
            return s
        l = s
        s = r

def calc_lcm(a, b):
    gcd = calc_gcd(a, b)
    return (a // gcd) * (b // gcd) * gcd

A, B = map(int, input().split())

print(calc_lcm(A, B))


Measured memory_bytes: 3060
#include <stdio.h>

int main(){
  int n,i,j;
  scanf("%d", &n);
  int h[n];
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  int count=n;
  for(i=1;i<n;i++){
    for(j=0;j<i;j++){
      if(h[i]<h[j]){ count--;
        break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int a,c;
	char b;
	scanf("%d %c %d",&a,&b,&c);
	if(b=='+'){
		printf("%d\n",a+c);
	}
	else if(b=='-'){
		printf("%d\n",a-c);
	}
	return 0;
}	

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

int main() {
  long long A, V, B, W, T;
  
  cin >> A >> V >> B >> W >> T;
  

  if(W - V >= 0){
    cout << "NO" << endl;
  }
  else if (W - V < 0 && abs(B - A) > abs(W - V) * T){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }
  
}

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

#define PPC(x) __builtin_popcountll(x)
typedef long long ll;

const int N = 16;

int n;
int x[N], y[N], p[N];
ll ans[N];
int dis[N];
int ordY[N], ordX[N];

// msk: 0(no line), 1(line)
// isx: only if msk bit=1 => 0(horizontal on y_i), 1(vertical on x_i)
void calc(int msk, int isx) {
	for (int i = 0; i < n; i++) {
		if (~msk & (1 << i))
			dis[i] = min(abs(x[i]), abs(y[i]));
		else
			dis[i] = 0;
	}
	int prvI = -1, nxtI = -1;
	for (int k = 0; k < n; k++) {
		int i = ordX[k];
		if (~msk & (1 << i)) {
			if (prvI != -1)
				dis[i] = min(dis[i], x[i] - x[prvI]);
		} else if (isx & (1 << i)) {
			prvI = i;
		}
	}
	for (int k = n - 1; k >= 0; k--) {
		int i = ordX[k];
		if (~msk & (1 << i)) {
			if (nxtI != -1)
				dis[i] = min(dis[i], x[nxtI] - x[i]);
		} else if (isx & (1 << i)) {
			nxtI = i;
		}
	}
	prvI = nxtI = -1;
	for (int k = 0; k < n; k++) {
		int i = ordY[k];
		if (~msk & (1 << i)) {
			if (prvI != -1)
				dis[i] = min(dis[i], y[i] - y[prvI]);
		} else if (~isx & (1 << i)) {
			prvI = i;
		}
	}
	for (int k = n - 1; k >= 0; k--) {
		int i = ordY[k];
		if (~msk & (1 << i)) {
			if (nxtI != -1)
				dis[i] = min(dis[i], y[nxtI] - y[i]);
		} else if (~isx & (1 << i)) {
			nxtI = i;
		}
	}
	ll res = 0;
	for (int i = 0; i < n; i++)
		res += dis[i] * 1LL * p[i];
	ans[PPC(msk)] = min(ans[PPC(msk)], res);
}

void rec(int i, int msk, int isx) {
	if (i == n) {
		calc(msk, isx);
		return;
	}
	rec(i + 1, msk, isx);
	rec(i + 1, msk | (1 << i), isx);
	rec(i + 1, msk | (1 << i), isx | (1 << i));
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	ans[n] = LLONG_MAX;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> p[i];
		ans[i] = LLONG_MAX;
		ordX[i] = i;
		ordY[i] = i;
	}
	sort(ordX, ordX + n, [&](int i, int j) {
		if (x[i] != x[j]) return x[i] < x[j];
		return y[i] < y[j];
	});
	sort(ordY, ordY + n, [&](int i, int j) {
		if (y[i] != y[j]) return y[i] < y[j];
		return x[i] < x[j];
	});
	rec(0, 0, 0);
	for (int i = 0; i <= n; i++)
		cout << ans[i] << "\n";
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>

using namespace std;
typedef long double ld;
typedef long long int ll;
typedef vector <ll> vl;
const int INF = (1 << 30);
const int mod = 1000000007;
const int M = 300000;

ll power(ll n, ll p, ll m) {
	if (n == 0) { return 0; }
	if (p == 0) { return 1; }
	if (p == 1) { return n%m; }
	if (p & 1) {
		ll y = power(n, (p - 1) / 2, m);
		y = (y*y) % m;
		return (n*y) % m;
	}
	else {
		ll y = power(n, p / 2, m);
		y = y*y%m;
		return y;
	}
}
int solve();

int main(void) {

	solve();

	return 0;

}

int solve() {

	ll H, W, A, B;
	cin >> H >> W >> A >> B;
	vl inv(M+1), iperm(M+1), perm(M+1);
	for (ll i = 1; i <= M; i++) {
		inv[i] = power(i, mod - 2, mod);
	}
	perm[0] = 1;
	iperm[0] = inv[1];
	iperm[1] = inv[1];
	perm[1] = 1;
	for (ll i = 2; i <= M; i++) {
		iperm[i] = (inv[i] * iperm[i - 1]) % mod;
		perm[i] = (i*perm[i - 1]) % mod;
	}

	vl memo(H - A,0);
	for (ll y = 0; y < H - A; y++) {
		ll n = (B-1 + y+mod)%mod;
		ll mem = perm[n] * iperm[y] % mod;
		mem = mem*iperm[n - y] % mod;
		memo[y] = mem;
	}

	ll ans = 0;
	for (ll y = 0; y < H - A; y++) {
		ll ny = (W - 1 - (B) + mod) % mod;
		ll nx = (H - 1 - y + mod) % mod;
		ll n = (nx+ny)%mod;
		ll d = perm[n] * iperm[ny] % mod;
		d = d*iperm[nx] % mod;
		d = d*memo[y] % mod;
		ans = (ans + d) % mod;
	}

	cout << ans << endl;
	return 1;
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int i=0,j=s.size()-1;
  while(true){
    if(s[i]=='A')
      break;
    i++;
  }
  while(true){
    if(s[j]=='Z')
      break;
    j--;
  }
  cout<<j-i+1;
}

Measured memory_bytes: 640
#include<cstdio>
#include<vector>
#include<cstring>

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

using namespace std;

int n;
char word[20][21];
vector<int> L[21]; // L[l] := ( 長さ l の単語の集合 )

char s[128];
vector<int> pos,len; // 空白で区切った s の部分文字列の開始位置と長さ

int dup;
char f[128],f_ans[128]; // アルファベットの対応表

bool used[80]; // s の部分文字列 i をすでに調べたかどうか
bool dfs(){
	if(dup>=2) return false;

	// 絶対に埋められない部分文字列が出てきたら探索打ち切り
	rep(i,pos.size()) if(!used[i]) {
		int m=len[i];
		const char *t=s+pos[i];
		bool ok=false;
		rep(j,L[m].size()){
			const char *w=word[L[m][j]];

			bool b=true;
			rep(k,m){
				char c1=t[k],c2=w[k];
				if(f[c1]!='?' && f[c2]!='?'){
					if(c2!=f[c1]) b=false;
				}
				else if(f[c1]=='?' && f[c2]=='?'){}
				else{
					b=false;
				}
			}
			if(b){ ok=true; break; }
		}
		if(!ok) return false;
	}

	int i0=-1;
	rep(i,len.size()) if(!used[i]) {
		if(i0==-1 || len[i0]<len[i]) i0=i;
	}
	if(i0==-1){
		dup++;
		if(dup>=2) return false;
		memcpy(f_ans,f,sizeof f);
		return true;
	}

	int m=len[i0];
	const char *t=s+pos[i0];
	char tmp[128];
	rep(i,L[m].size()){
		const char *w=word[L[m][i]]; // 部分文字列 t に単語 w を割り当てる

		bool ok=true; // その割り当てで矛盾が起こらないか
		memcpy(tmp,f,sizeof f);
		rep(j,m){
			char c1=t[j],c2=w[j];
			if(f[c1]!='?' && f[c2]!='?'){
				if(c2!=f[c1]) ok=false;
			}
			else if(f[c1]=='?' && f[c2]=='?'){
				f[c1]=c2;
				f[c2]=c1;
			}
			else{
				ok=false;
			}
		}

		if(ok){
			used[i0]=true;
			dfs();
			used[i0]=false;
		}

		memcpy(f,tmp,sizeof f);
	}

	return dup==1;
}

int main(){
	for(;scanf("%d",&n),n;){
		rep(i,n) scanf("%s ",word[i]);
		rep(l,21) L[l].clear();
		rep(i,n) L[strlen(word[i])].push_back(i);

		fgets(s,128,stdin);
		pos.clear();
		len.clear();
		for(int i=0,pre=0;;i++){
			if(s[i]=='.' || s[i]==' '){
				pos.push_back(pre);
				len.push_back(i-pre);
				pre=i+1;
				if(s[i]=='.') break;
			}
		}

		for(char c='A';c<='Z';c++) f[c]='?';

		dup=0;
		rep(i,pos.size()) used[i]=false;
		if(!dfs()) puts("-.");
		else{
			rep(i,pos.size()){
				rep(j,len[i]) putchar(f_ans[s[pos[i]+j]]);
				putchar(i<(int)pos.size()-1?' ':'.');
			}
			puts("");
		}
	}

	return 0;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

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

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t a,b;
  string op;
  do{
    cin >> a >> op >> b;
    if(op.compare("?")==0) break;
    
    if(op.compare("+")==0) cout << a+b << endl;
    else if(op.compare("-")==0) cout << a-b << endl;
    else if(op.compare("*")==0) cout << a*b << endl;
    else if(op.compare("/")==0) cout << a/b << endl;
  }while(cin.eof()==false);
 
  return 0;
}


Measured memory_bytes: 3164
import math

N,D= list(map(int,input().split()))
x = [0] * N
y = [0] * N
b=0

for i in range(N):
     x[i], y[i] = map(int, input().split())
     #print(x[i])
     a=x[i]**2+y[i]**2
     #print(math.sqrt(a))
     if math.sqrt(a) <=D:
          b+=1
print(b)


Measured memory_bytes: 24660
#include <stdio.h>
#include <math.h>

#define N 10000
#define TRUE 1
#define FALSE 0

int isprime(int);

int main(){
  int i,j,num,A[N],count=0;

  while(1){
    scanf("%d",&num);
    if(1 <= num && num <= N) break;
  }
  for(i = 0;i < num;i++) scanf("%d",&A[i]);
  for(i = 0;i < num;i++) if(isprime(A[i]) == TRUE) count++;
  printf("%d\n",count);

  return 0;
}

int isprime(int a){
  int i;
  if(a == 2) return TRUE;
  if(a < 2 || a%2 == 0) return FALSE;
  i = 3;
  while(i <= sqrt(a)){
    if(a%i == 0) return FALSE;
    i = i + 2;
  }
  return TRUE;
}

Measured memory_bytes: 628
#include <iostream>
#include <cstdio>
#include <string>
#include <set>
using namespace std;
const int maxk = 10;
int n,k;
set<int> d;
bool bad(int x)
{
	string s=to_string(x);
	for (int i=0; i<s.size(); i++)
		if (d.count(s[i]-'0')) return true;
	return false;
}
int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.inp","r",stdin);
	//freopen("output.out","w",stdout);
	cin >> n >> k;
	d.clear();
	for (int i=1; i<=k; i++)
		{
			int x;
			cin >> x;
			d.insert(x);
		}
	while (bad(n)) n++;
	cout << n;
	return 0;
}

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

int main() {
	
	int w, h, n; cin >> w >> h >> n;
	int upper = h;
	int	lower = 0;
	int	left = 0;
	int right = w;
	for (int i = 0; i < n; i++) {
		int x, y, a; cin >> x >> y >> a;
		if (a == 1) {
			left = max(left, x);
		}
		else if (a == 2) {
			right = min(right, x);
		}
		else  if (a == 3) {
			lower = max(lower, y);
		}
		else { // a == 4
			upper = min(upper, y);
		}
	}
	cout << max(0, right - left) * max(0, upper - lower) << endl;
	return 0;
}

Measured memory_bytes: 256
import Data.List
mo=10^9+7
main=do
 [a,b,c,d]<-map read.words<$>getLine
 print$flip mod mo$(f a b)-(f(c+1)b)-(f a(d+1))+f(c+1)(d+1)
f x y=mod(g[x+1..x+y]*p(g[1..y])(mo-2))mo
p a b
 |b==0=1
 |odd b=mod(a*p a(b-1))mo
 |even b=p(mod(a*a)mo)$div b 2
g=foldl1'$(flip mod mo.).(*)

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
#define ALL(v) (v).begin(), (v).end()
const int mod = INF+7;
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i,N){
    cin >> A[i];
  }

  int countin=0;
  int countout=0;
  rep(i,N){
    srep(j,i+1,N){
      if(A[i]>A[j]){
        countin++;
      }
    }
  }
  rep(i,N){
    rep(j,N){
      if(A[i]>A[j]){
        countout++;
      }
    }
  }

  countin=(long)countin*K%mod;
  countout=((long)K*(K-1)/2)%mod*countout%mod;

  printf("%ld\n", (long)(countin+countout)%mod);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  if(A>12){
    cout << B << endl;
  }
  else if(6<=A && A<=12){
    cout << B/2 << endl;
  }
  else if(A < 6){
    cout << "0" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
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; }

int main(){

	lli n;
	cin>>n;
	lli one;
	cin>>one;

	n%=500;
	if(n<=one){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll a, b;
int main() {
    cin>>a>>b;
    if(1<=a && a<=9 && 1<=b && b<=9) cout<<a*b<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long 
#define F first
#define end 1000000000
#define S second
#define pb push_back
#define mp make_pair
using namespace std;

int main()
{
  ll n,k;
  cin >> n >> k;
  ll a[n];
  for(ll i=0;i<n;i++)
  {
      cin >> a[i];
  }
  sort(a,a+n);ll sum=0;
  for(ll i=0;i<k;i++)
  {
      sum+=a[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

void solve() 
{   
    int n,m;cin>>n>>m;
    bool flag[n];
    REP(i,n)flag[i]=0;
    flag[0]=1;
    vector<int>a(n,1);
    REP(i,m){
        int x,y;cin>>x>>y;x--;y--;
        if(flag[x])flag[y]=1;
        a[x]--;a[y]++;
        if(!a[x])flag[x]=0;
    }
    int ans=0;
    REP(i,n)if(flag[i])ans++;
    cout<<ans<<endl;
}

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


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

char c[2];
int main() {
	int q; scanf("%d", &q);
	ll l = 0, r = 0;
	rep(i, q) {
		ll p, n; scanf("%lld%s%lld", &p, c, &n);
		if (c[0] == '(')l += n;
		else r += n;
		puts(l == r ? "Yes" : "No");
	}
}

Measured memory_bytes: 3176
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,M = MI()
ab = [tuple(MI()) for _ in range(N)]
cd = [tuple(MI()) for _ in range(M)]

for i in range(N):
    a,b = ab[i]
    min_dis = 10**10
    k = 100
    for j in range(M):
        c,d = cd[j]
        if min_dis > abs(a-c) + abs(b-d):
            k = j+1
            min_dis = abs(a-c) + abs(b-d)
    print(k)



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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

const ll INF = 1000000000000000000 + 7;

vector<ll> h;

ll cost(ll i, ll j) { return abs(h.at(i) - h.at(j)); }

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

  h.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> h.at(i);
  }

  vector<ll> dp(n, INF);

  dp.at(0) = 0;
  dp.at(1) = cost(0, 1);

  for (long long i = 2; i < n; i++) {
    dp.at(i) =
        min(dp.at(i - 1) + cost(i, i - 1), dp.at(i - 2) + cost(i, i - 2));
  }

  cout << dp.at(n - 1) << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll s(ll x){
	if(x%10!=0) return (x/10+1)*10;
	else return x;
}
//a,b x
int main(){
	ll N,A,B,C,D,E; cin>>N>>A>>B>>C>>D>>E;
	ll m=min(minn(A,B,C),min(D,E));
	ll G=ceil((double)N/m);
	cout<<G+4;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
using namespace std;

const int INF = numeric_limits<int>::max();
vector<int> C;

int solve(int n)
{
    vector<int> dp(n + 1, INF);
    dp[0] = 0;

    // dp[n] = min(1 + dp[n - C[0]], 1 + dp[n - C[1]], ...)
    for (int i = 0; i <= n; ++i) {
        for (auto c : C) {
            if (i - c >= 0) {
                dp[i] = min(dp[i], 1 + dp[i - c]);
            }
        }
    }
    return dp[n];
}

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int c;
        cin >> c;
        C.push_back(c);
    }

    cout << solve(n) << endl;

    return 0;
}


Measured memory_bytes: 3216
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        System.out.println(b - a == c - b ? "YES" : "NO");
    }
}

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

/**
 * Main
 */
public class Main {

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] p = new int[N];
        
        for(int i = 0; i < N; i++){
            p[i] = sc.nextInt();
        }

        Arrays.sort(p);

        int ans = 0;
        for(int i = 0; i < K; i++){
            ans += p[i];
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 30332
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
	if(a!=b+c&&b!=a+c&&c!=a+b)
	printf("No\n");
	else
	printf("Yes\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>

using namespace std;

int m, n;
bool edge[21][21];
int d[21];

int main()
{
    cin >> m >> n;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;

        x--, y--;
        edge[y][x] = true;
        d[y]++;
    }

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
            if (d[j] == 0) {
                d[j] = -1;
                cout << j + 1 << endl;
                for (int k = 0; k < m; k++)
                    if (edge[k][j]) {
                        edge[k][j] = false;
                        d[k]--;
                    }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#define N 250
int main() {
  int A[N];
  int count,i;

  scanf("%d",&count);
  for(i=0;i<count;i++) scanf("%d",&A[i]);
  for(i=0;i<count;i++){
    printf("node %d: key = %d, ",i+1,A[i]);
    if(i != 0 && i%2 == 1)printf("parent key = %d, ",A[(i-1)/2]);
    if(i != 0 && i%2 == 0)printf("parent key = %d, ",A[(i-2)/2]);
    if(i*2+1 < count)printf("left key = %d, ",A[i*2+1]);
    if(i*2+2 < count)printf("right key = %d, ",A[i*2+2]);
    printf("\n");
  }

  return 0;
}

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

	String s = sc.next();
	String result = "Good";
	
	for (int i = 0; i < s.length() - 1; i++) {
		char c0 = s.charAt(i);
		char c1 = s.charAt(i + 1);
		
		if (c0 == c1) {
			result = "Bad";
		}
	}

    System.out.println(result);
  }
}



Measured memory_bytes: 22868
using namespace std;
#include<iostream>
#include<stdio.h>

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

    bool ans = false;

    for(int i = 0; i < s.length()-1; i++){
        string tmp = s.substr(i,2);
        if (tmp == "AC"){
            ans = true;
        }
    }

    if (ans == true){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

struct UF{
   vector<int> par;
   UF(int n){
       par.resize(n, -1);
   }
   int find(int x){
        if(par[x] < 0) return x;
       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;
   }
};

int p[MAX_V];
bool marked[MAX_V];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    while(cin >> n >> q && n){
        memset(marked, false, sizeof(marked));
        marked[0] = true;  
        UF uf(n);           
        vector<char> c(q); 
        vector<int> v(q);           
        vector<bool> use(q); 
        rep(i, 1, n){
            cin >> p[i]; p[i]--;
        }
        rep(i, 0, q){
            cin >> c[i] >> v[i]; v[i]--;
            if(c[i] == 'M' && marked[v[i]] == false){
                marked[v[i]] = true;
                use[i] = true;
            }
        }
        int ans = 0;
        rep(i, 0, n){
            if(!marked[i]){
                uf.unite(p[i], i);
            }
        }
        for(int i = q - 1; i >= 0; i--){
            if(c[i] == 'M'){
                if(use[i]) uf.unite(p[v[i]], v[i]);
            }else{
                ans += uf.find(v[i]) + 1;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 5440
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
long long n,md,dp[101010],ans[101010];
vector<int>e[101010];
void dfs1(int x,int y)
{
	dp[x]=1;
	for(int i=0;i<e[x].size();i++)
	{
		if(e[x][i]==y)
		{
			continue;
		}
		dfs1(e[x][i],x);
		dp[x]=dp[x]*dp[e[x][i]];
		dp[x]%=md;
	}
	dp[x]++;
	dp[x]%=md;
}
void dfs2(int x,int y,long long bf)
{
	vector<long long>v1,v2;
	v1.push_back(1);
	for(int i=0;i<e[x].size();i++)
	{
		if(e[x][i]==y)
		{
			continue;
		}
		v1.push_back(dp[e[x][i]]);
		v2.push_back(dp[e[x][i]]);
	}
	v2.push_back(1);
	for(int i=1;i<v1.size();i++)
	{
		v1[i]*=v1[i-1];
		v1[i]%=md;
	}
	for(int i=v2.size()-2;i>=0;i--)
	{
		v2[i]*=v2[i+1];
		v2[i]%=md;
	}
	ans[x]=v1.back()*bf%md;
	int p=0;
	for(int i=0;i<e[x].size();i++)
	{
		if(e[x][i]==y)
		{
			continue;
		}
		dfs2(e[x][i],x,(v1[p]*v2[p+1]%md*bf+1)%md);
		p++;
	}
}
int main()
{
	cin>>n>>md;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	dfs1(1,-1);
	dfs2(1,-1,1);
	for(int i=1;i<=n;i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 24320
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n,x,i;
    int a[120];
    int minn;
    scanf("%d%d",&n,&x);
    int k;
    k=x;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    minn=a[0];
    for(int j=0;j<n;j++){
        k-=a[j];
        if(a[j]<minn)
            minn=a[j];
    }
    k/=minn;
    printf("%d\n",n+k);
return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
l = []
r = []
for _ in range(m):
    a,b = map(int,input().split())
    l.append(a)
    r.append(b)
r_ = min(r)
l_ = max(l)
if r_>=l_:
    print(min(r)-max(l)+1)
else:
    print(0)

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

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

  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

ll sum(ll n) {
  if (n == 0) {
    return 0;
  }
   ll s = sum(n - 1);
  return s + n;
}

int main(){
 ll  n,ans=0; cin>>n;
  vector<string>S(n);
  rep(i,n){
  string s;
  cin>>s;
    sort(s.begin(),s.end());
  S[i]=s;
  }
   sort(S.begin(),S.end());
  ll t=0;
  for(ll i=1;i<n;i++){
    if(i==n-1){
    if(S[i]==S[i-1])t++;
      ans+=sum(t);
    }
  else if(S[i]==S[i-1])t++;
    else { ans+=sum(t); t=0;}
  }
  cout<<ans<<endl;
}

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

int main(){
    int N;
    cin >> N;
    set<string> S;
    string buf;
    for(int i = 0; i < N; ++i){
        cin >> buf;
        S.insert(buf);
    }
    cout << S.size() << endl;
    return 0;
}

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

typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    vector<P> A(N);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        a--;
        A[i] = P(a, i);
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < N; i++) {
        cout << A[i].second + 1 << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k;
  long long int n,x=1,y=1,z=0;
  cin >> n >> k;
  vector<long long int> a(n+1);
  vector<long long int> b(n+1,0);
  for (long long int i = 1; i < n+1; i++) {
    cin >> a[i];
  }
  
  for (long long int i = 1; i < k+1; i++) {
    
    if(b[x]==0){
      b[x]=i;
    }else{
      y=i-b[x];
      z=i;
      x=a[x];
      break;
    }
    x=a[x];
  }
  if(y!=0||z!=0){
    for (long long int i = 0; i < (k-z)%y; i++) {
      x=a[x];
    }
  }
  cout << x << endl;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
#define fr(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    string s;
    string ans={};
    cin >> s;
    for(int i=0;i<s.size();i++){
        cout <<"x";
    }
    cout << endl;
}

Measured memory_bytes: 256
N=int(input())
S=list(map(int,list(input())))

answer=0
for i in range(1000):
  i0=i//100
  i1=(i//10)%10
  i2=i%10

  flag_num=0
  for s in S:
    if flag_num==0 and s==i0:
      flag_num+=1
    elif flag_num==1 and s==i1:
      flag_num+=1
    elif flag_num==2 and s==i2:
      answer+=1
      break
      
print(answer)

Measured memory_bytes: 44124
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
#define mod 1000000007
int main() { 
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
  int n,k,sum=0;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++) 
  cin>>arr[i];
  sort(arr,arr+n);
  for(int i=0;i<k;i++) 
  sum+=arr[i];
  cout<<sum;
  
  return 0;  
} 


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

#define for_(i,a,b) for(int i=a;i<b;++i)

int k;
string S, T;

char add(char c, int x) {
	int y = c - '0';
	return char('0' + (y + x) % 10);
}

void solve() {
	map< string, int > cst;
	cst[S] = 0;
	
	queue< string > q;
	q.push(S);
	
	while (!q.empty()) {
		string dial = q.front(); q.pop();
		int cnt = cst[dial];
		
		if (dial == T) {
			cout << cnt << endl;
			break;
		}
		
		for_(i,0,k) if (dial[i] != T[i]) {
			int dif = (T[i] - dial[i] + 10) % 10;
		
			for_(j,i,k) {
				dial[j] = add(dial[j], dif);
				if (!cst.count(dial)) {
					q.push(dial);
					cst[dial] = cnt + 1;
				}
			}
			
			break;
		}
	}
}

int main() {
	while (cin >> k, k) {
		cin >> S >> T;
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 2644
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
 
class Program
{
    public Program() { }
    public static int Main()
    {
        new Program().calc();
        return 0;
    }
 
    Scanner cin;
    
    void calc()
    {
        cin = new Scanner();
        int W = cin.nextInt(), a = cin.nextInt(), b = cin.nextInt();
        Console.WriteLine(Math.Max(Math.Abs(a - b) - W, 0));
    }

}

class Scanner
{
    string[] s;
    int i;
 
    char[] cs = new char[] { ' ' };
 
    public Scanner()
    {
        s = new string[0];
        i = 0;
    }
 
    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }
 
    public int nextInt()
    {
        return int.Parse(next());
    }
 
    public long nextLong()
    {
        return long.Parse(next());
    }
 
    public double nextDouble()
    {
        return double.Parse(next());
    }
 
}


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

vector<int>e[100005]{};
int par[100005];
int Rank[100005];
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
	}
	if (Rank[x] == Rank[y])Rank[x]++;
}
int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	for (int x = 0; x < a; x++) {
		par[x] = x;
		Rank[x] = 0;
	}
	for (int c = 0; c < a; c++) {
		int d;
		scanf("%d", &d);
		for (int f = 0; f < d; f++) {
			int g;
			scanf("%d", &g);
			g--;
			e[g].push_back(c);
		}
	}
	for (int x = 0; x < b; x++) {
		if (e[x].size() >= 2) {
			for (int p = 1; p < e[x].size(); p++)unite(e[x][0], e[x][p]);
		}
	}
	unordered_set<int>k;
	for (int i = 0; i < a; i++) {
		k.insert(find(i));
	}
	if (k.size() == 1)puts("YES");
	else puts("NO");
}

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

int n, mod = 1e9 + 7;
string s[2];
int main() {
	cin >> n >> s[0] >> s[1];
	long long rv = 1;
	bool prev = 0; //縦
	for (int i = 0; i < n; i++) {
		if (s[0][i] == s[1][i]) {
			rv *= i ? (prev ? 2 : 1) : 3;
			prev = 1;
		} else {
			rv *= i ? (prev ? 2 : 3) : 6;
			prev = 0;
			i++;
		}
		rv %= mod;
	}
	cout << rv << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

void swap(long long int* a, long long int* b){
    long long int t;
    t=*a;
    *a=*b;
    *b=t;
}

int main(){
    long long int T1,T2,A1,A2,B1,B2,ans,diff,top;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    //AとBでT1の速度が速い方を、Aに
    if(A1<B1){
        swap(&A1,&B1);
        swap(&A2,&B2);
    }
    diff = B1*T1+B2*T2 - A1*T1 - A2*T2;
    if(diff<0){
        cout <<0<<endl;
    }
    else if(diff==0){
        cout<<"infinity"<<endl;
    }
    else{
        top = A1*T1-B1*T1;
        if(top%diff==0){
            ans = (top/diff)*2;
        }
        else{
            ans = (top/diff)*2+1;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define gcd(x, y) int gcd(int x, int y) {return (y == 0) ? x : gcd(y, x % y);}
#define INF (1 << 30)

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

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    string s;
    cin >> s;
    if(s[0] == s[2]) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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 gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

  cout << (1900*M+100*(N-M))*(1<<M) << endl;
}

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

int main() {
  int N, A, B, C, D;
  cin >> N;
  A = N/1000;
  B = (N-A*1000)/100;
  C = (N-A*1000-B*100)/10;
  D = N-A*1000-B*100-C*10;

  if ( B==C ) {
    if ( A==B || D==C ){ 
      cout <<"Yes" << endl;
    } else
      cout << "No" << endl;
  } else {
  cout << "No" << endl;
  }
}


Measured memory_bytes: 256
/***
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 *      百年修得同船渡，千年修得代码重.
 */
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
using namespace std;
//int n,m,x,y;
//char a[1010][1010];
//int vis[1010][1010];
//void dfs()
//{
//
//}
//int main()
//{
//    while(~scanf("%d%d",&n,&m))
//    {
//        for(int i=0;i<n;i++)
//        scanf("%s",a[i]);
//        for(int i=0;i<n;i++)
//            for(int j=0;j<m;j++)
//        {
//            if(a[i][j]=='*')
//                vis[i][j]=2;
//                if(a[i][j]=='+')
//                    vis[i][j]=1;
//                if(a[i][j]=='F')
//                    vis[i][j]=3;
//                if(a[i][j]=='G')
//                {
//                    x=i;
//                    y=j;
//                }
//                if(i==0&&a[i][j]=='+')
//                    vis[i][j]=4;
//                if(i==n&&a[i][j]=='+')
//                    vis[i][j]=4;
//                if(j==0&&a[i][j]=='+')
//                    vis[i][j]=4;
//                if(j==m&&a[i][j]=='+')
//                    vis[i][j]=4;
//
//        }
//
//     for(int i=0;i<n;i++)
//            {
//                for(int j=0;j<m;j++)
//                printf("%d ",vis[i][j]);
//                printf("\n");
//            }
// }
//    return 0;
//}
int main()
{

    char a[10];
    char b[10];
    while(~scanf("%s",a))
    {
        scanf("%s",b);
    int flag=0;
    if(a[0]==b[2])
        flag++;
    if(a[1]==b[1])
        flag++;
    if(a[2]==b[0])
        flag++;
    if(flag==3)
        printf("YES\n");
    else
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
scores = []
n.times do
    scores.push(gets.chomp.to_i)
end
scores.sort!
sum = scores.inject(:+)
if sum % 10 == 0
    scores.each do |score|
        if score % 10 != 0
            puts sum - score
            exit
        end
    end
else
    puts sum
    exit
end

puts 0

Measured memory_bytes: 3836
#include <cstdint>
#include <iostream>
#include <map>
#include <vector>
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); i++)

using namespace std;

int main() {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if (a + b + c < 22)
    printf("win\n");
  else
    printf("bust\n");
}


Measured memory_bytes: 888
n = int(input())
a = list(map(int, input().split()))
cnt = 0
val = 0
for i in a:
    if i % 4 == 0:
        cnt += 1
    elif i % 2 == 0:
        val += 1
if (cnt + val//2) >= n // 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 15020
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
ll count_div(ll n, ll m) {
    if (n%m != 0) return 0;
    else return 1 + count_div(n/m, m);
}
#endif


int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vi a(N); REP(i, N) cin >> a[i];

    int ans = 0;
    REP(i,N) {
        ans += count_div(a[i], 2);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, T = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]

max_profit = 0
ans = 1
left = 0
right = 1

min_a = a[0]
for i in range(1, N):
    if min_a < a[i]:
        profit = a[i] - min_a
        if profit == max_profit:
            ans += 1
        else:
            max_profit = max(max_profit, profit)
    else:
        min_a = min(min_a, a[i])

print(ans)


Measured memory_bytes: 14244
#include<stdio.h>
#include<string.h>
int main(){
    char A[20],B[20],C[20];
    int a,b,flag1,flag2;
    flag1 = flag2 = 0;
    scanf("%s %s %s",A,B,C);
    a = strlen(A);
    b = strlen(B);
    if(A[a-1] == B[0]) flag1 = 1;
    if(B[b-1] == C[0]) flag2 = 1;
    if((flag1+flag2)==2) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
function main(input) {
  const N = parseInt(input.split(" ")[0] , 10);
  var sum=0
  for(var i=0; i<N; i++){
    if(input.split("\n")[i+1].split(" ")[1]=="JPY"){
      var x=parseInt(input.split("\n")[i+1].split(" ")[0] , 10);
      sum+=x
    }else{
      var x=parseFloat(input.split("\n")[i+1].split(" ")[0] , 10);
      sum+=x*380000
    }
  }
  console.log(sum);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9420
#include <stdio.h>

int main(void)
{
	char X[1];
	char Y[1];
	
	scanf("%c %c",&X[0],&Y[0]);
	if(X[0]==Y[0]) printf("=");
	else if(X[0]<Y[0]) printf("<");
	else if(X[0]>Y[0]) printf(">");

	return(0);
}

Measured memory_bytes: 128
from collections import deque


n = int(input())
a = list(map(int, input().split()))
b = deque()
for i in range(n):
    if i % 2:
        b.appendleft(a[i])
    else:
        b. append(a[i])
if n % 2:
    b.reverse()
print(' '.join(map(str, b)))

Measured memory_bytes: 29504
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  long long a, b, c;
  std::cin >> a >> b >> c;
  std::cout << std::min(b + c, a + 2 * b + 1) << std::endl;
  return 0;
}

Measured memory_bytes: 256
N = int(raw_input())
data = []
for i in range(N):
    data.append(map(int, raw_input().split()))

for d in data:
    if d[0] < d[1] + d[2]:
        print("No")
        exit(0)
    elif d[0] > d[1] + d[2]:
        even0 = d[0] % 2 == 0
        even12 = (d[1] + d[2]) % 2 == 0
        if even0 ^ even12:
            print("No")
            exit(0)
print("Yes")



Measured memory_bytes: 21508
from collections import deque
h, w = map(int, input().split())
s = [input() for i in range(h)]
def bfs(i0, j0):
    INF = 100
    search = deque([(i0, j0)])
    d = [[INF] * w for i in range(h)]
    d[i0][j0] = 0
    while search:
        i, j = search.popleft()
        for di, dj in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            ni, nj = i + di, j + dj
            if 0 <= ni < h and 0 <= nj < w and s[ni][nj] == '.' and d[ni][nj] == INF:
                search.append((ni, nj))
                d[ni][nj] = d[i][j] + 1
    return d[i][j]

max_d = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            max_dij = bfs(i, j)
            max_d = max(max_d, max_dij)
print(max_d)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[10001];
    a[0] = 0;
    a[1] = 0;
    for(int i = 2; i < 10001; i++)
    {
        a[i] = 1;
    }
    for(int i = 2; i < 101; i++)
    {
        for(int j = 2; i * j < 10001; j++)
        {
            a[i * j] = 0;
        }
    }
    int c[10000];
    int t = 0;
    for(int i = 0; i < 10001; i++)
    {
        if(a[i] == 1)
        {
            c[t] = i;
            t = t + 1;
        }
    }
    
    int n ;
    
    while(cin >> n, n)
    {
        int k = 0;
        int ans = 0;
        int p = 1;
        queue<int> q;
        q.push(c[0]);
        k = c[0];
        while(p < 10000)
        {
            if(k < n)
            {
                if(c[p] > 0)
                {
                    k = k + c[p];
                    q.push(c[p]);
                    p = p + 1;
                }
                else
                {
                    cout << ans << endl;
                    break;
                }
            }
            else if(k == n)
            {
                ans = ans + 1;
                k = k + c[p];
                q.push(c[p]);
                p = p + 1;
            }
            else
            {
                k = k - q.front();
                q.pop();
            }
        }
    }
}

Measured memory_bytes: 3124