akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl;
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<endl;
#define pi M_PI
int main()
{
    fastio();
    int n;cin>>n;
    ll arr[n];
    loop(i,0,n)
    {
        cin>>arr[i];
    }
    int x;
    int flag=0;
    loop(i,0,n-1)
    {
        x = arr[i+1]-arr[i];
        if(x==-1)
            arr[i+1]++;
        if(x<=-2)
        {
            flag=1;
            break;
        }
    }
    if(flag==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}    

Measured memory_bytes: 1024
/**
 * Pizza
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int d = parseInt(line);
			if (d == 0) break;

			int n = parseInt(br.readLine());
			int m = parseInt(br.readLine());

			// store
			int[] stores = new int[n + 1];
			for (int i = 1; i < n; i++) {
				int pos = parseInt(br.readLine());
				stores[i] = pos;
			}
			stores[n] = d;
			Arrays.sort(stores);

			// order
			int sum = 0;
			for (int i = 0; i < m; i++) {
				int pos = parseInt(br.readLine());
				int min = 0, max = n - 1, mid;
				while (min <= max) {
					mid = (max + min) / 2;
					if (pos < stores[mid]) {
						max = mid - 1;
					} else if (stores[mid + 1] < pos) {
						min = mid + 1;
					} else {
						sum += Math.min(pos - stores[mid], stores[mid + 1] - pos);
						break;
					}
				}
			}
			System.out.println(sum);
		} //end while
	} //end main
}

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

INF = float('inf')
last = [0] * 26
for i,s in enumerate(S):
    best_k = -1
    best_score = -INF
    for k,s in enumerate(s):
        score = s
        for j,c in enumerate(C):
            if j==k: continue
            score -= c * (i+1 - last[j])
        if score > best_score:
            best_score = score
            best_k = k
    last[best_k] = i+1
    print(best_k+1)

Measured memory_bytes: 9288
N  = gets.to_i
XY = N.times.map do # XYは2次元配列　　第一成分が発言者の数、第二成分が対象者とその真偽
    a = gets.to_i
    a.times.map do
        x, y = gets.split(" ").map(&:to_i)
        [x - 1, y]
    end
end

def is_valid(i)
    for n in 0...N
        for x, y in XY[n]
            return false if (i[x] != y) && (i[n] == 1)
        end
    end
    true
end

max = 0

for i in 0...2**N
    if is_valid(i)
        count = i.to_s(2).count(?1)
        max = count if max < count 
    end
end

puts max




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


void find_a_b(int *P, int *Q, int *now, int &a, int &b, int x, int n, int &c){
  if (x == n){
    c++;
    bool p = true, q = true;
    for (int i=0; i<n; i++){
      if (P[i] != now[i]) p = false;
      if (Q[i] != now[i]) q = false;
    }
    if (p) a = c;
    if (q) b = c;
    return;
  }

  int add = 1;
  while (add <= n){
    bool ok = true;
    for (int i=0; i<x; i++){
      if (now[i] == add) ok = false;
    }
    if (ok){
      now[x] = add;
      find_a_b(P, Q, now, a, b, x+1, n, c);
    }
    add++;
  }
}


int main(){
  int n, a, b, c = 0;
  cin >> n;
  int P[n];
  int Q[n];
  int now[n];
  for (int i=0; i<n; i++) cin >> P[i];
  for (int i=0; i<n; i++) cin >> Q[i];

  find_a_b(P, Q, now, a, b, 0, n, c);
  if (a > b) cout << a - b << endl;
  else cout << b - a << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  long long N,K;
  cin>>N>>K;
  int k_2[40];
  int dp[100000][40];
  long long beki[40];
  long long tmp=1;
  long long ans=0;
  beki[0]=tmp;
  for(int i=1;i<40;++i){
    tmp*=2;
    beki[i]=tmp;
  }
  //2^40>10^12>2^39;
  //kをビット化
  for(int i=39;i>=0;--i){
    if(K>=beki[i]){
      K-=beki[i];
      k_2[i]=1;
    }
    else{
      k_2[i]=0;
    }
  }
  long long A=0;
  //Aをビット化してdpに入れていく
  for(long long j=0;j<N;j++){
    cin>>A;
  for(int i=39;i>=0;--i){
    if(A>=beki[i]){
      A-=beki[i];
      dp[j][i]=1;
    }
    else{
      dp[j][i]=0;
    }
  }}
  tmp=0;
  int bound=0;
  //1桁ごとに見ていく
  for(int i=39;i>=0;--i){
    if(bound==0){
      if(k_2[i]==0){
        for(long long j=0;j<N;j++){
        if(dp[j][i]==1){
          ans+=beki[i];
        }
        }
        }
      else if(k_2[i]==1){
        tmp=0;
        //1の方が多いか同数ならbound解除
        for(long long j=0;j<N;j++){
        if(dp[j][i]==1){
          tmp+=1;
        }
        }
        if(tmp>=N-tmp){
          ans+=tmp*(beki[i]);
          bound=1;
        }
        else{
          ans+=(N-tmp)*(beki[i]);
        }
      }

    }


    else{
      tmp=0;
      for(long long j=0;j<N;j++){
      if(dp[j][i]==1){
        tmp+=1;
      }
      }
      if(tmp>=N-tmp){
        ans+=tmp*(beki[i]);
      }
      else{
        ans+=(N-tmp)*(beki[i]);
      }
    }
  }
  cout<<ans<<"\n";
return 0;
}

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

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
Ls = list(map(int, input().split()))
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [Ls[i], Ls[j], Ls[k]]
            arr.sort()
            if arr[0] + arr[1] > arr[2] and arr[0] != arr[1] and arr[1] != arr[2]:
                ans += 1
print(ans)





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

int main() {
  bool check = false;
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    string x;
    cin >> x;
    if (x != "P" && x != "W" && x != "G") {
      check = true;
      break;
    }
  }
  if (check) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,K;
	cin >> N >> K;
	vector<int> hist(26,0);
	for(int i=0;i<N;++i){
		string str;
		cin >> str;
		hist[ str[0]-'A' ]++;
	}
	
	int ans = 0;
	while(1){
		sort(ALL(hist));
		for(int i=0;i<K;++i){
			if( hist[25-i] ){
				hist[25-i]--;
			}else{
				cout << ans << endl;
				return;
			}
		}
		++ans;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

int main(){
  char b; cin >> b;
  if(b == 'A')  cout << 'T' << endl;
  else if(b == 'T') cout << 'A' << endl;
  else if(b == 'C') cout << 'G' << endl;
  else  cout << 'C' << endl;
}


Measured memory_bytes: 3532
#include <iostream>
using namespace std;
int main() {
	long long N, P;
	cin >> N >> P;
	long long ans = 1;
	for (long long i = 2; i * i <= P; ++i) {
		int cnt = 0;
		while (P % i == 0) {
			P /= i;
			++cnt;
		}
		for (int j = 0; j < cnt / N; ++j) {
			ans *= i;
		}
	}
	if (P > 1 && N == 1) ans *= P;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


def solve():
    s = ii()
    d = {s: 0}
    for i in range(1, 1000000000):
        s = f(s)
        if d.get(s) is None:
            d[s] = 0
        else:
            return i + 1


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3064
input = readlines()

a = input.shift().chomp.to_i
b = input.shift().chomp.to_i
c = input.shift().chomp.to_i
d = input.shift().chomp.to_i
e = input.shift().chomp.to_i
k = input.shift().chomp.to_i

res = 'Yay!'
[a, b, c, d, e].each_with_index do |a1, i1|
  [a, b, c, d, e].each_with_index do |a2, i2|
    next if i1 >= i2
    res = ':(' if (a2 - a1).abs > k
  end
end

puts res


Measured memory_bytes: 14332
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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;}
const int INF = 1e9+1;


int main() {
    int A, B;
    cin >> A >> B;
    cout << max(0,A - 2 * B) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int fun(int A[]){
    int min = A[0];
    int i = 0;
    for(i = 1; i < 201; i++){
        if(A[i] < min) min = A[i];
    }
    return min;


}

int main (void){
    int i,j;
    int n = 0;
    int sum[202] = {0};

    scanf("%d", &n);
    
    int array[n];
    for(i = 0; i < n; i++){
        scanf("%d", &array[i]);
    }
    for(i = -100; i <= 100; i++){
        for(j = 0; j < n; j++) {
            sum[i+100] += (array[j] - i)*(array[j] - i);
        }
    }

    printf("%d\n", fun(sum));

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    int total = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        total += A[i];
    }

    int count = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] >= (double)total / (4 * M)) {
            count++;
        }
    }

    if (count >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

static const ll MAX_N = 100001;
static const ll MAX_M = 200001;

int main() {
	string s; cin >> s;
	rep(i, 0, s.size()) {
		if (i < s.size() && s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
		if (i < s.size() - 1 && s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($N,$K) = explode(" ",trim(fgets(STDIN)));
//$a = explode(" ",trim(fgets(STDIN)));
//$H = explode(" ",trim(fgets(STDIN)));

$mp = 0;
$tot = 0;
for($i=0;$i<$N;$i++) {
  $p[$i]=trim(fgets(STDIN));
  $mp = max($mp,$p[$i]);
  $tot+=$p[$i];
}
printf("%d\n",$tot-$mp+($mp/2));


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

int main(){
    int len[5];
    int k;
    for(int i=0; i<5 ; i++){
        cin >> len[i];
    }
    cin >> k;
    
    for(int i=0; i<1; i++){
        if(len[i+4]-len[i] > k){
            cout << ":(" << endl;
            return 0;
        }
    }
    for(int i=0; i<2; i++){
        if(len[i+3]-len[i] > k){
            cout << ":(" << endl;
            return 0;
        }
    }
    for(int i=0; i<3; i++){
        if(len[i+2]-len[i] > k){
            cout << ":(" << endl;
            return 0;
        }
    }
    for(int i=0; i<4; i++){
        if(len[i+1]-len[i] > k){
            cout << ":(" << endl;
            return 0;
        }
    }

    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




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

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {

  ll n,w;cin>>n>>w;
  vector<ll> weight(n),value(n);
  rep(i,n) cin>>weight[i]>>value[i];
  ll dp[n+1][Svec(value)+1];
  rep(i,Svec(value)+1) dp[0][i]=1e17;
  dp[0][0]=0;
  rep(i,n){
    rep(j,Svec(value)+1){
      if(j>=value[i]) dp[i+1][j]=min(dp[i][j],dp[i][j-value[i]]+weight[i]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  for(ll i=Svec(value);i>=0;i--){
    if(dp[n][i]<=w){
      cout<<i<<endl;
      return 0;
    }
  }
}

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

//RSQ
struct SegmentTree{
private:
	int N;
	vector<long long> node, lazy;
	vector<bool> lazyFlg;
	const long long DEFAULT = 0LL;
public:
	void init(int n){ //初期化 O(N)
		node.clear();
		lazy.clear();
		lazyFlg.clear();
		N = 1;
		while(N < n) N = (N<<1);
		for(int i=0; i<2*N-1; i++){
			node.push_back(DEFAULT);
			lazy.push_back(0LL);
			lazyFlg.push_back(false);
		}
	}
	void eval(int k, int l, int r){ //遅延評価 O(1)
		if(lazyFlg[k]){ //RUQ：下に更新クエリが溜まっていても加算クエリが溜まっていても上書き
			node[k] = lazy[k];
			if(r-l > 1){
				lazy[2*k+1] = lazy[k] / 2;
				lazyFlg[2*k+1] = true;
				lazy[2*k+2] = lazy[k] / 2;
				lazyFlg[2*k+2] = true;
			}
			lazy[k] = 0LL;
			lazyFlg[k] = false;
		}
		else{ //RAQ：下に更新クエリが溜まっていても加算クエリが溜まっていても加算
			node[k] += lazy[k];
			if(r-l > 1){
				lazy[2*k+1] += lazy[k] / 2;
				lazy[2*k+2] += lazy[k] / 2;
			}
			lazy[k] = 0LL;
		}
	}
	void update(int a, long long x){ //[a,a+1)の値を変更 O(log N)
		update(a, a+1, x);
	}
	void update(int a, int b, long long x, int k=0, int l=0, int r=-1){ //[a,b)の値を変更 O(log N)
		if(r == -1) r = N;
		eval(k, l, r);
		if(b <= l || r <= a) return; //交差する場合
		if(a <= l && r <= b){ //完全に含む場合
			lazy[k] = x * (r-l);
			lazyFlg[k] = true;
			eval(k, l, r);
		}
		else{
			update(a, b, x, 2*k+1, l, (l+r)/2);
			update(a, b, x, 2*k+2, (l+r)/2, r);
			node[k] = node[2*k+1] + node[2*k+2];
		}
	}
	void add(int a, long long x){ //[a,a+1)の値に加算 O(log N)
		add(a, a+1, x);
	}
	void add(int a, int b, long long x, int k=0, int l=0, int r=-1){ //[a,b)の値に加算 O(log N)
		if(r == -1) r = N;
		eval(k, l, r);
		if(b <= l || r <= a) return; //交差する場合
		if(a <= l && r <= b){ //完全に含む場合
			lazy[k] += x * (r-l);
			eval(k, l, r);
		}
		else{
			add(a, b, x, 2*k+1, l, (l+r)/2);
			add(a, b, x, 2*k+2, (l+r)/2, r);
			node[k] = node[2*k+1] + node[2*k+2];
		}
	}
	long long sum(int a, int b, int k=0, int l=0, int r=-1){ //[a,b)の和 O(log N)
		if(r == -1) r = N;
		if(b <= l || r <= a) return DEFAULT; //交差する場合
		eval(k, l, r);
		if(a <= l && r <= b) return node[k]; //完全に含む場合
		return sum(a, b, k*2+1, l, (l+r)/2) + sum(a, b, k*2+2, (l+r)/2, r);
	}
};

int main(){
	int N, Q;
	cin >> N >> Q;
	SegmentTree st;
	st.init(N+1);
	for(int q=0; q<Q; q++){
		int c, s, t;
		cin >> c >> s >> t;
		if(c == 0){
			int x; cin >> x;
			st.update(s, t+1, x);
		}
		else cout << st.sum(s, t+1) << endl;
	}
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  for(int i=0;i<n;i++){
    cout << s[i] << t[i];
  }
  cout << endl;
  return 0;
}




Measured memory_bytes: 3728
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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


  ll N ;cin >> N ;

  cout << (N*800-(N/15)*200) << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from math import ceil
n,m = [int(x) for x in input().split(' ')]
arr = [int(x) for x in input().split(' ')]
t = ceil(sum(arr)/(4*m))
cnt = 0
for i in arr:
    if i>=t:
        cnt=cnt+1
if(cnt>=m):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <utility>
#include <tuple>

using namespace std;

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


Measured memory_bytes: 888
#include <stdio.h>

int a,b,c;

int main() {
  scanf("%d %d %d",&a,&b,&c);
 if(a!=b&a!=c)
   {printf("%d",a);}
   
   if(b!=a&b!=c)
     {printf("%d",b);} 
     
     if(c!=b&c!=a)
       {printf("%d",c);} 
  
  
 return 0;
}

Measured memory_bytes: 128
while True:
    a, op, b = raw_input().split()
    if op == "?":
        break
    else:
        if op == '+':
            print int(a) + int(b)
        elif op == '-':
            print int(a) - int(b)
        elif op == '*':
            print int(a) * int(b)
        elif op == '/':
            print int(a) / int(b)
        else:
            print "error"

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

int main() {
	int N,M;
	cin >> N >> M;
	if (N > M) cout << "safe" << endl;
	else cout << "unsafe" << endl;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,D[5],T=0,A[5];
    cin>>D[1]>>D[2]>>D[3]>>D[4]>>D[5];
    for(i=1;i<=5;i++){
        if(D[i]%10==0){
            T+=D[i];
            A[i]=10;
        }else{
            T+=D[i]-D[i]%10+10;
            A[i]=D[i]%10;
        }
    }
    T=T-10+min({A[1],A[2],A[3],A[4],A[5]});
    cout<<T<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    //#define int long long
    typedef long long ll;
    #define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
    #define forn(i, n) fore(i, 0, n)
    #define fori(i, l, r) fore(i, l, (r) + 1)
    #define sz(v) int((v).size())
    #define all(v) (v).begin(), (v).end()
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    using namespace std; 
     
    const double PI = atan(1)*4;

    int dx[8]={1,0,-1,0,1,-1,-1,1};
    int dy[8]={0,1,0,-1,1,1,-1,-1};
     
     
    bool isprime(int n)
    {
        for(int i=2;i*i<=n;i++)
            if(n%i==0)
                return false;
        return true;
    }

    const int mod = 998244353;
     
    bool comp(pair<int,int> a, pair<int,int> b)
    {
        return b.ff < a.ff ;
    }
     
    ll pw(ll b, ll e)
    {
        ll ans = 1;
        while(e)
        {
            if(e & 1)
                ans = (ans * b) % mod;
            b = (b * b) % mod;
            e >>= 1;
        }
        return ans;
    }

    ll fact[200002], inv[200002];
    
    ll C(ll n, ll k)
    {
        return ((((fact[n] * inv[k]) % mod) * inv[n-k]) % mod);
    }
     
    /*void bsearch(int max,int min)   //  for function 
    //void bsearch(int a,int n, int x)     // for array
    {
        int k=min;
     
        //  for array
     
    /*    for(int b=n/2; b>=1; b/=2)
        {
            while(k+b<n && arr[k+b]<=x) k+=b; 
        }
     
        if(arr[k]==x)
            cout<<"found at "<<k+1;
        else
            cout<<"not found";
    */
     
        //  for function 
     
    /*    for(int b=max; b>=1; b/=2)
        {
            while( !fn(b+k) ) k+=b;
        }
        cout<<k+1;
     
    }*/
     
    int vis[200005];
     
    int main()
    {
     
        int t=1;
        //cin>>t;
     
        while(t--)
        {
            int n;
            cin>>n;

            int dp[n+1][3];
            int a[n+1][3];
            fori(i,1,n)
            {
                forn(j,3)
                {
                    cin>>a[i][j];
                }
            }

            forn(i,3)
            {
                dp[1][i]=a[1][i];
            }

            fori(i,2,n)
            {
                
                forn(j,3)
                {
                    int mx=0;
                    forn(l,3)
                    {
                        if(l==j)
                            continue;
                        mx=max(dp[i-1][l] , mx);
                    }
                    dp[i][j] = mx+a[i][j];
                }
            }

            
            cout<<max(dp[n][0] , max(dp[n][1] , dp[n][2]));
        }
        return 0;
    }

Measured memory_bytes: 2560
# セグメント木。区間における要素の取得をO(logN)で行うことが可能である。
class SegTree():
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.func = function
        self.basement = basement
        self.seg = [basement]*2**(self.K+1)

        for i in range(self.n):
            self.seg[i+2**self.K-1] = lists[i]

        for i in range(2**(self.K)-2, -1, -1):
            self.seg[i] = self.func(self.seg[2*i+1], self.seg[2*i+2])

    def update(self, k, value):
        # 0-indexでa[k]の値をvalueに変更
        k += 2**self.K-1
        self.seg[k] = value
        while k:
            k = (k-1)//2
            self.seg[k] = self.func(self.seg[k*2+1], self.seg[k*2+2])

    def query(self, p, q):
        # 0-indexで[p,q)の値を取得する
        if q <= p:
            return self.basement
        num = 2**self.K
        p += num-1
        q += num-2
        res = self.basement
        while q-p > 1:
            if p & 1 == 0:
                res = self.func(res, self.seg[p])
            if q & 1 == 1:
                res = self.func(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.func(res, self.seg[p])
        else:
            res = self.func(self.func(res, self.seg[p]), self.seg[q])
        return res


#gcd on blackboard
#セグ木（区間gcd) verify
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
seg=SegTree(A,gcd,0)
ans=1
for i in range(-1,N):
    v=gcd(seg.query(0,i),seg.query(i+1,N))
    ans=max(v,ans)
print(ans)


Measured memory_bytes: 16152
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B = map(int, lines.pop(0).split(' '))
    c = abs(A+B)

    if ( c % 2 == 0 ):
        print(c//2)
    else:
        print('IMPOSSIBLE')

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

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

typedef vector<vector<int>> graph;

int m; vector<bool> used;
void dfs(const graph &g,int v){
    used[v]=true;
    for (int i = 0; i < g[v].size(); i++){
        if(used[g[v][i]])continue;
        dfs(g,g[v][i]);
    }
}

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

    int n; cin>>n>>m; int a[m],b[m]; graph g[m]={};
    for (int i = 0; i < m; i++)g[i].assign(n,vector<int>());
    for (int i = 0; i < m; i++){
        int p,q; cin>>p>>q; p--; q--; 
        for (int j = 0; j < m; j++){
            if(j!=i){
                g[j][p].push_back(q); g[j][q].push_back(p);
            }
        }
    }
    int ans=0;
    for (int i = 0; i < m; i++){
        if(m==1){
            ans=1;break;
        }else{
            used.assign(n,false);
            dfs(g[i],0);
            for (int j = 0; j < n; j++){
                if(!used[j]){
                    ans++; break;
                }
            }
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	cnt := map[pii]int{}
	a := make([]int, n)
	b := make([]int, n)
	zero := 0
	ca := 0
	cb := 0
	for i := 0; i < n; i++ {
		a[i], b[i] = scanInt(), scanInt()
		if a[i] == 0 && b[i] == 0 {
			zero++
		} else if a[i] == 0 {
			ca++
		} else if b[i] == 0 {
			cb++
		} else {
			c := gcd(a[i], b[i])
			a[i] /= c
			b[i] /= c
			cnt[pii{a[i], b[i]}]++
		}
	}

	ans := mpow(2, ca) + mpow(2, cb) - 1
	f := map[pii]bool{}
	for e, c := range cnt {
		if f[e] {
			continue
		}
		cc := cnt[pii{-e.b, e.a}] + cnt[pii{e.b, -e.a}]
		f[pii{-e.b, e.a}] = true
		f[pii{e.b, -e.a}] = true
		// debug(e, c, cc)
		ans *= mpow(2, c) + mpow(2, cc) - 1
		ans %= mod
	}
	ans += zero - 1
	ans += mod
	ans %= mod

	fmt.Fprintln(wr, ans)

}

const mod = 1000000007

func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

type pii struct {
	a, b int
}

func mpow(a, n int) int {
	res := 1
	for n > 0 {
		if n&1 == 1 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}


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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;

  int n = s.size(), m = t.size();
  // dp[i+1][j+1] := sのi文字目, tのj文字目まで見たときの最長共通部分列(LCS)
  vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
      if (s[i] == t[j]) {
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
      }
    }
  }

  int i = n, j = m;
  string ans = "";
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i - 1][j]) {
      i--;
    } else if (dp[i][j] == dp[i][j - 1]) {
      j--;
    } else {
      ans += s[i - 1];
      i--;
      j--;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 35584
#include <stdio.h>

int main(){

    int N, M, C;
    int i,j;
    int A[20][20], B[20];
    int sum, count=0;
    scanf("%d%d%d",&N,&M,&C);


    for(i=0;i<M;++i){
        scanf("%d",&B[i]);
    }
    for(i=0;i<N;++i){
        for(j=0;j<M;++j){
            scanf("%d",&A[i][j]);
        }
    }


    for(i=0;i<N;++i){

        sum=0;

        for(j=0;j<M;++j){
            sum += (A[i][j] * B[j]);
        }

        if(sum + C > 0){count++;}
    }

    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports)]
use proconio::marker::*;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize
    }

    let res = solve(a, b);
    println!("{}", res);
}

fn solve(a: usize, b: usize) -> usize {
    let mut c = 1;
    let mut res = 0;
    while c < b {
        c -= 1;
        c += a;
        res += 1;
    }
    res
}


Measured memory_bytes: 2136
using System;

public class Test
{
	public static void Main()
	{
		            string[] data = Console.ReadLine().Split();//????????\?????????
            int a = 0, b = 0, c = 0;
            a = int.Parse(data[0]);
            b = int.Parse(data[1]);
            c = int.Parse(data[2]);

            if (a < b)//a<?<?
            {
                if (b < c)//a<b<c
                {
                    Console.WriteLine("{0} {1} {2}", a, b, c);
                }
                else//a<c<b
                {
                    Console.WriteLine("{0} {1} {2}", a, c, b);
                }
            }

            else//a??\???<?<?
            {
                if (b < c)//b<?<?
                {
                    if (c < a)//b<c<a
                    {
                        Console.WriteLine("{0} {1} {2}",b,c,a);
                    }
                    else//b<a<c
                    {
                        Console.WriteLine("{0} {1} {2}", b, a, c);
                    }
                }
                else//c<?<?
                {
                    if (a < b)//c<a<b
                    {
                        Console.WriteLine("{0} {1} {2}",c,a,b);
                    }
                    else//c<b<a
                    {
                        Console.WriteLine("{0} {1} {2}", c, b, a);
                    }
                }
            }

	}
}

Measured memory_bytes: 9184
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n, d; cin >> n >> d;
    cout << (n + (2 * d)) / (2 * d + 1) << endl;
}


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

int main(){
    int A,B,M;
    int a[100010];
    int b[100010];
    cin >> A >> B >> M;
    int minA = 1000000;
    int minB = 1000000;
    int minV = 1000000;
    for(int i=0;i<A;i++){
        cin >> a[i];
        minA = min(minA,a[i]);
    }
    for(int i=0;i<B;i++){
        cin >> b[i];
        minB = min(minB,b[i]);
    }
    minV = minA + minB;
    for(int i=0;i<M;i++){
        int x,y,c;
        cin >> x >> y >> c;
        minV = min(minV,a[x-1]+b[y-1]-c);
    }
    cout << minV << endl;
}

Measured memory_bytes: 1024
n = int(input())
wl = [input() for i in range(n)]
saidl = [wl[0]]

for i in range(1,n):
	if wl[i-1][-1] == wl[i][0]:
		if wl[i] in saidl:
			print("No")
			quit()
		else:
			saidl.append(wl[i])
	else:
		print("No")
		quit()
print("Yes") 


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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
// Sat Apr 11 06:23:29 IST 2020   

#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long    
#define MOD                998244353
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"  
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             (x).begin(),(x).end() 

using namespace std ; 
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int M = 1e9+7 ;

int tests(){ 
  int K ;
  int i,j,k ;
  ll ans  = 0;
  cin >> K ;
  forn(i,1,K+1)
    forn(j,1,K+1)
      forn(k,1,K+1)
        ans += (ll)(__gcd(i,__gcd(j,k)));
  cout << ans  << '\n' ;
  return  0; 
}
int32_t main(){
    I__O ;            
    int cases = 1 ;  
    // cin >> cases ;  
    for(int  _ = 1 ; _ <= cases ; _++ ){   
    // cout << "Case #" << _ << ": "; 
      tests(); 
    }
    return 0 ; 
}

// -Wall -Weptra -O2
// -pedantic -std=c++11
// -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long llong;
const int maxSt = 6'005;

bool ba[maxSt], cb[maxSt], ca[maxSt];

void Set(bool* poss, const string& a, const string& b)
{
    fill(poss, poss + maxSt, true);
    for (int i = 0; i < a.size(); ++i)
        for (int j = 0; j < b.size() && i + j < a.size(); ++j)
            if (a[i + j] != b[j] && a[i + j] != '?' && b[j] != '?')
                poss[i] = false;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string a_[3];
    cin >> a_[0] >> a_[1] >> a_[2];
    int order[] = {0, 1, 2};
    int ans = a_[0].size() + a_[1].size() + a_[2].size();
    do {
        string a = a_[order[0]], b = a_[order[1]], c = a_[order[2]];
        Set(ba, a, b);
        Set(cb, b, c);
        Set(ca, a, c);
        for (int i = 0; i <= a.size(); ++i)
            for (int j = 0; j <= b.size() || j <= a.size() - i; ++j)
                if (ba[i] && cb[j] && ca[i + j])
                    ans = min(ans, (int)max({a.size(), i + b.size(), i + j + c.size()}));
    } while (next_permutation(order, order + 3));
    cout << ans;
}


Measured memory_bytes: 3688
#include <iostream>
using namespace std;
int main(){
	int pj,pm,pe;
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		for(int i=1;i<=n; i++){
			cin>>pm>>pe>>pj;
			if(pm==100||pj==100||pe==100){
				cout<<"A"<<endl;
			}else if((pm+pe)/2>=90){
				cout<<"A"<<endl;
			}else if((pm+pe+pj)/3>=80){
				cout<<"A"<<endl;
			}else if((pm+pe+pj)/3>=70){
				cout<<"B"<<endl;
			}else if((pm+pe+pj)/3>=50&&pe>=80){
				cout<<"B"<<endl;

			}else if((pm+pe+pj)/3>=50&&pm>=80){
				cout<<"B"<<endl;
			}else{
				cout<<"C"<<endl;
			}
		}
	} 
}

Measured memory_bytes: 1152
#include <cstdio>

int main(void) {
  int A, B, T, result = 0;
  
  scanf("%d %d %d", &A, &B, &T);
  for (int i = A; i < T + 0.5; i += A) {
    result += B;
  }

  printf("%d\n", result);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string s;
  cin >> N;
  cin >> s;
  int E = 0;
  int W = 0;
  for(char c : s){
    E += c == 'E';
  }
  int ans = N;
  for(char c : s){
    if(c == 'E'){
      E--;
    }
    ans = min(ans,E + W);
    if(c == 'W'){
      W++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#define ll long long
#define FASTIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mo 1000000007
using namespace std;
int main(){
	FASTIO
	ll n,m;
	cin>>n>>m;
	priority_queue<ll> pq;
	ll k;
	for(ll i=0;i<n;i++){
		cin>>k;
		pq.push(k);
	}
	while(m--){
		pq.push(pq.top()/2);
		pq.pop();
	}
	ll ans = 0;
	while(!pq.empty()){
		ans+=pq.top();
		pq.pop();
	}
	cout<<ans<<'\n';
	return 0;
}


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

int solve(string expr, int p, int q, int r) {
    int k = 0;
    function<int(void)> calc = [&]() {
        if (isdigit(expr[k])) return expr[k++] - '0';
        if (expr[k] == '-') { k++; return 2 - calc(); }
        if (expr[k] == '(') {
            k++;
            int x = calc();
            bool plus = expr[k++] == '+';
            int y = calc();
            k++;
            return plus ? max(x, y) : min(x, y);
        }
        return -1;
    };
    for (auto& e : expr) {
        switch (e) {
            case 'P': e = p + '0'; break;
            case 'Q': e = q + '0'; break;
            case 'R': e = r + '0'; break;
        }
    }
    return calc() == 2;
}

int main() {
    for (string expr; cin >> expr, expr != ".";) {
        int cnt = 0;
        rep(p, 3) rep(q, 3) rep(r, 3) if (solve(expr, p, q, r)) cnt++;
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3120
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            String tmp = sc.next();
            if (list.contains(tmp)) {
                System.out.println("No");
                return;
            } else {
                list.add(tmp);
            }
        }
        for (int i = 1; i < n; i ++) {
            char end = list.get(i - 1).charAt(list.get(i - 1).length() - 1);
            if (list.get(i).charAt(0) != end) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 23252
#ifdef __GNUC__
#include <bits/stdc++.h>
#else
#include "bits/stdc++.h"
#define scanf scanf_s
#endif
#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define WHL(i) while(i)
#define putn printf("\n")
#define all(container) container.begin(), container.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

template<class T> istream& operator >> (istream &is, vector<T> &vec) {
	for (T &x : vec)is >> x;
	return is;
}

int main() {

	string S, T;

	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> S >> T;

	auto rep = S.size();

	REP(i, rep) {
		if (S == T) { printf("Yes"); return 0; }
		auto s = S.substr(1) + S[0];
		S = s;
	}
	printf("No");
}



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

string a,b,c;
int n,m; 

int main()
{
	cin>>a;
	cin>>b;
	cin>>n>>m;
	cin>>c;
	if(c==a)
		cout<<n-1<<' '<<m<<endl;
	else
		cout<<n<<' '<<m-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<=(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  ll a,b;

  cin >> a >> b;


  if((a+b)%2 == 1){ 
      cout << "IMPOSSIBLE" << endl;
  }
  else{
      cout << (ll)(a+b)/2 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    CSF = [list(map(int, input().split())) for _ in range(n - 1)]

    for i in range(n):
        if i == n - 1:
            print(0)
            break
        c, s, f = CSF[i]
        now = s + c
        for j in range(i + 1, n - 1):
            c, s, f = CSF[j]
            if now >= s:
                diff = now - s
                if diff % f == 0:
                    now += c
                else:
                    now += f - diff % f + c
            else:
                now = s + c
        print(now)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9112
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    int n = Integer.parseInt(br.readLine());
    String s = br.readLine();
    int nRight = 0;
    int nLeft = 0;
    Stack<Boolean> stk = new Stack<Boolean>();
    for (int i=0; i<n; i++) {
      boolean next = s.charAt(i)==')';
      if (stk.isEmpty()) {
        stk.push(next);
      } else if (next && stk.peek()==false) {
        stk.pop();
      } else {
        stk.push(next);
      }
    }
    while (!stk.isEmpty()) {
      boolean b = stk.pop();
      if (b) {
        nRight++;
      } else {
        nLeft++;
      }
    }
    for (int i=0; i<nRight; i++) {
      sb.append('(');
    }
    sb.append(s);
    for (int i=0; i<nLeft; i++) {
      sb.append(')');
    }
    System.out.println(sb);
  }
}


Measured memory_bytes: 21332
<?php
  $n = trim(fgets(STDIN));
  $z = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  $ary = array($z, $z, $z);
  $ary = array($ary, $ary, $ary, $ary);
  for ($i = 1; $i <= $n; $i++) {
    list($b, $f, $r, $v) = explode(" ", trim(fgets(STDIN)));
    $ary[$b-1][$f-1][$r-1] = ($ary[$b-1][$f-1][$r-1] + $v);
  }
  $x = 1;
  foreach ($ary as $val) {
    $i = 1;
    foreach ($val as $v) {
      print (" " . implode(" ", $v));
      if (($x > 3) && ($i > 2)) {
        print "\n";
        return;
      } else {
        print "\n";
      }
      $i++;
    }
    if ($x < 4) {
      print (str_repeat("#", 20) . "\n");
    }
    $x++;
  }
?>

Measured memory_bytes: 6648