akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; 
}
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; 
} 

int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

int32_t main() { 
	
	setIO();

    ll a,b,c,d; cin >> a >> b >> c >> d;

    ll res = a*d;
    ckmax(res,a*c); ckmax(res,b*c); ckmax(res,b*d);
    
    cout << res << "\n";
    
}

Measured memory_bytes: 3636
def selectionSort(A, N):
    swap_count = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            A[i], A[minj] = A[minj], A[i]
            swap_count += 1
    return swap_count

n = int(input())
A = list(map(int, input().split()))
count = selectionSort(A, n)
print(*A)
print(count)

Measured memory_bytes: 7712
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#include <functional>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
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 (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

vector<vector<int>> graph(200010, vector<int>());
vector<int> x(200010), y(200010);

void dfs(int n, int par, int dis, int flag) {
	if(flag) x[n] = dis;
	else y[n] = dis;
	for (auto i : graph[n]) {
		if (i != par) {
			dfs(i, n, dis + 1, flag);
		}
	}
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n - 1; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[a[i]].push_back(b[i]);
		graph[b[i]].push_back(a[i]);
	}
	dfs(0, -1, 0, 1);
	int p = -1, d = -1;
	for (int i = 0; i < n; i++) {
		if (x[i] > d) {
			p = i; d = x[i];
		}
	}
	dfs(p, -1, 0, 0);
	int ans = 0;
	for (auto i : y) chmax(ans, i);
	cout << (ans % 3 == 1 ? "Second" : "First") << endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  if(A%3==0 || B%3==0 || (A+B)%3==0)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}

int main(void)
{
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    vector<int> pos(n, 0);

    REP(i,n){
        int bp = (n - 1 - a[i]) / 2;
        int bbp = (n - 1 + a[i]) / 2;

        if(bp < 0 || bbp >= n){
            cout << 0 << endl;
            return 0;
        }

        if (pos[bp] == 0)
        {
            pos[bp] = i + 1;
        }
        else if(pos[bbp] == 0){
            pos[bbp] = i + 1;
        }
        else{
            cout << 0 << endl;
            return 0;
        }
    }

    cout << RepeatSquaring(2, n / 2, 1e9+7) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include<cmath>


using namespace std;
int main(void){
    // Your code here!
    int X;
    cin>>X;
    int j=X;
    bool flag=0;
    int ans=0;
    while(1){
        flag=1;
        for(int i=2;i<=sqrt(j);i++){
            if(j%i==0){
                flag=0;
                break;
            }
            if(i==sqrt(X)){
                flag=1;
            }
        }
        if(flag==1){
            ans=j;
            break;
        }
        j++;
    }
    cout<<ans<<endl;
    return 0;
    
}


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

int main() {
  std::string w;
  std::cin >> w;

  int cnt[26] = {};
  int n = w.length();
  for (int i = 0; i < n; ++i) {
    ++cnt[w[i] - 'a'];
  }

  bool isbeautiful = true;
  for (int i = 0; i < 26; ++i) {
    if ( cnt[i] % 2 != 0 ) {
      std::cout << "No" << std::endl;
      isbeautiful = false;
      break;
    }
  }
  if ( isbeautiful ) std::cout << "Yes" << std::endl;

  return 0;
}


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

using namespace std;

inline int comp(string& s, string &t)
{
	if (s.size() < t.size()) return 1;
	if (s.size() > t.size()) return 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] < t[i]) return 1;
		if (s[i] > t[i]) return 0;
	}
	return 0;
}

void solve(void)
{
	int w, h;
	while(cin >> w >> h)
	{
		if (!w && !h) break;
		vector<string> g(h), dp(w);
		for (string& s : g) cin >> s;
		string ans = "";
		for (int i = 0; i < h; i++)
		{
			vector<string> nx(w);
			for (int j = 0; j < w; j++)
			{
				if ('0' > g[i][j] || '9' < g[i][j])
					continue;
				string s = "", t = "";
				if (i)
					s = dp[j];
				if (j)
					t = nx[j - 1];
				if (s.empty() && t.empty() && g[i][j] == '0') continue;
				nx[j] = (comp(s, t) ? t : s) + g[i][j];
				if (comp(ans, nx[j]))
					ans = nx[j];
			}
			swap(dp, nx);
		}
		bool f = 1;
		for (char c : ans)
		{
			if (c == '0' && f) continue;
			cout << c;
			f = 0;
		}
		if (f) cout << 0;
		cout << '\n';
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}




Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+100;
const ll mod = 1e9+7;
ll b[maxn],inv[maxn];
ll qpow(ll a,ll b,ll mod) {
    ll ans = 1;
    while(b) {
        if(b&1)
            ans = ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}
ll C(int n,int m) {
    return b[n]*inv[m]%mod*inv[n-m]%mod;
}
int main() {
    ios::sync_with_stdio(0);
    int n,k;
    cin>>n>>k;
    b[0]=1;
    inv[0]=1;
    for(int i=1; i<=n; i++)
        b[i]=b[i-1]*i%mod;
    for(int i=1; i<=n; i++)
        inv[i]=qpow(b[i],mod-2,mod);
    ll ans=1;
    for (int i=1; i<n; i++) {
        if(n-i<=k)
            ans=(ans+C(n,i)*C(n-1,i-1)%mod+mod)%mod;
    }
cout<<ans<<endl;
    return 0;
}


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

D, N = map(int, input().split())

output = 0
counter = 1
if(D == 0):
    while(counter <= N):
        if(counter % 100 == 0):
            output += 2
            counter += 1
        else:
            output += 1
            counter += 1
elif(D == 1):
    if(N == 100):
        output = 100 * (N+1)
    else:
        output = 100 * N
else:
    if(N == 100):
        output = 10000 * (N+1)
    else:
        output = 10000 * N


print(output)

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

int main(){
    int n;
    unsigned int a[10001] = {0};
    cin >> n;
    int count = 0, maximum=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<32; j++){
            if(a[i] % 2 == 0){
                a[i] /= 2.0;
                count++;
            }else{
                maximum += count;
                count = 0;
            }
            
        }
    }
    
    cout << maximum << endl;

    return 0;
}

Measured memory_bytes: 892
#include <stdio.h>

int main(){
  int a,b,x[3],max=-1000,i;
  scanf("%d %d",&a,&b);
  x[0]=a+b;
  x[1]=a-b;
  x[2]=a*b;
    for(i=0;i<3;i++){
    if(max<x[i]) max=x[i];
    }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 128
N = int(input())
a = [int(input()) for i in range(N)]
switch = True
i = 1
cnt = 1
roop = [1 for i in range(N)]
while switch == True:
    if roop[i-1] == 0:
        print(-1)
        break
    
    nextbottun =  a[i-1]
    if nextbottun == 2:
        print(cnt)
        break
    roop[i-1] = 0
    i = nextbottun
    cnt += 1

Measured memory_bytes: 7852
#include <stdio.h>

int main()
{
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    
    while(A != 0 && B != 0) {
        int a = A, b = B;
        if(a > b) {
            A = a % b;
        } else {
            B = b % a;
        }
    }
   
    printf("%s", (A != 0 && C % A == 0 || B != 0 && C % B == 0) ? "YES" : "NO");
    
    return 0;
}


Measured memory_bytes: 128
A, B, K = map(int, input().split())
if B - A + 1 <= 2 * K:
    for i in range(A, B + 1):
        print(i)
    exit()
for i in range(A, A + K):
    print(i)
for i in range(B - K + 1, B + 1):
    print(i)


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

int main() 
{
int n,M,c,ans=0,call,token;
cin>>n>>M>>c;
vector<int> A(M),B(M);
  for(int j=0;j<M;j++) 
  {
    cin>>B[j];
  }
  for(int i=0;i<n;i++)
  {
    call=0;
      for(int j=0;j<M;j++) 
	  {
        cin>>token;
        call+=token*B[j];
      }
      if(call+c>0) 
	  {
        ans++;
      }
  }
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

int n;

signed main(){
	read(n);
	if(!(n&(n-1))) return puts("No"),0;
	puts("Yes");
	for (int i=2;i+1<=n;i+=2){
		printf("%d %d\n",1,i),printf("%d %d\n",i,i+1);
		printf("%d %d\n",1,n+i+1),printf("%d %d\n",n+i+1,n+i);
	}
	printf("%d %d\n",3,n+1);
	if (n%2==0){
		int p=0;
		for(int i=1;i<=20;i++) if(n>>i&1){p=i;break;}
		printf("%d %d\n",n,(1<<p)+1+n);
		printf("%d %d\n",2*n,(n^(1<<p)));
	}
}

Measured memory_bytes: 3764
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int road[50];
bool pass[50][50] = { 0 };
queue<int> que;


int main() {

	int n, m;
	int ans = 0;
	cin >> n >> m;

	rep(i, 0, m) {
		int a,b;
		cin >> a >> b; a--; b--;
		pass[a][b] = pass[b][a] = true;
		road[a]++; road[b]++;
	}

	rep(i, 0, n) {
		if (road[i] == 1) {
			que.push(i);
		}
	}

	while (!que.empty()) {
		int s = que.front(); que.pop();
		rep(i, 0, n) {
			if (pass[s][i]&&road[s]==1) {
				ans++;
				pass[s][i] = pass[i][s] = false;
					road[i]--;
					que.push(i);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(input())
b = list(input())
c = list(input())
ans = 0
for i in range(n):
    l = [a[i],b[i],c[i]]
    l = list(set(l))
    if len(l) == 3:
        ans += 2
    elif len(l) == 2:
        ans += 1
    else:
        pass
print(ans)

Measured memory_bytes: 9124
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner s = new Scanner(System.in);
        
        int a = s.nextInt();
        int b = s.nextInt();
        
        System.out.print((int)a/b + " ");
        System.out.print((int)a%b + " ");
        System.out.printf("%.5f\n",(double)a/b);
   }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


signed main(){
    string a,b,c;
    cin>>a>>b>>c;
    cout<<(char)toupper(a[0])<<(char)toupper(b[0])<<(char)toupper(c[0])<<endl;
    return 0;
}


Measured memory_bytes: 384
n = int(input())
H = list(map(int,input().split()))
if n==1: print('Yes');exit()
H[0]-=1
for i in range(n-1):
    if H[i]>H[i+1]:
        print('No');exit()
    elif H[i]==H[i+1]:
        continue
    else:
        H[i+1]-=1
print('Yes')

Measured memory_bytes: 85240
h, w = map(int, input().split())

M = [str(input()) for _ in range(h)]
M = ['#'*w] + M + ['#'*w]
M = ['#'+c+'#' for c in M]

from collections import deque
ans = 0
for sy in range(1, h+1):
    for sx in range(1, w+1):
        if M[sy][sx] == '#':
            continue
        q = deque()
        q.append((sy, sx))
        visit = [[-1]*(w+2) for _ in range(h+2)]
        visit[sy][sx] = 0
        while q:
            y, x = q.popleft()
            for dy, dx in (-1, 0), (1, 0), (0, -1), (0, 1):
                ny, nx = y+dy, x+dx
                if visit[ny][nx] == -1 and M[ny][nx] != '#':
                    visit[ny][nx] = visit[y][x]+1
                    q.append((ny, nx))
        ans = max(ans, max(max(row) for row in visit))
print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i ++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i --)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;}

constexpr ll INF = (1ll << 60);
constexpr ll MOD = 1000000007ll;

ll llgcd(ll a, ll b){
    if(b == 0)
        return a;
    return llgcd(b, a % b);
}

ll llpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n, m, q;
    cin >> n >> m >> q;
    vector<ll> a(q), b(q), c(q), d(q);
    REP(i, q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }

    vector<ll> zero_one(m - 1 + n, 1);
    REP(i, m-1){
        zero_one[i] = 0;
    }

    ll ans = 0;

    do{
        ll zero_cnt = 1;
        vector<ll> A;
        REP(i, zero_one.size()){
            if(zero_one[i] == 1){
                A.push_back(zero_cnt);
            }else{
                zero_cnt++;
            }
        }

        ll mini_sum = 0;
        REP(i, q){
            if(A[b[i]] - A[a[i]] == c[i]){
                mini_sum += d[i];
            }
        }
        chmax(ans, mini_sum);
    } while (next_permutation(zero_one.begin(), zero_one.end()));

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

Measured memory_bytes: 3636
L = int(input())

cs = list(map(int, input().split()))

cave = []

cats = [0] * 110

for i, c in enumerate(cs):
    if c > 0 and cats[c] == 0:
        cave.append(c)
        cats[c] = 1
    elif c < 0 and cats[-c] == 1 and cave[-1] == -c:
        cave.pop()
        cats[-c] = 0
    else:
        print(i+1)
        exit()
    # print(cave)
    # print(cats[:10])

print("OK")



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int w1, w2, h1, h2, n;
    w1 = 0;
    h1 = 0;
    cin >> w2 >> h2 >> n;
    rep(i, n)
    {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1)
            w1 = max(w1, x);
        else if (a == 2)
            w2 = min(w2, x);
        else if (a == 3)
            h1 = max(h1, y);
        else if (a == 4)
            h2 = min(h2, y);
    }
    if (w2 - w1 > 0 && h2 - h1 > 0)
    {
        cout << (w2 - w1) * (h2 - h1) << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    // end

    return 0;
}


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

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

Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=998244353,MAX=1e5+1;

int countDigits(ll a, ll b)
{
    // if either of the number is 0, then
    // product will be 0
    if (a == 0 || b == 0)
        return 1;

    // required count of digits
    return floor(log10(abs(a)) + log10(abs(b))) + 1;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll mn=x%d,z=min((x-mn)/d,k);
    x-=z*d;
    k-=z;
    if(k&1)
        x=min(x+d,abs(x-d));
    cout<<x;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for(int i=0;i<n;++i) {
        cout << s[i] << t[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
import collections
def main():
    N = int(input())
    edges = collections.defaultdict(dict)
    for _ in range(N-1):
        u, v, w = map(int, input().split())
        edges[u][v] = w
        edges[v][u] = w
    color = dict()
    color[1] = '0'
    cur = [[1, 0]]
    while cur:
        temp = []
        for i, d in cur:
            for j in edges[i]:
                if j not in color:
                    color[j] = str((d + edges[i][j]) % 2)
                    temp.append([j, d + edges[i][j]])
        cur = temp
    for i in range(1, N+1):
        print(color[i])

if __name__ == '__main__':
    main()

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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 2e3 + 100;

vector<int>graph[maxn];

int cnt[maxn];
int dist[maxn];
int n;
void bfs(int x)
{
  MSET(dist, -1);
  queue<int>q;
  q.push(x);
  dist[x] = 0;
  while(q.size())
  {
    auto u = q.front();
    q.pop();
    for(const auto &v: graph[u])
    {
      if(dist[v] == -1)
      {
        dist[v] = dist[u] + 1;
        q.push(v);
      }
    }
  }

  for(int i = 1; i <= n; i++)
  {
    cnt[dist[i]]++;
  }
}

int main()
{
  ios::sync_with_stdio(0);
  int x,y;
  cin >> n >> x >> y;
  graph[x].push_back(y);
  graph[y].push_back(x);
  
  for(int i = 1; i < n; i++)
  {
    graph[i].push_back(i+1);
    graph[i+1].push_back(i);
  }

  for(int i = 1; i <= n ; i++)
  {
    bfs(i);
  }

  for(int i = 1 ; i < n ; i++)
  {
    cout << cnt[i]/2 << endl;
  }



  return 0;
}

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


int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int a;
	cin>>a;
	if (a<1200){
		cout<<"ABC";
	}
	else {
		cout<<"ARC";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        for(int i = 0; i < 3; i++){
                                System.out.print(Character.toUpperCase(sc.next().charAt(0)));
                        }
                        System.out.println("");
                }
        }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
//      String[] nyu=sc.nextLine().split(" ");

     String nyu=sc.nextLine();
//int[] num=new int[6];
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
int C=Integer.parseInt(nyu);
//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/
if(C<1200){
System.out.println("ABC");

}else if(C<2800){
System.out.println("ARC");

}else{
System.out.println("AGC");

}

	}
}

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

using namespace std;

inline void add(int &a, int b, int mod) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

inline void sub(int &a, int b, int mod) {
  a -= b;
  if (a < 0) {
    a += mod;
  }
}

inline int mul(int a, int b, int mod) {
  return (int)((long long)a * b % mod);
}

int power(int a, int b, int mod) {
  int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = mul(res, a, mod);
    }
    a = mul(a, a, mod);
    b /= 2;
  }
  return res;
}

const int N = 610;

int pw[2][N];
int a[N][N];
int r[2][N][N];
int c[2][N][N];

int main() {
  const int base[2] = {31, 43};
  const int mod[2] = {805306457, 402653189};
  int inv[2];
  for (int it = 0; it < 2; ++it) {
    pw[it][0] = 1;
    for (int i = 1; i < N; ++i) {
      pw[it][i] = mul(pw[it][i - 1], base[it], mod[it]);
    }
    inv[it] = power(base[it], mod[it] - 2, mod[it]);
  }
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      char ch = (char)getchar();
      while (ch < 'a' || ch > 'z') {
        ch = (char)getchar();
      }
      a[i][j] = a[n + i][j] = a[i][n + j] = a[n + i][n + j] = ch - 'a' + 1;
    }
  }
  for (int it = 0; it < 2; ++it) {
    for (int i = 0; i < n + n; ++i) {
      r[it][i][0] = 0;
      for (int j = 0; j < n; ++j) {
        add(r[it][i][0], mul(a[i][j], pw[it][j], mod[it]), mod[it]);
      }
      for (int j = 0; j < n - 1; ++j) {
        r[it][i][j + 1] = r[it][i][j];
        sub(r[it][i][j + 1], a[i][j], mod[it]);
        r[it][i][j + 1] = mul(r[it][i][j + 1], inv[it], mod[it]);
        add(r[it][i][j + 1], mul(a[i][n + j], pw[it][n - 1], mod[it]), mod[it]);
      }
    }
    for (int j = 0; j < n + n; ++j) {
      c[it][j][0] = 0;
      for (int i = 0; i < n; ++i) {
        add(c[it][j][0], mul(a[i][j], pw[it][i], mod[it]), mod[it]);
      }
      for (int i = 0; i < n - 1; ++i) {
        c[it][j][i + 1] = c[it][j][i];
        sub(c[it][j][i + 1], a[i][j], mod[it]);
        c[it][j][i + 1] = mul(c[it][j][i + 1], inv[it], mod[it]);
        add(c[it][j][i + 1], mul(a[n + i][j], pw[it][n - 1], mod[it]), mod[it]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      bool ok = true;
      for (int k = 0; k < n; ++k) {
        for (int it = 0; it < 2; ++it) {
          if (r[it][i + k][j] != c[it][j + k][i]) {
            ok = false;
          }
        }
        if (!ok) {
          break;
        }
      }
      if (ok) {
        ++ans;
      }
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <stack>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct N {
	int r;
	int rmax;
	bool b;
	vector<int> e;
};

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

	int n; cin >> n;
	int a, b; cin >> a >> b;

	vector<N> ns(n + 1, { 0, {} });
	FOR_LT(i, 0, n - 1) {
		int u, v; cin >> u >> v;
		ns[u].e.push_back(v);
		ns[v].e.push_back(u);
	}

	{
		stack<int> s;
		ns[b].r = 1;
		s.push(b);

		while (!s.empty()) {
			int c = s.top();
			auto& cn = ns[c];
			if (cn.b) {
				cn.rmax = cn.r;
				for (auto& e : cn.e) {
					cn.rmax = max(cn.rmax, ns[e].rmax);
				}
				s.pop();
				continue;
			}

			cn.b = true;
			for (auto& e : cn.e) {
				if (ns[e].r == 0) {
					ns[e].r = cn.r + 1;
					s.push(e);
				}
			}
		}
	}

	int ans = (ns[a].rmax - ns[a].r) + max(ns[a].r - 2, 0);
	int i = a;
	int j = 1;
	while (true) {
		auto& cn = ns[i];
		if (cn.r <= j) {
			break;
		}
		ans = max(ans, (ns[i].rmax - ns[i].r + max(ns[i].r - (j + 1), 0)) + (j - 1));
		j++;

		for (auto& e : cn.e) {
			if (cn.r > ns[e].r) {
				i = e;
				break;
			}
		}

	}
	cout << ans << endl;

	return 0;
}

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

long long int n,k,q,a;
int main(){
    cin>>n>>k>>q;
    long long int l[n+1];
    for (int i=1; i<=n; i++){
        l[i]=k;
    }
    for (int i=0; i<q; i++){
        cin>>a;
        l[a]+=1;
    }
    for (int i=1; i<=n; i++){
        if (l[i]-q<1){
            cout<<"No"<<endl;
        }
        else{
            cout<<"Yes"<<endl;
        }
    }
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define F first
#define S second
#define _READ freopen("input.txt","r", stdin);
#define _FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void solve()
{
    lli n,w;
    cin>>n>>w;
    vector<pair<lli,lli>> v(n);
    for(auto &i:v)
        cin>>i.F>>i.S;
    vector<lli> dp(w+1,0);
    //(weight, value)
    //dp[i]--> max price of items having weight i
    for(lli i=0;i<n;i++)//iterate over all items one by one
    {
        // weight of item be w
        // its value is v
        lli cur_weight=v[i].F,cur_price=v[i].S;

        for(lli j=w;j-cur_weight>=0;j--)
            dp[j]=max(dp[j],dp[j-cur_weight]+cur_price);
        // this item= some item whose weight is less than this
        //              + value of current item 
    }
    cout<<*max_element(dp.begin(),dp.end());
}
int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

cnt = 0
for i in range(0,N):
    #隣の町で余った勇者を現在の町へ増援
    #更に隣の町へは増援できないことに注意
    if B[i] <= A[i]:
        cnt += B[i]
    elif B[i] > A[i] and B[i] <= A[i]+A[i+1]:
        cnt += B[i]
        A[i+1] = A[i+1] -B[i] + A[i]
    else:
        cnt += A[i]+A[i+1]
        A[i+1] = 0
        
print(cnt)


Measured memory_bytes: 24144
class Integer
    def d_list
        return [1] if self == 1
        (1..Math.sqrt(self).to_i).select do |i|
            self%i == 0
        end.map {|e| [e, self/e]}.flatten.uniq.sort
    end
end
cnt=0
N=gets.to_i
N.d_list.each do |e|
    cnt+=N/e-1 if e<N/e-1
end
puts cnt

Measured memory_bytes: 2428
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (mut a, mut b) = (v[0], v[1]);
    if a > b {
        std::mem::swap(&mut a, &mut b);
    }
    for _ in 0..b {
        print!("{}", a);
    }
    println!("");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        String oldStr = input.next();
        String newStr = input.next();
        boolean flag = false;
        if(newStr.length()-oldStr.length()==1){
            if(newStr.substring(0,newStr.length()-1).equals(oldStr)){
                flag = true;
            }
        }
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 27004
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


/*
           1) long long vs int overflow
           2) read question carefully
*/

#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define umapii unordered_map < int , int >
#define umapll unordered_map<ll,ll>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vs vector<string>
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pi>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define all(v) (v).begin(),(v).end()
#define FOR(i,a,b) for(int i = a;i <= b; i++)

#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

const ll mod = 1000000007;
/*STL:
       (1) PRIORITY_QUEUE pq:
       -> priority_queue < int > pq; // max_heap
       -> priority_queue < int , vector < int > , greater < int > > pq; // min_heap 
       -> pq.top()   --> returns the maximum or minimum element
       -> pq.push()  --> push element into the queue
       -> pq.pop()   --> remove top most element
       -> pq.empty() --> checks whether queue is empty or not



*/
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int inf = 1e9 + 7;

int main(){
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
    char ch;
    cin >> ch;
    cout << (char)(ch+1) << '\n';   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int a[100010];
map<int,int>mp;
signed main(){
    int n,k,q;
    cin>>n>>k>>q;
    REP(i,q) {
        cin>>a[i];
        a[i]--;
        mp[a[i]]++;
    }
    for (int i = 0; i < n; i++)
    {
        if(k-(q-mp[i])>0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
       // cerr<<k-(q-mp[i])<<endl;
    }
    
   
    return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;




int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int maxa = -1;
    int mina = 1001;
    
    int n; cin >> n;
    rep(i,n) {
        int a; cin >> a;
        maxa = max(maxa,a);
        mina = min(mina,a);
    }
    
    cout << maxa - mina << endl;
    
}



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;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

    int ans = N - i + 1;

    cout << ans << endl;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    string s, t;
    cin >> s >> t;
    
    int n = s.size();
    if(t.substr(0, n) == s)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main()
{
  int d,t,s;
  cin>>d>>t>>s;
  if((d/s)<t)
    cout<<"Yes"<<endl;
  else if((d/s)==t&&(d%s==0))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
return 0;}


Measured memory_bytes: 3616
A, B, M=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c = [list(map(int, input().split())) for i in range(M)]

# とりあえず最小
minc=min(a)+min(b)

for v in c:
  minc = min(minc, (a[v[0]-1]+b[v[1]-1]-v[2]))

print(minc)

Measured memory_bytes: 38560
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

 
int main() {
    int n;
    cin >> n;
    vector<int> a(n+1,0);
    rep(i,n-1){
        int f;
        cin >> f;
        a[f]++;
    }
    rep(i,n){
        cout << a[i+1] << endl;
    }
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;

template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)

int main() {
    int n, m;
    while (cin >> n >> m) {
        vector<int> deg(n);
        rep(i, m) {
            int a, b;
            cin >> a >> b;
            --a; --b;
            deg[a] ++;
            deg[b] ++;
        }
        bool even = true;
        rep(i, n) {
            if (deg[i] & 1) even = false;
        }
        cout << (even ? "YES" : "NO") << endl;
    }
}


Measured memory_bytes: 768
n,k=map(int,input().split())
l=[]
for _ in range(n):
    l.append(int(input()))
l.sort()
a=0
for i in range(n-k+1):
    if i==0:
        a=l[i+k-1]-l[i]
    else:
        a=min(a,abs(l[i+k-1]-l[i]))
print(a)


Measured memory_bytes: 7384
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint_fast32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }

inline uint min2(const uint a, const uint b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

uint a[2000];
uint d[2000][2000];
int main(void){
	uint n=nextpint();
	uint x=nextpint();
	ulong ans=0;
	for(uint i=0; i<n; i++){
		ans+=d[0][i]=a[i]=nextpint();
	}
	for(uint j=1; j<n; j++){
		ulong now=(ulong)x*j;
		for(uint i=0; i<n; i++){
			now+=d[j][i]=min2(d[j-1][(i+n-1)%n],a[i]);
		}
		if(now<ans) ans=now;
	}
	printf("%ld\n", ans);
}


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

using namespace std;
#define REP(i, n) for(int i=0; i < (int)(n); ++i)
#define REPR(i, n) for(int i=n; i>= 0; --i)
#define FOR(i, m, n) for(int i=m; i<(n); ++i)

using ll = long long;

ll N, A, B;
vector<ll> h;

bool isOK(ll key){
    ll sum=0;
    REP(i, N){
        if(h[i] > B*key){
            sum+= (h[i]-B*key)/(A-B);
            if((h[i]-B*key)%(A-B)){
                sum++;
            }
        }
    }
    if(sum <= key){
        //cout << key << " " << "true" << endl;
        return true;
    }
    else{
        //cout << key << " " << "false" << endl;        
        return false;
    }
}

ll binary_search(){
    ll left = -1;
    ll right = 1e9+1000;

    while(right - left > 1){
        ll mid = left +(right -left) / 2;
        if(isOK(mid)) right = mid;
        else left = mid;
    }
    return right;
}


int main(){
    cin >> N >> A >> B;
    h.resize(N);
    REP(i, N){
        cin >> h[i];
    }
    ll ans = binary_search();
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N=100010,Mod=998244353;
const double pi=acos(-1.0);
typedef long long int ll;
typedef pair<int,int> pii;
int n,d,ans;
int main()
{
  cin>>n>>d;
  ans=n/(2*d+1)+((n%(2*d+1))!=0);
  cout<<ans<<endl;
  return 0;
}


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

int main( void )
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for ( int i = 0; i < 2; i++ )
    {
        if ( a >= b )
        {
            ans += a;
            a--;
        }
        else
        {
            ans += b;
            b--;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int map[210][210];
int q[10];
int finit[10];

int solve(int r, int u, int dist){
  int mi = 1e9;
  for (int i = 0; i < r; i++) {
    int c;
    if (finit[i] == 0) {
      finit[i] = 1;
      int v;
      if (u == -1) v = 0;
      else v = map[u][q[i]];
      c = solve(r, q[i], dist+v);
      mi = min(c, mi);
      finit[i] = 0;
    }
  }
  if (mi == 1e9) mi = min(mi, dist);
  return mi;
}

int main(){
  int n, m, r;
  cin >> n >> m >> r;
  for (int i = 0; i < r; i++){
    int k;
    cin >> k;
    q[i] = k;
  }
  for (int i = 0; i < m; i++){
    int a, b, c;
    cin >> a >> b >> c;
    map[a][b] = c;
    map[b][a] = c;
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (map[i][j] == 0) map[i][j] = 1e9;
    }
  }

  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        map[i][j] = min(map[i][k] + map[k][j], map[i][j]);
      }
    }
  }

  cout << solve(r, -1, 0) << endl;

  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int N = 200010;

int n;
int a[N];
bool st[N];

bool check(int x)
{
	int mi = 2 * n - 1;
	bool res;
	for (int i = 1; i <= 2 * n - 1; i++)
	{
		if (a[i] >= x) st[i] = true;
		else st[i] = false;
		if (st[i] != st[i - 1]) continue;

		if (i <= n)
		{
			if (n - i < mi)
			{
				mi = n - i;
				res = st[i];
			}
		}
		else
		{
			if ((i - 1) - n < mi)
			{
				mi = i - 1 - n;
				res = st[i];
			}
		}
	}

	if (mi > n)
	{
		res = st[1];
	}

	return res;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= 2 * n - 1; i++)
	{
		scanf("%d", &a[i]);
	}

	int l = 0, r = 0x3f3f3f3f;
	while (l < r)
	{
		int mid = (l + r + 1) >> 1;
		if (check(mid)) l = mid;
		else r = mid - 1;
	}
	printf("%d", r);
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N, 0);
    vector<int> B(N, 0);
    for(int i=1; i<N; i++){
        cin >> A[i];
        B[A[i]-1] = B[A[i]-1] + 1;
    }

    for(int i=0; i<N; i++){
        cout << B[i] << endl;
    }

    return 0; 

}

Measured memory_bytes: 4844
s = input()
k = int(input())

if len(s) == 1:
    print(k//2)
    exit(0)

if len(list(set(s))) == 1 and len(s)%2 == 1:
    print((len(s)//2)*k+k//2)
    exit(0)

count = 0
    
ngo = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        ngo+=1
    else:
        count += ngo//2
        ngo=1
count += ngo//2

ngongo = 0
while ngongo < len(s) and s[len(s)-ngongo-1] == s[-1]:
    ngongo+=1

ngongongo = 0
while ngongongo < len(s) and s[ngongongo] == s[0]:
    ngongongo += 1
    
f = 0
if ngongo %2 == 1 and ngongongo %2 == 1 and s[0] == s[-1]:
    count += 1
    f += 1

print(count*k-f)

Measured memory_bytes: 3064