akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define change(a,b) do{ll c=a; a=b; b=c;}while(0)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        change(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  string S;
  cin>>S;
  if(S=="AAA"||S=="BBB") cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

int main(){
	string S;
	int N;
	char aa;
	cin >> N;
	cin >> S;
	for(int i=0; i<S.size(); i++){
		aa = (char)S[i];
		std::cout << (char)('A'+(aa-'A'+N)%26);
	}
}



Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b = LI()
    if a+b <= 16 and a < 9 and b < 9:
        return 'Yay!'
    return ':('


print(main())



Measured memory_bytes: 7752
import java.util.*;

public class Main{

	static int p[];
	static int c[];
	static int d, g;
	static final int infinity = 10000;
	
	public static int solve(){
		int sum = 0, cnt = 0, ans = infinity;
		int t = 1, max = -1;
		int n = (int)Math.pow(2, d);
		for(int i = 0; i < n; ++i){
			max = 0;
			t = 1;
			cnt = 0;
			sum = 0;
			for(int j = 0; j < d; ++j){
				if((i & t) != 0){
					sum += p[j] * (j + 1) + c[j] / 100;
					cnt += p[j];
				}
				else max = j;
				t = t << 1;
			}	
			if(sum < g /100){
				int tmp = -1;
				if(max != -1)
				tmp = (g / 100 - sum + max) / (max + 1);
				if(tmp < 0)cnt = infinity;
				else if(tmp <= p[max] - 1)cnt += tmp;
				else cnt = infinity;
			}
			ans = Math.min(ans, cnt);
			
		}
		return ans;
	}

	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		d = sc.nextInt();
		g = sc.nextInt();
		p = new int[d];
		c = new int[d];
		for(int i = 0; i < d; ++i){
			p[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		sc.close();
		int ans = solve();
		System.out.println(ans);
	}
}

Measured memory_bytes: 22612
/*input
7
0010101
1 2
2 3
1 4
4 5
1 6
6 7

*/

#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <numeric>
#include <utility>
#include <tuple>
#include <climits>
#include <fstream>
#include <bitset>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <random>
#include <chrono>
#include <ios>
#include <iomanip>
#include <functional>
#include <array>

using namespace std;

#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORA(i, a) for (auto &i : a)
#define FORB(i, a, b) for (int i = a; i >= b; --i)
#define SZ(a) ((int) a.size())
#define ALL(a) begin(a), end(a)

typedef int64_t ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fi first
#define se second

// start of code

const int MAXN = 2007;
int N, sz[MAXN];
pii dp[MAXN];
vi G[MAXN];
string S;

pii operator+ (pii a, pii b)
{
	if (a > b) swap(a, b);
	return pii(a.se <= b.fi ? b.fi - a.se : ((a.fi ^ b.fi) & 1), a.se + b.se);
}

void dfs(int u, int p)
{
	dp[u] = {0, 0};
	sz[u] = (S[u] == '1');
	FORA(v, G[u]) if (v != p) {
		dfs(v, u);
		sz[u] += sz[v];

		pii x = dp[v];
		x.fi += sz[v], x.se += sz[v];
		dp[u] = dp[u] + x;
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> N >> S;
	S = "#" + S;
	FOR(i, 0, N - 2) {
		int u, v;
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}

	int ans = 1e9;
	FOR(u, 1, N) {
		dfs(u, u);
		if (dp[u].se & 1) continue;
		if (dp[u].fi != 0) continue;
		ans = min(ans, dp[u].se / 2);
	}
  	if (ans == 1e9) ans = -1;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#ifdef DBG
#define dbg(...) {cerr<<"\033[96;1m";ostream& cout=cerr;__VA_ARGS__;\
(void)(cout);cerr<<"\033[0m";}
#else
#define dbg(...)
#endif
#define st first
#define nd second
#define flg(...) __LINE__, __PRETTY_FUNCTION__
#define mkp(...) make_pair(__VA_ARGS__)
#define prt(...) print(cout, __VA_ARGS__)
#define dprt(...) dbg(prt(__VA_ARGS__))
#define dmp(...) prt(#__VA_ARGS__, __VA_ARGS__)
#define ddmp(...) dbg(dmp(__VA_ARGS__))
#define all(...) begin(__VA_ARGS__), end(__VA_ARGS__)
using namespace std; using ll = long long;
template<typename... t>using V=vector<t...>;
template<typename t>void print(ostream& os, const t& a){os<<a<<'\n';}
template<typename t, typename... v>void print(ostream& os, const t& a,
v&&... b){os<<a<<' ';print(os, b...);}
template<typename t>void inp(t& a){cin >> a;}
template<typename t, typename... v>void inp(t& a, v&... b){cin >> a;inp(b...);}

constexpr int maxn = 2e3;

int n, k, q, res = 2e9;
int tb[maxn + 1];
pair< int, int > ilo[maxn + 1];

inline int spr(int v)
{
    V< int > fin;
    V< int > ar;

    for (int i = 0; i < n; ++i)
    {
        if (tb[i] < v)
        {
            sort(all(ar));
            int p = (int)ar.size() - k + 1;
            for (int i = 0; i < p; ++i)
                fin.push_back(ar[i]);
            ar.clear();
        }
        else ar.push_back(tb[i]);
    }

    sort(all(ar));
    int p = (int)ar.size() - k + 1;
    for (int i = 0; i < p; ++i)
        fin.push_back(ar[i]);

    sort(all(fin));

    return (q <= fin.size()? fin[q - 1] : 2e9);
}

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

    inp(n, k, q);

    for (int i = 0; i < n; ++i)
        cin >> tb[i];

    for (int i = 0; i < n; ++i)
        res = min(res, spr(tb[i]) - tb[i]); 

    prt(res);
}

Measured memory_bytes: 256
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n = input_n
s = input_s

cnt = 0
(n - 2).times do |i|
  cnt += 1 if s[i] == "A" && s[i + 1] == "B" && s[i + 2] == "C"
end
puts cnt

Measured memory_bytes: 1788
#include <stdio.h>

int main(void) {
	int sosuu[51000];
	int sosuulist[51000];
	int i,j;
	int left,right;
	int n;
	for(i=0;i<51000;i++)sosuu[i]=1;
	sosuu[0]=0;
	for(i=1;i*i<51000;i++) {
		if(sosuu[i]==0)continue;
		for(j=i+i+1;j<51000;j+=i+1) {
			sosuu[j]=0;
		}
	}
	for(i=0,j=0;i<51000;i++) {
		if(sosuu[i]) {
			sosuulist[j]=i+1;
			j++;
		}
	}
	while(1) {
		if(scanf("%d",&n)==-1)break;
		left=0;right=j-1;
		while(right-left>1) {
			if(sosuulist[(left+right)/2]>n)right=(left+right)/2;
			else if(sosuulist[(left+right)/2]<n)left=(left+right)/2;
			else left=right=(left+right)/2;
		}
		if(sosuulist[left]==n)
			printf("%d %d\n",sosuulist[left-1],sosuulist[left+1]);
		else printf("%d %d\n",sosuulist[left],sosuulist[left+1]);
	}
	return 0;
}

Measured memory_bytes: 0
/*------------------------- Bism Allah Alruhmin Alrahim -------------------------------*/
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i > -1; i--)
#define forl(i, l, r) for (int i = l; i <= r; i++)
#define vc vector
#define f first
#define s second
#define pb(i) push_back(i)
#define mx(ar, n) (*max_element(ar, ar + n))
#define mn(ar, n) (*min_element(ar, ar + n))

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

ll LCM(ll x , ll y){
	return (x*y) / __gcd(x,y) ;
}

ll NumOfDiv(ll a , ll b , ll k){
	return b/k - a/k + (a%k == 0) ;
}
void start(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int res(int a , int b , int c){
	int x[3] = {a,b,c} ;
	sort(x,x+3);
	return x[1] ;

}

int main()
{
	start();
	int n ; 
	cin >> n ;
	int x[n] ;
	for (int i = 0; i < n; ++i)
	{
		cin >> x[i] ;
	}
	sort(x,x+n); 
	cout << x[n/2] - x[n/2-1] << endl ;
	return 0 ;
}

Measured memory_bytes: 640
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
 
const A = []
A.push(...lines[0].split(' ').map(Number))
A.push(...lines[1].split(' ').map(Number))
A.push(...lines[2].split(' ').map(Number))
 
const N = lines[3] - 0
const b = []
for (let i = 0; i < N; i++) {
  b[i] = lines[i + 4] - 0
}
 
for (let i = 0; i < N; i++) {
  for (let j = 0; j < A.length; j++) {
    if (A[j] === b[i]) {
      A[j] = 'b'
    }
  }
}
 
let ans = 'No'
if (A[0] === 'b' && A[4] === 'b' && A[8] === 'b') {
  ans = 'Yes'
} else if (A[2] === 'b' && A[4] === 'b' && A[6] === 'b') {
  ans = 'Yes'
} else if (A[0] === 'b' && A[1] === 'b' && A[2] === 'b') {
  ans = 'Yes'
} else if (A[3] === 'b' && A[4] === 'b' && A[5] === 'b') {
  ans = 'Yes'
} else if (A[6] === 'b' && A[7] === 'b' && A[8] === 'b') {
  ans = 'Yes'
} else if (A[0] === 'b' && A[3] === 'b' && A[6] === 'b') {
  ans = 'Yes'
} else if (A[1] === 'b' && A[4] === 'b' && A[7] === 'b') {
  ans = 'Yes'
} else if (A[2] === 'b' && A[5] === 'b' && A[8] === 'b') {
  ans = 'Yes'
}
console.log(ans)

Measured memory_bytes: 30292
A,B,C,D=map(int,input().split())
nT = 0
nA = 0
while C-B>0:
    C -= B
    nT += 1
while A-D>0:
    A -= D
    nA += 1
if nT <= nA:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61912
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		for (int i=X; ; i++) {
			boolean ch = false;
			for (int j=2; j<=X/2; j++) {
				if (i%j == 0) {
					ch = true;
					break;
				}
			}
			if (!ch) {
				System.out.println(i);
				break;
			}
		}
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
//#include<unordered_map>
//#include<unordered_set>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cstring>
#include <functional>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P; 
const int N = 100005;
//////////////////////////////

int dp[N];
int n, m, t;

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

	memset(dp, -1, sizeof dp);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> t;
		dp[t] = 0;
	}

	dp[0] = 1;
	if (dp[1] == -1) dp[1] = 1;
	for (int i = 2; i <= n; i++) {
		if (dp[i] == -1) {
			dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
		}
	}

	cout << dp[n] << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,t,m,n,a)vector<vector<t> > name(m,vector<t> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
const ll MAX = 3000000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ll x,y;
  std::cin >> x>>y;
  if((2*x-y)%3!=0||(2*x-y)<0||(2*y-x)%3!=0||(2*y-x)<0){
    std::cout << 0 << std::endl;
  }else{
    ll n,m;
    n=(2*x-y)/3;
    m=(2*y-x)/3;
    COMinit();
    cout << COM(n+m, n) << endl;
  }
}

Measured memory_bytes: 70528
#include <iostream>
using namespace std;
int main(void){
    int x;
    cin>>x;
    if(x%7==2){
        cout<<"sat"<<endl;
    }
    else if(x%7==3){
        cout<<"sun"<<endl;
    }
    else if(x%7==4){
        cout<<"mon"<<endl;
    }
    else if(x%7==5){
        cout<<"tue"<<endl;
    }
    else if(x%7==6){
        cout<<"wed"<<endl;
    }
    else if(x%7==0){
        cout<<"thu"<<endl;
    }
    else if(x%7==1){
        cout<<"fri"<<endl;
    }
    }


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

int main()
{
  int a,b,ans;
  int d[10]={0,1,10,100,1000,10000,100000,1000000,10000000,100000000};
  int e[10]={0,0,1,2,3,4,5,6,7,8};
  
  while(cin >> a >> b){
    int sum=a+b;
    for(int i=1;i<10;i++){
      if(d[i-1]<=sum && sum<d[i]){
	ans=e[i];
      }
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;

int main(){
    string S,T;cin>>S>>T;
    int N_S=S.size();
    int N_T=T.size();
    string dp[2][3010];

    for(int i=1;i<=N_S;i++){
        for(int j=1;j<=N_T;j++){
            if(dp[0][j].size()>dp[0][j-1].size())        dp[1][j]=dp[0][j];
            else if(dp[1][j-1].size()>dp[0][j-1].size()) dp[1][j]=dp[1][j-1];
            else{
                if(S[i-1]==T[j-1]) dp[1][j]=dp[0][j-1]+S[i-1];
                else               dp[1][j]=dp[0][j-1];
            }
        }
        for(int j=1;j<=N_T;j++)
            dp[0][j]=dp[1][j];
    }
    cout<<dp[0][N_T]<<endl;

    return 0;
}

Measured memory_bytes: 7952
/*=============================================================================================================================/*
                                               Bismillahir Rahmanir Rahim

      _     ____  ___  ____   _   _  _         ___  ____   _         _     __  __
     / \   / ___||_ _|| __ ) | | | || |       |_ _|/ ___| | |       / \   |  \/  |
    / _ \  \___ \ | | |  _ \ | | | || |        | | \___ \ | |      / _ \  | |\/| |
   / ___ \  ___) || | | |_) || |_| || |___     | |  ___) || |___  / ___ \ | |  | |
  /_/   \_\|____/|___||____/  \___/ |_____|   |___||____/ |_____|/_/   \_\|_|  |_|

   _   __           __  __  __
  |_) (_  _  o__   /   (_  |_
  |_)o__)(_  || |  \__ __) |__

    ___                    _   _      _                _ _               __   ___                 _         _        _
   / __|_ _ ___ ___ _ _   | | | |_ _ (_)_ _____ _ _ __(_) |_ _  _   ___ / _| | _ ) __ _ _ _  __ _| |__ _ __| |___ __| |_
  | (_ | '_/ -_) -_) ' \  | |_| | ' \| \ V / -_) '_(_-< |  _| || | / _ \  _| | _ \/ _` | ' \/ _` | / _` / _` / -_|_-< ' \
   \___|_| \___\___|_||_|  \___/|_||_|_|\_/\___|_| /__/_|\__|\_, | \___/_|   |___/\__,_|_||_\__, |_\__,_\__,_\___/__/_||_|
                                                            |__/                           |___/


   FB: https://facebook.com/SIAsibul
   Gmail: asibulislam8@gmail.com

/*=============================================================================================================================*/

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;
typedef vector<pll> vll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,n) for(ll i=0;i<(n);i++)
#define f1(i,n) for(ll i=1;i<=(n);i++)
#define f2(i,a,n) for(ll i=(a);i<=(n);i++)
#define fr(i,n,a) for(ll i=(n);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define nl "\n"


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

void solve(){
    int n; cin >> n;
    ll a[n];
    f0(i, n) cin >> a[i];


    int cnt = 0;
    f0(i, n){
        f2(j, i+1, n-1){
            f2(k, j+1, n-1){
                if(a[i]+a[j] > a[k] && a[j]+a[k] > a[i] && a[i]+a[k] > a[j] && a[i] != a[j] && a[j] != a[k] && a[i] != a[k]) cnt++;
            }
        }
    }

    cout << cnt << nl;

}



int main(){
    ll t;
    //cin >> t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
 }


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

char s[105], t[105];
int a[105], b[105];

int main()
{
	bool flag = 0;
	scanf ("%s", s);
	scanf ("%s", t);
	int lens = strlen(s);
	int lent = strlen(t);
	for (int i = 0; i <= lens - 1; i++)	a[i] = s[i] - '0';
	for (int i = 0; i <= lent - 1; i++)	b[i] = t[i] - '0';
	if (lens < lent){
		printf ("LESS\n");
		return 0;
	}
	else if (lens > lent){
		printf ("GREATER\n");
		return 0;
	}
	else{
		for (int i = 0; i <= lens - 1; i++){
			if (a[i] == b[i])	continue;
			else{
				flag = 1;
				if (a[i] > b[i]){
					printf ("GREATER\n");
					return 0;
				}
				else {
					printf ("LESS\n");
					return 0;
				}
			}
		}
	}
	if (flag == 0)	printf ("EQUAL\n");
}


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

int main()
{
    string s, p;
    int n;
    cin >> s >> p;
    s += s;
    for (int i = 0; i < s.length(); i++)
    {
        n = 0;

        if (s[i] == p[0])
        {
            n++;
            for (int j = 1; j < p.length(); j++)
            {
                if (s[i + j] == p[j])
                {
                    n++;
                }
                else 
                {
                    break;
                }
            }
            if (n == p.length())
            {
                 cout << "Yes" << endl;
                 break;
            }
        }
    }

    if(n != p.length())
    {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3228
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int SIZE = 1000000 + 5;
int n, m, A, a[SIZE], e[SIZE], v[SIZE], prime[SIZE];
int GCD(int x, int y)
{
	return y ? GCD(y, x % y) : x;
}
void primes()
{
	memset(v, 0, sizeof(v));
	m = A = 0;
	for(int i = 0; i < n; ++ i) A = max(A, a[i]);
	for(int i = 2; i <= A; ++ i)
	{
		if(!v[i])
		{
			v[i] = i;
			prime[++ m] = i;
		}
		for(int j = 1; j <= m; ++ j)
		{
			if(prime[j] > v[i] || prime[j] > A / i) break;
			v[prime[j] * i] = prime[j];
		}
	}
	return;
}
void divide()
{
	memset(e, -1, sizeof(e));
	for(int i = 0; i < n; ++ i)
	{
		int t;
		while(v[a[i]])
		{
			t = v[a[i]];
			a[i] /= t;
			if(e[t] == -1) e[t] = i;
			else if(e[t] != i) 
			{
				puts("setwise coprime");
				return;
			}
		}
	}
	puts("pairwise coprime");
	return;
}
int main()
{
	scanf("%d", &n);
	for(int i = 0; i < n; ++ i) scanf("%d", &a[i]);
	primes();
	int tmp = a[0];
	for(int i = 1; i < n; ++ i) tmp = GCD(tmp, a[i]);
	if(tmp > 1)
	{
		puts("not coprime");
		return 0;
	}
	divide();
	return 0;
}

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

 
int main(){
  int i;
  float N, T, A;
  cin >> N >> T >> A;
  int mini;
  vector<float> h(N), delta(N);
  for(i=0;i<N;i++){
    cin >> h[i];
    delta[i] = abs(T-(h[i]*0.006) - A);
  }
  mini = distance(delta.begin(),min_element(delta.begin(),delta.end()));
  cout << mini+1  << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;

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

	for (int i = 0; i < n; i++) {
		cin >> N[i];
	}

	int m;
	cin >> m;
	vector<int> P(m), X(m);

	for (int i = 0; i < m; i++) {
		cin >> P[i] >> X[i];
	}

	for (int i = 0; i < m; i++) {
		int tmp = N[P[i] - 1];
		N[P[i] - 1] = X[i];

		int sum = 0;
		for (int j = 0; j < n; j++) {
			sum = sum + N[j];
		}
		cout << sum << endl;
		N[P[i] - 1] = tmp;
	}
}

Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String ss = sc.next();
		String tt = sc.next();
		sc.close();

		char[] s = ss.toCharArray();
		char[] t = tt.toCharArray();
		int n = s.length;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append('z');
		}
		String z = sb.toString();
		String ans = z;

		String a = ss.replaceAll("\\?", "a");
		for (int i = 0; i <= n - t.length; i++) {
			boolean flg = true;
			for (int j = 0; j < t.length; j++) {
				if (s[i + j] != '?' && s[i + j] != t[j]) {
					flg = false;
					break;
				}
			}
			if (flg) {
				String val = a.substring(0, i) + tt;
				if (val.length() < n) {
					val += a.substring(i + t.length);
				}
				if (val.compareTo(ans) < 0) {
					ans = val;
				}
			}
		}
		if (ans.equals(z)) {
			System.out.println("UNRESTORABLE");
		} else {
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans=0;
	if(a>=k)
	{
		ans+=k;
	}
	else if(k>a && k-a<=b)
	{
		ans+=a;
	}
	else
	{
		ans+=(a-(k-a-b));
	}
	cout<<ans;
	 return 0;
}

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
ll dp[1000];
ll sdp[1001][5001];
vector<int> G[1000];
int X[1000];
void solve(int v) {
	for (int to : G[v]) {
		solve(to);
	}
	for (int i = 0; i <= G[v].size(); i++) {
		for (int j = 0; j <= X[v]; j++) sdp[i][j] = 1LL << 60;
	}
	sdp[0][0] = 0;
	for (int i = 0; i < G[v].size(); i++) {
		for (int j = 0; j <= X[v]; j++) {
			if (sdp[i][j] == 1LL << 60) continue;
			int c = G[v][i];
			if (j + X[c] <= X[v]) sdp[i + 1][j + X[c]] = min(sdp[i + 1][j + X[c]], sdp[i][j] + dp[c]);
			if (j + dp[c] <= X[v]) sdp[i + 1][j + dp[c]] = min(sdp[i + 1][j + dp[c]], sdp[i][j] + X[c]);
		}
	}
	ll ans = 1LL << 60;
	for (int i = 0; i <= X[v]; i++) ans = min(ans, sdp[G[v].size()][i]);
	dp[v] = ans;
}
 int main() {
	 int N;
	 cin >> N;
	 for (int i = 1; i < N; i++) {
		 int P;
		 cin >> P;
		 P--;
		 G[P].push_back(i);
	 }
	 for (int i = 0; i < N; i++) cin >> X[i];
	 solve(0);
	 if (dp[0] < (1LL << 60)) cout << "POSSIBLE" << endl;
	 else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 37376
#include <iostream>
#include <algorithm>
using namespace std; 
int main() { 
  int w[10], k[10], sum[2]={}; 
  for(int i=0; i<10; i++) cin >> w[i]; 
  for(int i=0; i<10; i++) cin >> k[i];   
  sort(w, w+10, greater<int>()); 
  sort(k, k+10, greater<int>()); 
  for(int i=0; i<3; i++) { 
    sum[0]+=w[i];  
    sum[1]+=k[i]; 
  } 
  cout << sum[0] << " " << sum[1] << endl;
  return 0;
}


Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1],b[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	int max1=b[n],max2=b[n-1];
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=max1)
		{
			cout<<max1<<endl;
		}
		else
		{
			cout<<max2<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3200
// D - Score Attack

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

const ll INF = 9223372036854775807;
const int MAX_V = 1000;
const int MAX_E = 2000;


struct Edge {
	int from;
	int to;
	ll cost;
};

Edge edges[MAX_E];
ll min_d[MAX_V]; // 最短距離
int V, E, r;

void bellman_ford(int s) {
  bool negative_cycle = false;

	for (int i=0; i<V; i++) {
		min_d[i] = INF;
	}

	min_d[s] = 0;

	int update_cnt = 0;
	while (true) {
		bool update = false;
		for (int i=0; i<E; i++) {
			Edge e = edges[i];
			if (min_d[e.from] == INF) continue;
			if (min_d[e.to] > min_d[e.from] + e.cost) {
				min_d[e.to] = min_d[e.from] + e.cost;
				update = true;
			}
		}

		if (!update) break;
		else update_cnt++;

		if (update_cnt >= V) {
			negative_cycle = true;
			break;
		}
	}

	if (!negative_cycle) return;

	// set negative cycle to -INF
	update_cnt = 0;
	while (true) {
		bool update = false;
		for (int i=0; i<E; i++) {
			Edge e = edges[i];
			if (min_d[e.from] == INF || min_d[e.to] == -INF) continue;
			if (min_d[e.from] == -INF || min_d[e.to] > min_d[e.from] + e.cost) {
				min_d[e.to] = -INF;
				update = true;
			}
		}

		if (!update) break;
		else update_cnt++;
	}
}

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

	V = N;
	E = M;

	int a, b, c;
	for (int i=0; i<E; i++) {
		cin >> a >> b >> c;
		a--;
		b--;
		edges[i] = {a, b, -c};
	}

	bellman_ford(0);

	if (min_d[N-1] == -INF) {
		cout << "inf" << endl;
	} else {
		cout << -min_d[N-1] << endl;
	}

	return 0;
}

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

using namespace std;

#define mm (int)1e5 + 5

int main() {
    
    int cn[mm] = {0};
    long long sum = 0;
    int n, q;
    cin >> n;
    for(int i = 0; i < n; ++i){
        int t;
        cin >> t;
        sum += (long long) t;
        cn[t]++;
    }
    cin >> q;
    for(int i = 0; i < q; ++i){
        int b, c;
        cin >> b >> c;
        int diff = (c - b);
        sum += (long long) diff * cn[b];
        cn[c] += cn[b];
        cn[b] = 0;
        cout << sum << "\n";
    }

}


Measured memory_bytes: 3940
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n;
	cin >> n;
	cout << (n + 1) / 2 << '\n';
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();// ボールの数
        int k = sc.nextInt();// 色の数

        long pattern = 1;
        for (int i = 0; i < n; i++) {
            if (i == 0) {
                pattern *= k;
                continue;
            }

            pattern *= k-1;
        }

        System.out.println(pattern);
    }
}


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

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pti;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; }
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }
template<typename X, typename Y> inline ostream& operator<< (ostream& out, const map<X, Y>& a) { return out << vector<pair<X, Y>>(all(a)); }
template<typename T> inline ostream& operator<< (ostream& out, const pair<T*, int>& a) { return out << vector<T>(a.x, a.x + a.y); }

inline ld gett() { return ld(clock()) / CLOCKS_PER_SEC; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

#ifdef SU1
//#define GEN
#ifndef GEN
#define LOG
#endif
#endif

int n;
string a[200];

bool read() {
  if (!(cin >> n)) return false;
  forn(i, n) assert(cin >> a[i]);
  return true;
}

void solve() {
  sort(a, a + n);
  n = int(unique(a, a + n) - a);
  if (n == 3) puts("Three");
  else if (n == 4) puts("Four");
  else throw;
}

int main() {
#ifdef SU1
  assert(freopen("input.txt", "rt", stdin));
  //assert(freopen("output.txt", "wt", stdout));
#endif

  cout << setprecision(10) << fixed;
  cerr << setprecision(5) << fixed;

  while (read()) {
    ld stime = gett();
    solve();
#ifdef SU1
    cerr << "Time: " << gett() - stime << endl;
#endif
    //break;
  }

  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop for(;;)
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;
#define all(v) begin(v),end(v)
#define pb push_back
#define inf (1e9)
#define eps (1e-9)

typedef long long Integer ;
typedef long double Real;
const Real PI = acosl(-1);
typedef pair<int, int> P;

template<class S, class T> inline
ostream& operator<<(ostream&os, pair<S,T> p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template<class S, class T, class U> inline
ostream& operator<<(ostream&os, tuple<S,T,U> t) {
  return os << '('
    << get<0>(t) << ", "
    << get<1>(t) << ", "
    << get<2>(t) << ')';
}

template<class T> inline
ostream& operator<<(ostream&os, set<T> v) {
  os << "(set";
  for (T item: v) os << ' ' << item;
  os << ")";
  return os;
}

template<class T> inline
ostream& operator<<(ostream&os, vector<T> v) {
  if (v.size() == 0) { return os << "(empty)"; }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

template<class T> inline
istream& operator>>(istream&is, vector<T>&v) {
  rep (i, v.size()) is >> v[i];
  return is;
}

//           ^   >  v   <
int dx[] = { -1, 0, 1,  0 };
int dy[] = {  0, 1, 0, -1 };

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<bool> vb;

int table[11][10000];
int memo[10];

void f(int size, int depth, int sum) {
  if (size + 1 == depth) {
    table[size][sum]++;
  }
  else {
    rep (i, 10) {
      if (memo[i] == 0) {
        memo[i] = 1;
        f(size, depth+1, sum+i*depth);
        memo[i] = 0;
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout.setf(ios::fixed);
  cout.precision(10);
  random_device dev;
  mt19937 rand(dev());

  rep (i, 10) {
    memset(memo, 0, sizeof(memo));
    f(i+1, 1, 0);
  }

  int n,s;
  while (cin >> n >> s)
    cout << table[n][s] << endl;

  return 0;
}

Measured memory_bytes: 1292
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(m)]
a = sorted(a,key=lambda x:x[1])
ans = [0]
for a_ in a:
    if not a_[0] < ans[-1] <= a_[1]:
        ans.append(a_[1])
print(len(ans)-1)

Measured memory_bytes: 29852
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

const int M = 1000000007;

ll h, w, a, b, ans;
ll fac[200005];

ll pow(ll p, ll q) {
    ll re = 1;
    for(; q; q >>= 1, p = p * p % M) {
        if(q&1) re = re * p % M;
    }
    return re;
}

int main()
{
    scanf("%lld%lld%lld%lld", &h, &w, &a, &b);
    fac[0] = 1;
    for(ll i = 1; i <= 200000; i++) fac[i] = fac[i - 1] * i % M;
    for(ll i = b; i < w; i++)
    {
        ll h1 = h - a - 1;
        ll t1 = fac[h1 + i] * pow(fac[h1], M - 2) % M * pow(fac[i], M - 2) % M;
        ll h2 = a - 1;
        ll t2 = fac[h2 + w - i - 1] * pow(fac[h2], M - 2) % M * pow(fac[w - i - 1], M - 2) % M;
        ans += t1 * t2;
        ans %= M;
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 1792
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    if n%2==1:
        print(0)
        exit()

    ans = 0
    cnt = 10
    while True:
        ans += n//cnt
        cnt *= 5
        if cnt > n:
            break
    print(ans)



if __name__=="__main__":
    main()


Measured memory_bytes: 65332
import Control.Applicative
import Data.Set as Set
import Data.List as List

chunksOf :: Int -> [a] -> [[a]]
chunksOf n [] = []
chunksOf n xs = (take n xs):(chunksOf n $ drop n xs)

f :: Int -> String -> [String]
f n s
  | n <= (length s) = (take n s):(f n $ tail s)
  | otherwise = []

g :: Int -> String -> (Set String)
g n s
  | n <= (length s) = Set.insert (take n s) (g n $ tail s)
  | otherwise = fromList []

main = do
  s <- getLine
  k <- read <$> getLine :: IO Int
  --let s = "atcoderandatcodeer"
  --let k = 5
  --let s = "aba"
  --let k = 4
  --print $ Set.toAscList $ Set.unions $ List.map (\i -> g i s) [1..k]
  putStrLn $ (!! (k - 1)) $ List.sort $ List.nub $ List.concat $ List.map (\i -> f i s) [1..k]


Measured memory_bytes: 5500
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 2*n;
    if((b-a)%2 == 0) ans = (b-a) / 2;
    else{
        ll na = 1, nb = b - (a - 1), cnt = a - 1;
        ans = cnt + (nb - na + 1) / 2;
        na = a + (n - b), nb = n, cnt = n - b;
        chmin(ans, cnt + (nb - na + 1) / 2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  char s[20];
  scanf("%s",s);
  int flg=0;
  FOR(strlen(s))if(i&&s[i]!='9')flg=1;
  PRN((s[0]-'0')-flg+9*(strlen(s)-1));
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n;
void dfs(int i, string s, int mx){
    if(i == n){
        printf("%s\n", s.c_str());
    }
    else{
        for(char j='a';j<=mx+1;j++){
            dfs(i+1, s+j, max(mx, (int)j));
        }
    }
}
int main(){
    scanf("%d", &n);
    dfs(0, "", 'a'-1);
}

Measured memory_bytes: 1536
s = input()
n = len(s)
r, l = 0, 0
odd, even = 0, 0
ans = [0] * n
for i in range(n):
    if i % 2 == 0:
        even += 1
    else:
        odd += 1
    if i == n - 1 or s[i] != s[i + 1]:
        if s[i] == 'R':
            r, l = i, i + 1
        if r % 2 == 0:
            ans[r] += even
            ans[l] += odd
        else:
            ans[r] += odd
            ans[l] += even
        odd, even = 0, 0
print(*ans, sep=' ')

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> table(H, vector<char>(W));
  vector<bool> hflag(H,true);
  vector<bool> wflag(W,true);

  // 行列チェック
  for(int h = 0; h < H; h++) {
    for(int w = 0; w < W; w++) {
      cin >> table.at(h).at(w);
      if( table.at(h).at(w) == '#') {
        hflag.at(h) = false;
        wflag.at(w) = false;
      }
    }
  }

  // falseのときはスキップして出力
  for(int h = 0; h < (int)table.size(); h++){
    if(hflag.at(h)) continue;
    for(int w = 0; w < (int)table.at(h).size(); w++){
      if(wflag.at(w)) continue;
      cout << table.at(h).at(w);
    }
    cout << endl;
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cctype>
using namespace std;
string lower_case = "abcdefghijklmnopqrstuvwxyz";
int judge(char s){
	if(s=='m')return 1000;
	else if(s=='c')return 100;
	else if(s=='x')return 10;
	else if(s=='i')return 1;
}
int decode(string s){
	int i,sum=0;
	for(i=0;i<s.size()||!s.empty();){
//		cout<<"s:"<<s<<endl;
		int d=1;
		int num=1;
//		cout<<"___"<<s<<endl;
		i=s.find_first_of(lower_case);
//		cout<<"i:"<<i<<endl;
		int index=i;
		if(i>0&&(s[i-1]>='0'&&s[i-1]<='9')){
			index--;d++;
			num=s[i-1]-'0';
		}
		sum+=num*judge(s[i]);
//		cout<<"("<<s[i]<<")sum:"<<sum<<endl;
//		cout<<"erase:"<<index<<"_"<<d<<endl;
		s.erase(index,d);

	}
	return sum;
}
string convert(int n){
	int d=1000;
	string s="";
//	cout<<"convert"<<endl;
	for(;d>0;d/=10){
		if((n/d)%10){
			if((n/d)%10>1)s+='0'+(n/d)%10;
			if(d==1000)s+="m";
			else if(d==100)s+="c";
			else if(d==10)s+="x";
			else if(d==1)s+="i";
		}
//		cout<<"d:"<<d<<" s:"<<s<<endl;
	}
	return s;
}
int main(){
	int sum,d;
	cin>>d;
	string str1,str2;
	for(;d>0;d--){
		cin>>str1>>str2;
		sum=decode(str1)+decode(str2);
//		cout<<"sum_"<<sum<<endl;
//		cout<<"-----------"<<endl;
		cout<<convert(sum)<<endl;;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

int main(void)

{  

   char num_str[1002];  

   int num;  

   long sum = 0;  

   int i;  

   char tmp;    

   while (1)  

   {   

         fgets(num_str, sizeof(num_str),stdin);      

         if(num_str[0] == '0') {

         break;

         }      

         for (i = 0; i <strlen(num_str)-1; i++)   

         {    

                  tmp = num_str[i];    

                  num = atoi(&tmp);    

                  sum = sum + num;   

         }      

         printf("%ld\n",sum);      

         sum = 0;   

          memset(num_str,1002,0);     

      }  

   return 0;

}

Measured memory_bytes: 532
import java.io.*;
import java.util.*;
public class Main {

  public static void main (String args[]) throws Exception {
  
    if(oddEven() == 1) {
        System.out.println("Odd");
    } else {
        System.out.println("Even");
    }
  }
 
  public static int oddEven() throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        StringTokenizer st;
        int prod = 0;
        String[] tmp = line.split(" ");
        prod = Integer.parseInt(tmp[0]) * Integer.parseInt(tmp[1]);
        
        return prod % 2;
  }

}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#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 rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    int n,k;cin>>n>>k;
    double ans=0;
    for(int i=1;i<=n;i++){
        int score=i;
        double tmp=1/(double)n;
        if(score<k){
            while(score<k){
                score*=2;
                tmp*=1/(double)2;
            }
        }
        //printf("%.10f\n",tmp);
        ans+=tmp;
        //cout<<tmp<<endl;
    }
    printf("%.10f\n",ans);
}


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

int main() {
  
  int A=0, B=0;
  
  cin >> A >> B;
  
  int judge = A*B;
  
  if(judge%2==0) {
    
    cout << "No" << endl;
    
    return 0;
    
  } else if(judge%2!=0) {
    
    cout << "Yes" << endl;
    
    return 0;
    
  }
  
}

Measured memory_bytes: 256
slist = list(input())
tlist = list(input())

slist_new = [slist[0] + '0', slist[1] + '1', slist[2] + '2']
tlist_new = [tlist[0] + '0', tlist[1] + '1', tlist[2] + '2']

list02 = slist_new + tlist_new
andlist = [x for x in list02 if list02.count(x) > 1]

print(len(andlist) // 2)


Measured memory_bytes: 9076
#include <stdio.h>

int main(void){

  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int count[9];
  for (int i = 0; i < 9; i++) {
    count[i] = 0;
  }
  int color;
  for (int i = 0; i < n; i++) {
    color = a[i]/400;
    if (color > 8) {
      color = 8;
    }
    count[color]++;
  }
  int min = 0;
  for (int i = 0; i < 8; i++) {
    if (count[i] != 0) {
      min++;
    }
  }
  int max = min;
  if (count[8] != 0) {
    max = min+count[8];
  }
  if (min == 0) {
    min = 1;
  }
  printf("%d %d\n", min, max);

  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>
#include <algorithm>
 
using namespace std;
 
 
 
int main() {
    int d,d1,i,j,k;
    int c[26];
    int s[365][26];
    cin >> d;
    d1 = 0;
    for(i = 0; i < 26; ++i) cin >> c[i];
    for(i = 0; i < d; ++i) for(j = 0; j < 26; ++j) cin >> s[i][j];
 
    int arr[365] = {};
 
    int t1,t2,s1,s2, diff, count;
    count = 0;
    int max, loc;
    int a[26];
    for(int i = 0; i < 26; ++i) a[i] = 1;
    int b[26] = {};
    for(i = 0; i < 365; ++i) {
        for(j = 0; j < 26; ++j) {
            b[j] = s[i][j]+3*a[j]*c[j];
            a[j]++;
        }
        max = *max_element(b,b+26);
        loc = find(b,b+26,max)-b;
        arr[i] = loc;
        a[loc] = 1;
    }
    
    
    while(true) {
 
 
        label1:
        for(i = 0; i < d; ++i) {
            for(j = 0; j < 26; ++j) {
                if(arr[i]==j) continue;
                if(count>20000000) goto label2;
                ++count;
                for(s1 = i+1; s1 < d; ++s1) {
                    if(arr[s1]==arr[i]) break;
                }
                for(t1 = i-1; t1 >= 0; --t1) {
                    if(arr[t1]==arr[i]) break;
                }
                for(s2 = i+1; s2 < d; ++s2) {
                    if(arr[s2]==j) break;
                }
                for(t2 = i-1; t2 >= 0; --t2) {
                    if(arr[t2]==j) break;
                }
                diff = s[i][j]-s[i][arr[i]]+(((s1-i)*(s1-i-1))/2+((i-t1)*(i-t1-1))/2-((s1-t1)*(s1-t1-1))/2)*c[arr[i]] + (-((s2-i)*(s2-i-1))/2-((i-t2)*(i-t2-1))/2+((s2-t2)*(s2-t2-1))/2)*c[j];
                if(diff>0) {
                    arr[i] = j;
                    goto label1;
                }
            }
        }
    }
    label2:
    for(i = 0; i < d; ++i) {
        cout<<(arr[i]+1)<<"\n";
    }
 
 
    return 0;
}

Measured memory_bytes: 3652
import itertools

n = int(input())

l = list(itertools.product([0,1], repeat=n))[::-1]

A = {}
for i in range(n):
    ai = int(input())
    for j in range(ai):
        x, y = map(int, input().split())
        if i not in A:
            A[i] = []
        A[i].append((x, y))
    if ai == 0:
        A[i] = []


def shoujiki(i):
    check = {}
    cnt = 0
    for j in range(n):
        check[j+1] = i[j]
    for j in range(n):
        ai = len(A[j])
        if i[j] == 1:
            for k in range(ai):
                x, y = A[j][k]
                if check[x] != y:
                    return 0
    #return (check, shougen, cnt0, cnt)
    return sum(i)

mans = 0
for i in l:
    mans = max(shoujiki(i), mans)

print(mans)


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

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

    if (V <= W)
    {
        cout << "NO" << endl;
        exit(0);
    }

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

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define lint long long
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define to_stirng to_string
using namespace std;

// cout << fixed << setprecision(12)

int main(){
  lint X,N;
  cin >> X >> N;
  
  vector<lint> P(N);
  for(lint i=0; i<N; i++) cin >> P[i];
  // sort(ALL(P));
  
  for(lint d=0; d<=99; d++){ // 差
    bool kaburi1 = false;
    bool kaburi2 = false;
    for(lint i=0; i<N; i++){
      if(P[i]==X+d) kaburi1 = true;
      if(P[i]==X-d) kaburi2 = true;
    }
    if(kaburi1 && kaburi2) continue;
    else{
      if(!(kaburi2)){
        cout << X-d << endl;
        break;
      }else{
        cout << X+d << endl;
        break;
      }
    }
  }
}
      
  
  


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
	int m,d;
	while(cin >> m >> d,m){
		int sum = 0;
		for(int i = 1; i < m; i++){
			switch(i){
				case 1:
				case 3:
				case 5:
				case 7:
				case 8:
				case 10:
					sum += 31;
					break;
				case 4:
				case 6:
				case 9:
				case 11:
					sum += 30;
					break;
				case 2:
					sum += 29;
					break;
				default:
					break;
			}
		}
		sum += d;
		switch(sum%7){
			case 0:
				cout << "Wednesday" << endl;
				break;
			case 1:
				cout << "Thursday" << endl;
				break;
			case 2:
				cout << "Friday" << endl;
				break;
			case 3:
				cout << "Saturday" << endl;
				break;
			case 4:
				cout << "Sunday" << endl;
				break;
			case 5:
				cout << "Monday" << endl;
				break;
			case 6:
				cout << "Tuesday" << endl;
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 1152