akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
int M,W,memo[13][1<<13];
vector<int> A,B;
 
int getEn(int bm,int bw){
    int x = abs(bm-bw);
    return x*pow(x-30,2);
}
 
int solve(int idx,int S){
    if(idx == M){ return memo[idx][S] = 0; }
    if(memo[idx][S] >= 0){ return memo[idx][S]; }
    int res = -1;
    for(int i = 0 ; i < W ; i++){
	if(S >> i & 1){ continue; }
	res = max(res,solve(idx+1,S|(1<<i))+getEn(A[idx],B[i]));
    }
    return memo[idx][S] = res;
}
 
int main(){
    while(cin >> M >> W, M){
	A.resize(M); B.resize(W);
	for(int i = 0 ; i < M ; i++){ cin >> A[i]; }
	for(int i = 0 ; i < W ; i++){ cin >> B[i]; }
	if(M > W){ swap(M,W); swap(A,B); }
	memset(memo,-1,sizeof(memo));
	cout << solve(0,0) << endl;
    }
    return 0;
}

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

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

    long long x;
    cin >> x;

    long long ans = x / 11 * 2;
    x %= 11;
    if(x > 0){
        if(x > 6) ans += 2;
        else ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 10000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < vi, int > a, pair < vi, int > b)//true for a before b
{
	if(a.F.empty())
		return 1;
	if(b.F.empty())
		return 0;
	int i;
	fo(i,0,min(sz(a.F),sz(b.F)))
	{
		if(a.F[i] < b.F[i])
			return 1;
		else if(a.F[i] > b.F[i])
			return 0;
	}
	return (sz(a.F) <= sz(b.F));
}

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 900;
const int SQRT = BUCK+9;

ll p3[N], p2[N];
string s;

void pre()
{
	int i;
	p3[0] = 1;
	p2[0] = 1;
	fo(i,1,N)
	{
		p3[i] = (3LL*p3[i-1])%mod;
		p2[i] = (2LL*p2[i-1])%mod;
	}
	return;
}

void solve()
{
	pre();
	int n, i, cnt1 = 0;
	ll ans = 0;
	cin >> s;
	n = s.length();
	fo(i,0,n)
		if(s[i] == '1')
		{
			ans = (ans + p3[n-1-i]*p2[cnt1])%mod;
			cnt1++;
		}
	ans = (ans + p2[cnt1])%mod;
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(15);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    int right=1;
    int count=0;
    bool ok=false;
    for(int i=0;i<n;i++){
        right=a[right-1];
        count++;
        if(right==2){
            ok=true;
            break;
        }
    }
    if(ok) cout<<count<<endl;
    else cout<<-1;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
	double p=3.141592653589,r,x,y;
	cin>>r;
	x=p*r*r;
	y=2*p*r;
	cout<<fixed<<setprecision(6)<<x<<" "<<y<<endl;
	return 0;
}

Measured memory_bytes: 1284
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll res=pow(x,y/2);
  res*=res;
  res%=mod;
  if(y%2==1) res*=x;
  return res%mod;
}
ll gyaku(ll x){
  return pow(x,mod-2);
}
vector<ll> frac,gfrac;
void set_frac(ll n){
  frac.push_back(1);
  gfrac.push_back(1);
  for(ll i=1;i<=n;i++){
    frac.push_back(frac[i-1]*i%mod);
    gfrac.push_back(gyaku(frac[i]));
  }
}
ll nCr(ll n,ll r){
  ll res=frac[n]*gfrac[r]%mod;
  res*=gfrac[n-r];
  return res%mod;
}

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll ans=pow(2,n);
  ll k1=1,k2=1;
  for(ll i=1;i<=a;i++){
    k1*=n-i+1;
    k1%=mod;
    k1*=gyaku(i);
    k1%=mod;
  }
  for(ll i=1;i<=b;i++){
    k2*=n-i+1;
    k2%=mod;
    k2*=gyaku(i);
    k2%=mod;
  }
  ll k=(k1+k2)%mod;
  ans-=k;
  ans+=mod;
  ans%=mod;
  cout<<ans-1<<endl;
}


Measured memory_bytes: 256
/*
氏名 : 杉谷　裕貴,学籍番号 : 190441066
概要 : ３つの整数を読み込み、それらを値が小さい順に並べて出力するプログラム
*/
#include<stdio.h>

int main(void)
{
	int a, b, c, change;/*整数型の変数の宣言*/

	scanf("%d %d %d", &a, &b, &c);/*数字の入力*/

	if (a > b)/*aがbより大きいとき*/
	{
		change = a, a = b, b = change;
	}

	if (b > c)/*bがcより大きいとき*/
	{
		change = b, b = c, c = change;
	}

	if (a > b)/*aがbより大きいとき*/
	{
		change = a; a = b, b = change;
	}

	printf("%d %d %d\n",a,b,c);

	return 0;
}


Measured memory_bytes: 2072
s = list(input())

a = [1]
for i in range(len(s)):
	k = i % 2
	if k ==0:
		if s[i] == 'R' or s[i] == 'U' or s[i] == 'D':
			a.append(1)
		else:
			a.append(0)
	else:
		if s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
			a.append(1)
		else:
			a.append(0)

if min(a) == 0:
	ans = 'No'
else:
	ans = 'Yes'

print(ans)


Measured memory_bytes: 3060
def kaibun(x):
  if(x != ''.join(list(reversed(x)))):
    return 0
  else:
    return 1


def main():
  s = input()
  s_num = len(s)

  num1 = kaibun(s[:int((s_num - 1)/2)])
  num2 = kaibun(s[(int((s_num + 1)/2)):s_num])

  if(num1 == 1 and num2 == 1):
    if(s == ''.join(list(reversed(s)))):
      print('Yes')
    else:
      print('No')
  else:
    print('No')

if __name__ == '__main__':
  main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <limits>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <deque>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <sstream>
#include <type_traits>
#define SET(x,y) x |= (1 << y)
#define CLEAR(x,y) x &= ~(1<< y)
#define READ(x,y) ((0u == (x & (1<<y)))?0u:1u)
#define TOGGLE(x,y) (x ^= (1<<y))
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define sl(n) scanf("%lld",&n)
#define slu(n) scanf("%llu",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pF first
#define pS second
#define CL(a,b) memset(a,b,sizeof(a))
#define sqr(x) ((x)*(x))
#define intLIMIT numeric_limits<int>
#define longLIMIT numeric_limits<long long>
#define GCD(a,b) __gcd((a),(b))
#define dbl(x) (double)(x)
#define vi vector <int>
#define vii vector < pair <int, int> >
#define vll vector <long long>
#define allof(x) (x).begin(), (x).end()
#define fastCin cin.sync_with_stdio(0);cin.tie(0)
#define scanUnsigned(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#define printArr(a,l) cout<<#a<<": ";for(int i=0;i<(l);i++){cout<<a[i]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(int i=0;i<(r);i++){for(int j=0;j<(c);j++){cout<<a[i][j]<<" ";}cout<<endl;}
char _;
using namespace std;
void PRINT (int x, int y) { for (int i = y-1; i >= 0; i--) { cout << READ(x,i); } cout << endl; }

vector<string>vec_splitter(string s){s+=',';vector<string>res;while(!s.empty()){res.push_back(s.substr(0,s.find(',')));s=s.substr(s.find(',')+1);}
return res;}
void debug_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,__attribute__((unused))int LINE_NUM){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(vector<string>args,int idx,int LINE_NUM,Head H,Tail...T){if(idx>0)cerr<<", ";else cerr<<"Line("<<LINE_NUM<<") ";stringstream ss;ss<<H;cerr<<args[idx]<<" = "<<ss.str();debug_out(args,idx+1,LINE_NUM,T...);}
#ifdef LOCAL_DBG
#define dbg(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define dbg(...) 42
#endif

int main () {
	fastCin;
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while (b <= a && k > 0) {
		k--;
		b *= 2;
	}
	while (c <= b && k > 0) {
		k--;
		c *= 2;
	}
	if (a < b && b < c) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3132
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;

    int A[N][3];
    for(int n = 0; n < N; ++n){
        cin >> A[n][0] >> A[n][1] >> A[n][2];    
    }
    
    int dp[N + 1][3];
    for(int n = 0; n <= N; ++n) {
        for(int i = 0; i < 3; ++i) {
            if (n == 0) {
                dp[n][i] = 0;
            } else {
                dp[n][i] = max(dp[n - 1][(i + 1) % 3],  dp[n - 1][(i + 2) % 3]) + A[n - 1][i];
            }
        }
    }
 
    int res = 0;
    for(int i = 0; i < 3; ++i){
        res = max(res, dp[N][i]);    
    }
    
    cout << res << endl;
    
}


Measured memory_bytes: 2560
use std::io;


/// https://beta.atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualB_b
fn main() {
    let (n, a, b) = {
        let i = read::<usize>();
        (i[0], i[1], i[2])
    };
    let sn = read_one::<String>().chars().collect::<Vec<char>>();
    let mut cnt = 0;
    let mut f = 0;
    for i in 0..n {
        match sn[i] {
            'a' => {
                if cnt < a + b { println!("Yes"); cnt += 1; }
                else { println!("No"); }
            },
            'b' => {
                if cnt < a + b && f < b { println!("Yes"); cnt += 1; f += 1; }
                else { println!("No"); }
            },
            'c' => {
                println!("No");
            },
            _ => unreachable!(),
        }
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4732
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	long long N;
	cin >> N;

	long long ans = 0;
	long long v_max = 0;

	for (long long i = 1; i * i <= N - 1; i++) {
		v_max = i;
	}

	ans = v_max * v_max;

	for (long long i = v_max + 1; i <= N - 1; i++) {
		for (long long j = 1; j * i <= N - 1; j++) {
			ans += 2;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3620
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!
    val b = readLine()!!
    val c = readLine()!!

    var cnt = 0
    for (i in 0 until n) {
        if (a[i] == b[i] && b[i] == c[i]) continue
        if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) {
            cnt += 2
        } else {
            cnt++
        }
    }

    println(cnt)
}

Measured memory_bytes: 33728
// Ho-kago Tea Time

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int MAXN = (int) 2e3;

int n, m, Q;

int S[MAXN + 5][MAXN + 5];

inline char safe_getchar()
{
	register char ch(getchar());
	while(!isgraph(ch)) ch = getchar();
	return ch;
}

inline void input()
{
	n = read<int>(), m = read<int>(), Q = read<int>();
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			S[i][j] = safe_getchar() == '1';
}

inline void solve()
{
	static int pre[MAXN + 5][MAXN + 5], f[MAXN + 5][MAXN + 5], g[MAXN + 5][MAXN + 5];

	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			pre[i][j] = pre[i - 1][j] + pre[i][j - 1] - pre[i - 1][j - 1] + S[i][j];
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j < m; ++j)
			f[i][j] = S[i][j] & S[i][j + 1];
	for(int i = 1; i < n; ++i)
		for(int j = 1; j <= m; ++j)
			g[i][j] = S[i][j] & S[i + 1][j];

	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
		{
			f[i][j] += f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];
			g[i][j] += g[i - 1][j] + g[i][j - 1] - g[i - 1][j - 1];
		}

	auto calc = [&] (int x0, int y0, int x1, int y1) { return pre[x1][y1] - pre[x1][y0 - 1] - pre[x0 - 1][y1] + pre[x0 - 1][y0 - 1]; };
	auto calc_f = [&] (int x0, int y0, int x1, int y1)
	{
		--y1;
		return y0 > y1 ? 0 : f[x1][y1] - f[x1][y0 - 1] - f[x0 - 1][y1] + f[x0 - 1][y0 - 1];
	};
	auto calc_g = [&] (int x0, int y0, int x1, int y1)
	{
		--x1;
		return x0 > x1 ? 0 : g[x1][y1] - g[x1][y0 - 1] - g[x0 - 1][y1] + g[x0 - 1][y0 - 1];
	};

	while(Q--)
	{
		int x0 = read<int>(), y0 = read<int>(), x1 = read<int>(), y1 = read<int>();
		int ans = calc(x0, y0, x1, y1) - calc_f(x0, y0, x1, y1) - calc_g(x0, y0, x1, y1);
		printf("%d\n", ans);
	}
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



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

int group(int x){
  if(x==1 or x==3 or x==5 or x==7 or x==8 or x==10 or x==12) return 0;
  else if(x==4 or x==6 or x==9 or x==11) return 1;
  else return 2;
}

int main(){
  int x,y; cin >> x >> y;
  x = group(x);
  y = group(y);
  if(x==y) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
string s;

int main(){
    cin >> n >> s;
    int ans = 0;
    bool ok = true;
    rep(i,s.size()) {
        if(s[i] == 'x') {
            if(!ok) {
                break;
            } else {
                ok = false;
            }
        } else {
            ok = true;
        }
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3340
#include <cstdio>
#include <vector>

using namespace std;

char s[2];
char ans[4001];

int main() {
    int a, b, n, i;
    vector <int> v;
    
    scanf("%d %d", &a, &b);
    
    if (a <= b) {
        puts("Impossible");
        
        return 0;
    }
    
    n = a + b;
    
    for (i = 0; i < n; i++) {
        if (v.size() == 0) {
            v.push_back(i);
        } else {
            printf("? %d %d\n", i, v.back());
            fflush(stdout);
            
            scanf("%s", s);
            
            if (s[0] == 'Y') {
                v.push_back(i);
            } else {
                v.pop_back();
            }
        }
    }
    
    for (i = 0; i < n; i++) {
        printf("? %d %d\n", v[0], i);
        fflush(stdout);
        
        scanf("%s", s);
        
        if (s[0] == 'Y') {
            ans[i] = '1';
        } else {
            ans[i] = '0';
        }
    }
    
    printf("! %s\n", ans);
    
    return 0;
}


Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int32_t main(){
	ios::sync_with_stdio(false);
    string s;
    cin>>s;

    if(s[0]==s[s.size()-1]){
        if(s.size()%2==1){
            cout<<"Second\n";
        }
        else{
            cout<<"First\n";
        }
    }
    else{
        if(s.size()%2==0){
            cout<<"Second\n";
        }
        else{
            cout<<"First\n";
        }
    }



	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first < another.first;
}


int main()
{

    int a,c,d;
    
    std::cin>> a;

    std::vector< std::pair< int64_t, int64_t > > aa( a );

    for( int i = 0; i < a; i++ )
    {
        std::cin>> aa[i].first;
        aa[i].second = i + 1;
    }

    std::sort( aa.begin(), aa.end(), sort_pair );

    for( int i = 0; i < a; i++ )
    {
        std::cout<< aa[i].second << " ";
    }
}


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

using namespace std;

int main(){
    int  A,B;
    cin >> A >> B;
    for(int i=0;i<100000;i++){
        if(i*8/100==A && i*10/100==B){
            cout << i << endl;
            break;
        }

        if(i==99999){
            cout << "-1" << endl;
        }
    }
}

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

#define INF 2e9

#define REP(i,n) for(int i = 0; i < n;++i)
#define REPA(i,a,n) for(int i = a; i < n; ++i)
#define REPR(i,a) for(int i = a; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

int gcd(int a, int b){ return b ? gcd(b, a % b) : a; }
template<typename A> void psn(A a){ cout << a << endl; }
template<typename A, typename... B> void psn(A a, B... b){ cout << a << ' '; psn(b...); }

int main(void) {
    
    int N;
    string S;
    
    cin >> N >> S;
    
    if(N % 2 == 1){
        psn("No");
        return 0;
    }
    
    string s1 = S.substr(0, N / 2);
    string s2 = S.substr(N / 2);
    
    if(s1.compare(s2) == 0) psn("Yes");
    else psn("No");
    
    return 0;
}

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

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

    if(a==b) cout << "Draw" << endl;
    else if(a==1) cout << "Alice" << endl;
    else if(b==1) cout << "Bob" << endl;
    else if (a>b) cout << "Alice" << endl;
    else cout << "Bob" << endl;

    return 0;
}

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

using namespace std;

#define endl '\n'

int n, a;
int arr[100003];
int arr_ordenado[100003];
map<int, int> posiciones;
int cont = 0;

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

    cin >> n;

    for(int i = 1; i <= n; i++)
    {
        cin >> a;
        arr[i] = a;
        arr_ordenado[i] = a;
    }

    sort(arr_ordenado + 1, arr_ordenado + n + 1);

    for(int i = 1; i <= n; i++)
    {
        posiciones[arr_ordenado[i]] = i;
    }

    for(int i = 1; i <= n; i++)
    {
        if((posiciones[arr[i]] & 1) && (i & 1))
            continue;
        if(!(posiciones[arr[i]] & 1) && !(i & 1))
            continue;
        cont++;
    }

    cout << cont / 2 << endl;
}

Measured memory_bytes: 5760
s=int(input())
a=[s]
b=[0]*1000001
b[s]=1
for i in range(1,1000001):
    if a[i-1]%2==0:
        f=a[i-1]//2
        if b[f]==1:
            print(i+1)
            exit()
        else:
            b[f]=1
            a.append(f)
    else:
        f=3*a[i-1]+1
        if b[f]==1:
            print(i+1)
            exit()
        else:
            b[f]=1
            a.append(f)


Measured memory_bytes: 46192
#include <bits/stdc++.h>
using namespace std;
long long n, m;

int main() {
    cin >> n >> m;
    long long limit = m / n;
    for(long long i = limit; i >= 1; --i) {
        if(m % i == 0) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+10;
const int mod=1e9+7;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,m,f[N][N],fac[N*N],inv[N*N],ifac[N*N];
int C(int n,int m) {
    if(n<0||m<0||n<m) return 0;
    return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main() {
    cin>>n>>m;int N=n*m;
    if(m==1) return puts("1"),0;
    fac[0]=1;for(int i=1;i<=N;i++) fac[i]=1ll*fac[i-1]*i%mod;
    inv[1]=1;for(int i=2;i<=N;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
    ifac[0]=1;for(int i=1;i<=N;i++) ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
    f[0][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=0;j<=i;j++) f[i][j]=(f[i-1][j]+1ll*f[i][j-1]%mod*(n-j+1)%mod*C(n-i+(n-j+1)*(m-1)-1,m-2)%mod)%mod;
    printf("%d\n",f[n][n]);
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


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

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

string s;

int main(){
    cin >> s;
    rep(i, s.length()){
        s[i] = 'x';
    }
    cout << s << endl;
}

Measured memory_bytes: 3604
#include<stdio.h>
int main(void)
{
  int a, b;

  scanf("%d",&a);
  scanf("%d",&b);

  if(a<=1000 && a>=-1000)
  {
    if(b<=1000 && b>=-1000)
    {

      if(a<b)
      {
        printf("a < b\n");
      }

      if(a>b)
      {
        printf("a > b\n");
      }

      if(a==b)
      {
        printf("a == b\n");
      }
    }
  }

  return 0;
}


Measured memory_bytes: 2612
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int sum(vector<int> A,int N){
    int res = 0;
    rep(i,N) res += A[i];
    return res;
}
class Range {
    public:
        int start;
        int step;
        int length;
        int operator[](int i){
            return start + step * i;
}
};
int sum(Range A){
    return (2 * A.start + (A.length - 1) * A.step) * A.length / 2;
}
template <typename T>
vector<T> slice_vector(vector<T> A,int start_idx,int fin_idx){
    vector<T> res(fin_idx - start_idx);
    for (int i = start_idx; i < fin_idx; i++)
    {
        res[i-start_idx] = A[i];
    }
    return res;
}
template <typename T>
void cout_vector(vector<T> A){
    for (int i=0;i<A.size();i++){
        cout << A[i] << " ";  
    }
    cout << endl;
}
int main(){
    int N,ans;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    rep(i,N) cin >> V[i];
    rep(i,N) cin >> C[i];
    rep(i,N) (V[i] > C[i]) && (ans += V[i] - C[i]);
    cout << ans << endl;
}

Measured memory_bytes: 256
d,g = map(int,input().split())
p_input = [0]*d
c_input = [0]*d

for i in range(d):
    p_input[i],c_input[i] = map(int,input().split())

ans=float('inf')
for i in range(2**d):
    problem=0
    point=0
    for j in range(d):
        if ((i>>j)&1):
            problem+=p_input[j]
            point+=(1+j)*100*p_input[j]+c_input[j]
    if point>=g:
        ans=min(ans,problem)
    else:
        for j in range(d-1,-1,-1):
            if ((i>>j)&1):
                continue
            for k in range(p_input[j]):
                if point>=g:
                    break
                problem+=1
                point+=100*(j+1)
        ans = min(ans,problem)
            
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        int y = sc.nextInt() / 1000;
        int tmp = y - n;

        int a = -1;
        int b = -1;
        int c = -1;
        for (int i = 0; i <= n; i++) {
            if (9 * i > tmp) {
                break;
            }

            if ((tmp - 9 * i) % 4 == 0) {
                int d = (tmp - 9 * i) / 4;
                if (i + d > n) {
                    continue;
                }

                a = i;
                b = d;
                c = n - a - b;
                break;
            }
        }

        System.out.println(a + " " + b + " " + c);
    }

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


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define inf 10000000000000007
#define eps 1e-8
#define PI 3.14159265359
#define sp printf(" ")
#define vi vector<int>
#define vl vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define mp make_pair
#define FF first
#define SS second
#define pb(x) push_back(x)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define sld(x) scanf("%ld", &(x))
#define pld(x) printf("%ld", (x))
#define pldn(x) printf("%ld\n", (x))
#define slf(x) scanf("%lf", &(x))
#define plf(x) printf("%.9lf", (x))
#define plfn(x) printf("%.4lf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define ios ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0)
#define endl '\n'
using namespace std;
vector<string>v;
int main()
{
    string s;
    cin>>s;
    int k;
    cin>>k;
    for(int i=0;i<s.size();i++)
    {
        string s1;
        for(int j=i;j<s.size()&&j<=i+k;j++)
        {
            s1+=s[j];
            v.pb(s1);
        }
    }
    sort(v.begin(),v.end());
    if(k==1)cout<<v[0]<<endl;
    else
    {
        int cnt=1;
        for(int i=1;i<v.size();i++)
        if(v[i]!=v[i-1])
        {
            cnt++;
            if(cnt==k){cout<<v[i]<<endl;return 0;}
        }
    }
    
    

    
   
}

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
    int H;
    cin>>H;
    int count = 0;
    int ans = 1;
    int prod = 1;
    while(H>1){
        ans = ans+2*prod;
        prod=prod*2;
        H=H/2;
        count++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, K;
  cin >> N >> K;
  long long tmp = N / K;
  if (K & 1) {
    cout << tmp * tmp * tmp << '\n';
  } else {
    long long tmp2 = 2 * N / K - tmp;
    cout << tmp2 * tmp2 * tmp2 + tmp * tmp * tmp << '\n';
  }
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<long long> d(N);
    for(int i = 0; i < N; i++){
        cin >> d[i];
    }

    long long ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

vector<int> mp(string S){
	vector<int> V(S.size()+1,-1);
	int j = -1;
	repp(i,0,S.size()){
		while(j >= 0 && S[i] != S[j]) j = V[j];
		++j;
		V[i+1] = j;
	}
	return V;
}

vector<LL> solve(LL z, vector<vector<LL>> &A, string S[2], int p){
	vector<LL> V(26,0);
	if(z <= 0) return V;
	if(z >= A[p][26]){
		repp(i,0,26) V[i] = A[p][i];
	} else if(p > 1){
		V = solve(z,A,S,p-1);
		auto W = solve(z-A[p-1][26],A,S,p-2);
		repp(i,0,26) V[i] += W[i];
	} else {
		repp(i,0,z) ++V[S[p][i]-'a'];
	}
	return V;
}

int main(){
	string S; cin >> S;
	LL l,r; cin >> l >> r;
	string T = S.substr(0,S.size()/2);
	int x = mp(T)[T.size()];
	vector<vector<LL>> A(2,vector<LL>(27,0));
	string U[2];
	if(x*2 <= T.size()){
		U[0] = T.substr(x,T.size()-x*2);
		U[1] = T.substr(0,x);
	} else {
		U[0] = T.substr(0,x);
		U[1] = T.substr(0,T.size()-x);
	}
	repp(k,0,2) repp(i,0,U[k].size()){
		++A[k][U[k][i]-'a'];
		++A[k][26];
	}
	x = 1;
	while(A[x][26] < r){
		A.push_back(vector<LL>(27));
		repp(i,0,27) A[x+1][i] = A[x][i] + A[x-1][i];
		++x;
	}
	auto B = solve(r,A,U,x);
	auto C = solve(l-1,A,U,x);
	repp(i,0,26) cout << B[i]-C[i] << (i==25?'\n':' ');
	return 0;
}


Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(std::string S, std::string T){   
    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        if(S[i] == T[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
i,j;main(x){char s[10000];for(;~scanf("%s",s);printf("%d\n%d\n",j,i))for(i=j=x=0;s[x+2]!=0;x++)if(s[x+1]==79&&s[x+2]==73)s[x]-74?s[x]-73?:i++:j++;exit(0);}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vector<ll> x(N);
    rep(i, N) cin >> x[i];
    auto v = x;
    sort(all(x));
    ll res1 = x[(N-1)/2], res2 = x[(N+1)/2];

    rep(i, N){
        if(v[i] <= res1){
            cout << res2 << endl;
        }else{
            cout << res1 << endl;
        }
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 9472
#include<stdio.h>

int main(){
    int i, j, k;
    int N, a[210000];
    int index, sum;
    int ans=0, b[210000];
    int c[210000];
    scanf("%d", &N);
    for(i=0; i<N; i++){
        scanf("%d", &a[i]);
    }

    for(i=N-1; i>=0; i--){
        index=i+i+1;
        sum=0;
        while(index<N){
            sum += b[index];
            index+=i+1;
        }
        if(sum%2!=a[i]){
            b[i]=1;
            c[ans]=i+1;
            ans++;
        }
        //printf("%d ", sum);
    }
    //printf("\n");
    if(ans==0){
        printf("0");
    }else{
        printf("%d\n", ans);
        for(i=ans-1; i>=0; i--){
            printf("%d ", c[i]);
        }
    }

    return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100
int n, m;
bool done(vector<bool> visited)
{
    for(int i = 1; i <= n; i++)
    {
        if(!visited[i]) return false;
    }
    return true;
}

int main()
{
    cin >> n >> m;
    vi adj[9];
    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    vector<bool> visited(9);
    queue<pair<int, vector<bool>>> q;
    visited[1] = 1;
    q.push(make_pair(1, visited));
    int ans = 0;
    while(!q.empty())
    {
        int node = q.front().first;
        vector<bool> visit = q.front().second;
        q.pop();
        if(done(visit))
        {
            ans++;
            continue;
        }
        for(auto u : adj[node])
        {
            vector<bool> visit2(visit);
            if(!visit2[u])
            {
                visit2[u] = 1;
                q.push(make_pair(u, visit2));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

ll lcm(ll a,ll b){
	return a/__gcd(a,b)*b;
}

void mainmain(){
	int n;
	while(cin>>n,n){
		vector<pll> v(n);
		rep(i,n) cin>>v[i].F>>v[i].S;
		ll t=1;
		rep(i,n){
			t=lcm(t,v[i].F);
		}
		vll w(n);
		rep(i,n){
			w[i]=t/v[i].F*v[i].S;
		}
		t=w[0];
		rep(i,n){
			t=__gcd(t,w[i]);
		}
		rep(i,n){
			cout<<w[i]/t<<endl;
		}
	}
}


signed main() {
	ios_base::sync_with_stdio(false);
    cin.tie(0);
  	cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 1204
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
ll n;
//ld ;
//string s, t;
// char c;

int main() {
  cin >> n;
  string ans = "hon";
  ll n1 = n%10;
  if(n1 == 3){
    ans = "bon";
  }else if(n1 == 0 || n1 == 1 || n1 == 6 || n1 == 8){
    ans = "pon";
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0 ; i < N; i ++) {
    cin >> vec.at(i);
  }
  
  int ans = 0;
  
  for (int i = 0; i < N; i++) {
    while(vec.at(i) != 0) {
      ans++;
      for (int j = i; j < N; j++) {
        if (vec.at(j) != 0) vec.at(j)--;
        else break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
 int a, b, c, count = 0;
 while(cin >> a >> b){
 c = a + b;
 while(c != 0){
  c = c / 10;
  count++;
 }
 cout << count << endl;
 count = 0;
}

 return 0; 
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

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

ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}



int main(){
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

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

result = -float('inf')
for i in range(1, 1024):
    t = 0
    for j in range(N):
        t += P[j][sum((i >> k & 1) & F[j][k] for k in range(10))]
    if t > result:
        result = t
print(result)


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

int main() {
    int N, X;
    std::cin >> N >> X;

    int m[N], cnt = N;
    for (int i = 0; i < N; ++i) {
        std::cin >> m[i];
        X -= m[i];
    }

    std::sort(m, m + N);
    cnt += (X / m[0]);

    std::cout << cnt << std::endl;

    return 0;
}


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

string S, T;
int ans = 0;
int main(){
    getline(cin, S);
    getline(cin, T);
    int n = S.size(), idx = 0;
    while(n--){
        if(S[idx] != T[idx]) ans++;
        idx++;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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 gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
int r;cin>>r;
cout<<r*r<<endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n=int(input())
before=[0,0,0]
for i in range(n):
    after=list(map(int,input().split()))
    dt=after[0]-before[0]
    dx=abs(after[1]-before[1])
    dy=abs(after[2]-before[2])
    if dt<dx+dy or (dt-dx-dy)%2==1:
        print('No')
        exit()  
    before=after
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/gcd(a,b)

int main(){
  int a1,m1,a2,m2,a3,m3;

  while(true){
    cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3;
    if(a1+m1+a2+m2+a3+m3 == 0) break;

    ll xx = 0,yy = 0,zz = 0;
    ll x = 1,y = 1,z = 1;

    while(true){
      x = a1*x%m1;
      xx++;
      if(x == 1) break;
    }
    while(true){
      y = a2*y%m2;
      yy++;
      if(y == 1) break;
    }
    while(true){
      z = a3*z%m3;
      zz++;
      if(z == 1) break;
    }

    cout << lcm(xx,lcm(yy,zz)) << endl;
  }

  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S1,S2; cin >> S1>>S2;
    LL ans = 1;
    VI vec;
    int cnt = 0;
    while(cnt < N-1){
        if(S1[cnt] == S1[cnt+1]) {
            vec.eb(2);
            cnt += 2;
        }
        else{
            vec.eb(1);
            cnt++;
        }
    }
    if(cnt == N-1) vec.eb(1);
//    cout << printVector(vec) << endl;
    int pre = -1;
    if(vec[0] == 2){
        ans *= 6;
        pre = 2;
    }
    else{
        ans *= 3;
        pre = 1;
    }
    vec.erase(vec.begin());
    for(auto p : vec){
        if(pre == 2){
            if(p == 1){
                pre = 1;
            }
            else{
                ans = ans * 3 % MOD;
                pre = 2;
            }
        }
        else{
            if(p == 1){
                ans = ans * 2 % MOD;
                pre = 1;
            }
            else{
                ans = ans * 2 % MOD;
                pre = 2;
            }
        }
    }
    cout << ans << endl;

}

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

vector<int> ans, c;
int cur = 0;

void dfs(int v, int p, vector<vector<int>> &G){
	ans[v] = c[cur++];
	for(auto nv : G[v]){
		if(nv == p) continue;
		dfs(nv, v, G);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<vector<int>> G(n);
	ans.resize(n);
	c.resize(n);
	int a, b;
	rep(i,n-1){
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	ll sum = 0;
	rep(i,n){
		cin >> c[i];
		sum += c[i];
	}
	sort(c.rbegin(), c.rend());
	cout << sum - c[0] << endl;
	dfs(0, -1, G);
	rep(i,n){
		cout << ans[i];
		if(i < n-1) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1408