akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            int num = sc.nextInt();
            if (map.containsKey(num)) {
                map.put(num, map.get(num) + 1);
            } else {
                map.put(num, 1);
            }
        }
        int ans = 0;
        for (int num : map.keySet()) {
            if (map.get(num) % 2 != 0) {
                 ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 60524
#include "bits/stdc++.h"
using namespace std;

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

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




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


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}

template<typename T>
ll com(T n, T m, T mod){
  ll a = 1, b = 1, ans;
  if(n == m || m == 0){
    ans = 1;
  }else{
    for(ll i = 0;i < m; i++){
      a *= n-i;
      a %= mod;
      b *= i+1;
      b %= mod;
    }
    ans = (a * powmod(b, mod-2, mod)) % mod;
  }
  
  return ans;
}



 
int main() {
  string S;

  cin >> S;

  string ans = S.substr(0, 3);

  cout << ans << endl;
  
  // cout << setprecision(8) << ans << endl;  // For double
}



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

class Point
{
    private:
        int x, y;

    public:
        Point( int x = 0, int y = 0 );
        void setXY( int a, int b ){ x = a; y = b; }
        int getX(){ return x; }
        int getY(){ return y; }
        bool operator==( Point a );
        Point operator+( Point a );
        Point operator-( Point a );
};

Point::Point( int a, int b )
{
    x = a;
    y = b;
}

bool Point::operator==( Point a )
{
    if( x == a.x && y == a.y )
        return true;
    else
        return false;
}

Point Point::operator+( Point a )
{
    Point res;
    res.x = x + a.x;
    res.y = y + a.y;
    
    return res;
}

Point Point::operator-( Point a )
{
    Point res;
    res.x = x - a.x;
    res.y = y - a.y;
    
    return res;
}


int main()
{
    int n, m, x, y;

    while( cin >> n )
    {
        if( !n )
            break;

        Point a[n];
        for( int i = 0; i < n; i++ )
        {
            cin >> x >> y;
            a[i].setXY( x, y );
        }

        cin >> m;

        Point b[m];
        for( int i = 0; i < m; i++ )
        {
            cin >> x >> y;
            b[i].setXY( x, y );
        }

        Point c[m];
        for( int i = 0; i < m; i++ )
            c[i] = b[i] - a[0];

        for( int i = 0; i < m; i++ )
        {
            bool judge = true;
            for( int j = 0; j < n; j++ )
            {
                Point d = a[j] + c[i];

                bool judge2 = false;
                for( int k = 0; k < m; k++ )
                    if( d == b[k] )
                        judge2 = true;
                
                if( !judge2 )
                    judge = false;
            }
                
            if( judge )
            {
                cout << c[i].getX() << " " << c[i].getY() << endl;
                break;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3032
/*
* @Author: kabbo
* @Date:   2020-05-10 17:38:56
* @Last Modified by:   kabbo
* @Last Modified time: 2020-05-10 18:00:57
*/
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define endl '\n'
#define ull unsigned long long
#define ll long long
const int mod = 1e9 + 7;
using u64 = uint64_t;
using u128 = __uint128_t;
void solve() {
	int n;
	cin >> n;
	int W;
	cin >> W;
	vector<ll>val(n + 1);
	vector<ll>wt(n + 1);
	//ull dp[W + 1] = {0};
	for (int i(0); i < n; ++i) {
		cin >> wt[i];
		cin >> val[i];

	}

	ll K[n + 1][W + 1];

	// Build table K[][] in bottom up manner
	for (int i = 0; i <= n; i++)
	{
		for (int w = 0; w <= W; w++)
		{
			if (i == 0 || w == 0)
				K[i][w] = 0;
			else if (wt[i - 1] <= w)
				K[i][w] = max(val[i - 1] + K[i - 1][w - wt[i - 1]],  K[i - 1][w]);
			else
				K[i][w] = K[i - 1][w];
		}
	}

	cout << K[n][W] << endl;
}



int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	/*int t;
	cin >> t;
	for (int i(1); i <= t; ++i) {
		printf("Case %d: ", i);*/
	solve();
	//}
#ifndef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
	return 0;
}

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

struct UnionFind {
    vector<int> data;
    int sz;
    UnionFind(int _sz) : data(_sz, -1), sz(_sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x; sz--;
        return true;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return sz; }
};

int main(){
    int N, Q;
    cin >> N >> Q;
    UnionFind uf(N);
    for(int i = 0; i < Q; i++){
        int a, b, z;
        cin >> a >> b >> z;
        --a;
        --b;
        uf.unionSet(a, b);
    }
    int s = uf.size();
    cout << s << endl;
    return 0;
}

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

def solve():
    N, K = list(map(int, input().split(" ")))
    S = input()

    # 左から順に考える
    # 累積和
    ruiseki = []
    i = 0
    while True:
        if i >= N:
            break
        
        num = 0
        if S[i] == "1":
            while i < N and S[i] == "1":
                num += 1
                i += 1
            ruiseki.append(["1", num])
        else:
            while i < N and S[i] == "0":
                num += 1
                i += 1
            ruiseki.append(["0", num])
    
    if ruiseki[0][0] == "0":
        i = 0
    else:
        i = 1

def solve2():
    N, K = list(map(int, input().split(" ")))
    S = input()

    i = 0
    ruiseki = [0]
    while True:
        if i >= N:
            break
        
        num = 0
        if S[i] == "1":
            while i < N and S[i] == "1":
                num += 1
                i += 1
            ruiseki.append(num + ruiseki[-1])
        else:
            while i < N and S[i] == "0":
                num += 1
                i += 1
            ruiseki.append(num + ruiseki[-1])

    import math
    if S[0] == "1":
        zero_num = math.floor((len(ruiseki) - 1) / 2)
    else:
        zero_num = math.ceil((len(ruiseki)-1)/2)

    if K >= zero_num:
        print(ruiseki[-1])
        return

    ans = 0
    if S[0] == "1":
        for i in range(2, len(ruiseki), 2):
            end = i + 2*(K-1)
            if end >= len(ruiseki):
                break
            if end+1 < len(ruiseki):
                # 後ろが"1"のとき
                end += 1

            ans = max(ruiseki[end] - ruiseki[i-2], ans)

    else:
        for i in range(1, len(ruiseki), 2):
            end = i + 2*(K-1)
            if end >= len(ruiseki):
                break
            if end+1 < len(ruiseki):
                end += 1

            if i-2 >= 0:              
                ans = max(ruiseki[end]-ruiseki[i-2], ans)
            else:
                ans = max(ruiseki[end]-ruiseki[i-1], ans)

    print(ans)            




if __name__ == "__main__":
    solve2()

Measured memory_bytes: 7156
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18

ll solve(ll a, ll b){
    // a>b
    ll x = a;
    ll y = b;
    ll r = a % b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    ll ret = x/b;
    ret *= y;
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ll ans = 1;
    REP(i,N){
        ll t;
        cin >> t;
        if(t>ans){
            ll tmp = t;
            t = ans;
            ans = tmp;
        }
        if(ans%t!=0){
            ans = solve(ans,t);
        }
    }
    cout << ans << endl;
    return 0;
}

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

constexpr int64_t mod = 1'000'003;

int64_t mpow(int64_t x, int64_t y){
    if(y==0) return 1;
    if(y==1) return x%mod;
    if(y%2 == 0) return mpow(x*x%mod, y/2) % mod;
    return mpow(x*x%mod, y/2) % mod * x % mod;
}

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

    int Q;
    cin >> Q;
    static int64_t fact[mod+1], finv[mod+1];
    fact[0] = 1;
    for(int i=1;i<=mod;i++) fact[i] = i*fact[i-1]%mod;
    finv[mod-1] = mpow(fact[mod-1], mod-2);
    for(int i=mod-2;i>=0;i--) finv[i] = (i+1)*finv[i+1]%mod;

    for(int q=0;q<Q;q++){
        int x, d, n;
        cin >> x >> d >> n;
        if(d==0){
            cout << mpow(x, n) << endl;
            continue;
        }
        int st = x * mpow(d, mod-2) % mod;
        int ed = st + n - 1;
        if(ed >= mod){
            cout << 0 << endl;
            continue;
        }
        cout << fact[ed] * finv[max(0, st-1)] % mod * mpow(d, n) % mod << endl;
    }

    return 0;
}

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

using namespace std;

const int maxn = 2e5 + 5;


int y[maxn];
int main() {
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    memset(y, 127, sizeof(y));
    for(int i=0;i<k;i++)
    {
        int tx, ty;
        scanf("%d%d",&tx,&ty);
        y[tx]=min(y[tx], ty);
    }
    int ans=n;
    int now=1;
    for(int i=2;i<=n;i++)
    {
        if(y[i]<=now){
            ans=i-1;break;
        }
        else if(y[i]==now+1){
            continue;
        }
        else{
            now++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
import math

a, b, h, m = map(int, input().split())

def hour_to_rad(hour):
    return hour * (math.pi * 2 / 12)

def mod_hour_to_rad(minute):
    return minute * (math.pi * 2 / (12 * 60))

def minute_to_rad(minute):
    return minute * (math.pi * 2 / 60)

def calc_cosine_edge(a, b, angle):
    return abs(a * a + b * b - 2 * a * b * math.cos(angle)) ** 0.5

angle = abs(hour_to_rad(h) + mod_hour_to_rad(m) - minute_to_rad(m))

print(calc_cosine_edge(a, b, angle))

Measured memory_bytes: 9524
//FightingoverCandies.cpp (A)
#include <iostream>
#include <string>
using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b==c||b+c==a||c+a==b) printf("Yes\n");
  else printf("No\n");

}


Measured memory_bytes: 256
s=list(input())
a = 0
for i,S in enumerate(s):
    if i%2 ==0:
        if (S != "R") and (S != "U") and (S != "D"):
            break
    else:
        if (S != "L") and (S != "U") and (S != "D"):
            break
else:
    a = 1
    
if a == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		long N = nextLong();
		long K = nextLong();

		long ans = 1;
		for(int i=0;i<N;i++) {
			if(ans+K<ans*2) {
				ans+=K;
			}else {
				ans*=2;
			}
		}

		pw.println(ans);
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 21076
/**
 *    author:  erekle
 *    created: 19.09.2020 12:42:59
**/
#include <bits/stdc++.h>

using namespace std;

#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define swap2(x,y) x=x^y; y=x^y; x=x^y;




int main() {
	fastIO
	
	int n; cin >> n;
	int cur = 0;
	bool three = false;
	for (int i = 0; i < n; ++i) {
		int d1, d2; cin >> d1 >> d2;
		if (d1 == d2) ++cur;
		else {
			if (cur >= 3) three = true;
			cur = 0;
		}
	}
	if (cur >= 3) three = true;
	
	cout << (three ? "Yes" : "No") << endl;

	return 0;
}


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

#define int long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second


signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int a[3][3];
    bool ok[3][3];
    map<int,bool> mp;
    ffor(i,3){
    	ffor(j,3){
    		cin >> a[i][j];
    		ok[i][j] = false;
    	}
    }
    int n;
    cin >> n;
    while(n--){
    	int x;
    	cin >> x;
    	mp[x] = true;
    }
    ffor(i,3){
    	ffor(j,3){
    		if(mp[a[i][j]] == true) ok[i][j] = true;
    	}
    }

    // check rows
    ffor(i,3){
    	if(ok[i][0] && ok[i][1] && ok[i][2]) {
    		cout << "Yes";
    		return 0;
    	}
    }

    // check for cols
    ffor(i,3){
    	if(ok[0][i] && ok[1][i] && ok[2][i]){
    		cout << "Yes";
    		return 0;
    	}
    }

    // check diagonals
    if(ok[0][0] && ok[1][1] && ok[2][2]) {
    	cout << "Yes";
    	return 0;
    }
    if(ok[0][2] && ok[1][1] && ok[2][0]){
    	cout << "Yes";
    	return 0;
    }
    cout << "No";
}		


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,sum1,sum2,a[110];//维护和
int main(){
    scanf("%d",&n);
    sum1=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum1+=a[i];
    }
    scanf("%d",&m);
    sum2=sum1;//轮番维护
    while(m--){
        int p,x;
        scanf("%d%d",&p,&x);
        if(x>=a[p-1]) sum1+=x-a[p-1];//按题模拟
        else sum1-=a[p-1]-x;
        printf("%d\n",sum1);
        sum1=sum2;
    }
    return 0;
}

Measured memory_bytes: 256
# heapqの方針で上手くいかなかった
# 解説放送を見てimosにした

def main():
    from collections import namedtuple
    from heapq import heappop, heappush
    import sys
    input = sys.stdin.readline

    Prog = namedtuple('Prog', 'L R')
    Prog.__eq__ = lambda self, other: self.R == other.R
    Prog.__lt__ = lambda self, other: self.R < other.R

    N, C = map(int, input().split())
    ps = [[] for _ in range(30)]
    for _ in range(N):
        l, r, ch = map(int, input().split())
        heappush(ps[ch - 1], Prog(l, r))

    imos = [0] * (10 ** 5 + 1)
    for ps_ch in ps:
        while ps_ch:
            l, r = heappop(ps_ch)
            while ps_ch and ps_ch[0].L == r:
                r = ps_ch[0].R
                heappop(ps_ch)
            else:
                imos[l - 1] += 1
                imos[r] -= 1

    ans = imos[0]
    for i in range(10 ** 5):
        imos[i + 1] += imos[i]
        ans = max(ans, imos[i + 1])

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
 int N, cnt = 0;
 cin >> N;
 int a[N];
  
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  for(int i = 0; i < N; i = i + 2){
    if(a[i] % 2 != 0){
      cnt++;
    }
  }
    
  cout << cnt << endl;
}

Measured memory_bytes: 3560
#include<iostream>

using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = 0;i <= (signed)s.length() - 3;i++) {
		if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	if (s.length() >= 2) {
		if (s[s.length() - 1] == s[s.length() - 2]) {
			cout << s.length() - 1 << " " << s.length() << endl;
			return 0;
		}
	}
	cout << "-1 -1\n";
}

Measured memory_bytes: 3248
import heapq

X,Y,A,B,C = map(int, input().split())

p = sorted(map(int, input().split()), reverse=True)
q = sorted(map(int, input().split()), reverse=True)
r = sorted(map(int, input().split()), reverse=True)

red = p[:X]
green = q[:Y]
nocolor = r


heapq.heapify(red)
heapq.heapify(green)
# heapq.heapify(nocolor)

for nc in nocolor:
    R = heapq.heappop(red)
    G = heapq.heappop(green)
    heapq.heappush(red,R)
    heapq.heappush(green,G)
    if R > nc and G > nc:
        break
    elif nc > R and nc > G:
        if R > G:
            q = heapq.heappop(green)
            heapq.heappush(green,nc)
        else:
            q = heapq.heappop(red)
            heapq.heappush(red,nc)
    elif nc > R:
        q = heapq.heappop(red)
        heapq.heappush(red,nc)
    elif nc > G:
        q = heapq.heappop(green)
        heapq.heappush(green,nc)


print(sum(red)+sum(green))

Measured memory_bytes: 23360
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n, m, AC=0, WA=0;
    cin >> n >> m;
    vector<ll> ac(n,0), wa(n,0);
    rep(i,m){
        ll a; string s;
        cin>>a>>s;
        a--;
        if(ac[a]) continue;
        if(s=="AC"){
            ac[a]=1;
        }else{
            wa[a]++;
        }
    }
    rep(i,n){
        AC += ac[i];
        if(ac[i]) WA += wa[i];
    }
    cout << AC << " " << WA << endl;
    return 0;
}

Measured memory_bytes: 4828
#include<iostream>
using namespace std;
int main(){
    int a;
    cin >> a;
    int b[a];
    for(int i = 0;i < a;i++){
        cin >> b[i]; 
    }
    long int money = 1000,kabu = 0;
    for(int i = 0;i < a;i++){
        if(b[i] < b[i+1]){
            if(kabu == 0){
                kabu = money / b[i];
                money = money % b[i];
            }
        }
        if(b[i] > b[i+1]){
            if(kabu != 0){
                money += kabu * b[i];
                kabu = 0;
            }
        }   
    }
    if(kabu != 0){
        money += kabu * b[a-1];
        kabu = 0;
    }
    cout << money << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define endl "\n"
#define INF (int)1e9
#define watch(x) cout << (#x) << " is " << (x) << endl

using ll = long long;
using ull = unsigned long long;
using namespace std;

int dp[100000 + 1];


int solve(vector<int> arr, int k){
	if (k < 0)
		return 1;
	if(k == 0)
		return 0;
	
	if(dp[k] == 0 or dp[k] == 1)
		return dp[k];
	
	int state = 1;
	for(int x: arr)
		state &= solve(arr, k - x);
	
	dp[k] = !state;
	return dp[k];
}

int main(){
	
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	
	memset(dp, 3, sizeof(dp));
	
	int n, k;
	cin >> n >> k;
	
	vector<int> arr(n);
	
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	
	int ans = solve(arr, k);
	
	if(ans) cout << "First" << endl;
	else cout << "Second" << endl;
}


Measured memory_bytes: 53760
#include<stdio.h>

#define N 100

void selectionSort(int A[], int n);

main(){

  int i, n, A[N];
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++) scanf("%d", &A[i]);
  
  selectionSort(A, n);
  
  return 0;
}

void selectionSort(int A[], int n){

  int i, j, min, temp, a = 0, k;
  
  if(n != 1){
    for(i = 0; i < (n - 1); i++){
      min = i;
      for(j = (i + 1); j < n; j++){
	if(A[j] < A[min]) min = j;
      }
      if(i != min){
	temp = A[i];
	A[i] = A[min];
	A[min] = temp;
	a++;
      }
    }
  }
  for(i = 0; i < n; i++){
    if(i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n%d\n", a);
}




  

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define F first
#define S second
#define pii pair<int,int>
#define pb push_back
typedef long long ll;
using namespace std;
const int M = 4 * 1e6 + 10 , N = 2017 , mod = 1e9 + 7;
ll fact[M] , inv[M] , dp[N][N];
int n , k;

int power(int a , int b){
    if(b == 0)return 1;
    ll ret = power(a , b/2);
    ret *= ret; ret %= mod;
    if(b % 2)ret *= a; ret %= mod;
    return ret;
}


int comb(int n , int k){
    if(k > n)return 0;
    ll ret = fact[n];
    ret *= inv[k]; ret %= mod;
    ret *= inv[n - k]; ret %= mod;
    return ret;
}

void Piri(){
    fact[0] = 1;
    for(int i=1;i<M;i++)fact[i] = (fact[i - 1] * i) % mod;
    inv[M - 1] = power(fact[M - 1] , mod - 2);
    for(int i=M-2;i>=0;i--)inv[i] = (inv[i + 1] * (i + 1)) % mod;
}


int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    if(k == 1)return cout << 1 << '\n' , 0;
    Piri();
    dp[0][0] = 1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j < i){
                ll len = j * k + (i - j) * (k - 1);
                ll c = comb(len - 1 , k - 2); c *= i; c %= mod;
                c *= dp[i - 1][j]; c %= mod;
                dp[i][j] += c; dp[i][j] %= mod;
            }
            if(j > 0){
                dp[i][j] += dp[i][j - 1];
                dp[i][j] %= mod;
            }
        }
    }
    cout << dp[n][n] << '\n';
}


Measured memory_bytes: 85504
#include  <stdio.h>

int main(void)
{
        int n,k,i,s=0;
        scanf("%d%d",&n,&k);
        int x[n];
        for(i=0;i<n;i++)
                scanf("%d",&x[i]);

        for(i=0;i<n;i++){
                if(x[i]*2<(k-x[i])*2) s+=x[i]*2;
                else s+=(k-x[i])*2;
        }

        printf("%d\n",s);
        return 0;
}


Measured memory_bytes: 1728
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a-b>=0) {
			System.out.println("delicious");
		}else if(a-b>=-x) {
			System.out.println("safe");
		}else {
			System.out.println("dangerous");
		}

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<double, double> pd;


int main()
{
  int n, m;
  scanf("%d %d", &n, &m);
  
  if(n > m)
    printf("No\n");
  else
    printf("Yes\n");
  
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n;
	ll ans = 0;
	string march = "MARCH";
	cin >> n;
	vector<string>name(n);
	rep(i, n) {
		cin >> name[i];
	}
	map<char, ll>m;
	for (auto mp : name)m[mp[0]]++;
	rep(i, 3) for (int j = i + 1; j < 4; j++)for (int k = j + 1; k < 5; k++) {
		ans += m[march[i]] * m[march[j]] * m[march[k]];
	}

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



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

int main() {
  int H, W;
  cin >> H >> W;
  
  string str;
  
  for (int i = 0; i < H; i++){
    string S;
    cin >> S;
    
    str += S;
  }
  
  for (int i = 0; i < H * W; i++) {
    int count = 0;
    if (str.at(i) == '.') {
      if (i % W != 0) {
        if (str.at(i - 1) == '#') count++;
        if (i / W != 0) if (str.at(i - W - 1) == '#') count++;
        if (i / W != H - 1) if (str.at(i + W - 1) == '#') count++;
      }
      if (i / W != 0) if (str.at(i - W) == '#') count++;
      if (i / W != H - 1) if (str.at(i + W) == '#') count++;
      if (i % W != W - 1) {
        if (str.at(i + 1) == '#') count++;
        if (i / W != 0) if (str.at(i - W + 1) == '#') count++;
        if (i / W != H - 1) if (str.at(i + W + 1) == '#') count++;
      }
      cout << count;
    }
    else cout << '#';
    if (i % W == W - 1) cout << endl;
  }
  
}

Measured memory_bytes: 256
C = [list(map(int,input().split())) for _ in range(3)]

dx1 = C[0][1] - C[0][0]
dx2 = C[0][2] - C[0][1]
dy1 = C[1][0] - C[0][0]
dy2 = C[2][0] - C[1][0]

Ans = "Yes"
for i in range(3):
    if (C[i][1] - C[i][0] != dx1 or C[i][2] - C[i][1] != dx2 or
        C[1][i] - C[0][i] != dy1 or C[2][i] - C[1][i] != dy2):
        Ans = "No"
        break

print(Ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static List<ulong> Divisor(ulong input)
        {
            List<ulong> result = new List<ulong>();

            for (ulong i = 1; i * i <= input; i++)
            {
                if (0 == input % i)
                {
                    result.Add(i);
                    if (i * i != input)
                    {
                        result.Add(input / i);
                    }
                }
            }

            return result;
        }

        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);

            List<ulong> div = Divisor((ulong)M);
            div.Sort();

            int ans = 1;
            int index = 0;
            for(index = 0; index < div.Count; index++)
            {
                if ((int)div[index] >= N)
                {
                    break;
                }
            }

            ans = M / (int)div[index];
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9+7;
const int MAX_N = 2010;
ll C[MAX_N][MAX_N];

void comb() {
	for (int i = 0; i < MAX_N; i++) {
		C[i][0] = 1;
		C[i][i] = 1;
	}

	// C(n, m) = C(n - 1, m - 1) + C(n - 1, m)
	for (int i = 2; i < MAX_N; i++) {
		for (int j = 1; j <= i; j++) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
		}
	}
}

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

	FOR(i, 1, k+1) {
		if (i > n - k + 1) {
			cout << "0" << endl;
		}
		else {
			cout << (C[n - k + 1][i] % mod) * (C[k - 1][i - 1] % mod) % mod << endl;
		}
	}
}

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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    string s;
    cin >> s;
    int t = s.size() - 7;
    for(int i = 0; i + t <= s.size(); i++) {
        string rest = s.substr(0, i) + s.substr(i + t);
        if (rest == "keyence") {
            cout << "YES" << endl;
            return;
        }
    }
    cout << "NO" << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
# B - Resale
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

sum_v = []
ans = 0
for i in range(N):
    sum_v.append(V[i]-C[i])
sum_v.sort(reverse=True)

for j in range(N):
    if sum_v[j] > 0:
        ans += sum_v[j]
    else:
        break

print(ans)

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

int main(void)
{
	int n, k, ans = 0;
	cin >> n >> k;
	for (int i = 1; i <= n; i+=2)
	{
		ans++;
	}
	if (k <= ans) { cout << "YES"; }
	else {
		cout << "NO";
	}
	return 0;
}

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

int h, w;
char field[101][101];
int con[101][101];
int used[101][101];
void dfs(int x, int y, int px, int py) {
	used[x][y]++;
 	int xx = x + 1;
	int yy = y + 1;
	if (field[px][py] == '#') {
		if (field[x][y] == '.' || (x == h - 1 && y == w - 1)) {
			con[x][y] = min(con[x][y], con[px][py] + 1);
		} else if (field[x][y] == '#') {
			con[x][y] = min(con[x][y], con[px][py]);
		}
	}
	else if (field[px][py] == '.') {
		if (field[x][y] == '.') {
			con[x][y] = min(con[x][y], con[px][py]);
		}
		else if (field[x][y] == '#' && (x == h - 1 && y == w - 1)) {
			con[x][y] = min(con[x][y], con[px][py] + 1);
		} else if (field[x][y] == '#') {
			con[x][y] = min(con[x][y], con[px][py]);
		}
	}
	if (used[x][y] == 2) {
		if (xx < h && y < w)
			dfs(xx, y, x, y);
		if (x < h && yy < w)
			dfs(x, yy, x, y); 
	}
	return;
}
int main() {
	//freopen("a.txt", "r", stdin);
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> field[i][j];
			con[i][j] = 1e+9;
			if (i == 0 || j == 0) {
				used[i][j] = 1;
			}
		}
	}
	con[0][0] = 0;
	dfs(0, 0, 0, 0);
	cout << con[h - 1][w - 1] << endl;
	return 0;
}

Measured memory_bytes: 384
import sys
N = int(input())
A = list(map(int, input().split()))

ans = 1
thres = 10**18

if 0 in A:
  print(0)
  sys.exit()

for i in A:
  ans = i * ans
  if ans > thres:
    print(-1)
    sys.exit()

print(ans)


Measured memory_bytes: 21692
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

// dp[i][j] = considering 0...i, capacity j
ll n, w, wt[100001], v[100001];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
    cin>>n>>w;
    for(int i=0; i<n; i++) cin>>wt[i]>>v[i];
    ll dp[n+1][w+1];
    for(int i=0; i<=n; i++) dp[i][0] = 0;
    for(int j=0; j<=w; j++) dp[0][j] = 0;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=w; j++){
            dp[i][j] = max(dp[i-1][j], (j-wt[i-1]>=0 ? (v[i-1] + dp[i-1][j-wt[i-1]]) : 0));
        }
    }
    cout<<dp[n][w]<<"\n";
	return 0;
}

Measured memory_bytes: 82376
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
 
int main(){
  int N;
  cin>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  int ans=1;
  rep(i,N) ans*=(A[i]%2==0);
  cout<<(ans?"second":"first")<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
struct unifnd{
  VI ht,pr;
  in fnd(in a){
    in ta=a;
    while(a!=pr[a])a=pr[a];
    in tt=ta;
    while(ta!=a){
      tt=pr[ta];
      pr[ta]=a;
      ta=tt;
    }
    return a;
  }
  void uni(in a, in b){
    a=fnd(a);
    b=fnd(b);
    if(a==b)return;
    if(ht[b]<ht[a])swap(a,b);
    pr[a]=b;
    ht[b]+=(ht[a]==ht[b]);
  }
  void ini(in n){
    ht.resize(n);
    pr.resize(n);
    forn(i,n){
      ht[i]=0;
      pr[i]=i;
    }
  }
};
const in mdl=1000000007LL;
in p2(in a){
  return (1LL<<a);
}
in pw(in a, in b, in lm=62){
  a%=mdl;
  if(a<0)
    a+=mdl;
  in r=1;
  for(in i=lm;i>=0;--i){
    r=r*r%mdl;
    if(b&p2(i))
      r=r*a%mdl;
  }
  return r;
}
in inv(in a){
  a%=mdl;
  if(a<0)
    a+=mdl;
  assert(a!=0);
  return pw(a,mdl-2,30);
}
VI fc,invfc;
in ncr(in a, in b){
  if(b==0 || b==a)
    return 1;//even if a<0
  if(b<0 || b>a)
    return 0;
  return fc[a]*invfc[b]%mdl*invfc[a-b]%mdl;
}
void inifc(){
  const in mxfc=1001000;
  fc.resize(mxfc);
  invfc.resize(mxfc);
  fc[0]=fc[1]=invfc[0]=invfc[1]=1;
  for(in i=2;i<mxfc;++i){
    fc[i]=fc[i-1]*i%mdl;
    invfc[i]=invfc[mdl%i]*(mdl-mdl/i)%mdl;
  }
  for(in i=2;i<mxfc;++i){
    invfc[i]*=invfc[i-1];
    invfc[i]%=mdl;
  }
}

unifnd tfd;
in n,x,y;
VI c,w;
vector<vector<pair<in,in> > > clv;
vector<pair<in,in> > alv;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  inifc();
  cin>>n>>x>>y;
  c=w=VI(n);
  tfd.ini(n);
  fc.PB(1);
  forn(i,n+3)
    fc.PB(fc[i]*(i+1)%mdl);
  clv.resize(n+1);
  forn(i,n){
    cin>>c[i]>>w[i];
    clv[c[i]].PB(MP(w[i],i));
  }
  forv(i,clv){
    sort(all(clv[i]));
    if(sz(clv[i])){
      forv(j,clv[i]){
	if(clv[i][j].first+clv[i][0].first<=x)
	  tfd.uni(clv[i][j].second,clv[i][0].second);
      }
      alv.PB(clv[i][0]);
    }
  }
  sort(all(alv));
  for(in i=0;i<2 && i<sz(alv);++i){
    forn(j,n){
      if(((c[j]==c[alv[i].second]) && (w[j]+alv[i].first<=x)) || ((c[j]!=c[alv[i].second]) && (w[j]+alv[i].first<=y)))
	tfd.uni(j,alv[i].second);
    }
  }
  map<in,in> ocs;
  map<pair<in,in>,in> oclr;
  forn(i,n){
    ++ocs[tfd.fnd(i)];
    ++oclr[MP(c[i],tfd.fnd(i))];
  }
  in w=1;
  fors(i,ocs)
    w=w*fc[i->second]%mdl;
  fors(i,oclr)
    w=w*invfc[i->second]%mdl;
  cout<<w<<endl;
  return 0;
}


Measured memory_bytes: 60016
#include<bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
vector<string>v;
void dfs(string str,string t="",int cnt=0){
    if(cnt==2){
        v.push_back(t);
        return;
    }else{
        for(int i=0;i<str.size();i++){
            dfs(str,t+str[i],cnt+1);
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b,c,d,e,k;
    while(cin>>a>>b>>c>>d>>e>>k){
        (e-a)<=k?cout<<"Yay!"<<endl:cout<<":("<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010], trakm[100010];
int main(){
    int n;
    while(cin>>n){
        ll ans=0;
        for(int i=0; i<n; ++i){
            scanf("%d",a+i);
            ++trakm[a[i]];
        }
        for(int i=1; i<4010; ++i){
            trakm[i]+=trakm[i-1];
        }
        int mx, mn;
        for(int i=0; i<n; ++i){
            for(int j=i+1; j<n; ++j){
                mx=a[i]+a[j];
                mn=abs(a[i]-a[j]);
                ans+=trakm[mx-1]-trakm[mn];
                if(a[i]<mx&&a[i]>mn)
                    --ans;
                if(a[j]<mx&&a[j]>mn){
                    --ans;
                }
//                cout<<a[i]<<" "<<a[j]<<" "<<mx<<" "<<mn<<" "<<trakm[mx-1]-trakm[mn]<<endl;
            }
        }
        cout<<ans/3<<endl;
    }
  return 0;
}




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

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define lp(start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
ll h,w;
ll arr[1007][1007];
ll dp[1007][1007];
ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

ll fun(ll x , ll y)
{
	if(dp[x][y]!=-1)
		return dp[x][y];
	if(x==1 && y==1)
	{
		return 1;
	}
	else
	{
		dp[x][y]=0;
		ll f1=0,f20=0;
		if(arr[x-1][y]==0 && x!=1)
		{
			f1=1;
			dp[x][y] = (dp[x][y] + fun(x-1,y))%mod;
		}
		if(arr[x][y-1]==0 && y!=1)
		{
			f20=1;
			dp[x][y] = (dp[x][y] + fun(x,y-1))%mod;
		}
		//dp[x][y]+=f1+f20 -1;
	}
	//deb3(x,y,dp[x][y]);
	return dp[x][y];
}

int main()
{
	fastio	
	cin >> h >> w;
	for(ll i=1;i<=h;i++)
	{
		for(ll j=1;j<=w;j++)
		{
			char tem;
			cin >> tem;
			//cout << tem << endl;
			if(tem=='.')
				arr[i][j]=0;
			else
				arr[i][j]=1;

			dp[i][j]=-1;
		}
	}
	cout << fun(h,w) << endl;
	return 0;	
}


Measured memory_bytes: 16128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int N;
    cin >> N;
    vector<ll> a(N), b(N), c(N);
    for(int i=0; i<N; i++) cin >> a[i] >> b[i] >> c[i];

    vector<ll> dp(3), n(3);
    for(int i=0; i<N; i++){
        n[0] = max(dp[1]+a[i], dp[2]+a[i]);
        n[1] = max(dp[2]+b[i], dp[0]+b[i]);
        n[2] = max(dp[0]+c[i], dp[1]+c[i]);
        for(int j=0; j<3; j++) dp[j] = n[j];
    }

    cout << *max_element(dp.begin(), dp.end()) << endl;
}

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

int gcd(int a, int b) {
   if (a % b == 0) return(b);
   else return(gcd(b, a % b));
}

int main() {
    /* Input */
    int k;
    cin >> k;

    /* Main Logic */
    int ans = 0;

    rep (a, k) rep (b, k) rep (c, k) ans += gcd(a, gcd(b, c));

    /* Output */
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
t_hp_str,t_atack_str,a_hp_str,a_atack_str= input().split()
t_hp = int(t_hp_str)
t_atack = int(t_atack_str)
a_hp=int(a_hp_str)
a_atack = int(a_atack_str)

for num in range(300):
  if num%2 == 0:
    a_hp = a_hp - t_atack
    if a_hp <= 0:
      print("Yes")
      break
  else:
    t_hp = t_hp - a_atack
    if t_hp <= 0:
      print("No")
      break



Measured memory_bytes: 9152
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;
 
void solve(){
    string a,b;
    cin>>a>>b;
    cout<<b<<a;
}
    
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    // fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		
		int x = N/100;
		
		if(N <= 100*x + 10*x + x) {
			System.out.println((100*x + 10*x + x));
		}else {
			System.out.println((100*(x+1) + 10*(x+1) + (x+1)));
		}
		
		
	}
}


Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// Recieve StdIn
    	Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a<=8 && b<=8) {
			System.out.println("Yay!");
		} else {
			System.out.println(":(");
		}
	}

}


Measured memory_bytes: 22612
a = [list(map(int,input().split())) for i in range(3)]
x = [0]*3
y = [0]*3
flag = 0
for i in range(3):
    y[i] = a[0][i]
    x[i] = a[i][0] - y[0]
for j in range(3):
    for k in range(3):
        if not a[j][k] == (x[j] + y[k]):
            flag = 1
            break
if flag == 0:
    print('Yes')
else:
    print('No')

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

using namespace std;

int occ[4];
double dp[314][312][312];
double p[314][312][312];

double get_proba(int a, int n) {
	double p = a;
	p /= n;
	return p; 
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);

	for(int i = 0; i <= 301; i++)
		for(int j = 0; j <= 301; j++)
			for(int k = 0; k <= 301; k++) {
				dp[i][j][k] = 0;
				p[i][j][k] = 0;
			}

	memset(occ, 0, 4);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		occ[a[i]]++;
	}

	// E(R) = 1/p
	
	int x = occ[1];
	int y = occ[2];
	int z = occ[3];

	p[x][y][z] = 1;
	int c = 1;
	double pw, pi, ew;

	for(int k = n; k >= 0; k--) {
		for(int j = n; j >= 0; j--) {
			for(int i = n; i >= 0; i--) {
				if((i+j+k) == 0) continue;
				if((i+j+k) > n) continue;

				pw = get_proba(n-i-j-k, n);
				ew = pw/(1-pw) + 1;

				dp[i][j][k] += ew*p[i][j][k];

				if(i != 0) {
					p[i-1][j][k] +=  p[i][j][k] * get_proba(i, i+j+k);
					dp[i-1][j][k] +=  dp[i][j][k] * get_proba(i, i+j+k);
				}
				if(j != 0) {
					p[i+1][j-1][k] +=  p[i][j][k] * get_proba(j, i+j+k);
					dp[i+1][j-1][k] +=  dp[i][j][k] * get_proba(j, i+j+k);
				}
				if(k != 0) {
					p[i][j+1][k-1] +=  p[i][j][k] * get_proba(k, i+j+k);
					dp[i][j+1][k-1] +=  dp[i][j][k] * get_proba(k, i+j+k);
				}
			}
		}
	}

	printf("%.10lf\n", dp[0][0][0]);
}


Measured memory_bytes: 463104
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<stack>
#include<map>
#include<vector>
#include<queue>
#define N 15
using namespace std;
typedef long long ll;
char a[N];
int main()
{
    ios::sync_with_stdio(false);
    int n,left,right,mid,x,y;
    cin>>n;
    cout<<"0"<<endl;
    cin>>a;
    if(a[0]=='V')
        return 0;
    if(a[0]=='M') x=1;
    else x=0;
    left=0,right=n;
    while(left!=right-1)
    {
        mid=(left+right)/2;
        cout<<mid<<endl;
        cin>>a;
        if(a[0]=='V')
           return 0;
        else if(a[0]=='M') y=1;
        else  y=0;
        int t =mid-left;
        if(t%2==0){
            if(y==x) left=mid,x=y;
            else right=mid;
            }
        else{
            if(x==y)right=mid;
            else left=mid,x=y;
            }
    }
    cout << flush;
    return 0;
}



Measured memory_bytes: 852
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N, M = map(int, input().split())
G = [[] for _ in range(N+1)]
for _ in range(M):
    A, B = map(int, input().split())
    G[A].append(B)

def dfs(v, o):
    for c in G[v]:
        if c == o:
            return [v]
    for c in G[v]:
        if visited[c]:
            continue
        visited[c] = True
        ret = dfs(c, o)
        if ret:
            return [v] + ret

for v in range(1, N+1):
    visited = [False] * (N+1)
    cur = dfs(v, v)
    if cur:
        break
else:
    print(-1)
    exit()

while True:
    cur_set = set(cur)
    unused = None
    for i in range(len(cur)):
        u, v = cur[i], cur[(i+1) % len(cur)]
        for c in G[u]:
            if c == v:
                continue
            elif c in cur_set:
                unused = (i, cur.index(c))
                break

    if not unused:
        break
    else:
        t, s = unused
        nxt = []
        i = s
        while i != t:
            nxt.append(cur[i])
            i = (i + 1) % len(cur)
        nxt.append(cur[t])
        cur = nxt

print(len(cur))
print(*cur, sep='\n')

Measured memory_bytes: 43356
#include <stdio.h>

int main(void)
{
  int a,b;

  while (1) {
    scanf("%d %d", &a,&b);
    if (a == 0 && b == 0) break;
    (a < b) ? printf("%d %d\n",a,b) : printf("%d %d\n",b,a);
  }

  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TLE
		try (Scanner sc = new Scanner(System.in)) {
			long N = sc.nextLong();
			int X = sc.nextInt();
			int M = sc.nextInt();
			int[] arr = new int[M + 1];
			arr[1] = X;
			int[] isVisited = new int[M + 1];
			isVisited[X] = 1;
			int stopAt = 0;
			int roopStart = 0;
			for (int i = 2; i <= N; i++) {
				long nextlong = (long) arr[i - 1] * (long) arr[i - 1] % M;
				int next = (int) nextlong;
				if (isVisited[next] != 0) {
					stopAt = i - 1;
					roopStart = isVisited[next];
					break;
				} else {
					isVisited[next] = i;
					arr[i] = next;
				}
			}
			long ans = 0;
			if (stopAt == 0) {
				for (int i = 1; i <= N; i++) {
					ans += arr[i];
				}
			} else {
				long last = (N - (roopStart - 1)) % (stopAt - roopStart + 1);
				long roopCnt = (N - (roopStart - 1)) / (stopAt - roopStart + 1);
				for (int i = 1; i < roopStart; i++) {
					ans += arr[i];
				}
				for (int i = roopStart; i < roopStart + last; i++) {
					ans += arr[i];
				}
				long oneLoop = 0;
				for (int i = roopStart; i <= stopAt; i++) {
					oneLoop += arr[i];
				}
				ans += roopCnt * oneLoop;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 36512