akhauriyash/Code-Regression huggingface dataset:
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == "?":
        break
    if op == "+":
        print(a + b)
    if op == "-":
        print(a - b)
    if op == "*":
        print(a * b)
    if op == "/":
        print(a // b)


Measured memory_bytes: 5596
local k, a, b = io.read("*n", "*n", "*n")
if k <= a then
  print(1)
elseif a <= b then
  print(-1)
else
  if (k - a) % (a - b) == 0 then
    print((k - a) // (a - b) * 2 + 1)
  else
    print((k - a) // (a - b) * 2 + 3)
  end
end

Measured memory_bytes: 760
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main(){
	int N, M, Q;
	vector<int> va[500];
	cin >> N >> M >> Q;
	for(int i = 0; i < M; i++){
		int L, R;
		cin >> L >> R;
		L--; R--;
		va[L].push_back(R);
	}
	for(int i = 0; i < N; i++){
		sort(va[i].begin(), va[i].end());
	}
	for(int i = 0; i < Q; i++){
		int p, q;
		cin >> p >> q;
		p--; q--;
		int res = 0;
		for(int j = p; j <= q; j++){
			res += upper_bound(va[j].begin(), va[j].end(), q) - va[j].begin();
		}
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 2176
N,K=map(int,raw_input().split())
c=[0]*N
for i in range(N):
	a,b=map(int,raw_input().split())
	c[i]=(a,b)
c.sort()
i,j=0,0
while i<=K-1:
	i+=c[j][1]
	if i>=K:break
	j+=1
print c[j][0]

Measured memory_bytes: 18436
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 1e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
vector<ll> R[550010];
vector<pair<ll, double> > tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<"\n";
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,f,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
ll dp[5005][5005];
char s[500005];
char t[500005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> a >> b;
    p(6 - a - b);
    return 0;
}















Measured memory_bytes: 39424
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

ll safemod(ll a, ll k){ return (a%k+k)%k; }

int main(){
    Init();
    ll n, k; cin >> n >> k;
    vi a(n+1), sum(n+1);
    // 累積和の計算
    repf(i, n){
        cin >> a[i];
        sum[i] = safemod(a[i]+sum[i-1], k);
    }
    if(k == 1){ cout << 0 << endl; return 0; }
    ll cnt = 0;
    map<ll, ll> occ;
    for(ll j=1; j<=n; j++){
        if(j == 1){
            for(ll i=max(0LL, j-k); i<j; i++) occ[safemod(sum[i]-i, k)]++;
            cnt += occ[safemod(sum[j]-j, k)];
        }
        else{
            if(j-k >= 0) occ[safemod(sum[j-k]-(j-k), k)]--;
            occ[safemod(sum[j-1]-(j-1), k)]++;
            cnt += occ[safemod(sum[j]-j, k)];
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 18732
import java.util.*;

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

        int N = sc.nextInt();
        int[] A = new int[N];
        int[] L = new int[N + 1];
        int[] R = new int[N + 1];
        L[0] = 0;
        R[N] = 0;

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

        for(int i=0; i<N; i++){
            if(i==0){
                L[i + 1] = A[i];
                continue;
            }
            L[i + 1] = getCommonDivisor(L[i], A[i]);
        }
        for(int i=N-1; i>=0; i--){
            if(i==N-1){
                R[i] = A[i];
                continue;
            }
            R[i] = getCommonDivisor(R[i+1], A[i]);
        }
        int max = 0;
        for(int i=0; i<N; i++){
            if(i==0){
                max = Math.max(max, R[i + 1]);
                continue;
            }
            if(i==N-1){
                max = Math.max(max, L[i]);
                continue;
            }
            max = Math.max(max, getCommonDivisor(L[i], R[i + 1]));
        }
        System.out.println(max);
    }

    

    private static int getCommonDivisor(int x, int y){
        int bigger = Math.max(x, y);
        int smaller = Math.min(x, y);
        int surplus = bigger % smaller;
        
        if(surplus==0){
            return smaller;
        }
        surplus = getCommonDivisor(smaller, surplus);

        return surplus;
    }
}

Measured memory_bytes: 62096
#include <iostream>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main()
{
  string s;
  REP(i, 3) {
    cin >> s;
    cout << s[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;


int main()
{
	long long int a, b;

	cin >> a >> b;

	if((a + b) % 2 == 0)
		cout << (a + b) / 2 << endl;
	else
		cout << "IMPOSSIBLE" << endl;

	return 0;

}

Measured memory_bytes: 256
fun main(args: Array<String>) = yorukatsu23e()

fun yorukatsu23e() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val pList = readLine()!!.split(' ').map { it.toInt() - 1 }
    val xyList = (1..m).map {
        readLine()!!.split(' ').map { it.toInt() - 1 }.let { it[0] to it[1] }
    }

    val unionFind = UnionFind(n)
    xyList.forEach {
        val (i, i1) = it
        unionFind.unite(i, i1)
    }

    val answer = pList.withIndex().count { unionFind.isSame(it.index, it.value) }

    println(answer)
}

private class UnionFind(initSize: Int) {
    private val parent = IntArray(initSize) { it }
    private val size = LongArray(initSize) { 1L }

    fun root(x: Int): Int {
        if (x == parent[x]) return x

        val xr = root(parent[x])
        parent[x] = xr
        return xr
    }

    fun unite(x: Int, y: Int) {
        val xr = root(x)
        val yr = root(y)
        if (xr == yr) return

        if (size[xr] >= size[yr]) {
            size[xr] += size[yr]
            parent[yr] = xr
        } else {
            size[yr] += size[xr]
            parent[xr] = yr
        }
    }

    fun isSame(x: Int, y: Int): Boolean = root(x) == root(y)

    fun size(x: Int): Long = size[root(x)]
}


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

using namespace std;
int n,k,ans,i;
int a[1005];
int main()
{
    cin>>n>>k;
    for(i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1, a+n+1);
    for(i=1;i<=k;i++)
        ans+=a[i];
    cout<<ans;
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long uLL;
typedef long double ldb;
typedef pair<int,int> pii;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s, t;
    cin>>s>>t;
    reverse(s.begin(), s.end());
    cout<<(s==t ? "YES" : "NO")<<endl;
    return 0;
}


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

mod = 10**9+7

S = 0
T = 0
for a in A:
    S = (S+a  )%mod
    T = (T+a*a)%mod

ans = (S*S-T)%mod
print(ans*pow(2, mod-2, mod)%mod)


Measured memory_bytes: 31748
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
xs = list(map(int, input().split()))
G = [set() for _ in range(N+1)]
es = []
for i in range(M):
    u, v = sorted(map(int, input().split()),key=lambda x:[xs[x-1],-x])
    G[v].add(u)
    es.append((v,u))
xs,d,cc = sorted([(x,i+1) for i, x in enumerate(xs)]),{},{}
#for i in range(N):
#    if not G[i+1]:
#        print(-1)
#        sys.exit()
for x, u in xs:
    if u in cc:
        continue
    if not G[u]:
        print(-1)
        sys.exit()
    cc[u] = 1
    for c in G[u]:
        if c in cc:
            cc[u] = 1-cc[c]
    S = [u]
    while S:
        q = S.pop()
        for c in G[q]:
            d[(q,c)] = x
            if c in cc: continue
            S.append(c)
            cc[c] = 1-cc[q]
print("".join("BW"[cc[i]] for i in range(1,N+1)))
for i in range(M):
    print(d[es[i]])

Measured memory_bytes: 135708
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,m,k; cin>>n>>m>>k;
	rep(i,n+1){
		rep(j,m+1){
			int b=i*m+j*n-2*i*j;
			if(b==k) return cout<<"Yes"<<endl,0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
 
vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];


int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    to[u].push_back({v, w});
    to[v].push_back({u, w});
  }
   //bfs
    queue<int> que;
    que.push(0);
    visited[0] = true;
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        ll d = dist[v];
        for (auto p : to[v]) {
            if (visited[p.first]){ continue;}
            dist[p.first] =  d+p.second;
            que.push(p.first);
            visited[p.first] = true;
        }
    }
  for (int i = 0; i < N; i++) cout << dist[i] % 2 << endl;
}


Measured memory_bytes: 10424
def A():
    s = input()
    if s == 'SSS': print(0)
    elif s=='RRR': print(3)
    elif s=='RRS' or s=='SRR': print(2)
    else: print(1)

def B():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    for i in range(n):
        for j in range(i+1, n):
            if a[i] == a[j]: continue
            for k in range(j+1, n):
                if a[i]==a[k] or a[j] == a[k]: continue
                s = a[i] + a[j] + a[k]
                if s > 2 * max(a[i], a[j], a[k]):
                    cnt += 1
    print(cnt)

def C():
    x, k, d = map(int, input().split())
    if abs(x) > k * d:
        print(abs(x) - k*d)
    else:
        tm = abs(x) // d
        x = abs(x) % d
        k -= tm
        if k % 2 == 0:
            print(x)
        else:
            print(d-x)
C()


Measured memory_bytes: 62112
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int A[3][101] = { 0 };

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

    for (int i = 1; i <= 2; i++) {
        for (int j = 1; j <= N; j++) {
            int aij;
            cin >> aij;
            A[i][j] = aij;
        }
    }

    int mcnt = 0;
    for (int t = 1; t <= N; t++) {
        int cnt = 0;
        for (int j = 1; j <= N; j++) {
            if (t == j) {
                cnt += A[1][j];
                cnt += A[2][j];
            } else if (j < t) {
                cnt += A[1][j];
            } else {
                cnt += A[2][j];
            }
        }
        mcnt = max(mcnt, cnt);
    }

    cout << mcnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 10;
const int mod = 998244353;
typedef long long ll;
#define lowbit(i) (i & (-i))
ll sum[maxn];
int n,m,k,a[maxn],s,dp[maxn];
int main() {
	scanf("%d%d",&n,&s);
	for (int i = 1; i <= n; i++)
		scanf("%d",&a[i]);
	int ans = 0;
  	//dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = s; j >= a[i]; j--)
			dp[j] = (dp[j] + dp[j - a[i]]) % mod;
		dp[a[i]] = (dp[a[i]] + i) % mod;
      	ans = (ans + dp[s]) % mod;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const ULL MOD = 1e10;

int main(void) {
    ULL h, w, n;
    cin >> h >> w >> n;
    vector<ULL> p(n);
    vector<ULL> ans(10, 0);
    ans[0] = (h-2) * (w-2);
    
    auto cnt = [&](ULL a, ULL b) -> ULL {
        int da[3] {-1, 0, 1};
        int db[3] {-1, 0, 1};
        ULL ret = 0;
        for(int i=0; i<3; ++i) {
            for(int j=0; j<3; ++j) {
                if(a+da[i] < 1 || a+da[i] > h || b+db[j] < 1 || b+db[j] > w) continue;
                ULL key = (a+da[i])*MOD + (b+db[j]);
                if(binary_search(p.begin(), p.end(), key)) ++ret;
            }
        }
        return ret;
    };
    
    for(ULL i=0; i<n; ++i) {
        ULL a, b;
        cin >> a >> b;
        p[i] = a*MOD + b;
    }
    sort(p.begin(), p.end());
    
    for(ULL i=0; i<n; ++i) {
        ULL a = p[i]/MOD;
        ULL b = p[i]%MOD;
        int da[3] {-1, 0, 1};
        int db[3] {-1, 0, 1};
        for(int i=0; i<3; ++i) {
            for(int j=0; j<3; ++j) {
                if(!(a+da[i] < 2 || a+da[i] > h-1 || b+db[j] < 2 || b+db[j] > w-1)) {
                    ans[cnt(a+da[i], b+db[j])] += 1;
                }
            }
        }
    }
    
    ULL sum = 0;
    for(int i=1; i<=9; ++i) {
        ans[i] /= i;
        sum += ans[i];
    }
    ans[0] -= sum;
    for(int i=0; i<=9; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
    int H, W, i, k;
    char a, b;
    while(scanf("%d%d", &H,&W), H!=0 || W!=0){
        for(i=0;i<H;i++){
            switch(i%2){
                case 0:
					a='#'; b='.';
					break;
                case 1:
					a='.'; b='#';
					break;
				default:
					break;
            }
            for(k=0;k<W;k++){
                switch(k%2){
                    case 0:
						printf("%c", a);
						break;
                    case 1:
						printf("%c", b);
						break;
					default:
						break;
                }
            }
            puts("");
        }
        puts("");
    }
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in();
	int H[101*101];
	int x,y,h;
	int read = 0;
	do{
		read++;
		x=in(),y=in(),h=in();
		for(int i=0;i<=100;i++){
			for(int j=0;j<=100;j++){
				H[j+101*i] = h+abs(x-j)+abs(y-i);
			}
		}
	}while(h<1);
	int ai=y,aj=x,ah=h;
	REP(n,N-read){
		int num = 0;
		x=in(),y=in(),h=in();
		if(h==0) continue;
		for(int i=0;i<=100;i++){
			for(int j=0;j<=100;j++){
				int z = h+abs(x-j)+abs(y-i);
				if(H[j+101*i]>0 && H[j+101*i]==z){
					num++;
					ai=i,aj=j,ah=z;
				}
				else{
					H[j+101*i] = -1;
				}
			}
		}
		if(num==1) break;
	}

	cout << aj << ' ' << ai << ' ' << ah << endl;
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  int n=999;
  for(int i=0;i<s.length()-2;i++) n=min((int) abs((s[i]-'0')*100 + (s[i+1]-'0')*10 + s[i+2]-'0'-753),n);
  cout<<n;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

const int M=1e9+7;

signed main(void)
{
  in(int,n);
  int i;
  ll sum=1;
  rep(i,n)
    sum=(sum*(i+1))%M;
  putv(sum);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<stack>
#include<algorithm>
#include<string>
#include<string.h>
#include<assert.h>
#include<iomanip>
#include<cmath>
#define F first
#define S second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;

int n;
int ar[15];

void bf(int len, string ans, int mx){
    if(len > n){
        cout << ans << endl;
        return;
    }

    for(int i = 1; i <= mx + 1; ++i){
        string nx = ans + (char)(i - 1 + 'a');
        if(i <= mx)bf(len + 1, nx, mx);
        else bf(len + 1, nx, mx + 1);
    }
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    bf(1, "", 0);
}

/*
2 3 2
*/

Measured memory_bytes: 1536
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;


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

	cin >> W>>H;
	while (H) {
		N = 0;
		vector<vector<int>>field(H + 2, vector<int>(W + 2, 0));
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> field[i][j];
			}
		}
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				queue<pair<int, int>>Q;
				if (field[i][j]) {
					field[i][j] = 0;
					Q.push({ i,j });
					N++;
					while (!Q.empty()) {
						int cy = Q.front().first;
						int cx = Q.front().second;
						//cout << N << " " << cy << " " << cx << endl;
						Q.pop();
						
						for (int k = -1; k <= 1; k++) {
							for (int l = -1; l <= 1; l++) {
								if (field[cy + k][cx + l]) {
									field[cy + k][cx + l] = 0;
									Q.push({ cy + k,cx + l });
								}
							}
						}
					}
				}
			}
		}
		cout << N << endl;
		cin >> W >> H;
	}
	return 0;
}

Measured memory_bytes: 3176
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	string s, t; cin >> s >> t;
	int n = s.length(), m = t.length(), ans = INT_MAX;

	for (int i = 0; i + m - 1 <= n - 1; i++) {
		string ss = s.substr(i, m);

		int cost = 0;
		for (int j = 0; j <= m - 1; j++) cost += (ss[j] != t[j]);

		ans = min(ans, cost);
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long double a, b, x, out;
    cin >> a >> b >> x;

    long double bound= a*a*b/2;
    if (bound < x) {
        out = atan((pow(a, 3.0))/(2.0*(((pow(a, 2.0))*b)-x)));
    } else {
        out = atan(2.0 * x / (a * pow(b, 2.0)));
    }
   
    cout << setprecision(10) << 90.0 - (180.0 * out / M_PI) << endl;
    return 0;
}


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

const int N=1e5+5;

int n, ans=0;
string s;
vector<char> v;

bool check(char ch)
{
	if(v.size()==1)
		return 0;
	int sz=v.size();
	if(v[sz-2]==ch)
		return 0;
	v.pop_back();
	ans++;
	return 1;
}

int32_t main()
{
	IOS;
	cin>>s;
	n=s.size();
	v.push_back(s[0]);
	for(int i=1;i+1<n;i++)
	{
		while(check(s[i]));
		if(v.back() != s[i+1])
			ans++;
		else
			v.push_back(s[i]);
	}
	while(check(s[n-1]));
	if(ans%2)
		cout<<"First";
	else
		cout<<"Second";
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
ll gcd(ll a, ll b)
{
    if (a < b)
    {
        ll o;
        o = a;
        a = b;
        b = o;
    }
    while (b != 0)
    {
        //小さい方を常にどっちかにする
        ll y;
        y = b; //bの値を保存しておく
        b = a % b;
        a = y; //常に大きい方がaとなっている
    }
    return a;
}
map<ll, ll> insu;
void bunkai(ll n)
{
    ll a = 2; //割る数
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            insu[a] += 1;
            n /= a;
        }
        else
        {
            a++;
        }
    }
    // 最後に残った n は素因数
    insu[n] += 1;
}

int main()
{
    ll a, b;
    cin >> a >> b;
    ll d = gcd(a, b); //dの約数の組を考えれば良い。
    //d=10^12
    //公約数を求める方法が知りたい→素因数分解かな？
    bunkai(d); //素数の組が]
    ll c = 0;
    for (auto g : insu)
    {
        c += 1;
    }

    if (d == 1)
    {
        cout << c << endl;
    }
    else
    {
        cout << c + 1 << endl;
    }
}

Measured memory_bytes: 256
"use strict";

const main = arg => {
  const input = arg.trim().split("\n")[0];
  if (input.substring(2,3) === input.substring(3,4) && input.substring(4,5) === input.substring(5,6)) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29648
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <ctime>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <fstream>
#include <cassert>

using namespace std;

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, b, a) for(int i = b - 1; i >= a; --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)

#define ALL(V) V.begin(), V.end()
#define SIZE(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define EPS 1e-7
#define Pi 3.14159265358979
#define FILL(a,v) memset(a,v,sizeof(a))

using namespace std;


typedef long long Long;
typedef unsigned long long ULong;
typedef unsigned int Uint;
typedef unsigned char Uchar;
typedef vector <int> VI;
typedef pair <int, int> PII;


int main() {
    ios_base::sync_with_stdio(false);
    int prev = -1;
    int ans = 0;
    int cur = 0;
    int n,t;
    cin >> n;
    REP(i,n) {
        cin >> t;
        if (t == prev)
            ++ cur;
        else {
            ans += cur/2;
            prev = t;
            cur = 1;
        }
    }

    ans += cur/2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  string s;cin>>s;
  int a = 0;
  for(int i = 0; 3 > i; i++){
    if(s[i] == 'o')a++;
  }
  cout << 700+100*a;
}

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

int main(){
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    unsigned long mx{0}, g{0};
    for(unsigned long i{0}, A; i < N; ++i){
        cin >> A;
        mx = max(mx, A);
        g = __gcd(g, A);
        if(mx >= K && K % g == 0)return 0 & puts("POSSIBLE");
    }
    puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t h;
  cin >> h;
  int64_t ans=0;
  int64_t t=1;
  while(h){
    h/=2;
    ans+=t;
    t*=2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>

using namespace std;

#define cn cout << '\n'
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

int main() {
    cio;
    int n;
    cin >> n;
    ll ar[n];
    for (int i = 0; i < n; ++i)
        cin >> ar[i];

    int a,b,c, x = 0;
    for (int i = 0; i < n; ++i)
        for (int j = i+1; j < n; ++j) {
            if (j == j+1) continue;
            for (int l = j+1; l < n; ++l) {
                if (l == j || l == i) continue;
                a = ar[i]; b = ar[j]; c = ar[l];
                if (a < b+c && b < c+a && c < a+b)
                    x++;
            }
        }

    cout << x;
    cn;
}


Measured memory_bytes: 3164
#include <stdio.h>

int main(void){
  int a, b, c, x;
  scanf("%d%d%d%d", &a, &b, &c, &x);
  int count = 0;
  int i, j, k;
  for(i = 0; i <= a; i++){
    for(j = 0; j <= b; j++){
      for(k = 0; k <= c; k++){
        if(500 * i + 100 * j + 50 * k == x) count++;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}

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

int main(void){
    vector<int> A(3);
    cin>>A.at(0)>>A.at(1)>>A.at(2);
    sort(A.begin(),A.end());
    cout<<A.at(0)<<" "<<A.at(1)<<" "<<A.at(2)<<endl;

}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

void dfs(vector<vector<int>> &tree, vector<int> &cost, vector<int> &ans, int now, int bf, ll cos){
	ll add = cos + cost.at(now);
	ans.at(now) = add;
	for(auto i : tree.at(now)){
		if(i == bf) continue;
		dfs(tree, cost, ans, i, now, add);
	}
}

int main(){
	int n, q;
	cin >> n >> q;
	vector<vector<int>> tree(n, vector<int>());
	rep(i, n-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		tree.at(a).push_back(b);
		tree.at(b).push_back(a);
	}
	vector<int> cost(n, 0);
	rep(i, q){
		int p, x;
		cin >> p >> x;
		p--;
		cost.at(p) += x;
	}
	vector<int> ans(n, 0);
	dfs(tree, cost, ans, 0, -1, 0);
	rep(i, n){
		if(i != 0) cout << " ";
		cout << ans.at(i);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 30464
import java.util.Scanner;

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

    long X = scanner.nextLong();
    long a = 100;
    int t = 0;
    while (a < X) {
      a += a / 100;
      t++;
    }
    System.out.println(t);
  }
}


Measured memory_bytes: 27056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

ll a, b, x;

ll f(ll n)
{
    if (n == -1)
    {
        return 0;
    }
    else
    {
        return ll(n / x) + 1;
    }
}

int main()
{
    int a_flg = 0, b_flg = 0;
    cin >> a >> b >> x;
    cout << f(b) - f(a - 1) << endl;
    return 0;
}


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

using namespace std;

int main(void) {
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);

    if ( A * C <= B) {
        printf("%d\n", C);
    } else {
        printf("%d\n", B/A);
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if(N==1){
  	cout << "Hello World" << endl;
  }else if(N == 2){
  	int A,B;
    cin >> A >> B;
    cout << A+B << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
  int a,b;
  int sum;
  int digit=7;

  while(cin >> a >> b)
    {
      sum=a+b;
      
      for(int i=1000000;i>=1;i=i/10)
	{
	  
	  if(sum==0)
	    {
	      cout << 1 <<endl;
	      break;
	    }
	  
	  if(sum/i>0)
	    { cout << digit <<endl;break;}

	  digit--;
	}

      digit=7;
    }

  return 0;

}


Measured memory_bytes: 3084
#include <iostream>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N=1e6+7;
typedef long long ll;
int n;
ll x;
int main()
{
    std::ios::sync_with_stdio(0);cout.tie(0);
    std::cin>>n;
    ll flag=0,ans=0;
    rep(i,1,n){
        std::cin>>x;
        if(i==1) flag=x,ans=1;
        else{
            if(flag>x) ans++,flag=x;
        }
    }
    std::cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int h, w, d;
  cin >> h >> w >> d;
  vector<vector<int>> a(h, vector<int>(w));
  vector<int> dist(h * w + 1), par(h * w + 1);
  vector<pii> mp(h * w + 1);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      mp[a[i][j]] = pii{i, j};
    }
  }
  for (int i = 1; i <= d; i++) {
    dist[i] = 0;
    par[i] = i;
  }
  for (int i = d + 1; i <= h * w; i++) {
    par[i] = par[i - d];
    dist[i] = dist[i - d] + abs(mp[i].fi - mp[i - d].fi) + abs(mp[i].se - mp[i - d].se);
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int u, v;
    cin >> u >> v;
    cout << abs(dist[u] - dist[v]) << "\n";
  }
}



Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    vector<int> v{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1};
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        int ans = INF<int>, jj = 0, kk = 0;
        for (int j = 0; j < v.size(); ++j) {
            for (int k = j+1; k < v.size(); ++k) {
                if(v[j] == a && v[k] == b){
                    if(ans > abs(j-k)){
                        ans = abs(j-k);
                        jj = j; kk = k;
                    }
                }
            }
        }
        for (int j = jj; j <= kk; j++) {
            if(j != jj) printf(" ");
            printf("%d", v[j]);
            if(j == kk) break;
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 3088
N, M = list(map(int, input().split(" ")))
S = []
for i in range(M):
    ks = list(map(int, input().split(" ")))
    S.append(ks[1:])
P = list(map(int, input().split(" ")))

switchMap = []
for i in range(N):
    switchMap.append([])
for i, s in enumerate(S):
    for ss in s:
        switchMap[ss-1].append(i)

count = 0
for i in range(pow(2, N)):
    switches = bin(i).replace("0b", "").zfill(N)
    light = [0] * M
    for j, switch in enumerate(switches):
        if switch == '1':
            for s in switchMap[j]:
                light[s] += 1

    flag = True
    for j, l in enumerate(light):
        if l % 2 != P[j]:
            flag = False
            break

    if flag:
        # print(switches)
        count += 1

print(count)


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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; i++) {
        cin >> x.at(i);
    }

    sort(x.begin(),x.end()); 
    int sum = 0;
    if (n < m) {
        vector<int> dist(m - 1);
        sum = x.at(m - 1) - x.at(0);
        for (int i = 0; i < m - 1; i++) {
            dist.at(i) = max(x.at(i), x.at(i + 1)) - min(x.at(i), x.at(i + 1));
        }
        sort(dist.begin(), dist.end());
        reverse(dist.begin(),dist.end());
        for (int i = 0; i < n - 1; i++) {
            sum -= dist.at(i);
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#define MOD 998244353
using namespace std;

int main()
{
	/*
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	*/

	int x;
	scanf("%d", &x);

	for (int i = 1; i <= 360; i++)
	{
		if ((x * i) % 360 == 0)
		{
			printf("%d", i);
			break;
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s;
  int k;
  cin>>k>>s;
  if(s.size()<=k){
    cout<<s<<endl;
  }
  else{
    cout<<s.erase(k)<<"..."<<endl;
  }
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NAB = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var A = NAB[1];
            var B = NAB[2];
            var S = Console.ReadLine();
            var abcnt = 0;
            var bcnt = 0;
            for(var i=0;i<NAB[0];i++)
            {
                if (S[i] == 'b' && bcnt < B && abcnt < A + B)
                {
                    Console.WriteLine("Yes");
                    bcnt++;
                    abcnt++;
                    continue;
                }
                if (S[i] == 'a' && abcnt < A + B)
                {
                    Console.WriteLine("Yes");
                    abcnt++;
                    continue;
                }
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 15968
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

string S, T;
map<char, int> s1, t1;

int main(){
    cin >> S >> T;
    
    for ( int i = 0; i < S.size(); i++) {
        s1[S[i]]++;
        t1[T[i]]++;
    }
    
    for ( int i = 0; i < S.size(); i++) {
        if ( s1[S[i]] != t1[S[i]]) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    for ( int i = 0; i <= S.size(); i++) {
        if ( S==T ) {
            cout << "Yes" << endl;
            return 0;
        } else {
            T = T[T.size()-1] + T.substr(0, T.size()-1);
        }
    }
    
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl = vector<ll>; using vvl = vector<vl>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main() {
  string s,t;cin >> s >> t;
  int Ans = 0;
  rep(i,s.size()) if(s[i] != t[i]) Ans++;
  cout << Ans << endl;
}

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

int main () {
  int a,b;
  char c;
  cin>>a>>c>>b;
  if(c=='+'){
    cout<<a+b<<endl;
  }
  if(c=='-'){
    cout<<a-b<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline")
#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);}
}

#define int long long

int n,cnt[100][100],ma2,ma5,ans1,ans2;

signed main(){
	read(n);
	for(int i=1;i<=n;i++){
		double x;
		scanf("%lf",&x);
		int y=(int)(x*1e9+0.5),cnt2=0,cnt5=0;
		while(y%2==0) y/=2,cnt2++;
		while(y%5==0) y/=5,cnt5++;
		cnt[cnt2][cnt5]++;
		ma2=max(ma2,cnt2);
		ma5=max(ma5,cnt5);
	}
	for(int i=0;i<=ma2;i++) for(int j=0;j<=ma5;j++) if(cnt[i][j])
		for(int x=0;x<=ma2;x++) for(int y=0;y<=ma5;y++) if(cnt[x][y]&&min(i+x,j+y)>=18)
			i==x&&j==y?ans1+=cnt[i][j]*(cnt[i][j]-1)/2:ans2+=cnt[i][j]*cnt[x][y];
	write(ans2/2+ans1);
}

Measured memory_bytes: 3764
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>
#include<atcoder/segtree>




using namespace std;
using namespace atcoder;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 998244353;

vector<vector<int> > g;
vector<int> used;

void dfs(int pos) {
    used[pos] = 1;
    for (auto to:g[pos]) {
        if (used[to])
            continue;
        dfs(to);
    }
}

void solve() {
    int n, m;
    cin >> n >> m;
    g.assign(n, vector<int>());
    int a, b;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int c = 0;
    used.assign(n, 0);
    for (int i = 0; i < n; ++i) {
        if (used[i])
            continue;
        ++c;
        dfs(i);
    }
    cout << c - 1 << endl;

}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 9540
a, b, k = map(int , input().split())
a_list = []
b_list = []

for i in range(1,a+1):
    if a % i == 0:
        a_list.append(i)
for i in range(1,b+1):
    if b % i == 0:
        b_list.append(i)
print(sorted(list(set(a_list) & set(b_list)))[::-1][k-1])



Measured memory_bytes: 3060
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int x = cin.ReadInt;
            int y = cin.ReadInt;

            Console.WriteLine(x + y / 2);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;

        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(),a.end());
  
  for(int i=0;i<n-1;i++){
    if(a.at(i) == a.at(i+1)){
      cout << "NO" << endl;
      return(0);
    }
  }
  
  cout << "YES" << endl;
  return(0);
}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    string t = "2018";
    rep(i,4){
        s[i] = t[i];
    }
    cout << s << endl;
}


Measured memory_bytes: 256