akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


signed main() {
	int n;
	vector<int>list;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		list.push_back(num);
	}

	sort(list.begin(), list.end(), greater<int>());

	int sum = 0;
	for (int i = 1; i < n; i++)sum += list[i];

	if (sum > list[0]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}




	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>

int main(void) {
	int count[4] = { 0 };

	for (size_t i = 0; i < 6; i++) {
		int a;

		std::cin >> a;
		count[a - 1]++;
	}

	int a = 0, b = 0;
	for (size_t i = 0; i < 4; i++) {
		if (count[i] == 1) {
			a++;
		}
		else if (count[i] == 2) {
			b++;
		}
	}

	if (a == 2 && b == 2) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

S = input()
N = len(S)


s1 = S[0::2]
b1 = s1.count('0')
w1 = len(s1) - b1
s2 = S[1::2]
b2 = s2.count('0')
w2 = len(s2) - b2

print(min(b1 + w2, w1 + b2))

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


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

    vector<double> p(n);
    vector<double> sum(n+1);
    sum.at(0)=0;
    rep(i,n){
        cin>>p.at(i);
        p.at(i) = (p.at(i)+1)/2;
        sum.at(i+1) = sum.at(i) + p.at(i);
    }

    double ma=0;
    for(int i=0;(i+k-1)<n;i++){
        ma = max(ma,sum.at(i+k)-sum.at(i));
    }
    cout<<fixed<<setprecision(10)<<ma<<endl;


}

Measured memory_bytes: 3328
a = [0] * 4
for i in range(3) :
  x, y = map(int, input().split())
  a[x-1] = a[x-1] + 1
  a[y-1] = a[y-1] + 1
if a[0] ^ a[1] ^ a[2] ^ a[3] == 0 : print("YES")
else : print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;



int main()
{
	ll k;
	cin>>k;
	ll t= k%10;
	if(t==2 || t==4 || t==5 || t==7 || t==9)
		cout<<"hon"<<endl;
		else if(t==0 || t==1 || t==6 || t==8)
			cout<<"pon"<<endl;
			else
				cout<<"bon"<<endl;

	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=10e9+7;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

int main(void){
    string S,T;
    cin>>S>>T;
    ll ans=0;
    rep(i,3) if(S.at(i)==T.at(i)) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const int MAX_V = 310;
ll INF = 100000000000000;
struct edge{ll to,cap,rev;};
vector<edge> G[MAX_V];
ll level[MAX_V],iter[MAX_V];
void add_edge(ll from,ll to,ll cap){
    G[from].push_back({to,cap,(ll)G[to].size()});
    G[to].push_back({from,0,(ll)G[from].size() - 1});
}

void bfs(int s){
    for(int i=0;i<MAX_V;i++){
        level[i] = -1;
    }
    level[s] = 0;
    queue<int> que;
    que.push(s);
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(int i=0;i<G[v].size();i++){
            edge &e = G[v][i];
            if(e.cap>0 && level[e.to]<0){
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

ll dfs(int v,int t,ll f){
    if(v==t) return f;
    for(ll &i = iter[v];i<G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap>0 && level[v]<level[e.to]){
            ll d = dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

ll max_flow(int s, int t){
    ll flow = 0;
    while(true){
        bfs(s);
        if(level[t]<0) return flow;
        for(int i=0;i<MAX_V;i++){
            iter[i] = 0;
        }
        while(true){
            ll f = dfs(s,t,INF);
            if(f==0) break;
            flow += f;
        }
    }
}

int main(){
    int i,n,m;
    cin >> n >> m;
    for(i=0;i<m;i++){
        int u,v; ll c;
        cin >> u >> v >> c;
        add_edge(u,v,c);
    }
    cout << max_flow(0,n - 1) << endl;
}


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

int main(void){
    int A,B,C;
    cin >> A >> B >> C;
    if(A == 7 && B == 5 && C == 5 || A == 5 && B == 7 && C == 5 || A == 5 && B == 5 && C == 7){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
string s[1000010];
int main() {
	int n;
	cin >> n;
	vector<pair<pair<int, int>, int>> vec, vec1;
	for (int i = 0; i < n; i++) {
		int l = 0, r = 0;
		cin >> s[i];
		for (int j = 0; j < s[i].size(); j++) {
			if (s[i][j] == '(') {
				l++;
			}
			else {
				if (l != 0) {
					l--;
				}
				else {
					r++;
				}
			}
		}
		if (l - r >= 0) {
			vec.emplace_back(make_pair(make_pair(r, l),i));
		}
		else {
			vec1.emplace_back(make_pair(make_pair(l, r),i));
		}
	}
	sort(vec.begin(), vec.end());
	sort(vec1.begin(), vec1.end());
	string co = "";
	for (int i = 0; i < vec.size(); i++) {
		co += s[vec[i].second];
	}
	for (int i = vec1.size() - 1; i >= 0; i--) {
		co += s[vec1[i].second];
	}
	int l = 0, r = 0;
	for (int j = 0; j < co.size(); j++) {
		if (co[j] == '(') {
			l++;
		}
		else {
			if (l != 0) {
				l--;
			}
			else {
				r++;
			}
		}
	}
	if (l == 0 && r == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 48972
n = int(input())
a = list(map(int,input().split()))

def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b,a%b)

mae = [a[0]]

for i in range(1,n):
    mae.append(gcd(mae[i-1],a[i]))

#print(mae)

a = list(reversed(a))
usi = [a[0]]
for i in range(1,n):
    usi.append(gcd(usi[i-1],a[i]))
usi = list(reversed(usi))
#print(usi)

ans = usi[1]
for i in range(1,n-1):
    ans = max(ans, gcd(mae[i-1],usi[i+1]))

ans = max(ans, mae[-2])

print(ans)


Measured memory_bytes: 68460
L = input()
mod = 10**9 + 7

pow2 = [1]
pow3 = [1]
for i in range(len(L)):
    pow2.append((pow2[-1]*2) % mod)
    pow3.append((pow3[-1]*3) % mod)

one=[]
for i in range(len(L)):
    if L[i] == "1":
        one.append(i)

total = 0
for i in range(len(one)):
    n = one[i]
    total += pow2[i] * pow3[len(L) - n - 1]
    total = total%mod

total += pow2[len(one)]
total =total%mod
print(total)


Measured memory_bytes: 52976
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Watch
{
    class Program
    {
        static void Main(string[] args)
        {
            int S = int.Parse(Console.ReadLine());
            int h = S / 3600;
            int m = S / 60 - h*60;
            int s = S % 60;

            Console.WriteLine(h+":"+m+":"+s);
        }
    }
}

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	string s,t;cin>>s>>t;
	string Min(100000,'z');
	rep(i,s.size()-t.size()+1){
		bool flag=true;
		string k=s;
		for(int j=0;j<t.size();j++){
			if(k[i+j]!='?'&&t[j]!=k[i+j]){
				flag=false;
			}
			else k[i+j]=t[j];
		}
		for(char&c:k){
			if(c=='?')c='a';
		}
		if(flag)Min=min(Min,k);
	}
	if(Min.size()==100000)puts("UNRESTORABLE");
	else cout<<Min<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#define IF(i) if(i%400==0||(i%100&&i%4==0))
using namespace std;
int c(int y,int m,int d)
{
	int ct=(m-1)*30+d;
	for(int i=1;i<m;i++) if(!(i==2||i==4||i==6||i==9|i==11)) ct++;
	if(m>2){
		IF(y) ct--;
		else ct-=2;
	}
	return(ct);
}
int main()
{
	int i;
	int y1,m1,d1,y2,m2,d2;
	while (cin>>y1>>m1>>d1>>y2>>m2>>d2){
		if(y1<0) break;
		int o=(y2-y1)*365;
		for (i=y1;i<y2;i++) IF(i) o+=1;
		o = o - c(y1,m1,d1) + c(y2,m2,d2);
		cout << o << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;
 
public class Main {
    //static final long MOD = 1000000007L;
    static final long DIV2 = 500000004L;
    static final long MOD = 998244353L;
    static final int INF = 50000000;
    static final int NINF = -500000000;
 
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        
        int N = sc.ni();
        pw.println(1-N);
        
        pw.close();
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int ni() {
            return Integer.parseInt(next());
        }
 
        long nl() {
            return Long.parseLong(next());
        }
 
        double nd() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

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

using namespace std;

#define all(v) v.begin(), v.end()
#define F first
#define S second
#define FOR(i, n) for(int i = 0; i < (int) n; i++)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

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

	int a, b; cin >> a >> b;
	string a1="", b1="";
	for(int i = 0; i < b; i++)
		a1.push_back(a+'0');
	FOR(i, a)
		b1.push_back(b+'0');

	cout << min(a1, b1) << '\n';

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        boolean flg = false;
        for (int i = 0 ; i <= k ; i++) {
            for (int j = 0 ; j <= k ; j++) {
                for (int l = 0 ; l <= k ; l++) {

                    if (i + j + l == k) {
                        if (Math.pow(2, i) * a < Math.pow(2, j) * b && Math.pow(2, j) * b < Math.pow(2, l) * c) {
                            flg = true;
                        }
                    }
                }
            }
        }
        System.out.println(flg ? "Yes" : "No");
    }

}


Measured memory_bytes: 35676
x,y=list(map(int,raw_input().split()))
w=x
h=y
if x==1 or y==1:
  print("1")
  exit(0)
ans=x//2 * (h//2 + (h+1)//2)
if x%2==1:
     ans+=(h+1)//2
print(ans) 

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

using namespace std;

int main()
{
	int s[] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
	int x, y;
	cin >> x >> y;
	cout << ((s[x - 1] == s[y - 1]) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int a,b; 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b;
	if(a>b)cout<<"safe";
	else cout<<"unsafe";
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

ll a[4];
int n;

int main(){
  a[0] = a[1] = a[2] = a[3] = 1<<29;
  scanf("%d", &n);
  int x, j, k;
  rep(i, n){
    scanf("%d", &x);
    for(j=0;j<4;j++) if(x<a[j]) break;
    if(j<4){
      for(k=2;k>=j;k--) a[k+1] = a[k];
      a[j] = x;
    }
  }
  //  rep(i, 4) cout << a[i]; cout << endl;
  vector<ll>res;
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      if(i==j) continue;
      int x;
      if(a[j]/10==0) x = a[i]*10 + a[j];
      else if(a[j]/100==0) x = a[i]*100 + a[j];
      else if(a[j]/1000==0) x = a[i]*1000 + a[j];
      else if(a[j]/10000==0) x = a[i]*10000 + a[j];
      else x = a[i]*100000 + a[j];
      res.push_back(x);
    }
  }

  sort(res.begin(),  res.end());
  //  rep(i, res.size()) cout << res[i] << endl;
  printf("%lld\n", res[2]);
  return 0;
}

Measured memory_bytes: 1204
import copy
n = int(input())
a = [int(input()) for A in range(n)]
max_a,secound_max_a = max(a),0
b = copy.copy(a)
b.sort()
bol = True
for j in range(n,n,-1):
    if b[j] != max(a):
        secound_max_a = b[j]
        bol = False
        break
if bol:
    secound_max_a = b[-2]

for i in range(n):
    if a[i] != max_a:
        print(max_a)
    else:
        print(secound_max_a)

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

void swap(int *a,int *b){
	int *n=a;
	a=b;
	b=n;
}

int BubbleSort(int a[],int n){
	int flag=1;
	int sum=0;
	int i=0;
	while(flag){
		flag=0;
		for(int j=n-1;j>=i+1;j--){
			if(a[j]<a[j-1]){
				swap(a[j],a[j-1]);
				flag=1;
				sum++;
			}
		}
		i++;
	}
	return sum;
}



int main(){
	int n;
	cin>>n;
	int a[100];
	for(int i=0;i<n;i++)cin>>a[i];
	
	int x=BubbleSort(a,n);
	for(int i=0;i<n;i++){
		if(i>0)cout<<" ";
		cout<<a[i]; 
	}
	cout<<endl<<x<<endl;
} 


Measured memory_bytes: 3108
#from collections import deque
#from heapq import heapify, heappop, heappush
#from bisect import insort
#from math import gcd
#mod = 10**9 + 7
#N = int(input())
#N, K = map(int, input().split())
#A = list(map(int, input().split()))
#flag = True
#for k in range(N):
#ans = 0
#print(ans)
#print('Yes')
#print('No')
S = input()
if S[-1] != 's':
	print(S + 's')
else:
	print(S+'es')


Measured memory_bytes: 9096
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, m) = get!(usize, usize);
    let mut ss = Vec::new();
    for _ in 0..n {
        ss.push(get!(i64, i64));
    }
    let mut ps = Vec::new();
    for _ in 0..m {
        ps.push(get!(i64, i64));
    }

    for (a, b) in ss.into_iter() {
        let mut min_d = i64::max_value();
        let mut p = 0;
        for i in 0..m {
            let (c, d) = ps[i];
            let d = (a-c).abs() + (b-d).abs();
            if d < min_d {
                min_d = d;
                p = i;
            }
        }
        println!("{}", p+1);
    }
}

Measured memory_bytes: 4352
from itertools import accumulate
import sys
input = sys.stdin.readline

def solve():
    N, X = map(int, input().split())
    tests = []
    D0 = 0
    for _ in range(N):
        B, L, U = map(int, input().split())
        v = L*B + U*(X-B)
        tests.append((v, B, L, U))
        D0 -= L*B
    tests.sort(reverse=True)
    accVs = list(accumulate([0] + tests, lambda accX, X: accX + X[0]))

    def isOK(k):
        q = k // X
        r = k % X
        accV = accVs[q+1]
        for v, B, L, U in tests[:q]:
            d = D0 + accV - v
            if r <= B:
                d += L*r
            else:
                d += L*B + U*(r-B)
            if d >= 0:
                return True
        accV = accVs[q]
        for v, B, L, U in tests[q:]:
            d = D0 + accV
            if r <= B:
                d += L*r
            else:
                d += L*B + U*(r-B)
            if d >= 0:
                return True
        return False

    ng, ok = -1, N*X
    while abs(ok-ng) > 1:
        mid = (ng+ok) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid

    return ok


print(solve())


Measured memory_bytes: 32680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int max1,max2;
    max1 = max(a[0],a[1]);
    max2 = min(a[0],a[1]);
    for(int i=2; i<n; i++){
        if(max1 < a[i]){
            max2 = max1;
            max1 = a[i];
        }
        else if (max1 == a[i]){
            max2 = a[i];
        }
        else if(max1 > a[i] && a[i] > max2){
            max2 = a[i];
        }
    }
    int ans;
    rep(i,n){
        if(a[i] == max1){
            ans = max2;
        }
        else{
            ans = max1;
        }
        cans;
    }
    return 0;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> x(n),y(n);
    rep(i,n) {
        cin >> x[i];
        y[i]=x[i];
    }
    sort(x.begin(),x.end());
    rep(i,n) {
        if (y[i]<=x[n/2-1]) cout << x[n/2] << endl;
        else cout << x[n/2-1] << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3840
#include <stdio.h>

int main(void){
	
	int a,b,c,d,e,f;
	double x,y;
	
	while(scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f) != EOF){
		y = ((double)(a * f) - (d * c)) / ((a * e) - (b * d));
		x = (c - b * y) / a;
	
		printf("%.3f %.3f\n",x,y);
	}	
	
	return 0;
	
}

Measured memory_bytes: 636
use std::io::*;
use std::str::FromStr;

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

fn main() {
	let a: i32 = read();
	let b: i32 = read();
	let c: i32 = read();
	if a + b + c >= 22 {
		println!("bust");
	} else {
		println!("win");
	}
}


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

int main(){
	int N;
	cin >> N;
	vector<int> P(N);
	for(int i = 0; i < N; i++) cin >> P[i];
	int cnt = 0;
	for(int i = 1; i < N - 1; i++){
		int A = max(max(P[i - 1], P[i]), P[i + 1]);
		int B = min(min(P[i - 1], P[i]), P[i + 1]);
		if(P[i] != A && P[i] != B) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int n;
int ra[114514], a[114514];

int main(void)
{
	cin >> n;
	for (int i = 0; i < n; ++i)cin >> ra[i];
	long long ans = LLONG_MAX;
	for (int fl = 0; fl < 2; ++fl)
	{
		for (int i = 0; i < n; ++i)a[i] = ra[i];
		long long can = 0;
		int tot = 0;
		for (int i = 0; i < n; ++i)
		{
			if ((i + fl) % 2)
			{
				if (tot + a[i] <= 0)
				{
					can += abs(a[i] - (1 - tot));
					a[i] = 1 - tot;
				}
			}
			else
			{
				if (tot + a[i] >= 0)
				{
					can += abs(a[i] - (-1 - tot));
					a[i] = -1 - tot;
				}
			}
			tot += a[i];
		}
		ans = min(ans, can);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);

// use unordered_map to save memory usage
unordered_map<int, int> mp;
int get(int x) {
  int ret = mp[x];
  if (ret == 0) {
    mp.erase(x);
    ret = INT_MAX/2;
  }
  return ret;
}

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

  int n, a, b; cin >> n >> a >> b;
  string s; cin >> s;

  int passcnt = 0;
  int intcnt = 0;
  rep(i, n) {
    bool passed = false;
    if (s[i] == 'a') {
      if (passcnt < a+b) {
        passcnt++;
        passed = true;
      }
    } else if (s[i] == 'b') {
      if (passcnt < a+b && intcnt < b) {
        passcnt++;
        intcnt++;
        passed = true;
      }
    }
    cout << (passed ? "Yes" : "No") << '\n';
  }
}


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

int r, c;
int dx[]={0, 0, 1, -1};
int dy[]={1, -1, 0, 0};
char str[205][205];
int dis[205][205];
int chk[205][205];

void bfs(int i, int j){
    int a, b, tx, ty;
    queue< pair<int,int> > qu;
    pair<int, int> p;
    memset(chk, 0, sizeof chk);
    for(a=0; a<r; ++a) for(b=0; b<c; ++b) dis[a][b]=4000005;
    chk[i][j]=1;
    qu.push(make_pair(i, j));
    dis[i][j]=0;
    while(!qu.empty()){
        p=qu.front(); qu.pop();
        for(a=0; a<4; ++a){
            tx=dx[a]+p.first; ty=dy[a]+p.second;
            if(tx>=0 && tx<r && ty>=0 && ty<c && !chk[tx][ty] && str[tx][ty]!='#'){
                chk[tx][ty]=1;
                dis[tx][ty]=dis[p.first][p.second]+1;
                qu.push(make_pair(tx, ty));
            }
        }
    }
}

int main(){
    int i, j, k;
    int m1, m2=4000005;
    scanf("%d %d", &r, &c);
    for(i=0; i<r; ++i) scanf("%s", str[i]);
    for(i=0; i<r; ++i){
        for(j=0; j<c; ++j){
            if(str[i][j]=='\%'){
                bfs(i, j);
                i=r; j=c;
            }
        }
    }
    for(i=0; i<r; ++i){
        for(j=0; j<c; ++j){
            if(str[i][j]=='@') m1=dis[i][j];
            else if(str[i][j]=='$') m2=min(m2, dis[i][j]);
        }
    }

    //cout << m1 << " " << m2 << endl;

    if(m1<m2) printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 3572
S = int(input())
A,B = map(int,input().split())
check = False
ans = 0
i = 1
while ans <= B:
  ans = S * i
  if A <= ans and B >= ans:
    check = True
    break
  i += 1
if check:
  print('OK')
else:
  print('NG')

Measured memory_bytes: 9060
#include <iostream>
#include<stdio.h>
#define LEN 100005
using namespace std;
typedef struct pp{
    char name[100];
    int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    if (tail + 1 == LEN){
        tail = 0;
    }else tail++;
}

P dequeue(){
    P x = Q[head];
    if (head + 1 == LEN){
        head = 0;
    }else head++;
    
    return x;
}

int main(void){
    int elaps = 0, c;
    int q;
    P u;
    scanf("%d %d", &n, &q);
    
    for(int i = 1; i <= n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1;
    tail = n + 1;
    
    while(head != tail){
        u = dequeue();
        if (u.t > q) {
            c = u.t-q;
            u.t = c;
            enqueue(u);
            elaps += q;
        }else{
            elaps += u.t;
            cout<<u.name <<" " <<elaps <<endl;
        }
        
    }
    return 0;
    
}



Measured memory_bytes: 13392
import sys
#input = sys.stdin.readline

INF = 10**12
N,M = map(int,input().split())
K = []
for i in range(M) :
    a,b = map(int,input().split())
    s = 0 #setをbitで管理.
    cx = list(map(int,input().split()))
    for c in cx :
        s = s | (1 << (c-1)) #setの和集合
    K.append([s, a])

#dp[bit]: 集合=bit のときのコストの最小値
dp = [INF]*(1 << N)
dp[0] = 0

for bit in range(1 << N) :
    for i in range(M) :
        s,a = K[i]
        t = bit | s
        cost = dp[bit] + a
        dp[t] = min(dp[t], cost)
ans = -1 if dp[-1] == INF else dp[-1]

print(ans)


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

int main() {
  int n, m, path = 0;
  scanf("%d %d", &n, &m);
  vector<vector<int>> v(n+1);//v[0] = []
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  vector<int> order(n);
  for(int i = 0; i < n; i++) order[i] = i + 1;
  do {
    bool reach = true;
    for(int i = 0; i < n - 1; i++) {
      auto result = find(v[order[i]].begin(), v[order[i]].end(), order[i + 1]);
      if(result == v[order[i]].end()) {
        reach = false;
        break;
      }
    }
    if(reach) path++;
  } while (next_permutation(order.begin()+1, order.end()));
  cout << path;
}

Measured memory_bytes: 3668
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p, l, r;
};

struct Node T[MAX];
int n;
int D[MAX], H[MAX];

int getDepth(int u){
  int d = 0;
  while(1){
    u = T[u].p;
    if ( u == NIL ) break;
    d++;
  }
  return d;
}

int getSibling(int u){
  if ( T[u].p == NIL ) return NIL;
  if ( T[T[u].p].l != u && T[T[u].p].l != NIL ) return T[T[u].p].l;
  if ( T[T[u].p].r != u && T[T[u].p].r != NIL ) return T[T[u].p].r;
  return NIL;
}

void print(int u){
  printf("node %d: ", u);

  printf("parent = %d, ", T[u].p);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if ( T[u].l != NIL ) deg++;
  if ( T[u].r != NIL ) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].p == NIL ){
    printf("root\n");
  } else if ( T[u].l == NIL && T[u].r == NIL ){
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

main(){
  int i, v, l, r;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    T[i].p = NIL;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL ) T[l].p = v;
    if ( r != NIL ) T[r].p = v;
  }

  for ( i = 0; i < n; i++ ){
    D[i] = getDepth(i);
    H[i] = 0;
  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].l == NIL && T[i].r == NIL ) { // is leaf
      H[i] = 0;
      int p = T[i].p;
      int c = 1;
      while(1){
	if ( p == NIL ) break;
	if ( H[p] < c ) H[p] = c;
	c++;
	p = T[p].p;
      }
    }
  }

  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}


Measured memory_bytes: 2048
try:
    n = int(input().strip())
    (d,x) = input().strip().split(" ")
    max = 0 
    for i in range(n):
        f = int(input().strip())
        for m in range(100):
            day=(m*f)+1
            if day > int(d):
                break
            max+=1        
    max+=int(x)
    print(max)
except EOFError:
    pass

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

using namespace std;
#define ll long long
const int N=1e3+5;
const int mod=1e9+7;
int main()
{
    ios::sync_with_stdio(false);
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    cout<<"D";
    for(int i=0; i<tx-sx+1; i++)
        cout<<"R";
    for(int i=0; i<ty-sy+1; i++)
        cout<<"U";
    for(int i=0; i<tx-sx+1; i++)
        cout<<"L";
    for(int i=0; i<ty-sy; i++)
        cout<<"D";
    for(int i=0; i<tx-sx; i++)
        cout<<"R";
    for(int i=0; i<ty-sy+1; i++)
        cout<<"U";
    for(int i=0; i<tx-sx+1; i++)
        cout<<"L";
    for(int i=0; i<ty-sy+1; i++)
        cout<<"D";
    cout<<"R"<<endl;
    return 0;
}
//1 2 4 8 16 30 60 96


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<utility>
#include<queue>
#define mod 1000000007
#define INF 1000000000000000
using namespace std;
typedef long long ll;
char s[100010];
ll ans,t[100010];
int n;

ll calc(int x){
    if(x==n){
        return 1;
    }
    ll res;
    if(s[x]=='1'){
        res=t[n-1-x];
        res%=mod;
        res+=2LL*calc(x+1);
        res%=mod;
        return res;
    }
    else{
        return calc(x+1);
    }
}
int main(){
    scanf("%s",s);
    n=strlen(s);
    t[0]=1LL;
    for(int i=1;i<=n;i++){
        t[i]=t[i-1]*3LL;
        t[i]%=mod;
    }
    printf("%lld\n",calc(0));
}

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

using namespace std;
const int INF = 0x3f3f3f3f;


int main() {
	int N;
	cin >> N;
	vector<int> subs(N,0);
	for (int i = 0; i<N-1; i++){
		int num;
		cin >> num;
		subs[num-1] += 1;
	}
	for (auto x: subs){
		cout << x << endl;
	}
}


Measured memory_bytes: 4048
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[4];
		for(int i=0;i<4;i++) {
			A[i] = sc.nextInt();
			//System.out.println(A[i]);
		}
		
		while(A[0]>0||A[2]>0) {
			A[2] = A[2]-A[1];
			//System.out.println(A[2]);
			if(A[2]<=0) {
				System.out.println("Yes");
				break;
			}
			A[0] = A[0]-A[3];
			if(A[0]<=0) {
				System.out.println("No");
				break;
			}
			
		}
	}
}


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

ll gcd(ll x, ll y) {
    return (x % y) ? gcd(y, x % y) : y;
}

ll lcm(ll x, ll y) {
  return x * y / gcd(x, y);
}

int main() {
  ll a, b; cin >> a >> b;
  if (gcd(a, b) == 1) {
    cout << a * b;
    return 0;
  }
  cout << lcm(a, b);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <unordered_set>

template <class T>
struct Point {
    static_assert(std::is_integral<T>(), "Fuck you");

    Point() = default;
    Point(T _x, T _y)
        : x(_x)
        , y(_y)
    {
        x = _x;
        y = _y;
    }
    Point(const Point&) = default;
    Point(Point&&) = default;
    Point& operator =(const Point&) = default;
    Point& operator =(Point&&) = default;
    ~Point() = default;

    Point operator +(const Point& p) const {
        return Point<T>(x + p.x, y + p.y);
    }
    Point& operator +=(const Point& p) {
        x += p.x;
        y += p.y;
        return *this;
    }
    Point operator -(const Point& p) const {
        return Point<T>(x - p.x, y - p.y);
    }
    Point& operator -=(const Point& p) {
        x -= p.x;
        y -= p.y;
        return *this;
    }

    T x, y;
};

const int N = 2e5 + 5;

std::unordered_set <int> e[N];

bool solve() {
    int n, m, u, v;
    std::cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        e[u].insert(v);
        e[v].insert(u);
    }
    for (auto i : e[1]) {
        if (e[i].count(n)) {
            std::cout << "POSSIBLE\n";
            return 0;
        }
    }
    std::cout << "IMPOSSIBLE";

    return 0;
}

int main() {
#ifdef LOCALHOST
    freopen("input", "r", stdin);
#endif
    while (solve());

    return 0;
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int H, W; cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W));
    for(int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> a.at(i).at(j);
        }
    }
    vector<bool> Hjudge(H, true), Wjudge(W, true);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (a.at(i).at(j) == '#') {
                Hjudge.at(i) = false;
            }
        }
    }
    for (int j = 0; j < W; j++) {
        for (int i = 0; i < H; i++) {
            if (a.at(i).at(j) == '#') {
                Wjudge.at(j) = false;
            }
        }
    }
    for (int i = 0; i < H; i++) {
        if (Hjudge.at(i) == false) {
            for (int j = 0; j < W; j++) {
                if (Wjudge.at(j) == false) {
                    cout << a.at(i).at(j);
                }
            }
            cout << endl;
        }
    }
    return 0;
}

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

#T=[]
#for i in range(D):
#  T.append(int(input()))

#M=int(input())
#dq=[list(map(int,input().split())) for i in range(M)]

def dissat(day):
  dissat = 0
  for i in range(26):
    if T[day-1]-1 == i:
      continue
    dissat += C[i]*(day-lastdays[i])

  return dissat    
    
def last(day):
  lastdays[T[day-1]-1] = day

# 
def calcscore(D):
  sat = 0
  for i in range(D):
    # dayi
    last(i)
    sat += S[i][T[i]-1] - dissat(i+1)
  #print(sat)
  return sat

# main
#lastdays = [0]*26
#calcscore(D)


# change contenst
#for i in range(M):
#  T[dq[i][0]-1] = dq[i][1]
#  lastdays = [0]*26
#  calcscore(D)

#
import random

T = [0]*D
for i in range(D):
  T[i] = random.randrange(1,26)

lastdays = [0]*26
oldscore = calcscore(D)

count = 0
while count < 300:
  T = [0]*D
  for i in range(D):
    T[i] = random.randrange(1,26)

  lastdays = [0]*26
  newscore = calcscore(D)
  if oldscore > 0 and newscore > oldscore:
    oldscore = newscore
    break
  count += 1


count = 0
while count < 3000:
  count += 1
  d=random.randrange(1,D)
  q=random.randrange(1,26)
  old = T[d-1] # 後で戻せるように元の値を記憶しておく
  T[d-1] = q
  lastdays = [0]*26
  newscore = calcscore(D)
  if newscore < oldscore:
    T[d-1] = old
  else:
    oldscore = newscore

for i in range(D):
  print(T[i])


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  int max = 0;
  int min = 1000;
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i);
    if(a.at(i) > max)
    {
      max = a.at(i);
    }
    if(a.at(i) < min)
    {
      min = a.at(i);
    }
  }
  cout << max-min << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<map>
#include<cmath>
#include<algorithm>
#define int long long int
bool prime(int x)
{
	if(x==1||x==4)
	    return false;
	if(x==2||x==3||x==5)
	    return true;
   else if(x%2==0||x%3==0||x%5==0)
        return false;
    for(int i=7;i*i<=x;i++)
    {
		if(x%i==0)
		   return false;
	}
	return true;
}
int32_t main()
{
     int n,d;
     cin>>n>>d;
     int answer=ceil((double)(n)/(2*d+1));
     cout<<answer<<endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.Scanner;
import java.util.Set;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long N = Long.parseLong(in.next());

            MultiSet ms = Factrization(N);
            // 出力
            long ans = 0;
            for (long k : ms.keyset()) {
                long num = 1;
                long val = ms.set.get(k);
                int cnt = 0;
                while (val >= 0) {
                    val -= num;
                    ++num;
                    if (val >= 0) {
                        ++cnt;
                    }
                }
                ans += cnt;
            }
            out.println(ans);


        }

        public MultiSet Factrization(long e) {
            MultiSet ret = new MultiSet();
            for (long i = 2; i * i <= e; i++) {
                while (e % i == 0) {
                    ret.add(i);
                    e /= i;
                }
            }
            if (e != 1) ret.add(e);
            return ret;
        }

        class MultiSet {
            TreeMap<Long, Long> set;
            long size;
            long sum;

            MultiSet() {
                set = new TreeMap<Long, Long>();
                size = 0;
                sum = 0;
            }

            void add(long e) {
                if (set.containsKey(e)) set.put(e, set.get(e) + 1);
                else set.put(e, 1L);
                size++;
                sum += e;
            }

            Set<Long> keyset() {
                return set.keySet();
            }

        }

    }
}



Measured memory_bytes: 35964
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

class floating{
    public:
        int ex;
        LL num;
        floating(string str){
            ex=0;
            num=0;
            REP(i, str.size()){
                num*=2;
                num+=str[i]-'0';
            }
        }
        floating(){
            ex=num=0;
        }
};

floating operator+(floating a, floating b){
    floating res;
    a.num|=(LL)1<<52;
    b.num|=(LL)1<<52;
    if(a.ex < b.ex)swap(a, b);
    b.num >>= a.ex - b.ex;
    res.ex=a.ex;
    res.num=a.num+b.num;
    if(res.num>>53){
        ++res.ex;
        res.num>>=1;
    }
    res.num^=(LL)1<<52;
    return res;
}

string tostring(floating a){
    string res = "";
    REP(i, 52){
        res += a.num & ((LL)1<<i) ? "1" : "0";
    }
    REP(i, 12){
        res += a.ex & ((LL)1<<i) ? "1" : "0";
    }
    reverse(ALL(res));
    return res;
}

LL toLL(string str){
    LL res = 0;
    foreach(i, str){
        res<<=1;
        res+=i-'0';
    }
    return res;
}

int main(){
    LL n;
    while(cin>>n&&n){
        string str;
        cin >> str;
        str = "1" + str;
        int count = 0;
        LL sum = toLL(str);
        LL add = toLL(str);
        while(true){
            if(add==0)break;
            LL d = (((LL)1<<53) - sum + add - 1) / add;
            if(d>n){
                sum += add * n;
                break;
            }else if(d==n){
                sum += add * d;
                sum >>= 1;
                ++count;
                break;
            }else{
                sum += add * d;
                n -= d;
                sum >>= 1;
                add >>= 1;
                ++count;
            }
        }
        floating a;
        a.ex = count;
        a.num = sum ^ ((LL)1<<52);
        cout << tostring(a) << endl;
    }
}



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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

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

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)1e5+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        cin>>n>>k;
        m=n*3+k;
        cout<<m/2<<endl;
        
        
        
        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

Measured memory_bytes: 3644
//Apparat : drobucs, aleonov, vit_72
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <iomanip>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>

//pragma warning(disable : 4996)
//#pragma GCC optimize("O3")

#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define ff first
#define ss second
#define pb push_back

using namespace std;

typedef long long ll;

const int maxn = (int)1e6 + 13;
const ll INFL = 9223372036854775807;
const int INF = 2147483647;
const ll MOD = (int)1e9 + 93, MOD2 = 1e9 + 21;//1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101, base2 = 37;
const long double pi = 3.1415926535897932;



int main() {
	drobucs;
	
	string s, t;
	cin >> s >> t;
	
	if (s.size() + 1 != t.size()) {
		cout << "No\n";
	}
	else {
		for (int i = 0; i < s.size(); ++i) {
			if (s[i] != t[i]) {
				cout << "No\n";
				return 0;
			}
		}
		cout << "Yes\n";
	}
	
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin>>s;
	for(int i=0;i<4;i++)
	cout<<s[i];
	cout<<" ";
	for(int i=4;i<12;i++)
	cout<<s[i];
	cout<<"\n";
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b;
    char op;

    while (1)
    {
        scanf("%d %c %d", &a, &op, &b);

        if (op == '+')
        {
            printf("%d\n", a + b);
        }
        else if (op == '-')
        {
            printf("%d\n", a - b);
        }
        else if (op == '*')
        {
            printf("%d\n", a * b);
        }
        else if (op == '/')
        {
            printf("%d\n", a / b);
        }
        else if (op == '?')
        {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2112
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int[] tmp = new int[3];
		tmp[0] = sc.nextInt();
		tmp[1] = sc.nextInt();
		tmp[2] = sc.nextInt();
		Arrays.sort(tmp);
		System.out.println(tmp[0]+" "+tmp[1]+" "+ tmp[2]);
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}



Measured memory_bytes: 26288
for e in iter(input,'0'):
 a=[[*map(int,input().split())]for _ in[0]*int(e)]
 s,t=min(a)
 b={tuple(map(int,input().split()))for _ in[0]*int(input())}
 m=max(b)[0]-max(a)[0]+s
 for x,y in b:
  if x>m:continue
  for u,v in a:
   if(x+u-s,y+v-t)not in b:break
  else:print(x-s,y-t);break


Measured memory_bytes: 6048