akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int H,W;

signed main(){

    in(H,W);
    out((H-1)*(W-1));

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int dig(long int x)
{
  long long int dig=0;
  while(x>0)
  {
    dig++;
    x=x/10;
  }
  return dig;
}
long long int concat(long long int x,long long int t,long long int n)
{
  long long int p=x;

  for(long long int i=0;i<n-1;i++)
  {
    p=p*pow(10,t)+x;
  }
  return p;
}
int main()
{
long long int a,b,x,y;
cin>>a>>b;
  x=dig(a);
  y=dig(b);
  if(x*b>a*y)
    cout<<concat(a,x,b);
  else
    cout<<concat(b,y,a);


  return 0;
}

Measured memory_bytes: 256
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e2 + 10, M = 1e5 + 10;

bool dp[M];
int a[N];

int main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i ++)
        cin >> a[i];
    dp[0] = 0;
    for (int i = 1; i <= k; i ++)
    {
        bool f = 0;
        for (int j = 0; j < n; j ++)
        {
            if (0 <= i - a[j] && dp[i - a[j]] == 0)
                f = 1;
        }
        dp[i] = f;
    }
    cout << (dp[k] ? "First" : "Second");
    return 0;
}


Measured memory_bytes: 384
import sys
import queue
input = sys.stdin.readline
N, Q = map(int, input().split())
 
tree = [[] for i in range(N+1)]
values = [0] * (N+1)
visit = [False]*(N+1)
for _ in range(N-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)
 
for _ in range(Q):
    p, x = map(int, input().split())
    values[p] += x
 
 
q = queue.Queue()
q.put(1)
visit[1] = True
while (not q.empty()):
    now = q.get()
    for next in tree[now]:
        if not visit[next]:
            values[next] += values[now]
            visit[next] = True
            q.put(next)
 
values = values[1:]
print(" ".join(map(str, values)))

Measured memory_bytes: 130164
n=int(input())
s=list(map(int,input().split()))
from itertools import accumulate
from collections import Counter
from math import factorial
p=0
def f(n,m):
    return factorial(n)//(factorial(n-m)*factorial(m))
t=[0]+list(accumulate(s))
for i in Counter(t).values():
    if i>1:
        p+=f(i,2)
print(p)

Measured memory_bytes: 42252
# coding: utf-8
# Your code here!
n,k=map(int,input().split())
S=list(input())
tmp=0
cnt=-1

for i in range(n):
    if tmp!=S[i]:
        cnt+=1
    tmp=S[i]

if k*2>=cnt:
    print(n-1)
else:
    print(n-1-cnt+k*2)

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

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	int div = min(a,b);
	int cnt = 0;
	int val = 0;
	for (int i = div; i > 0; --i) {
		if (a % i == 0 && b % i == 0) {
			++cnt;
			if (cnt == k) {
				val = i;
				break;
			}
		}
	}
	cout << val << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>
#include <numeric>


int main(){
	int s;
	std::cin >> s;
	int first, second;
	first = s / 100;
	second = s % 100;
	bool fm = false, sm = false;
	if(first != 0 && first <= 12){
		fm = true;
	}
	if(second != 0 && second <= 12){
		sm = true;
	}
	if(fm&&sm){
		std::cout << "AMBIGUOUS" << std::endl;
	}else if(fm && !sm){
		std::cout << "MMYY" << std::endl;
	}else if(sm && !fm){
		std::cout << "YYMM" << std::endl;
	}else{
		std::cout << "NA" << std::endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;

namespace adaptor = boost::adaptors;

void Main()
{
	int N;
    string S;
    cin >> N >> S;

    int count = 0;
    int flag = 0;
    for (int i = 0; i < N; i++) {
		if(flag == 0) {
            if(S[i] == 'A') {
                flag = 1;
            }
        } else if(flag == 1) {
            if(S[i] == 'B') {
                flag = 2;
            } else if(S[i] == 'A') {
                flag = 1;
            } else {
                flag = 0;
            }
        } else if(flag == 2) {
            if(S[i] == 'C') {
                flag = 0;
                count++;
            } else if(S[i] == 'A') {
                flag = 1;
            } else {
                flag = 0;
            }
        }
	}
    cout << count << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	
	Main();
}

Measured memory_bytes: 256
def mod_inv(n: int, mod: int)->int:
    b, u, v = mod, 1, 0
    while b > 0:
        t = n // b

        n -= t * b
        u -= t * v

        n, b = b, n
        u, v = v, u

    return (u+mod) % mod


def cell_distance(N: int, M: int, K: int)->int:
    MOD = 10**9 + 7

    C = 1
    for k in range(K-2):
        C *= (N*M - K + k + 1)
        C %= MOD
        C *= mod_inv(k+1, MOD)
        C %= MOD

    S = 0
    for d in range(N):
        S += d * (N-d) * M * M
        S %= MOD

    for d in range(M):
        S += d * (M-d) * N * N
        S %= MOD

    S *= C
    S %= MOD

    return S


if __name__ == "__main__":
    N, M, K = map(int, input().split())

    ans = cell_distance(N, M, K)
    print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#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
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
 

int main(){
  int N;
  cin>>N;
  while(N/100!=N%10||(N%100)/10!=N%10){
    N++;
  }
  cout<<N<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{

    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int len = input.Length;
            string a = input.Substring(0, 1);
            string b = input.Substring(len - 1, 1);


                Console.WriteLine(a + (len-2) + b);

            

        }
    }
}

    




Measured memory_bytes: 25944
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000010
#define N 10010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,p[N],a[N],degree[N],val[N],t,ans;
struct data{int to,nxt;
}edge[N<<1];
void addedge(int x,int y){t++;edge[t].to=y,edge[t].nxt=p[x],p[x]=t;}
signed main()
{
	n=read();
	for (int i=1;i<n;i++)
	{
		int x=read(),y=read();
		addedge(x,y),addedge(y,x);
		degree[x]++,degree[y]++;
	}
	for (int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++)
	{
		int mn=n;
		for (int j=1;j<=n;j++)
		if (val[j]==0) mn=min(mn,degree[j]);
		for (int j=1;j<=n;j++)
		if (val[j]==0&&degree[j]==mn) {mn=j;break;}
		val[mn]=a[i];ans+=degree[mn]*a[i];
		for (int j=p[mn];j;j=edge[j].nxt)
		degree[edge[j].to]--;
	}
	cout<<ans<<endl;
	for (int i=1;i<=n;i++) cout<<val[i]<<' ';
	return 0;
	//NOTICE LONG LONG!!!!!
}

Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;
use std::collections::BTreeMap;

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

fn main() {
    let n: usize = read();
    let W: usize = read();
    let mut w: Vec<usize> = (0..n).map(|_| 0).collect();
    let mut v: Vec<usize> = (0..n).map(|_| 0).collect();

    for i in 0..n {
        w[i] = read();
        v[i] = read();
    }

    let vn = (&v).into_iter().fold(0, |a, &b| a + b) + 1;
    let m = n + 1;
    let mut dp: Vec<Vec<usize>> = (0..m).map(|_| (0..vn).map(|_| 1000000000000).collect()).collect();
    dp[0][0] = 0;

    for i in 0..n {
        for j in 0..vn {
            dp[i + 1][j] = dp[i][j];
            if v[i] <= j {
                dp[i + 1][j] = std::cmp::min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
            }
        }
    }

    let mut ret = std::usize::MAX;
    for i in 0..vn {
        if dp[n][i] <= W {
            ret = i;
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 106748
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int mod=1000000007;
int main(void){
  int n; cin>>n;
  vector<ll> a(n);
  for(auto& i:a) cin>>i;
  ll res=0,two=1;
  for(int d=0; d<60; ++d){
    ll add,odd=0,even=0;
    for(auto& i:a) if(i&(1LL<<d)) ++odd; else ++even;
    add=(odd*even)%mod*two%mod;
    res=(res+add)%mod;
    two=(two*2)%mod;
  }
  cout<<res;
  return 0;
}

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

using namespace std;

int main(){
    string s; cin>>s;
    long Aswi=0,ans=0,count=0,flag=0;
  	vector<int> N(s.size(),0);

  if(s.size()>=2){
    for(int i=0;i<=s.size()-2;i++){
      if(flag==1){
       flag=0;
        continue;
      }
        if(s[i]=='A'){
            N[count]=1;
            count++;
        }else if(s[i]=='B' && s[i+1]=='C'){
            N[count]=2;
            count++;
          flag=1;
        }else{
            N[count]=0;
            count++;
        }
    }
    for(int i=0;i<=count-1;i++){
        if(N[i]==1) Aswi++;
        else if(N[i]==2) ans+=Aswi;
        else if(N[i]==0) Aswi=0;
      //printf("%d",N[i]);
    }
    printf("%ld",ans);
}else{
    printf("0");
  }
    return 0;
}


Measured memory_bytes: 1412
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<ctime>
#include<cassert>
using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fj(a,b) for(int j=a;j<b;++j)
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef long long ll;
//////////////////////

int const N = 2e5 + 41;

int n;
ll a[N], b[N];
vector<pii> ans;

void solve(){
	bool f = false;
	int id = -1;
	fi(0, n){
		if(id == -1 || abs(a[i]) > abs(a[id])){
			id = i;
		}
	}
	if(a[id] > 0) f = true;
	else f = false;
	fi(0, n){
		if(i != id){
			ans.pb(mp(id, i));
		}
	}
	if(f){
		fi(1, n){
			ans.pb(mp(i-1, i));
		}
	}else{
		fdi(n-1, 0){
			ans.pb(mp(i+1, i));
		}
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%d",&n);
	fi(0, n) scanf("%lld",&a[i]);
	
	solve();

	printf("%d\n",sz(ans));
	fi(0, sz(ans)){
		printf("%d %d\n",ans[i].first+1,ans[i].second+1);
	}
#ifdef _DEBUG
	fi(0, n) b[i] = a[i];
	fi(0, sz(ans)){
		b[ans[i].second] += b[ans[i].first];
	}
	fi(0, n){
		printf("%lld ", b[i]);
	}
#endif

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

#define ran 3033

int n;
double dp[ran][ran];

int main() {
	scanf("%d", &n);
	dp[0][0] = 1.;
	for(int i=1;i<=n;i++) {
		double p;
		scanf("%lf", &p);
		for(int j=0;j<i;j++) {
			dp[i][j] += dp[i-1][j] * (1-p);
			dp[i][j+1] += dp[i-1][j] * p;
		}
	}
	double ans = 0;
	for(int i=n;i>n-i;i--)
		ans += dp[n][i];
	printf("%.10lf\n", ans);
	
	return 0;
}

Measured memory_bytes: 70144
#include <stdio.h>
#include <string.h>
int N;
struct mise{
	char name[11];
	int P;
	int num;
};

int main(){
	scanf("%d",&N);
	struct mise S[N],temp;
	for(int i=0;i<N;i++){
		scanf("%s%d",S[i].name,&S[i].P);
		S[i].num=i+1;
	}

	for(int i=0;i<N;i++){
		for(int j=N-1;j>=i;j--){
			if(strcmp(S[i].name,S[j].name) > 0){
				temp=S[i];
				S[i]=S[j];
				S[j]=temp;
			}else if(strcmp(S[i].name,S[j].name) == 0){
				if(S[i].P < S[j].P){
					temp=S[i];
					S[i]=S[j];
					S[j]=temp;
				}
			}
		}
	}
	for(int i=0;i<N;i++){
		printf("%d\n",S[i].num);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;

int main(){

    int a,b,h;
    cin >> a >> b >> h;

    int s;

    s = (a + b) * h / 2;

    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <assert.h>
#include <cstring>
#include <set>

using namespace std;

typedef long long ll;

int main()
{
    ll sum;
    string s;
    cin >> s;
    for(char c : s)
    {
        sum += (int)c-48;
    }
    if(sum%9==0)cout << "Yes";
    else cout << "No";
    
}

Measured memory_bytes: 3732
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <unordered_set>
#include <cctype>
#include <cassert>


using namespace std;

typedef long long ll;
typedef long double ld;

const int nax = 1005;
const int mod = (int)1e9 + 7;

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

int dp[nax][nax];

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("angle2.in", "r", stdin);
	//freopen("angle2.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int h, w;
	cin >> h >> w;

	dp[1][1] = 1;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			char c;
			cin >> c;
			if (c == '#') continue;
			add(dp[i][j], dp[i - 1][j]);
			add(dp[i][j], dp[i][j - 1]);
		}
	}

	cout << dp[h][w];
	return 0;
}

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

int main(){
	int cost[] = {-1, 6000, 4000, 3000, 2000};
	
	for(int i=0; i<4; ++i){
		int t , n;
		cin >> t >> n;
		cout << (cost[t]*n) << endl;
	}
}


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

int main() {
  int a, b;
  cin >> a >> b;

  if (a % 2 == 1 && b % 2 ==1) {
    cout << "Odd" << endl;
  }
  
  else {
    cout << "Even" << endl;
  }

}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>

using namespace std;

int dp[55];
int weight[6] = { 2 ,3 ,5 ,10 ,12 ,15 };
int value[6] = { 380 ,550 ,850 ,1520 ,1870 ,2244 };

void compute(void){
  
  for( int i = 0 ; i < 100 ; i++ ) dp[i] = 99999;;
  dp[0] = 0;
  for( int i = 0 ; i < 6 ; i++ ){
    for( int j = 0 ; j + weight[i] < 55 ; j++ ){
	dp[j + weight[i]] = min( dp[j + weight[i]] , dp[j] + value[i] );
      // 値段はvalueの6種類のみだからづいじそのパターンで計算
    }
  }

}

int main(void){

  compute();

  int n;
  while( cin >> n , n ){
    cout << dp[n/100] << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
             
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> Pi;
typedef map<ll,ll> mi;
             
template<class T> T nrem(T x,T y){return ((x%y)+y)%y;}
             
#define For(i,a,n) for(int i=a;i<n;++i)
#define For0(i,n) for(int i=0;i<n;++i)
#define For1(i,n) for(int i=1;i<=n;++i)
#define Forl0(i,n) for(ll i=0;i<n;++i)
#define Forl1(i,n) for(ll i=1;i<=n;++i)
#define fi freopen("input.txt","r",stdin);
#define fo freopen("output.txt","w",stdout);
#define pb push_back
#define mp make_pair
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cs 100005
#define pi acos(-1)
#define INF (int)INFINITY
void in()
    {
         #ifndef ONLINE_JUDGE
         freopen("input.txt", "r", stdin);
         freopen("output.txt", "w", stdout);
        #endif
    }

bool cmp(pair<int,pair<int,int>> a,pair<int,pair<int,int>> b)
{
    return (a.second.first>b.second.first)||(a.second.first==b.second.first&&a.first<b.first);
}
int bs_lower_bound(pair<int,int> a[], int n, int x) {
    int l = 0;
    int h = n; // Not n - 1
    while (l < h) {
        int mid =  l + (h - l) / 2;
        if (x <= a[mid].first) {
            h = mid;
        } else {
            l = mid + 1;
        }
    }
    return l;
}
int main()
{   IOS
    in();

    int n;
    cin>>n;
    
    int f=0;
    for(int i=1;i<=n;++i)
    {
        if(n%i==0&&(n/i<=9)&&(i<=9))
        {
            f=1;
            break;
        }
    }
     if(f)
     cout<<"Yes"<<endl;

     else cout<<"No"<<endl;
    

}

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

int main(){
  string s,t;
  cin>>s>>t;
  for(int i=0;i<t.size()-1;i++)
    if(s.at(i)!=t.at(i)){
      cout << "No"<<endl;
      return 0;
    }
  cout << "Yes"<<endl;
  
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

char ban[55][55];
int dx[] = {-1, 0,   1, -1, 1, -1, 0, 1};
int dy[] = {-1, -1, -1,  0, 0,  1, 1, 1};

int main(){
	int i, j, k, n, m;
	int h, w;
	
	scanf("%d%d", &h, &w);

	for (i = 0; i < h; i++) {
		scanf("%s", ban[i]);
	}
	
	int x, y, cnt;
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (ban[i][j] == '#') continue;

			cnt = 0;
			for (k = 0; k < 8; k++) {
				y = i + dx[k];
				x = j + dy[k];
				if (x < 0 || y < 0 || x >= w || y >= h) continue;

				if (ban[y][x] == '#') cnt++;
			}
			ban[i][j] = '0' + cnt;
		}
	}
	
	for (i = 0; i < h; i++) printf("%s\n", ban[i]);

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
	int N;
	string S;
	string answer="";
	cin >> N >> S;
	int right=0,left=0;
	
	
	for(int i=0;i<N;i++){
		if(S[i]=='('){
			right++;
		}else{
			if(right>0){
				right--;
			}else{
				left++;
			}
		}
	}
	
	for(int i=0;i<left;i++){
		answer+='(';
	}
	answer+=S;
	for(int i=0;i<right;i++){
		answer+=')';
	}
	/*
	for(int i=0;i<N;i++){
		if(S[i]==')'){
			if(right>0){
				answer+=S[i];
				right--;
			}else{
				left++;
			}
		}else{
			for(int j=0;j<left;j++){
				answer+='(';
			}
			for(int j=0;j<left;j++){
				answer+=')';
			}
			left=0;
			right++;
			answer+=S[i];
		}
	}
	 
	for(int i=0;i<right;i++){
		answer+=')';
	}
	 */
	cout << answer << endl;
	
	return 0;
}

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

using namespace std;
#define ll long long
#define sz(x) (ll)(x.size())
#define f first
#define se second
int main() {
    ios::sync_with_stdio(0);
    ll x;
    cin>>x;
    if(x==3 || x==5 || x==7){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
}

Measured memory_bytes: 256
n = int(input())
T = 1
A = 1
for _ in range(n):
    i = 1
    t, a = map(int, input().split())
    i = max((T + t - 1) // t, (A + a -1) // a)
    T = i * t
    A = i * a
print(T + A)

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

#define int ll
#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define pb push_back
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
constexpr int inf = 1ll<<61;

struct node {
  ll v, d;
  node(ll _a, ll _b):v(_a),d(_b){}
  bool operator<(const node &n) const { return d > n.d; }
};
struct edge {
  ll to, d;
  edge(ll _to, ll _d):to(_to),d(_d){}
};
class dijkstra{
public:
  ll ans;

  dijkstra(ll s,ll t,vector<vector<edge>> &g,vector<vector<edge>> &f){ // sからtへの最短経路
    vector<vector<vector<edge>>> G(2);
    G[0] = move(g);
    G[1] = move(f);
    vvi dist(2,vi(G[0].size(),inf));
    vector<vector<bool>> visit(2,vector<bool>(G[0].size(),false));
  
    vector<priority_queue<node>> que(2);
    que[0].push(node(s,0));
    que[1].push(node(t,0));
    dist[0][s] = 0;
    dist[1][t] = 0;
    ll mu = inf;

    while(!que[0].empty() and !que[1].empty()){
      if(que[0].top().d + que[1].top().d > mu) break;
      rep(k,2){
     	ll v = que[k].top().v, d = que[k].top().d;
	que[k].pop();

	if(visit[k^1][v]) goto L;
	visit[k][v] = true;

	rep(i, G[k][v].size()){
	  auto n = G[k][v][i];
	  ll tmp = d + n.d;
	  if(dist[k][n.to] > tmp){
	    mu = min(mu, dist[k][v] + n.d + dist[k^1][n.to]);
	    dist[k][n.to] = tmp;
	    que[k].push(node(n.to, tmp));
	  }
	}
      }
    }
  L:
    g = move(G[0]);
    f = move(G[1]);

    ans = inf;
    rep(i,g.size()) ans = min(ans, dist[0][i]+dist[1][i]);
  }
};

main(){
  int k; cin >> k;
  vector<vector<edge>> g(k),f(k);
  rep(i,k){
    g[i].pb(edge((i+1)%k,1));
    g[i].pb(edge((i*10)%k,0));
    
    f[(i+1)%k].pb(edge(i,1));
    f[(i*10)%k].pb(edge(i,0));
  }
  dijkstra d(1,0,g,f);
  cout << d.ans+1 << endl;
}

Measured memory_bytes: 18544
import java.io.IOException;
import java.util.BitSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			boolean[][] map = new boolean[n][31];
			for (int i = 0; i < n; i++) {
				int f = scanner.nextInt();
				while (f-- > 0)
					map[i][scanner.nextInt()] = true;
			}
			int ans = -1;
			BitSet[] bit = new BitSet[n];
			for (int i = 0; i < n; i++) {
				bit[i] = new BitSet();
				bit[i].set(i);
			}
			loop:
			for (int t = 1; t <= 30; t++) {
				BitSet tmp = new BitSet();
				for (int i = 0; i < n; i++)
					if (map[i][t]) {
						tmp.or(bit[i]);
						if (tmp.cardinality() == n) {
							ans = t;
							break loop;
						}
					}
				for (int i = 0; i < n; i++)
					if (map[i][t])
						bit[i] = tmp;

			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 67116
#include <iostream>

using namespace std;

int main(void){

  int a, b;
  for(int i = 0 ; i < 4 ; i++){
    cin >> a >> b;
    switch(a){

    case 1:
      cout << 6000 * b << endl;
      break;
    case 2:
      cout << 4000 * b << endl;
      break;
    case 3:
      cout << 3000 * b << endl;
      break;
    case 4:
      cout << 2000 * b << endl;
      break;

    }
  }
  return 0;
}

Measured memory_bytes: 1160
n,k=map(int,input().split())
l=[0]*n
for i in range(k):
    x=int(input())
    d=list(map(int,input().split()))
    for i in d:
        l[i-1]+=1
c=0
for i in l:
    if(i==0):
        c=c+1
print(c)


Measured memory_bytes: 67808
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
#define pb push_back
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, K;
    cin >> N >> K;
    if (N % K == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll ans = 1;
    ll state = 2;
    rep(i,n-1){
        if(state == 2){
            if(a[i] < a[i+1]) state = 1;
            if(a[i] > a[i+1]) state = 0;
        }else if(state == 1){
            if(a[i] > a[i+1]){
                state = 2;
                ans++;
            }
        }else{
            if(a[i] < a[i+1]){
                state = 2;
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
/// @author MuSTAFA MOGHAZY
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool a [100+5];
int main()
{
  int a, b;
  cin>>a>>b;
  if( ((a%10) * (b%10)) % 2 == 0 ){
    cout<<"Even";
  }
  else
    cout<<"Odd";
}




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


int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  int ans = 0;
  int l = s.size();
  for (int i = 0; i < l/2; i++) {
    if (s[i] != s[l-i-1]) {
      ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
   string s;int k;
    cin>>k>>s;
    for(int i=0;i<s.length();i++)
    {
        if(char(s[i]+k)>'Z')cout<<char(s[i]+k-26);
        else cout<<char(s[i]+k);
    }



    return 0;
}


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


int main()
{
    int W, H, x, y;
    cin >> W >> H >> x >> y;


    cout << setprecision(9) << (double) W*H/2 << " ";

    if( x == W or y == H ){
        cout << 0 << endl;
        return 0;
    }
    if( 2*x == W and 2*y == H ){
        cout << 1 << endl;
        return 0;
    }
    if( 2*x == W or 2*y == H ){
        cout << 0 << endl;
        return 0;
    }

    if( H == W and y == x ){
        cout << 0 << endl;
        return 0;
    }
    if( H == W and y == H-x ){
        cout << 0 << endl;
        return 0;
    }

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

Measured memory_bytes: 256
/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define int ll
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int32_t main()
{
	prep();
	string s,t;
	cin>>s>>t;
	string p(t.begin(),t.end()-1);
	if(p==s) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 3652
using System;

namespace ABC157
{
    /// <summary>
    /// A - Duplex Printing
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            Console.WriteLine(Math.Ceiling(N / 2.0));
        }
    }
}


Measured memory_bytes: 27564
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
namespace path {
	vector<ll> dijkstra(int s, vector<vector<edge>>* G, ll INF = LLONG_MAX) {
		int V = (*G).size();
		vector<ll> d(V);
		fill(d.begin(), d.end(), INF);
		priority_queue<P, vector<P >, greater<P > > que;
		d[s] = 0;
		que.push(P(d[s], s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first)continue;
			for (edge e : (*G)[v]) {
				if (e.to < V && d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(P(d[e.to], e.to));
				}
			}
		}
		return d;
	}

	vector<vector<ll>> warshall_floyd(vector<vector<edge>>* G, ll INF = LLONG_MAX) {
		int V = (*G).size();
		vector<vector<ll>> d(V, vector<ll>(V, INF));
		for (int i = 0; i < V; i++) {
			d[i][i] = 0;
			for (edge e : (*G)[i]) {
				if (e.to < V) {
					d[i][e.to] = e.cost;
				}
			}
		}
		for (int k = 0; k < V; k++) {
			for (int i = 0; i < V; i++) {
				if (d[i][k] == INF)continue;
				for (int j = 0; j < V; j++) {
					if (d[k][j] == INF)continue;
					// 頂点iから頂点jへ行きたい。
					//   (頂点i, jの他には)頂点0～kのみを使える場合
					//     もしも頂点kを使わない場合は、頂点0～(k-1)のみを使える場合と同コスト
					//     頂点kを使う場合は、頂点iから頂点kまで頂点0～(k-1)以外を使わずに行くコストと、頂点kから頂点jまで頂点0～(k-1)以外を使わずに行くコストの和
					//   補足: 負の閉路がある <=> d[i][i]<0となるiが存在する
					//   　　: (負の閉路が存在しないならば)同じ頂点を２度通る必要はない
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
		return d;
	}
}
map<pair<ll,ll>, ll>mp;
ll solve(vector<ll>* r, vector<vector<ll>> *a,ll x, ll b) {
	if (x == 0)return 0;
	if (mp.find(P(x,b)) != mp.end()) {
		return mp[P(x,b)];
	}
	int R = (*r).size();
	ll res = LLONG_MAX;
	for (int i = 0; i < R; i++) {
		if (x & (1 << i)) {
			res = min(solve(r, a, x - (1 << i), (*r)[i]) + (*a)[(*r)[i]][b], res);
		}
	}
	return mp[P(x, b)] = res;
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int N, M, R;
	cin >> N >> M >> R;
	vector<ll> r(R);
	rep(i, R) {
		cin >> r[i];
		r[i]--;
	}
	vector<vector<edge>> G(200);
	rep(i, M) {
		int A, B, C;
		cin >> A >> B >> C;
		A--, B--;
		G[A].push_back({ B,C });
		G[B].push_back({ A,C });
	}
	auto a = path::warshall_floyd(&G);
	ll ans = LLONG_MAX;
	rep(i, R) {
		ans = min(ans, solve(&r, &a, (1 << (R)) - 1 - (1 << i), r[i]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main()
{
  int data[7][7]={
    {0,300,500,600,700,1350,1650},
    {6,0,350,450,600,1150,1500},
    {13,7,0,250,400,1000,1350},
    {18,12,5,0,250,850,1300},
    {23,17,10,5,0,600,1150},
    {43,37,30,25,20,0,500},
    {58,52,45,40,35,15,0}
  };
  int s;
  for(;cin>>s,s;)
    {
      int h,m,e;
      int start,end;
      cin>>h>>m;
      start=h*60+m;
      cin>>e;
      cin>>h>>m;
      end=h*60+m;
      if(s>e)
	swap(s,e);
      s--;e--;
      int ans;
      if((start>=17*60+30||end<=19*60+30)&&data[e][s]<=40)
       ans=data[s][e]/2;
      else
	ans=data[s][e];
      for(;ans%50!=0;)
	ans++;
      cout<<ans<<endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cctype>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define fast ios::sync_with_stdio(0)
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define ls rt<<1
#define rs rt<<1|1
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,a,b) for(int i=(a);i>=(b);--i)
#define FOR_edge(i)  for(int i=hd[u];i;i=e[i].nxt)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-8;
const double pi=acos(-1);
const int dx[]={1,-1,0,0};
const int dy[]={0,0,-1,1};

/////////////////////////////         IO         /////////////////////////////
void judge() {
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
inline char in() {
	static char buf[10001],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,10000,stdin),p1==p2)?EOF:*p1++;
}
template <class Tp> inline Tp read(register Tp &s) {
	s=0;
	register Tp w=1;
	register char c=in();
	while(c<'0'||c>'9') {if(c=='-')w=-1;c=in();}
	while(c>='0'&&c<='9') s=(s<<1)+(s<<3)+c-48,c=in();
	s*=w;
}
template <class Tp> inline void write(const Tp &x) {
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
template <class Tp> inline void print(register Tp x,const char &end) {
	if(x<0) putchar('-'),x=-x;
	write(x); putchar(end);
}

/////////////////////////////       Common       /////////////////////////////
template <class Tp> inline Tp POW(register Tp x,register Tp p,const Tp &mod) {
	register Tp res=1;
	for(;p;p>>=1,x=(x*x)%mod) if(p&1) res=(res*x)%mod;
	return res;
}
template <class Tp> inline Tp sqr(const Tp &x) {return x*x;}
template <class Tp> inline Tp gcd(const Tp &x,const Tp &y) {return(y==0?x:gcd(y,x%y));}
template <class Tp> inline void swap(register Tp &x,register Tp &y) {x^=y;y^=x;x^=y;}
template <class Tp> inline void _swap(register Tp &x,register Tp &y) {const Tp t=x;x=y;y=t;}
template <class Tp> inline Tp inv(const Tp &x,const Tp &mod) {return POW(x,mod-2,mod);}
template <class Tp> inline Tp lowbit(const Tp &x) {return x&-x;}

/////////////////////////////        Main        /////////////////////////////

int n,k,a[100005];
int main() {
//	judge();
	read(n);  read(k);
	FOR(i,1,n) read(a[i]);
	int a=(n-1)/(k-1);
	if(a*k-a+1<n)  ++a;
	write(a);
	return 0;
}

Measured memory_bytes: 640
import sys, math, itertools, bisect, copy, re

from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

# 10倍速いらしい
input = sys.stdin.readline

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

N = int(input())
S = input().strip()
L = [0] * 2 * N
D = []

cnt = 1
D.append('L')
L = [cnt]
for i, s in enumerate(S):
    if i == 0:
        continue
    if s == 'W':
        if cnt % 2 == 1:
            cnt += 1
            D.append('L')
        else:
            cnt -= 1
            D.append('R')
    else:
        if cnt % 2 == 1:
            cnt -= 1
            D.append('R')
        else:
            cnt += 1
            D.append('L')
    L.append(cnt)

if len(list(filter(lambda x: x < 0, L))) > 0 or L[-1] != 0:
    print(0)
    sys.exit()

ans = 1
for i in range(1, 2 * N):
    if D[i] == 'R':
        ans *= L[i - 1]
        ans %= MOD

for i in range(1, N + 1):
    ans *= i
    ans %= MOD

print(ans)

# print(D)
# print(L)


Measured memory_bytes: 18260
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int A, B, K, ans = 0;
	cin >> A >> B >> K;
	for (int i = min(A,B); i > 0; i--) {
		if (A % i == 0 && B % i == 0) {
			ans++;
			if (ans == K) {
				cout << i << endl;
			}
		}
	}
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N, M, C; cin >> N >> M >> C;
  vector<int> B(M); REP(i, M) cin >> B[i];
  vector<vector<int>> A(N, vector<int>(M));
  REP(i, N) {
    REP(k, M) {
      cin >> A[i][k];
    }
  }

  int cnt = 0;
  REP(i, N) {
    int tmp = 0;
    REP(k, M) {
      tmp = tmp + A[i][k] * B[k];
    }
    tmp += C;
    if(tmp > 0) cnt++;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
#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;}

const int mod=1000000007;

int N,K;

int dp[111][22222];

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

signed main(){
    cin>>N>>K;

    dp[N][0]=1;
    for(int i=N-1;i>=0;i--){
        for(int j=0;j<=K;j++){
            for(int k=0;k<11111;k++){
                if(dp[i+1][k]==0)continue;
                if(j>i+1){
                    add(dp[i][k],dp[i+1][k]);
                }
                else{
                    add(dp[i][k+(j+k)/(i+1)],dp[i+1][k]);
                }
            }
        }
    }

    int sum=0;
    for(int i=0;i<11111;i++)sum=(sum+dp[0][i]*i)%mod;

    int x=N*K*(K+1)/2;
    x%=mod;
    for(int i=0;i<N-1;i++)x=x*(K+1)%mod;

    cout<<(x-sum+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 16768
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    x %= b;
    cout << x << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	var n, k, x, y int
	fmt.Scan(&n, &k, &x, &y)
	ans := min(n, k)*x + max((n-k), 0)*y
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
	char op;
	int a[1000],b[1000],i,j,r[1000];
//	long r[1000];
	
	for(i=0;i<1000;i++){
//		printf("%c\n",op);
		scanf("%d %c %d",&a[i],&op,&b[i]);
//		printf("%c\n",op);
		if(op=='?') break;
		else if(op=='+') r[i] = a[i] + b[i];
		else if(op=='-') r[i] = a[i] - b[i];
		else if(op=='*') r[i] = a[i] * b[i];
		else if(op=='/'){
			if(b!=0) r[i] = a[i] / b[i];
			else i = i - 1;
		}
		
		else i = i - 1;
		
//		printf("%d\n",r[i]);
		
//		printf("%c\n",op);
	}
	
	for(j=0;j<i;j++){
		printf("%d\n",r[j]);
	}

	return 0;
}

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

int main(){
	ll a,b;
	cin >> a >> b ;
	cout << a* b << endl;
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[4000];
ll dp[3001][3001][2];

ll f(ll pos , ll n , ll i , ll j)
{
    if(i > j)
    {
       // cout << i << " " << j << "\n";
       return 0;
    }
   // cout << i << " " << j << "\n";
    if(dp[i][j][pos%2] != -1)
    return dp[i][j][pos%2];
    ll ans = -1e18;
    if((pos%2))
    {
        ans = max(ans , a[i] + f(pos+1 , n , i+1  , j));
        ans = max(ans , a[j] + f(pos+1 , n , i , j-1)); 
    }
    else
    {
        ans = 1e18;
       //  cout << i << " " << j << "  " << ans << "\n";
        ans = min(ans, -a[i] + f(pos+1 , n , i+1 , j));
        ans = min(ans , -a[j]+f(pos+1 , n , i , j-1));
       //  cout << i << " " << j << "  " << ans << "\n";
    }
    dp[i][j][pos%2] = ans;
    return ans;
}

int main() {
    
   ll n;
   cin >> n;
   for(ll i = 1 ; i <=  n ; i++)
   cin >> a[i];
   for(ll i = 0 ; i <= 3000 ; i++)
   {
       for(ll j = 0 ; j <= 3000 ; j++)
       {
           dp[i][j][0] = -1;
           dp[i][j][1] = -1;
       }
   }
    //cout << "hello" << "\n";
   cout <<  f(1 , n , 1 , n);

}


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

typedef long long ll;

int main(){
	ll n;
	cin >> n;
	ll ans;
	cin >> ans;
	for(int i=1; i<n; i++){
		ll a;
		cin >> a;
		ans = gcd(ans,a);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,b;
   cin>>n;
   char a[10001];
   cin>>a;
   b=strlen(a);
   for(int i=0;i<b;i++)
   {
       a[i]=a[i]+n;
       if(a[i]>90)
       {
           a[i]=(a[i]-26);
       }
   }
   cout<<a<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
//#define REPR(i, n) for(int i = n; i >= 0; i--)
//#define FOR(i, m, n) for(int i = m; i < n; i++)
//#define INF 1e9
// template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
// template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;

int main() { //int argc, const char * argv[]

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

    int n, a[9];
    string ans = "No";
   
    REP(i,9){
        cin >> a[i];
    }

    cin >> n;

    int b[n];
    REP(i,n){
        cin >> b[i];
        REP(j,9){
            if (b[i] == a[j]){
                a[j] =0;
            }
        }
    }
    
    if (a[0]==0 & a[4]==0 & a[8]==0){
        ans = "Yes";
    }

    if (a[2]==0 & a[4]==0 & a[6]==0){
        ans = "Yes";
    }

    if (a[0]==0 & a[1]==0 & a[2]==0){
        ans = "Yes";
    }

    if (a[3]==0 & a[4]==0 & a[5]==0){
        ans = "Yes";
    }

    if (a[6]==0 & a[7]==0 & a[8]==0){
        ans = "Yes";
    }

    if (a[0]==0 & a[3]==0 & a[6]==0){
        ans = "Yes";
    }

    if (a[1]==0 & a[4]==0 & a[7]==0){
        ans = "Yes";
    }

    if (a[2]==0 & a[5]==0 & a[8]==0){
        ans = "Yes";
    }


    cout << ans;
}


Measured memory_bytes: 256
n=int(input())
a,b=[],[]
for _ in range(n):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
ans=0
for i in range(n-1,0,-1):
    if a[i]%b[i]!=0: temp=b[i]+b[i]*(a[i]//b[i])-a[i]
    else: temp=0
    ans+=temp
    a[i-1]+=ans
if a[0]%b[0]!=0: ans+=b[0]+b[0]*(a[0]//b[0])-a[0]
print(ans)

Measured memory_bytes: 21700
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll x;
    cin >> x;

    ll y = x/500;
    ll z = x%500;
    ll a = z/5; 
    
    out(1000*y + 5*a);
    re0;
}

Measured memory_bytes: 256