akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

vector<ll> v;
ll n, k;

void solve(ll i, ll res)
{
    if (i == n)
    {
        v.push_back(res);
        return;
    }

    solve(i + 1, res * 2);
    solve(i + 1, res + k);
}

int main(int argc, char const *argv[])
{
    cin >> n >> k;
    solve(0, 1);
    cout << *min_element(v.begin(), v.end())<< endl;
}


Measured memory_bytes: 256
import math

N=int(input())
X=[]
Y=[]
for n in range(N):
    x,y=map(int,input().strip().split())
    X.append(x)
    Y.append(y)

def f(n):
    if n==2:
        return [[1,2],[2,1]]
    else:
        new=[]
        l=f(n-1)
        for e in l:
            base=tuple(e)
            for m in range(len(e)+1):
                e=list(base)
                e.insert(m,n)
                new.append(e)
    return new

l=f(N)
a=[]
for e in l:
    total=0
    for n in range(len(e)-1):
        d=math.sqrt((X[e[n]-1]-X[e[n+1]-1])**2+(Y[e[n]-1]-Y[e[n+1]-1])**2)
        total+=d
    a.append(total)
ave=sum(a)/len(a)

print(ave)

Measured memory_bytes: 10996
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())

    for i in reversed(range(1, int(n ** 0.5) + 1)):
        if n % i == 0:
            j = n // i
            print(i + n // i - 2)
            exit()


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 40044
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main(){
int w,a,b;
cin >> w>> a>>b;
if(b+w>=a&&b<=a+w) cout << 0<<endl;
else cout << min(abs(b+w-a),abs(b-a-w))<<endl;
}


Measured memory_bytes: 256
import bisect
pr=[]
for i in range(2,110000):
    for j in range(2,int(i**0.5)+1):
        if not i%j:break
    else:pr+=[i]
while 1:
    n,p=map(int,input().split())
    if n<0:break
    n=bisect.bisect_right(pr,n)
    print(sorted([pr[i]+pr[j] for i in range(n,n+p) for j in range(i,n+p)])[p-1])

Measured memory_bytes: 8404
A, B = map(int, input().split())
n = 2
answer = ((B+1)//2-A//2)%2
A -= 1
while n <= B:
  cnt_b = 0
  if (B//n)%2 != 0:
    cnt_b += B%n
  cnt_b += B//n
  cnt_a = 0
  if (A//n)%2 != 0:
    cnt_a += A%n
  cnt_a += A//n
  if (cnt_b-cnt_a)%2 != 0:
    answer += n
  n *= 2
print(answer)
  


Measured memory_bytes: 61772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int MAX_N=1005;
const int MAX_X=5005;
int x[MAX_N],y[MAX_N];
vector<int> g[MAX_N];


int dfs(int v){
    bitset<MAX_X> dp;
    dp[0]=1;
    int sum=0;
    for(auto e:g[v]){
        y[e]=dfs(e);
        dp=((dp<<x[e]|dp<<y[e]));
        sum+=x[e]+y[e];
    }
    int ans=-1;
    for(int i=x[v];i>=0;--i){
        if(dp[i]){
            ans=i;break;
        }
    }
    if(ans==-1){
        cout<<"IMPOSSIBLE"<<endl;
        exit(0);
    }
    return sum-ans;
}

int main(){
  int n;cin>>n;
  rep(i,n-1){
      int p;cin>>p;
      --p;
      g[p].push_back(i+1);
  }
  rep(i,n){
      cin>>x[i];
  }
  dfs(0);
  cout<<"POSSIBLE"<<endl;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  if (a > 8 || b > 8) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
     Scanner sc = new Scanner(System.in);
     int n = 0;
     if(sc.hasNextInt())
            n = sc.nextInt();
        int[] dp = new int[n];
     for(int i = 0 ; i < n ; i++)
     {
         dp[i] = sc.nextInt();
     }
     int[] x = new int[n];
     Arrays.fill(x,Integer.MAX_VALUE);
     x[0] = 0;
     for(int i = 0 ; i < n ; i++)
     {
         for(int j = i+1 ; j < i+3 ; j++)
         {
             if(j < n)
             {
                 x[j] = Math.min(x[j] , x[i]+Math.abs(dp[i]- dp[j]));
             }
         }
     }
     System.out.println(x[n-1]);


    }
}


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

typedef long long ll;

int n;
ll c;
ll x[100050], v[100050];
ll rsum[100050],lsum[100050];
ll r2sum[100050], l2sum[100050];

int main() {
    cin >> n >> c;
    r2sum[0] = rsum[0] = l2sum[n+1] = lsum[n+1] = 0;
    ll res = 0;
    for(int i = 1; i <= n; i++) cin >> x[i] >> v[i];
    for(int i = 1; i <= n; i++){
        rsum[i] = rsum[i-1] + v[i];
    }
    for(int i = 1; i <= n; i++){
        rsum[i] -= x[i];
        r2sum[i] = max(r2sum[i-1], rsum[i]-x[i]);
        res = max(res, rsum[i]);
    }
    for(int i = 1; i <= n; i++){
        x[i] = c - x[i];
    }
    for(int i = n; i >= 1; i--){
        lsum[i] = lsum[i+1] + v[i];
    }

    for(int i = n; i >= 1; i--){
        lsum[i] -= x[i];
        l2sum[i] = max(l2sum[i+1], lsum[i] - x[i]);
    }
    for(int i = 1; i <= n; i++){
        res = max(res, lsum[i] + r2sum[i-1]);
        res = max(res, rsum[i] + l2sum[i+1]);
    }
    cout << res;



    return 0;
}

Measured memory_bytes: 4992
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;
vi alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };





int main() {
    int H, W;
    cin >> H >> W;
    vvi c(10, vi(10));
    rep(i, 10) {
        rep(j, 10) cin >> c[i][j];
    }
    vi counter(10,0);
    rep(i, H* W) {
        int x;
        cin >> x;
        rep(j, 10) {
            if (x == j)counter[j]++;
        }
    }

    vi per(10);
    rep(i, 10) per[i] = i;
    vi kouho(10,200000);
    do {
        int x = per[0];
        int sum = 0;
        int mae;
        int ima = x;
        int i = 0;
        while (ima != 1) {
            mae = ima;
            ima = per[i];
            i++;
            sum += c[mae][ima];
        }
        if (sum < kouho[x]) kouho[x] = sum;
    } while (next_permutation(per.begin(), per.end()));
    

    ll ans = 0;
    rep(i, 10) {
        ans += kouho[i] * counter[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

sys.setrecursionlimit(10000)

N, K, L = (int(i) for i in input().split())

import collections
import itertools
import operator

class UnionFind:
    def __init__(self, elems=None):
        class KeyDict(dict):
            def __missing__(self, key):
                self[key] = key
                return key

        self.parent = KeyDict()
        self.rank = collections.defaultdict(int)

        if elems is not None:
            for elem in elems:
                _, _ = self.parent[elem], self.rank[elem]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def are_same(self, x, y):
        return self.find(x) == self.find(y)

    def grouper(self):
        roots = [(x, self.find(x_par)) for x, x_par in self.parent.items()]
        root = operator.itemgetter(1)
        for _, group in itertools.groupby(sorted(roots, key=root), root):
            yield [x for x, _ in group]

ufk = UnionFind()
for i in range(K):
    a, b = (int(i) for i in input().split())
    ufk.unite(a, b)

ufl = UnionFind()
for i in range(L):
    a, b = (int(i) for i in input().split())
    ufl.unite(a, b)

L = []
for i in range(1,N+1):
    L.append( (ufk.find(i), ufl.find(i), i) )

def countList(L, ma = None):#maは要素の個数の最大値
    if ma == None:
        ma = len(L)
    L.sort() #すでにしているなら不要
    temp = (None, None, None)
    cc = 1
    reslis = [0] * (N+1)
    v = [L[0][2]]
    for se in L:
        if temp[0] == se[0] and temp[1] == se[1]:
            cc += 1
            v.append(se[2])
        else:
            if temp[0] == None:
                pass
            else:
                for aa in v:
                    reslis[aa] = cc
                v = [se[2]]
                cc = 1
            temp = se
    for aa in v:
        reslis[aa] = cc
    return reslis

reslis = countList(L, N)
reslis = reslis[1:]
reslis = [str(i) for i in reslis]
print(" ".join(reslis))

Measured memory_bytes: 76988
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N=1e6+5;

int32_t main()
{
    IOS;
    int n, m;
    cin>>n>>m;
    if(n==1)
    {
    	if(m==1)
    	{
    		cout<<"1";
    	}
    	else
    	{
    		cout<<m-2;
    	}
    	return 0;
    }
    else if(m==1)
    {
    	cout<<n-2;
    	return 0;
    }
   	int ans=(n-2)*(m-2);
   	cout<<ans;
    return 0;
} 

Measured memory_bytes: 256
//#include "pch.h"
//#include "stdafx.h"
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define MIN(a, b)		((a) < (b) ? a : b)
#define MAX(a, b)		((a) > (b) ? a : b)
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)		/* 奇数 */
#define IsEven(x)		(!IsOdd((x)))					/* 偶数 */
#define ArrayLength(x)	(sizeof(x) / sizeof(x[0]))
#define DWORD_MAX		(0xFFFFFFFF)

typedef short SWORD;
typedef unsigned short WORD;
typedef long SDWORD;
typedef unsigned long DWORD;
typedef long long int QWORD;
typedef pair<int, int> P;

#define N_MAX	(100000)
#define M_MAX	(1000)
#define H_MAX	(1000)
#define W_MAX	(1000)

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	int A, B;
	cin >> A >> B;
	if (A <= 5) {
		cout << 0;
	} else if (A <= 12) {
		cout << B / 2;
	} else {
		cout << B;
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100000

int A[MAX];

int main(){

  int i, j, k, n, x, p, r, tmp;

  scanf("%d", &n);

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

    scanf("%d", &A[i]);

  }

  p = 0;

  r = n - 1;

  x = A[r];

  i = p - 1;
  
  for(j = p; j <= r - 1; j++){

    if(A[j] <= x){

      i++;

      tmp = A[i];

      A[i] = A[j];

      A[j] = tmp;

    }

  }

  tmp = A[i + 1];

  A[i + 1] = A[r];

  A[r] = tmp;

  for(k = 0; k < (i + 1); k++){

    printf("%d ", A[k]);

  }

  printf("[%d] ", A[i + 1]);

  for(k = (i + 2); k < (n - 1); k++){

    printf("%d ", A[k]);

  }

  printf("%d\n", A[k]);

  return 0;

}

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

using namespace std;

#define ll long long




void solve() {

	string s;
	cin >> s;
	int mx = 0, cnt = 0;
	for(int i = 0; i < s.length(); i++) {
		if(s[i] == 'R') {
			cnt++;
		}
		else {
			mx = max(mx, cnt);
			cnt = 0;
		}
	}
	mx = max(mx, cnt);
	cout << mx;

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>
#define ll long long
ll absolute(ll a){
    if(a>0) return a;
    return -a;
}
int main(){
    int n,ans;
    scanf("%d",&n);
    ll h[n];
    int p=1;
    for(int i=0;i<n;i++)
        scanf("%lld",&h[i]);
    for(int i=1;i<n;i++){
        if(h[i-1]<=h[i]-1)
            h[i]-=1;
        else if(h[i-1]==h[i]){
            ans++;
        }
        else
            p=0;
    }
    if(p)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 896
//Nayeem Shahriar Joy ,Applied Physics And Electronic Engineering , University of Rajshahi.

  #include <iostream>
  #include <cstdio>
  #include <algorithm>
  #include <cstring>

  #define MAX 105000

  using namespace std;

  int main()

  {
      int n;

      while(cin>>n)

      {
          cout<<((n*(n+1))/2)+1<<endl;
      }

      return 0;
  }

Measured memory_bytes: 2980
def simple_interest(r, y):
    return (100 + r * y) / 100
def compound_interest(r, y):
    return ((100 + r) / 100) ** y
import sys
import operator
f = sys.stdin

get_ganri = {1:simple_interest,2:compound_interest}
while True:
    n = int(f.readline())
    if n == 0:
        break
    y = int(f.readline())
    brt = [list(map(int, f.readline().split())) for _ in range(n)]
    b_ganri = [(b, get_ganri[t](r, y)) for b, r, t in brt]
    print(max(b_ganri, key=operator.itemgetter(1))[0])
    

Measured memory_bytes: 6816
import sys
import  math
from statistics import *
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

x, y, z = na()
if x - (x//(y+z)) * (y+z) >= z:
    print(x//(y+z))
else:
    print(x//(y+z)-1)

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m,pp,wa=0,ac=0;
  string ss;
  cin >> n >> m;
  vector<long int> p(n+1);
  vector<long int> s(n+1);
  for (int i = 0; i < m; i++) {
    cin >> pp >> ss;
    if(s[pp]==0){
      if(ss=="WA"){
        p[pp]++;
      }else{
        ac++;
        s[pp]=1;
        wa+=p[pp];
      }
    }
  }
  cout << ac << " " << wa << endl;
}

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

const LL Mod = 1000000007;
const LL Maxn = 200010;
const LL AlphaSize = 2001;
LL N, A[ Maxn ], B[ Maxn ], Fact[ AlphaSize + 10 << 2 ], INV[ AlphaSize + 10 << 2 ];
LL F[ AlphaSize + 10 << 1 ][ AlphaSize + 10 << 1 ];

void Exgcd( LL a, LL b, LL &x, LL &y ) {
    if( b == 0 ) {
        x = 1; y = 0;
        return;
    }
    Exgcd( b, a % b, y, x );
    y -= a / b * x;
    return;
}

LL Inv( LL a ) {
    LL x, y;
    Exgcd( a, Mod, x, y );
    if( x < 0 ) x += Mod;
    return x;
}

LL C( LL n, LL m ) {
    return Fact[ m ] * INV[ n ] % Mod * INV[ m - n ] % Mod;
}

int main() {
    Fact[ 0 ] = 1;
    for( LL i = 1; i <= AlphaSize << 2; ++i ) Fact[ i ] = Fact[ i - 1 ] * i % Mod;
    INV[ AlphaSize << 2 ] = Inv( Fact[ AlphaSize << 2 ] );
    for( LL i = ( AlphaSize << 2 ) - 1; i >= 0; --i ) INV[ i ] = INV[ i + 1 ] * ( i + 1 ) % Mod;
    scanf( "%lld", &N );
    for( LL i = 1; i <= N; ++i ) scanf( "%lld%lld", &A[ i ], &B[ i ] );
    for( LL i = 1; i <= N; ++i ) ++F[ AlphaSize - A[ i ] ][ AlphaSize - B[ i ] ];
    for( LL i = 1; i <= AlphaSize << 1; ++i )
        for( LL j = 1; j <= AlphaSize << 1; ++j )
            F[ i ][ j ] = ( F[ i ][ j ] + F[ i - 1 ][ j ] + F[ i ][ j - 1 ] ) % Mod;
    LL Ans = 0;
    for( LL i = 1; i <= N; ++i ) Ans = ( Ans + F[ AlphaSize + A[ i ] ][ AlphaSize + B[ i ] ] ) % Mod;
    for( LL i = 1; i <= N; ++i ) Ans = ( ( Ans - C( A[ i ] * 2, A[ i ] * 2 + B[ i ] * 2 ) ) % Mod + Mod ) % Mod;
    printf( "%lld\n", Ans * Inv( 2 ) % Mod );
    return 0;
}

Measured memory_bytes: 129792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;

    int main(){
      int n,a,b;
      cin >> n >> a >> b;
      int ans=0;
      if(a+b>=n)ans=a+b-n;
      cout << min(a,b) << ' ' << ans << endl;
      return 0;}

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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

struct edge {
    int u, v;
    long long x;
    edge() = default;
    edge(int u, int v, int x) : u(u), v(v), x(x) { }
};

struct num {
    long long a, x;
    num() = default;
    num(long long a, long long x) : a(a), x(x) { }

    num operator+(const num& rhs) {
        return num(a + rhs.a, x + rhs.x);
    }

    num operator-(const num& rhs) {
        return num(a - rhs.a, x - rhs.x);
    }
};

int n, m;
long long AWW = -1;
vector<edge> g[N];
bool used[N];
num f[N];

bool read() {
    if (!(cin >> n >> m))
        return false;

    for (int i = 0; i < m; ++i) {
        int u, v, x;
        cin >> u >> v >> x;
        g[u - 1].emplace_back(u - 1, v - 1, x);
        g[v - 1].emplace_back(v - 1, u - 1, x);
    }

    return true;
}

void dfs(int v, num cur) {
    used[v] = true;
    f[v] = cur;

    for (auto to : g[v])
        if (!used[to.v]) {
            dfs(to.v, num(to.x, 0) - f[v]);
        } else {
            num sum = f[to.v] + f[v];

            if (sum.x == 0) {
                if (sum.a != to.x) {
                    cout << 0 << endl;
                    exit(0);
                }
            } else {
                if ((to.x - sum.a) % sum.x != 0 || (to.x - sum.a) / sum.x <= 0) {
                    cout << 0 << endl;
                    exit(0);
                }

                if (AWW != -1 && AWW != (to.x - sum.a) / sum.x) {
                    cout << 0 << endl;
                    exit(0);
                }

                AWW = (to.x - sum.a) / sum.x;
            }
        }
}

void solve() {
    num kek(0ll, 1ll);
    long long L = 1ll;
    long long R = 1ll * MOD * MOD;
    dfs(0, kek);

    for (int i = 0; i < n; ++i) {
        if (f[i].a >= 0) {
            if (f[i].x < 0)
                R = min(R, (f[i].a - 1) / (-f[i].x));
        } else {
            if (f[i].x > 0) {
                L = max(L, (1 - f[i].a + f[i].x - 1) / f[i].x);
            } else {
                cout << 0 << endl;
                exit(0);
            }
        }
    }

    if (AWW != -1 && (AWW < L || AWW > R)) {
        cout << 0 << endl;
        exit(0);
    }

    if (AWW != -1)
        cout << 1 << endl;
    else
        cout << max(0ll, R - L + 1) << endl;
}

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

    while (read())
        solve();

    return 0;
}



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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int ab = a + b;
  int cd = c + d;
  if (ab > cd) {
    cout << "Left" << endl;
  } else if (ab < cd) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
//bool scan(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
//vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

typedef vector<int> vi;

int main() {
	for (int a, b; a = in(), b = in(), a || b;) {
		vector<vi> m(b + 1, vi(a + 1));
		for (int n = in(); n--;) {
			int x = in(), y = in();
			m[y][x] = -1;
		}
		m[1][1] = 1;
		for (int i = 1; i <= b; i++)
			for (int j = 1; j <= a; j++) {
				if (m[i][j] == -1)
					continue;
				if (m[i - 1][j] != -1)
					m[i][j] += m[i - 1][j];
				if (m[i][j - 1] != -1)
					m[i][j] += m[i][j - 1];
			}
		out(m[b][a], '\n');
	}
}


Measured memory_bytes: 2456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
	int a;
	map<int,int>m;
	for(int i=0;i<3;i++)
	{
		cin>>a;
		m[a]++;
	}
	if(m[5]==2&&m[7]==1)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(A, N, B):
    flgs = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
    for b in B:
        for i in range(3):
            for j in range(3):
                if b == A[i][j]:
                    flgs[i][j] = 1
    for i in range(3):
        if sum(flgs[i]) == 3:
            return "Yes"
    for j in range(3):
        if flgs[0][j] + flgs[1][j] + flgs[2][j] == 3:
            return "Yes"
    if flgs[0][0] + flgs[1][1] + flgs[2][2] == 3:
        return "Yes"
    if flgs[0][2] + flgs[1][1] + flgs[2][0] == 3:
        return "Yes"
    return "No"


if __name__ == "__main__":

    # A_{1, 1} A_{1, 2} A_{1, 3}
    # A_{2, 1} A_{2, 2} A_{2, 3}
    # A_{3, 1} A_{3, 2} A_{3, 3}
    # N
    # b_1
    # \vdots
    # b_N
    #
    A = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]

    ans = solv(A, N, B)

    print(ans)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(true){
        
        cin >> H >> W;
        
        if(H == 0 && W == 0) break;
        
        for(int i=0;i<H;i++){
            
            for(int j=0;j<W;j++){
                
                if(i%2 == 0){
                    if(j%2 == 0){
                        cout << '#';
                    }
                    else{
                        cout << '.';
                    }
                }
                else{
                    if(j%2 == 0){
                        cout << '.';
                    }
                    else{
                        cout << '#';
                    }
                }

            }
            
            cout << endl;
        }
        cout << endl;
    }

}


Measured memory_bytes: 3088
#include <iostream>
using namespace std;
const int LEN = 36 + 10;
struct Data {
    char c;
    int val;
} arr_Bubble[LEN], arr_Select[LEN];

void BubbleSort(Data A[], int n) {
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n - i; j++) {
            if (A[j].val > A[j + 1].val) {
                swap(A[j], A[j + 1]);
            }
        }
    }
}

void SelectSort(Data A[], int n) {
    for (int i = 1; i <= n; i++) {
        int minPos = i;
        for (int j = i + 1; j <= n; j++) {
            if (A[minPos].val > A[j].val) {
                minPos = j;
            }
        }
        if (minPos != i) {
            swap(A[i], A[minPos]);
        }
    }
}

void print(Data A[], int n) {
    for (int i = 1; i < n; i++) {
        cout << A[i].c << A[i].val << " ";
    }
    cout << A[n].c << A[n].val << endl;
}

void isStable(Data A[], Data B[], int n) {
    int flag = 1;
    for (int i = 1; i <= n; i++) {
        if (A[i].c != B[i].c) {
            flag = 0;
            break;
        }
    }
    if (flag) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr_Bubble[i].c >> arr_Bubble[i].val;
        arr_Select[i].c = arr_Bubble[i].c;
        arr_Select[i].val = arr_Bubble[i].val;
    }
    BubbleSort(arr_Bubble, n);
    print(arr_Bubble, n);
    cout << "Stable" << endl;
    SelectSort(arr_Select, n);
    print(arr_Select, n);
    isStable(arr_Bubble, arr_Select, n);
    return 0;
}


Measured memory_bytes: 3096
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 27;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

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

int main(){
	string s;
	while(getline(cin, s) && s != "."){
		stack<char> st;
		bool ok = true;
		for(int i = 0; i < (int)s.size(); i++){
			if(s[i] == '(') st.push(s[i]);
			if(s[i] == '[') st.push(s[i]);
			if(s[i] == ')'){
				if(st.empty() || st.top() != '('){
					ok = false;
				}else{
					st.pop();
				}
			}
			if(s[i] == ']'){
				if(st.empty() || st.top() != '['){
					ok = false;
				}else{
					st.pop();
				}
			}
		}
		if(ok && st.empty()) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

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

using namespace std;


int main()
{
  int N;

  cin >> N;
  bitset< 2000 * 2001 > bit(1);
  int sum = 0;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    sum += x;
    bit |= bit << x;
  }
  sum = (sum + 1) / 2;
  for(int i = sum;; i++) {
    if(bit[i]) {
      cout << i << endl;
      return (0);
    }
  }
}


Measured memory_bytes: 1664
#include<stdio.h>
int main(void){
  int num;
  int moti[100];
  int i,j;
  int kaburi = 0;
  
  if(scanf("%d\n",&num));
  for(i=0;i<num;i++){
    if(scanf("%d\n",&moti[i]));
  }
  
  for(i=0;i<num;i++){
    if(moti[i] == 0){
      continue;
    }
    for(j=i+1;j<num;j++){
      if(moti[i] == moti[j] && moti[j] != 0){
        kaburi += 1;
        moti[j] = 0;
      }
    }
  }  
   printf("%d",num - kaburi); 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front

typedef long long ll;

using namespace std;

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

int main(){
    int N;
    int A,B,C,D;
    cin>>N;
    A=N/1000;
    B=(N%1000)/100;
    C=(N%100)/10;
    D=(N%10);
    if(A+B+C+D == 7)cout<<A<<"+"<<B<<"+"<<C<<"+"<<D<<"=7";
    else if(A+B+C-D == 7)cout<<A<<"+"<<B<<"+"<<C<<"-"<<D<<"=7";
    else if(A+B-C+D == 7)cout<<A<<"+"<<B<<"-"<<C<<"+"<<D<<"=7";
    else if(A+B-C-D == 7)cout<<A<<"+"<<B<<"-"<<C<<"-"<<D<<"=7";
    else if(A-B+C+D == 7)cout<<A<<"-"<<B<<"+"<<C<<"+"<<D<<"=7";
    else if(A-B+C-D == 7)cout<<A<<"-"<<B<<"+"<<C<<"-"<<D<<"=7";
    else if(A-B-C+D == 7)cout<<A<<"-"<<B<<"-"<<C<<"+"<<D<<"=7";
    else if(A-B-C-D == 7)cout<<A<<"-"<<B<<"-"<<C<<"-"<<D<<"=7";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define elif else if
typedef long long ll;
typedef unsigned long long ull;
#define DEBUG(x) cout<<(x)<<endl
#define TGET(a,b) get<b>(a)

int main()
{
    int n;
    scanf("%d", &n);
    int flag = 0;
    while(n)
    {
        if(n%10==7)
        {
            flag = 1;
        }
        n /= 10;
    }
    if(flag)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    return 0;
}


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

int main()
{
	int M, D;
	scanf("%d%d", &M, &D);
	int count{};
	for (int i{1}; i <= M; i++)
		for (int j{11}; j <= D; j++)
		{
			int d1{j / 10}, d2{j % 10};
			if (d1 >= 2 && d2 >= 2 && i == d1 * d2)
				count++;
		}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
#include <math.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int L, R; cin >> L >> R;
  vector<int> num;
  int ans;
  if(R-L >= 2019) {
    ans = 0;
  }else {
    for(int i=0; i<=(R-L); i++){
      num.push_back((L % 2019) + i);
    }
    ans = 2020;
    for(int i=0; i<num.size(); i++){
      for(int j=i+1; j<num.size(); j++){
        ans = min(ans, num[i]*num[j]%2019);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
using namespace std;
ll L[90];
ll Lucas(ll n){
    if(L[n]!=0) return L[n];
    else{
        ll l = Lucas(n-1) + Lucas(n-2);
        L[n] = l;
        return l;
    }
}

int main() {
    ll N;
    cin >> N;
    L[0] = 2;
  	L[1] = 1;
    ll ans = Lucas(N);
    cout << ans << endl;
}

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

int main() {
    int64_t X;
    cin >> X;

    int64_t min_value = X / 100 * 100;
    int64_t max_value = X / 100 * 105;
    cout << (min_value <= X && X <= max_value) << endl;
}

Measured memory_bytes: 256
n = int(input())
X = list(map(int, input().split()))
X_sort = sorted(X)

mid_1 = X_sort[int(n/2) -1]
mid_2 = X_sort[int(n/2)]

for x in X:
    if x <= mid_1:
        print(mid_2)
    else:
        print(mid_1)



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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
/*ll get(ll *arr,ll low,ll high,ll n){
	int mid=low+(high-low)/2;
	if((mid==0 or arr[mid-1]<=arr[mid]) and (mid==(n-1) or arr[mid+1]<=arr[mid])){
		return arr[mid];
	}
	else if(mid>0 and arr[mid-1]>arr[mid]){
		return get(arr,low,mid-1,n);
	}
	else{
		return get(arr,mid+1,high,n);
	}
}*/
/*ll get(int *arr,int n,int left,int i){
	if(i==n){return 1;}
	int curr=arr[i];
	int right=get(arr,n,arr[i]*left,i+1);
	arr[i]=left*right;
	return curr*right;
}*/
void solve(){
	ll n,x,t;cin>>n>>x>>t;
	ll a=0;
	if(n%x==0){a=n/x;}
	else if(n>x){a=n/x+1;}
	else{a=1;}
	cout<<a*t;
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case #"<<k<<": ";
		solve();
		//e;
	}
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n;
  cin >> n;
  ll a = 0;
  ll b = 0;
  ll c = 0;
  ll d = 0;
  rep(i,n) {
    string s;
    cin >> s;
    if (s == "AC") ++a;
    if (s == "WA") ++b;
    if (s == "TLE") ++ c;
    if (s == "RE") ++d;
  }
  cout << "AC x " << a << '\n';
  cout << "WA x " << b << '\n';
  cout << "TLE x " << c << '\n';
  cout << "RE x " << d << '\n';
}

Measured memory_bytes: 3656
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;
const int maxn = 2000100;

int main(){
        _
        int n; cin >> n;
        string ans; cin >> ans;
        string s;
        for(int i = 0; i<n-1; i++){
            cin >> s;
            string temp;
            vector<bool>vis(s.size(),false);

            for(char ch : ans){
                    for(int j = 0; j<s.size();j++){
                        if(vis[j])continue;
                        if(ch==s[j]){
                            temp+=s[j];
                            vis[j]=true;
                            break;
                        }
                    }
            }
            ans = temp;
        }

        sort(all(ans));
        cout<<ans<<endl;


return 0;
}



Measured memory_bytes: 256
/*
AizuOnline A1167
Title Pollock's conjecture
@kankichi573
*/
#include <stdio.h>
#include <limits.h>
#define UPPER 181
int n;
int tetrah[UPPER+1];
int ans_table[1000000];
int ans_table_odd[1000000];
//
int find_odd(int x)
{
        int ret=find(x);
        if((ret % 4)==1)
                return(ret);
        else if((ret % 4)==0)
                return(ret-3);
        else if((ret % 4)==2) 
                return(ret-1);
        else
                return(ret-2);
}
int find_(int x,int l,int u)
{
        int c;

        if(x>=tetrah[l] && x<tetrah[l+1])
                return(l);
        if(x>=tetrah[u-1] && x<tetrah[u])
                return(u-1);
        c=(l+u)/2;
        if(x>=tetrah[c] && x<tetrah[c+1])
                return(c);
        if(x>=tetrah[c+1])
                return(find_(x,c+1,u));
        if(x<tetrah[c])
                return(find_(x,l,c-1));

}
int find(int x)
{
        return(find_(x,1,UPPER));
}

void init()
{
        int i;
        for(i=1;i<=UPPER;i++)
                tetrah[i]=i*(i+1)*(i+2)/6;

}

int solve_odd(int x)
{
        int i,min_,ret,v;

        if(ret=ans_table_odd[x])
                return(ret);
        if(x<tetrah[5])
                return(x);
        
        min_=INT_MAX;
        for(i=find_odd(x);i>=1;i -= 4)
        {
                v=x - i*(i+1)*(i+2)/6;
                if(v==0)
                        return(1);
                ret=solve_odd(v);
                if(ret < min_)
                        min_ = ret;
        }
        ans_table_odd[x]=min_+1;
        return(min_+1);
}

int solve(int x)
{
        int i,min_,v,f,ret;
        
        //printf("SV=%d\n",x);
        if(ret=ans_table[x])
                return(ret);

        if(x<tetrah[2])
                return(x);

        min_=INT_MAX;

        f=find(x);
        //printf("F=%d %d",f,f*(f+1)*(f+2)/6);
        for(i=f;i>=2;i--)
        {
                v=x - i*(i+1)*(i+2)/6;
                if(v==0)
                        return(1);
                ret=solve(v);
                if(ret < min_)
                        min_ = ret;
        }
        ans_table[x]=min_+1;
        return(min_+1);
}
main()
{
        int i;

        init();

        for(i=0;i<1000000;i++)
        {
                solve(i);
                solve_odd(i);
        }
        while(EOF!=scanf("%d",&n) && n)
        {
                // printf("%d \n",solve(n));
                printf("%d %d\n",solve(n),solve_odd(n));
        }
        return(0);
}

Measured memory_bytes: 8412
N = int(input())

count = 0
for _ in range(N):
  D = map(int, input().split())
  D = list(D)
  if D[0] == D[1]:
    count += 1
    if count >= 3:
      print('Yes')
      break
    continue
  count = 0
else:
  print('No')

Measured memory_bytes: 9176
li = []
flag = True
for i in range(3):
    c = list(map(int,input().split()))
    li.append(c)
sum = li[0][0] + li[1][1] + li[2][2]
for i in range(3):
    for j in range(3):
        if li[i][j] != sum - li[(i+1)%3][(j+1)%3] - li[(i+2)%3][(j+2)%3]:
            flag = False
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main() {
	int N, K, X, Y; cin >> N >> K >> X >> Y;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (i < K) ans += X;
		else ans += Y;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
MOD = 10**9 + 7
N = int(input().strip())
x = [int(_) for _ in input().split()]
#print(x)

count = 1
mult = 1
G = 0
for i, pos in enumerate(x):
  #print(i,pos,count,G,mult)
  count = (count * mult) % MOD
  G += 1
  if 2 * G > pos + 1:
    G -= 1
  else:
    mult += 1
print(count)

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


int main(){

    string x;
    cin>>x;

    int n=0;
    int s=0;
    int e=0;
    int w=0;

    for(int i=0;i<x.size();i++){
        if(x[i]=='N')n++;
        else if(x[i]=='S')s++;
        else if(x[i]=='E')e++;
        else if(x[i]=='W')w++;
    }


    // cout<<n<<" "<<s<<" "<<e<<" "<<w<<endl;

    int ns=n+s;
    int ew=e+w;
    bool hori=false;
    bool vert=false;

    if(n>=1&&s>=1){
        vert=true;
    }

    if(e>=1&&w>=1){
        hori=true;
    }
    // if(abs(n-s)==0&&abs(w-e)==0){
    //     cout<<"Yes"<<endl;
    // }else{
    //     cout<<"No"<<endl;
    // }

    // cout<<vert<<" "<<hori<<endl;

    if((vert&&hori)||(vert&&ew==0)||(hori&&ns==0)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}


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

int main(){
    int a[300000];
    int b[300000];
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int left=150000, right=150001;
    for(int i=0;i<n;i++){
        if(i%2!=n%2){
            b[left]=a[i];
            left--;
        }else{
            b[right]=a[i];
            right++;
        }
    }
    cout<<b[++left];
    for(int i=1;i<n;i++){
        cout<<" "<<b[left+i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <string.h>

int d[300000];

int main(void)
{
    int N;
    int i;
    int flag_out;
    int flag_in;
    int max;

    scanf("%d", &N);
    
    for (i = 0; i < N; i++){
        scanf("%d", &d[i]);
        d[i] /= 10;
    }

    max = 0;
    flag_out = 1;
    for (i = 0; i < N; i++){
        if (i > max){
            flag_out = 0;
            break;
        }
        if (max < i + d[i]){
            max = i + d[i];
        }
    }

    max = 0;
    flag_in = 1;
    for (i = 0; i < N; i++){
        if (i > max){
            flag_in = 0;
            break;
        }
        if (max < i + d[N - i - 1]){
            max = i + d[N - i - 1];
        }
    }
//printf("out:%d in:%d\n", flag_out, flag_in);
    if (flag_out * flag_in == 1){
        printf("yes\n");
    }
    else {
        printf("no\n");
    }

    return (0);
}



Measured memory_bytes: 2892
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll a[20][20],dp[1<<16];
ll sum[1<<16];

ll rec(int mask){
    if(dp[mask]!=longinf)return dp[mask];
    if(mask==0)return 0;
    int x=17;
    while(((1<<x)&mask)==0)--x;
    mask^=(1<<x);
    ll ret=-longinf;
    for(int i=mask;i>=0;--i){
        i&=mask;
        ret=max(ret,sum[(1<<x)+i]+rec(mask-i));
    }
    return dp[mask^(1<<x)]=ret;
}
int main(){
    int n;
    cin>>n;
    rep(i,n)rep(j,n)cin>>a[i][j];
    int mask=1<<n;
    rep(i,mask)rep(j,n)rep(k,j){
        if(i&(1<<j)&&i&(1<<k))sum[i]+=a[j][k];
    }

    rep(i,mask)dp[i]=longinf;
    cout<<rec(mask-1)<<endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1LL << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int dp[105][4][2];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	int K;
	cin >> s >> K;
	int n = s.size();
	dp[0][0][0] = 1;
	rep(i, n)rep(j, 4)rep(k, 2) {
		int d = s[i] - '0';
		rep(a, 10) {
			int ni = i + 1, nj = j, nk = k;
			if (a != 0) nj++;
			if (nj > K) continue;
			if (nk == 0) {
				if (d > a) nk = 1;
				if (d < a) continue;
			}
			dp[ni][nj][nk] += dp[i][j][k];
		}
	}
	cout << dp[n][K][0] + dp[n][K][1] << endl;
	return 0;
}

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

#define ll long long
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define gg return 0;
#define pii pair < int, int>

using namespace std;

const int maxn = (int)1e5 + 7;
const int INF = (int)1e9;

ll a,b[4],c,d,cnt,e[(int)2e3 + 1][(int)2e3 + 1],cost[maxn],tout[maxn],mn = INF,mx = -INF,l,r;

string s[101];

int main()
{
	cin >> a >> c;
	for(int i = 1; i <= a; ++i){
		cin >> s[i];
	}
	sort(s + 1, s + 1 + a);
	for(int i = 1; i <= a; ++i){
		cout << s[i];
	}
	gg;
}


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

int main(){
  int n;
  double x[100], y[100];
  double dist1=0;
  double dist2=0;
  double dist3=0;
  double dist_inf=0;

  cin >> n;
  cout << fixed << setprecision(8);

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

  for(int i=0; i<n; i++){
    dist1 += abs(y[i] - x[i]);
  }
  cout << dist1 << endl;

  for(int i=0; i<n; i++){
    dist2 += pow(abs(y[i] - x[i]), 2.0);
  }
  dist2 = pow(dist2, 1/2.0);
  cout << dist2 << endl;


  for(int i=0; i<n; i++){
    dist3 += pow(abs(y[i] - x[i]), 3.0);
  }
  dist3 = pow(dist3, 1.0/3);
  cout << dist3 << endl;

  for(int i=0; i<n; i++){
    if(abs(y[i] - x[i])>dist_inf){
      dist_inf = abs(y[i] - x[i]);
    }
  }
  cout << dist_inf << endl;
}


Measured memory_bytes: 3448
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;

int main(){
	int N;
	cin >> N;
	vector<string>	ss(N+1);
	vint p(N+1), used(N+1, 0), ans;
	for(int i = 1;i <= N;i++){
		cin >> ss[i] >> p[i];
	}
	while(true){
		string s = "zzzzzzzzzzz";
		for(int j = 1;j <= N;j++){
			if(used[j] == 0){
				if(s.compare(ss[j]) > 0)	s = ss[j];
			}
		}
		vint vv;
		for(int j = 1;j <= N;j++){
			if(used[j] == 0 && s.compare(ss[j]) == 0){
				vv.push_back(j);
				used[j] = 1;
			}
		}
		vector<P> vp;
		for(int k = 0;k < vv.size();k++)	vp.emplace_back(p[vv[k]], vv[k]);
		sort(vp.rbegin(),vp.rend());
		for(int k = 0;k < vp.size();k++){
			ans.push_back(vp[k].second);
		}	
		int cnt = 0;
		for(int j = 1;j <= N;j++){
			if(used[j] == 1)	cnt++;
		}
		if(cnt == N)	break;
	}
	for(int i = 0;i < N;i++)	cout << ans[i] << endl;
}

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

int solve(string& str) {
	char prev = str[0];
	int count = 0;
	for(int i = 0; i < str.length(); i++){
		if (prev != str[i])
			count++;
		prev = str[i];
	}
	return count;
}

int main(){
	string input;
	cin >> input;
	cout << solve(input) << endl;
}



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

int main() {
    double d,t,s;
    cin>>d>>t>>s;

    if (d/s <= t)
        cout << "Yes" << endl;
    else
        cout << "No" <<endl;
}

Measured memory_bytes: 3720
n,m=map(int,input().split())
s=input()
ans=[0]*n
count=0
for i in range(n-1):
  ans[i]=count
  if s[i]=='A' and s[i+1]=='C':
    count+=1
ans[n-1]=count
for i in range(m):
  a,b=map(int,input().split())
  print(ans[b-1]-ans[a-1])

Measured memory_bytes: 6084
/*
	?????????????????¶???????????????a???b???????????????????????¢??§???????????????????????£???????????????
	????????\??????????????????
 */
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int c,m,n;
	cin >> c;
	while(c--){
		cin >> m >> n;
		if(m*m + n*n <= 1){
			cout << 'C' << endl;
			continue;
		}
		int ct = 0;
		int size = m*m + n*n + 1;//20000??§?????????
		for(int x = -sqrt(size) ;x*x <= size;++x){
			for(int y = -sqrt(size) ;y*y <= size;++y){
				if(x==y && x==0)continue;
				int sqsum = x*x + y*y;
				int a = x*m + y*n, b = x*n - y*m;
				if(a % sqsum == 0 && b % sqsum == 0){
					ct++;
					//					cout << "x:" << x << " y:" << y << endl;
				}
			}
		}
		if(ct == 8)cout << 'P' << endl;
		else cout << 'C' << endl;
	}
  return 0;
}

Measured memory_bytes: 2960