akhauriyash/Code-Regression huggingface dataset:
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))


H,A=input2()
a=input_array()

dam=sum(a)
if dam>=H:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 13964
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main {
  val DIRS = Array("R","D","L","U")
  val tox = Array(1,0,-1,0)
  val toy = Array(0,1,0,-1)

  def f(x:Int,y:Int,d:Int,v:Array[String],h:Array[String]):(Int,Int,Int,String) = {
    val path = d match {
          case 3 => v(y-1)(x)
          case 0 => h(y)(x)
          case 1 => v(y)(x)
          case 2 => h(y)(x-1)
          case _ => '0'
    }
    if(path == '1') (tox(d),toy(d),d,DIRS(d)) else f(x,y,(d+1)%4,v,h)
  }


  def getPath(x:Int,y:Int,d:Int,s:String,v:Array[String],h:Array[String]):String = {
    if(x==1 && y==1) s
    else {
      val (x2,y2,d2,s2) = f(x,y,(d+3)%4,v,h)
      getPath(x+x2,y+y2,d2,s+s2,v,h)
    }
  }

  def main(args:Array[String]) = {
    val v = new ArrayBuffer[String]
    val h = new ArrayBuffer[String]

    h += "0"*6; v += "0"*7
    for(i<-1 to 4) { h += "0"+readLine.trim+"0"; v += "0"+readLine.trim+"0" }
    h += "0"+readLine.trim+"0"
    v += "0"*7; h += "0"*6

    println(getPath(2,1,0,"R",v.toArray,h.toArray))
  }
}

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

int main() {
    ios::sync_with_stdio(false);
    string n;
    cin >> n;
    string ans;
    for(auto i : n) {
        if(i == 'B') {
            if(ans.size() == 0)
                continue;
            else
                ans.pop_back();
        } else {
            ans.push_back(i);
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
from collections import deque
S=input()
N=len(S)
cnt=0
for i in range(pow(2,N-1)):
    d=deque()
    flag=[0]*(N-1)
    num = []
    v=[]
    for j in range(N):
        d.append(S[j])
    for j in range(N-1):
        if (i>>j)&1:
            flag[j]=1
    #print(flag)
    for j in range(N):
        s=d.popleft()
        v.append(s)
        if (j<N-1):
            if(flag[j]==1):
                s="".join(v)
                num.append(int(s))
                v=[]
        else:
            s = "".join(v)
            num.append(int(s))
            v = []
    #print(num)
    cnt=cnt+sum(num)
print(cnt)

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

using namespace std;


int main() {

    int N;
    cin >> N;

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

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        int value = V[i];
        int cost = C[i];

        if (value > cost) {
            ans += value - cost;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int x[10001];
	int i;
	int t;

	for (i = 1; i <= 10000;i++) {
		
		scanf("%d",&x[i]);
		
		if (x[i]==0) {
			break;
		}
	}
	for (t = 1; t <= 10000; t++) {
		if (t == i)break;
		printf("Case %d: %d\n", t, x[t]);
	}
	return 0;
	}

Measured memory_bytes: 636
n = int(raw_input())
a = map(int, raw_input().split())
count = 0
for i in range(n):
    mini = i
    for j in range(i,n):
        if a[j] < a[mini]:
            mini = j
    if i != mini:
        a[i], a[mini] = a[mini], a[i]
        count += 1
print " ".join(map(str, a))
print count

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

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

    vector<double> B(1010);
    B[1] = 1;
    for (int i = 2; i <= 1000; i++) {
        B[i] = B[i -1] + 0.5;
    }

    vector<double> P(N + 1);
    P[0] = 0.0;
    int p;
    for (int i = 1; i < N + 1; i++) {
        cin >> p;
        P[i] = P[i-1] + B[p];
    }

    double res = 0;
    for (int i = K; i < N + 1; i++) {
        res =  max(res, P[i] - P[i - K]);
    }

    cout << std::fixed << std::setprecision(7) << res << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
  long long int n;
  scanf("%lld",&n);
  if(n%2){
    n=n*((n-1)/2);
  }else{
    n=n*((n-1)/2)+n/2;
  }
  printf("%lld\n",n);
  return 0;
}


Measured memory_bytes: 256
X, Y, A, B, C =gets.chomp.split.map(&:to_i)
p = gets.chomp.split.map(&:to_i)
q = gets.chomp.split.map(&:to_i)
r = gets.chomp.split.map(&:to_i)

p = p.sort.reverse.take(X)
q = q.sort.reverse.take(Y)

x = p + q + r

puts x.sort.reverse.take(X + Y).inject(:+)

Measured memory_bytes: 35132
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();

        System.out.println(solve(N));
    }

    private static int solve(int N) {
        int count = 0;

        for (int i=1; i<=N; i++) {
            if(check(i)) count++;
        }

        return count;
    }

    private static boolean check(int a) {
        if (a%2 == 0) return false;
        int p = 0;

        for (int i=1; i<=a; i++) {
            if (a%i == 0) p++;
        }


        return p == 8;
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
class UnionFind
{
public:
  int par[100005];
  int depth[100005];
  int nGroup[100005];
 
  UnionFind(int n) {
    init(n);
  }
 
  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
 
  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
 
  bool same(int x, int y) {
    return root(x) == root(y);
  }
 
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
 
    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
} 
int main() {
ll n; cin>>n;
ll x = 0;
ll f = 0;
rep(i,50001){
x = i*108/100;
if(x==n){
f++;
x = i;
break;}
}
if(f==0) cout << ":(" << endl;
else cout << x << endl;}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m, K; cin >> n >> m >> K;
    vector<LL> preA{0}, preB{0};
    for (int i = 0 ; i < n ; i++) {
        LL v; cin >> v; preA.push_back(preA.back() + v);
    }
    for (int i = 0 ; i < m ; i++) {
        LL v; cin >> v; preB.push_back(preB.back() + v);
    }
    LL ans = 0;
    for (int i = 0 ; i <= n ; i++) {
        if (preA[i] > K)
            break;
        LL x = upper_bound(preB.begin(), preB.end(), K - preA[i]) - preB.begin() - 1;
        if (x >= 0)
            ans = max(ans, x + i);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 7920
import java.util.Scanner;

public class Main {

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

		System.out.printf("%d %d",a * b ,2 * ( a + b ) );
		System.out.println();

		sc.close();

	}

}



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

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

int main(void){
  int n; cin >> n;
  int x[n];
  rep(i,n) cin >> x[i];
  int ans = 1000000000;
  for(int i = 1; i < 101; i++){
    int count = 0;
    for(int j = 0; j < n; j++){
      count+= (x[j] - i)*(x[j]-i);
    }
    ans = min(ans,count);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N; 
  cin >> N ; 
  vector<int> T(N) ; 
  int Tot = 0 ;
  for(int i = 0 ; i < N ; i++) cin >>T.at(i) ;
  for(int i = 0 ; i < N ; i++) Tot += T.at(i) ;  
  
  int M ; 
  cin >> M ; 
  vector<int> P(M) , X(M) ; 
  for(int i = 0 ; i < M ; i++) cin >> P.at(i) >> X.at(i) ;
  
  for(int i = 0 ; i < M ; i++){
    cout << Tot - T.at(P.at(i)-1) + X.at(i) << endl ; 
  }
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main(){

  int P, Q, R;
  cin >> P >> Q >> R;

  cout << min(min(P+Q, Q+R), R+P) << endl;;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

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

}

int main(void)
{
int a,b;

while(scanf("%d%d",&a,&b)!=EOF){
printf("%d\n",gcd(a,b));
}

    return 0;
}

Measured memory_bytes: 596
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn  = 4100;

int n,A,B;
int t[maxn],tp;
char str[110];
bool v[maxn];

int main()
{
	//freopen("tmp.in","r",stdin);
	//freopen("tmp.out","w",stdout);
	
	cin>>A>>B; n=A+B;
	if(A<=B) { cout<<"Impossible"<<endl; return 0; }
	
	for(int i=0;i<n;i++)
	{
		if(!tp) t[++tp]=i;
		else
		{
			cout<<"? "<<t[tp]<<" "<<i<<endl;
			cin>>str;
			if(str[0]=='N') tp--;
			else t[++tp]=i;
		}
	}
	int x=t[tp]; v[x]=true;
	for(int i=0;i<n;i++) if(i!=x)
	{
		cout<<"? "<<x<<" "<<i<<endl;
		cin>>str;
		v[i]=str[0]=='Y'?true:false;
	}
	cout<<"! ";
	for(int i=0;i<n;i++) cout<<(v[i]?1:0);
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 724
#define f first
#define s second
#define loop(a,b) for(int i=a;i<b;i++)
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ll long long
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define loop2(a,b) for(int j=a;j<b;j++)
#define str_in cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define sz(a) int(a.size())
#define displaymatrix(a,m,n) for(int i=0;i<m;i++)\
{for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vl a(n);loop(0,n)cin>>a[i]
#define ainput(a,n) loop(0,n)cin>>a[i]
#define nl cout << "\n";
//#define all(c) c.begin(),c.end()
#define tr(container,it)\
for(__typeof(container.begin()) it=container.begin();it!=container.end();it++)
#include<bits/stdc++.h>

using namespace std;
int visited[200005];
int parent[200005];
queue<int> bfsq;

const int mod=1e+9+7;

void bfs(vvi& g, int node){
    bfsq.push(node);
    visited[node] = 1;
    while(sz(bfsq) > 0){
        int q = bfsq.front();
        bfsq.pop();
        for (auto x:g[q]){
            if (visited[x]) continue;
            //            cout << q << " " << x << " ";
            bfsq.push(x);
            visited[x] = 1;
            parent[x] = q;
        }
        //        printf("\n");
    }
}

vi pfact(ll n)
{
    int fac = 0;
    int ct = 0;
    vi pow;
    while (n % 2 == 0)
    {
        if (ct == 0) fac++;
        n = n/2;
        ct++;
    }
    pow.pb(ct);
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        ct = 0;
        while (n % i == 0)
        {
            if (ct==0)fac++;
            n = n/i;
            ct++;
        }
        pow.pb(ct);
    }
    if (n > 2) {fac++;pow.pb(1);}
    return(pow);
}

void solve(){
    ll n;cin>>n;
    vi pows = pfact(n);
    int ctr = 0;
    int num = 0;
    for (int p:pows){
        while(p>=num+1){
            ctr++;
            num++;
            p -= num;
        }
        num = 0;
    }
    cout << ctr << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int t=1;
    //    cin>>t;
    while(t--) solve();
    return 0;
}




Measured memory_bytes: 5336
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin >> n;
	int sum = 0;
	map<int,int> mp;
	for(int i = 0;i < n;i++){
		cin >> x;
		mp[x]++;
		sum += x;
	}
	int q;
	cin >> q;
	while(q--){
		int a,b;
		cin >> a >> b;
		if(mp.find(a) != mp.end()){
			sum -= (mp[a]*a);
			sum += (mp[a]*b);
			mp[b] += mp[a];
			mp.erase(a);
		}
		cout << sum << "\n";
	}
}
//.........

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

//E

const long long mod=1000000007;
int fflag=-1,zflag=-1,s,i,l[100005];
char ll[100005];

long long mypow(long long x, int y){
	if(y==0) return 1;
	else if(y%2==0) return mypow((x*x)%mod,y/2);
	else return (mypow(x,y-1)*x)%mod;
}

long long count(int size){
	if(size==s){
		if(l[s]==1) return 3;
		else return 1;
	}
	if(l[size]==1) return (mypow(3,s-size)+(2*count(size+1))%mod)%mod;
	else return count(size+1);
}

int main() {
	// your code goes here
	cin >> ll;
	s=strlen(ll);
	for(i=1;i<=s;i++){
		if(ll[i-1]=='1') l[i]=1;
		else l[i]=0;
	}
	cout << count(1) << endl;
	return 0;
}

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


using namespace std;


using ll = long long;


int main() {
    ll N;
    vector<ll> A;

    cin >> N;

    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }

    map<ll, ll> lhs, rhs;
    for (ll i = 0; i < N; i++) {
        lhs[i + A[i]]++;
        rhs[i - A[i]]++;
    }

    ll ans = 0;
    for (auto e : lhs) {
        ans += e.second * rhs[e.first];
    }
    cout << ans << endl;
}


Measured memory_bytes: 38976
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(str, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    ans = ['Odd', 'Even']
    print(ans[(a*b)%2-1])
    return

#B
def B():
    a, b = map(str,input().split())
    a = a + b
    if math.sqrt(int(a)).is_integer():
        print("Yes")
    else:
        print("No")
    return

#C
def C():
    n = II()
    pre = (0, 0, 0)
    for _ in range(n):
        t,x,y = LI()
        dist = abs(pre[0] - x) + abs(pre[1] - y)
        if dist <= t - pre[2] and dist % 2 == (t - pre[2]) % 2:
            pre = (x, y, t)
            continue
        print("No")
        return
    print("Yes")
    return

# D
# 解説AC
# prd_xxxさんのを参考にしたけど理解できてないので絶対に理解すること
# https://atcoder.jp/contests/abc086/submissions/3454297
# PS: 2019/10/12
# なんとなく理解
# まず白の情報は市松模様的にk右に行ったところが黒になるという情報と同じ
# 更に座標を2*kの剰余で考えても問題ない
# あとは2次元累積和をとって市松模様の一番左下に当たる白の領域の右上が
# どの位置にあるかはk*k通りあるのでそれを試してその時の模様における
# 黒配置がどの数ただしくなるか調べる
def D():
    n, k = LI()
    dp = [[0] * (2 * k + 1) for i in range(2 * k + 1)]
    for _ in range(n):
        x, y, c = LS()
        x, y = int(x), int(y)
        if c == "W":
            dp[y % (2 * k) + 1][(x + k) % (2 * k) + 1] += 1
        else:
            dp[y % (2 * k) + 1][x % (2 * k) + 1] += 1
    for y in range(2 * k + 1):
        for x in range(1, 2 * k + 1):
            dp[y][x] += dp[y][x - 1]
    for y in range(1, 2 * k + 1):
        for x in range(2 * k + 1):
            dp[y][x] += dp[y - 1][x]
    
    def count(l, r, d, u):
        return dp[d][l] - dp[d][r] - dp[u][l] + dp[u][r]
    
    ans = 0
    for i in range(k):
        for j in range(k):
            tmp = count(j, j + k, i, i + k) + count(0, j, 0, i) + count(j + k, 2 * k, 0, i) + \
                 count(0, j, i + k, 2 * k) + count(j + k, 2 * k, i + k, 2 * k)
            ans = max(ans, tmp, n - tmp)
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 77660
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start:i64,end:i64,step:i64) -> Vec<i64>{
    let mut ret = Vec::new();
    let mut i = start;

    while i < end{
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS : [i64; 4] = [0,0,1,-1];
#[allow(dead_code)]
const DYS : [i64; 4]  = [1,-1,0,0];
#[allow(dead_code)]
const INF : i64 = 999999999;

////////////////////////////////////////////////

fn main(){
    let n = read_int() as usize;
    let xs = read_ints();
    let mut ys : Vec<i64> = xs.clone();
    ys.sort();
    let b0 = ys[n/2-1];
    let b1 = ys[n/2];

    for i in 0..n{
        let x = xs[i];

        if x <= b0{
            println!("{}",b1);
        }else{
            println!("{}",b0);
        }
    }
}

Measured memory_bytes: 12696
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))

def to_minus_one(num):
    return -1 - num

def to_plus_one(num):
    return 1 - num

s_list = np.zeros(n)
s = 0
for i in range(n):
    s += a[i]
    s_list[i] += s


def cal(sum_list, t, ans):
    hoge = 0
    for i in range(n):
        sum_list[i] += hoge
        if (i+t) % 2 == 0:
            if sum_list[i] >= 0:
                hiku = to_minus_one(sum_list[i])
                hoge += hiku
                ans += abs(hiku)
            else:
                continue
        else:
            if sum_list[i] <= 0:
                tasu = to_plus_one(sum_list[i])
                hoge += tasu
                ans += abs(tasu)
    return ans

q = np.copy(s_list)
w = np.copy(s_list)
num1 = cal(q, 0, 0)
num2 = cal(w, 1, 0)

print(int(min(num1, num2)))

Measured memory_bytes: 23284
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

C = Counter(A)
D = {}
MOD = 10**9+7
for i in range(N-1, -1, -2):
    if i == 0:
        D[i] = 1
    else:
        D[i] = 2

if C != D:
    print(0)
else:
    ans = pow(2, N//2, MOD)
    print(ans)

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);
    string S; cin >> S;
    string T = "FESTIVAL";
    for (int i=0; i<(int)S.size() - (int)T.size(); i++) {
        cout << S[i];
    }
    cout << endl;
}

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

int main(){
    int N,K,Q;

    cin>>N>>K>>Q;
    int a[Q];

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

    int b[N];

    for(int i=0;i<N;i++){
        b[i]=K;
    }

    for(int i=0;i<Q;i++){
        b[a[i]-1]++;
    }

    for(int i=0;i<N;i++){
        if((b[i]-Q)<=0)cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <climits>
using namespace std;
typedef long long ll;

int main(void){
    
    map<string,int> mp;
    
    int N;
    string S;
    cin >> N;
    set<string> st;
    for(int i = 0; i < N;i++){
        cin >> S;
        mp[S]++;
        st.insert(S);
    }
    cin >> N;
    for(int i = 0; i < N;i++){
        cin >> S;
        mp[S]--;
        st.insert(S);
    }
    int mx = 0;
    for(auto ss:st){
        mx = max(mx,mp[ss]);
    }
    cout << mx <<endl;
    
    
    
}


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    a,b,c,d = LI()

    ans = 0
    if a >= 0:
        if d >= 0:
            ans = b * d
        else:
            ans = a * d
    elif a <= 0 and b >= 0:
        if c >= 0:
            ans = b * d
        elif c <= 0 and d >= 0:
            ans = max(a*c,b*d)
        else:
            ans = a * c
    else:
        if c >= 0:
            ans = b * c
        elif c <=0 and d >= 0:
            ans = a * c
        else:
            ans = a* c
    print(ans)



if __name__ == '__main__':
    main()

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

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

int main() {
    int a, b, k,cnt=0;
    cin >> a >> b >> k;
    vector<int>n;
    for (int i = 1; i <= min(a, b); i++) {
        if (a % i == 0 && b % i == 0)n.push_back(i);
    }
    auto itr = n.end();
    rep(i, k)itr--;
    cout <<  *itr<< endl;
    return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MOD 1e9+7

int main(){
  ll i;
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(i = 0; i < n; i++)
    cin >> a[i];
  ll result = 0;
  ll judge = 1; //減少で0、増加で1
  ll maxbuf = a[0];
  ll minbuf = 0;
  for(i = 0; i < n - 1; i++){
    if(judge == 1 && a[i] <= a[i + 1]){
      maxbuf = a[i + 1];
    }
    else if(judge == 1)
      judge = 0;
    else if(judge == 0 && a[i] < a[i + 1]){
      result += maxbuf - minbuf;
      minbuf = a[i];
      maxbuf = a[i + 1];
      judge = 1;
    }
  }
  result += maxbuf - minbuf;  
  
  cout << result << endl;

  return 0;
}

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

int main() {
  // ここにプログラムを追記
  int a;
  string s;
  
  cin >> s;
  
  if(s[0] == '1') a++;
  if(s[1] == '1') a++;
  if(s[2] == '1') a++;
  
  cout << a << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter


def solve(N: int, s: "List[str]"):
    c = Counter()
    for x in s:
        c["".join(sorted(x))] += 1
    ans = 0
    for i in c.values():
        ans += i * (i - 1) // 2
    return ans


# -----------------------------------------------------------------------------
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(N)]  # type: "List[str]"

    ans = solve(N, s)
    if ans is not None:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25296
use std::io::*;
 
 fn main() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut scan = s.split_whitespace();

    let n:u64 = scan.next().unwrap().parse().unwrap();
    let k:u64 = scan.next().unwrap().parse().unwrap();

    let ans:u64;
    if n % k == 0 {
        ans = 0;
    } else {
        ans = 1;
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(int argc,char*argv[]){

    int a, b, c, x;

    while(c != 1){

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

    if(a<1 || a>100 || b<1 || b>100){
        c = 0;
        printf("1から100までの整数を入力してね！");
    }else{
        x = a * b;
        c = 1;
        printf("%d",x);
    }


    }

}

Measured memory_bytes: 1672
#include <stdio.h>

int main(void) {
   int  N,A,B,C,D,price_X,price_Y,mod;
   scanf( "%d %d %d %d %d" , &N,&A,&B,&C,&D );
   if( N%A != 0 ){ mod = 1 ;}else{ mod = 0 ;}
   price_X=(N/A+mod)*B;
   if( N%C != 0 ){ mod = 1 ;}else{ mod = 0 ;}
   price_Y=(N/C+mod)*D;
   if( price_X < price_Y ){
	 printf("%d\n" , price_X);
      }else{
    	 printf("%d\n" , price_Y);
      }
   return 0;
}



Measured memory_bytes: 2140
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::map<LL, LL> decomposit_prime(LL n)
{
	LL d = 2;
	std::map<LL, LL>res;
	while (d*d <= n)
	{
		if (n%d == 0)
		{
			++res[d];
			n /= d;
		}
		else ++d;
	}
	++res[n];
	return res;
}

int main()
{
	LL N;
	in >> N;

	std::map<LL, LL>primes;
	for (LL i = 1; i <= N; ++i)
	{
		auto res = decomposit_prime(i);
		for (auto j : res) primes[j.first] += j.second;
	}

	std::map<LL, LL>cnt;
	for (auto i : primes)
	{
		if (i.second >= 74) ++cnt[74];
		if (i.second >= 24) ++cnt[24];
		if (i.second >= 14) ++cnt[14];
		if (i.second >= 4) ++cnt[4];
		if (i.second >= 2) ++cnt[2];
	}

	LL ans = 0;
	ans += cnt[74];
	ans += cnt[24] * (cnt[2] - 1);
	ans += cnt[14] * (cnt[4] - 1);
	ans += (cnt[4] * (cnt[4] - 1)) / 2 * (cnt[2] - cnt[4]);
	ans += (cnt[4] * (cnt[4] - 1)) / 2 * (cnt[4] - 2);

	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter
n,m,k = map(int,input().split())
fgraph = [list() for i in range(n)]
bgraph = [list() for i in range(n)]
cgraph = [list() for i in range(n)]

rks = [None] * n
sys.setrecursionlimit(10**9)

# r: どの連結成分に存在するか
def dfs(graph, s, r):
    if rks[s] is None:
        rks[s] = r
    for i in range(len(graph[s])):
        if rks[graph[s][i]-1] is not None:
            continue
        dfs(graph,graph[s][i]-1,r)

for i in range(m):
    a,b = map(int,input().split())
    fgraph[a-1].append(b)
    fgraph[b-1].append(a)

# 連結成分にindexをつける
c = -1
for i in range(n):
    if rks[i] is None:
        c += 1
        dfs(fgraph, i, c)

for i in range(k):
    c,d = map(int,input().split())
    # おなじ連結成分に属するものだけ処理すれば良い
    if rks[c-1] == rks[d-1]:
        bgraph[d-1].append(c)
        bgraph[c-1].append(d)

counter = Counter(rks)
for i in range(n):
    print(counter[rks[i]] - len(fgraph[i]) - len(bgraph[i]) - 1, end=' ')


Measured memory_bytes: 60192
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

struct edge {
  int v, w;
};

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

  vector<vector<edge>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a - 1].push_back({b - 1, c});
    g[b - 1].push_back({a - 1, c});
  }

  vector<long long> dist(n);
  function<void(int, int)> dfs = [&](int u, int p) {
    for (edge e : g[u]) if (e.v != p) {
      dist[e.v] = dist[u] + e.w;
      dfs(e.v, u);
    }
  };
  int Q, K;
  cin >> Q >> K;
  dfs(K - 1, -1);

  while (Q--) {
    int x, y;
    cin >> x >> y;
    cout << dist[x - 1] + dist[y - 1] << endl;
  }
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>

using namespace std;



int main() {
  string s;
  long long int k;
  cin >> s >> k;

  char p = '1';
  for (int i = 0; i < s.size() && i < k; i++) {
    if (s[i] > '1') {
      p = s[i];
      break;
    }
  }
  cout << p << endl;
  return 0;
}

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

int main() {
	int A,B,C,x,a,b;
	x=0;
	cin>>A>>B>>C;
	while(A%2==0&&B%2==0&&C%2==0){
	    if(A!=B||B!=C){
	        a=B/2+C/2;
	        b=A/2+C/2;
	        C=A/2+B/2;
	        A=a;
	        B=b;
	        x++;
	    }
	    else{
	        x=-1;
	        break;
	    }
	}
	cout<<x<<endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll sum = 0;
    rep(i,n) {
        int c = min(a[i], b[i]);
        a[i]-=c; b[i]-=c; sum+=c;
        int d = min(a[i+1], b[i]);
        a[i+1]-=d; b[i]-=d; sum+=d;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  char s[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      bool flag = false;
      if (s[i][j] == '#') {
        if (s[i - 1][j] == '#') continue;
        if (s[i][j - 1] == '#') continue;
        if (s[i][j + 1] == '#') continue;
        if (s[i + 1][j] == '#') continue;
        if (flag == false) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}


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

long long int num_of_one(long long int x, long long int digit) {
    long long int n = 1L << (digit + 1L);
    long long int ret = (x / n) * (n / 2LL) + std::max(x % n - n / 2LL + 1LL, 0LL);
    return ret;
}

int main() {
    long long int a, b;
    std::cin >> a >> b;
    long long int bb = b;
    int digits = 0;
    while (bb > 0) {
        digits++;
        bb = bb >> 1;
    }
    long long int ans = 0;
    for (int i = 0; i < digits; i++) {
        long long int ones_b = num_of_one(b, digits-i-1);
        long long int ones_a = num_of_one(std::max(0LL, a-1), digits-i-1);
        long long int ones = ones_b - ones_a;
        ans += ones % 2;
        if (i != digits - 1) ans = ans << 1;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class C
{
    static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        int ans = 0;
        for (int a = 1, b = 1; b < n; b++)
        {
            while (a * b < n)
            {
                ans++;
                a++;
            }
            a = 1;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 27528
import sys
readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readints():return list(map(int,readline().split()))

from collections import deque

h,w = readints()

start = readints()
start = (start[0]-1)*w + start[1]-1

goal = readints()
goal = (goal[0]-1)*w + goal[1]-1

maze = [readstr() for i in range(h)]

dist = [10**10]*(h*w)

dq = deque()
dq.append(start)
dist[start] = 0

while dq:
    p = dq.popleft()
    if dist[goal] <= dist[p]:
        break
    y = p//w
    x = p%w
    for dy in range(-2,3):
        for dx in range(-2,3):
            if 0<=y+dy<h and 0<=x+dx<w and maze[y+dy][x+dx]=='.':
                q = (y+dy)*w + x+dx
                if abs(dy)+abs(dx)==1:
                    if dist[q]>dist[p]:
                        dq.appendleft(q)
                        dist[q] = dist[p]
                else:
                    if dist[q]>dist[p]+1:
                        dq.append(q)
                        dist[q] = dist[p] + 1


print(-1 if dist[goal]==10**10 else dist[goal])


Measured memory_bytes: 89088
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>

#define mod 1000000007
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;

int main(){
    int X,Y,Z;
    int K;
    cin>>X>>Y>>Z;
    cin>>K;
    vector<long long> A(X),B(Y),C(Z);
    rep(i,X)cin>>A[i];
    rep(i,Y)cin>>B[i];
    rep(i,Z)cin>>C[i];
    vector<long long> AB;
    rep(i,A.size())rep(j,B.size())AB.push_back(A[i]+B[j]);
    sort(AB.begin(),AB.end(),greater<long long>());

    vector<long long> ABC;
    if(K<AB.size())rep(i,K)rep(j,C.size())ABC.push_back(AB[i]+C[j]);
    else rep(i,AB.size())rep(j,C.size())ABC.push_back(AB[i]+C[j]);
    sort(ABC.begin(),ABC.end(),greater<long long>());

    rep(i,K)cout<<ABC[i]<<endl;
    return 0;
}

Measured memory_bytes: 43112
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

template<class T> 
ostream& operator<<(ostream &os, vector<T> input) {
    os << "[ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "]";
}

template<class T> 
ostream& operator<<(ostream &os, set<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, unordered_set<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, multiset<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, unordered_multiset<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class L, class R> 
ostream& operator<<(ostream &os, map<L,R> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << "(" << elem.first << "," << elem.second << ") ";
	}
	return os << "}";
}

template<class L, class R> 
ostream& operator<<(ostream &os, unordered_map<L,R> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << "(" << elem.first << "," << elem.second << ") ";
	}
	return os << "}";
}

#define ll long long
const int MAXN = 100005;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

class TaskE {
private:

public:
	void solveOne(int it){
		int n;
		cin >> n;
		vector<ll> x(n), y(n);
		for(int i = 0; i < n; i++) {
			cin >> x[i] >> y[i];
		}
		ll ans = -INF;
		for(int i = -1; i <= 1; i+=2) {
			for(int j = -1; j <= 1; j+=2) {
				ll maxi = -INF;
				ll mini = INF;
				for(int idx = 0; idx < n; idx++) {
					ll tmp = x[idx] * i + y[idx] * j;
					maxi = max(maxi, tmp);
					mini = min(mini, tmp);
				}	
				ans = max(ans, maxi - mini);
			}
		}
		cout << ans << endl;

	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskE solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 6392
#!usr/bin/env python3

import sys


def main():
    s = sys.stdin.readline().strip('\n')
    q = int(sys.stdin.readline().strip('\n'))

    for instruction in range(q):
        words = [word for word in sys.stdin.readline().strip('\n').split()]
        if words[0] == 'replace':
            s = s[:int(words[1])] + words[3] + s[int(words[2])+1:]
        elif words[0] == 'reverse':
            s = s[:int(words[1])] \
                    + ''.join(reversed(s[int(words[1]):int(words[2])+1])) \
                    + s[int(words[2])+1:]
        elif words[0] == 'print':
            print(s[int(words[1]):int(words[2])+1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 7676
#include <iostream>
#include <math.h>
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAX_N=100000;
int n,a[MAX_N]={},ma=0;
int list[MAX_N]={};

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	for(int i=0;i<n;i++){
		list[a[i]]++;
	}
	
	for(int i=1;i<100000-1;i++){
		int c = list[i]+list[i-1]+list[i+1];
		ma = max(ma, c);
	}
	
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
  int a, b, c, k, i, max, sum;

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

  max = a;
  if (max < b) {
    max = b;
  }
  if (max < c) {
    max = c;
  }

  sum = (a + b + c) - max;

  for (i = 1; i <= k; i++) {
    max *= 2;
  }

  printf("%d\n", sum + max);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;


int main(void){
    ll n;
    string s;
    cin>>s;
    n=s.size();
    ll max=0;
    for(int i=0;i<n;i++){
        ll j=i;
        ll c=0;
        while(1){
            if(i==n)break;
            if(s[j]!='A'&&s[j]!='C'&&s[j]!='G'&&s[j]!='T')break;
            j++;
            c++;
        }
    if(max<c)max=c;
    }
    cout<<max<<endl;
}


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

using namespace std;

#define ll long long
#define mod 1000000007
#define pb push_back

int inp[20010],a1[20010],b1[20010],pr[20010];
int main(){

    int n;
    cin>>n;

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

    for(int i=1;i<=n;i++){
        a1[i]=n*i;
    }

    for(int i=1;i<=n;i++){
        b1[inp[i]]=i-a1[inp[i]];
    }

    for(int i=1;i<=n;i++){
        cout<<a1[i]<<" ";
    }
    cout<<endl;
    int mini = 1000000000;
    for(int i=1;i<=n;i++){
        mini=min(mini,b1[i]);
    }

    for(int i=1;i<=n;i++){
        b1[i]+=(abs(mini)+1);
        cout<<b1[i]<<" ";
    }
    cout<<endl;

    return 0;
}



Measured memory_bytes: 896
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
/*---------------------------------------------------------------------*/
const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    ll n,a,b;
    cin>>n>>a>>b;
    if(a==0)
    {
        cout<<0<<nl;return 0;
    }
    else if(b==0)
    {
        cout<<n<<nl;return 0;
    }
    ll ans=min(a,(n%(a+b)));
    cout<<(a*(n/(a+b))+ans)<<nl;
    return 0;
}


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

int main() {
	int a;
	int b;
	int c;

	cin >> a >> b >> c;

	if (a < b && b < c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3080
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long llong;

#define MAX 200005
const llong mod = 1000000000 + 7;

int main()
{
  int K, N;
  int A[MAX];
  int tmp, ma = 0, total = 0;
  scanf("%d%d", &K, &N);

  // 差分は最後の要素と比較するため計算しない
  scanf("%d", &A[0]);
  // 差分の最大値を取得
  for (int i = 1; i < N; i++)
  {
    scanf("%d", &A[i]);
    ma = max(ma, A[i] - A[i - 1]);
  }
  // 最初の要素と最後の要素の差分を取得
  ma = max(ma, (K + A[0] - A[N - 1]));

  // 答え
  printf("%d\n", K - ma);

  return 0;
}

Measured memory_bytes: 2456
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 1000000
#define MID (l+r)/2
#define ll long long


int b[10*INF];
ll seg[100*INF];

ll query(int rl, int rr, int l=0, int r=INF-1, int ind=1){
	if(rl<=l && r<=rr) return seg[ind];
	else if(rl>r || l>rr) return 0;
	return query(rl, rr, l, MID, ind*2) + query(rl,rr,MID+1,r,ind*2+1);
}

void update(int x, int l=0, int r=INF-1, int ind=1){
	if(l==r && l==x){ seg[ind]++; return;}
	if(x<l || x>r) return;
	update(x,l,MID,ind*2);
	update(x,MID+1,r,ind*2+1);
	seg[ind] = seg[ind*2] + seg[ind*2+1];
}


int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	ll l=0, r=2000000000;
	ll m;
	ll anss=0;
	while(l<=r){
		m = MID;
		ll ans=0, s = n+1;
		memset(seg, 0, 4*INF * sizeof(1ll));
		update(s);
		for(int i=0;i<n;i++){
			s += (a[i]>=m ? 1 : -1);
			ans+=query(0,s);
			update(s);
		}
		if(ans < (n*(n+1)+3)/4) r = m-1;
		else l = m+1, anss=m;
	}
	cout<<anss<<endl;
}


Measured memory_bytes: 33792
X,N= map(int,input().split())
p = list(map(int, input().split()))
p = sorted(p)
ans_tmp = 10**9+7
ans = 0
if N==0:
    print(X)
else:
    if X not in p:
        print(X)
        exit()
    else:
        tmp1,tmp2 = X-1,X+1
        while True:
            if tmp1 not in p:
                print(tmp1)
                exit()
            if tmp2 not in p:
                print(tmp2)
                exit()
            tmp1 -= 1
            tmp2 += 1

Measured memory_bytes: 9128
n = int(input())
a = input()
b = input()
c = input()
x = 0
for i in range(n):
	if a[i]==b[i]==c[i]: pass
	elif a[i]==b[i] or b[i]==c[i] or c[i]==a[i]: x+=1
	else: x+=2
print(x)

Measured memory_bytes: 3060
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

"""
・次数3以上の点は使わないとしてよい
・次数1の点は全て回収できる。次数2の点を、パスとなる形で回収する。
"""

N = int(readline())
PQ = [tuple(int(x)-1 for x in line.split()) for line in readlines()]

graph = [[] for _ in range(N)]
for p,q in PQ:
    graph[p].append(q)
    graph[q].append(p)    

deg = [len(x) for x in graph]

cnt_deg1 = sum(x==1 for x in deg)

deg2_path = 0

def dfs(x,parent):
    global deg2_path
    # 部分木で完結する場合、しない場合
    arr = [dfs(y,x) for y in graph[x] if y != parent]
    if len(arr) == 0:
        return 0
    if len(arr) == 1:
        return arr[0] + (deg[x] == 2)
    arr.sort()
    deg2_path = max(deg2_path, arr[-1] + arr[-2] + (deg[x]==2))
    return arr[-1] + (deg[x] == 2)

dfs(0,-1)
answer = cnt_deg1 + deg2_path
print(answer)

Measured memory_bytes: 32076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000500
 
ll n, W, w[105], v[105], dp[105][100005];
 
int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> n >> W;
    for (int i = 1; i <= n; i++) cin >> w[i] >> v[i];
    for (int cnt = 1; cnt <= n; cnt++){
        for (int c = 0; c <= W; c++){
            dp[cnt][c] = max(dp[cnt][c], dp[cnt - 1][c]);
            if (c + w[cnt] <= W) 
                dp[cnt][c + w[cnt]] = max(dp[cnt][c + w[cnt]], dp[cnt - 1][c] + v[cnt]);
        }
    }
    cout << dp[n][W];
    return 0;
}

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

template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n = 0) : n(n), d(n + 1) {}
    void add(int i, T x = 1) {
        for(i++; i <= n; i += i & -i) {
            d[i] += x;
        }
    }

    T sum(int i) {
        T x = 0;
        for(i++; i; i -= i & -i) {
            x += d[i];
        }
        return x;
    }

    T sum(int l, int r) {
        return sum(r - 1) - sum(l - 1);
    }
};

int main()
{
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<int> pi(n + 1, -1);
    vector<vector<int>> ps(n);
    for(int i = 0; i < n; i++) {
        int l = pi[a[i]];
        if(l != -1) ps[l].emplace_back(i);
        pi[a[i]] = i;
    }
    vector<vector<pair<int, int>>> qs(n);
    for(int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        qs[l].emplace_back(r, i);
    }
    BIT<int> d(n);
    vector<int> ans(q);
    for(int x = n - 1; x >= 0; x--) {
        for(int y : ps[x]) d.add(y, 1);
        for(auto query : qs[x]) {
            int r = query.first;
            int i = query.second;
            ans[i] = r - x + 1 - d.sum(r);
        }
    }
    for(int i = 0; i < q; i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 59916