akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    ll X;
    cin >> X;
    ll A = 100;
    ll cnt = 0;
    while (A < X) {
        cnt++;
        A += A/100;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	long long n, k;
	cin >> n >> k;
	long long t = 0;
  	for(int i = k; i<= n+1; i++) {
    	t += (n-i+1) * i + 1;
      	t %= MOD;
    }
  	cout << t << endl;
}


Measured memory_bytes: 3580
<?php
$inputs = trim(fgets(STDIN));
list($A, $B, $K) = explode(' ', $inputs);

for ($i = min($A, $B); $i >= 1; $i--) {
    if ($A % $i == 0 && $B % $i == 0) {
        $K--;
    }
    if (0 == $K) {
        print($i);
        break;
    }
}

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int tot,n,a[N<<1],b[N],nex[N],bk[N],pre[N];
ll k,A,B;
bool vis[N];
ll getdis(int s,int t)
{
    if(s==0) s=n;
    ll ans=0;
    while(s!=t)
    {
        ans+=nex[s];
        s=(s+nex[s])%n;
        if(s==0) s=n;
    }
    return ans;
}
void getAns(int now)
{
    for(int i=now;i<=n;i++)
    {
        int x=a[i];
        if(pre[x])
        {
            while(b[tot]!=x) pre[b[tot]]--,tot--;
            pre[x]--;tot--;
        }
        else b[++tot]=x,pre[x]++;
    }
}
int getPos(int now,ll k)
{
    while(k>=nex[now])
    {
        k-=nex[now];
        now=(now+nex[now])%n;
        if(now==0) now=n;
    }
    return now;
}
int main()
{
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),a[i+n]=a[i];
    for(int i=n<<1;i>=1;i--)
    {
        if(i<=n)
            nex[i]=bk[a[i]]-i+1;
        bk[a[i]]=i;
    }
    int now=1;
    while(!vis[now])
    {
        vis[now]=true;
        now=(now+nex[now])%n;
        if(now==0) now=n;
    }
    A=getdis(1,now);
    B=getdis(now+nex[now],now)+nex[now];
    k*=n;
    k--;
    if(k<=A)
        getAns(getPos(1,k));
    else
        getAns(getPos(now,(k-A)%B));
    for(int i=1;i<=tot;i++)
        printf(i==tot?"%d\n":"%d ",b[i]);
}


Measured memory_bytes: 6400
#include <functional>
#include <utility>

template <typename T, typename F = std::less<>>
void InsertionSort(T& a, F comp = F()) {
	int n = a.size();
	
	for(int i = 0; i < n; ++i){
        int j = i - 1;
        while(j >= 0 && comp(a[j + 1], a[j])){
        	std::swap(a[j], a[j + 1]);
            --j;
        }
    }
}

#include <iostream>
#include <vector>
#include <cassert>
using namespace std;

template <typename T, typename F = std::less<>>
void f(T& a, F comp = F()) {
	int n = a.size();
	
	for(int i = 0; i < n; ++i){
        int j = i - 1;
        while(j >= 0 && comp(a[j + 1], a[j])){
        	std::swap(a[j], a[j + 1]);
            --j;
        }
        
        for(int i = 0; i < n; ++i) {
        	if(i) cout << ' ';
        	cout << a[i];
        }
        cout << endl;
    }
}

int main()
{
	
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    
    f(v);
    
}

Measured memory_bytes: 3096
import java.util.*;

public class Main {
public static void main(String[] args) {
	
	Scanner sc = new Scanner(System.in);
		
 	String str  = sc.next();
  
  	char[] c_arr = str.toCharArray();
    
    sc.close();
  	
    if (c_arr[0] == 'A' && c_arr[1] == 'A' && c_arr[2] == 'A') {
         System.out.print("No"); 
    } else if (c_arr[0] == 'B' && c_arr[1] == 'B' && c_arr[2] == 'B') {
         System.out.print("No"); 
    } else {
         System.out.print("Yes"); 
    }
    
	
	}
}

Measured memory_bytes: 21844
n = int(input())
for i in range(n):
    u, k, *v = map(int, input().split())
    row = ""
    for j in range(1, n + 1):
        if j in v:
            row += "1"
        else:
            row += "0"
        if j != n:
            row += " "
    print(row)

Measured memory_bytes: 7700
#include <iostream>

using namespace std;

int main(void){

  int n;
  while( cin >> n , n ){

    int cnt = 0;

    while( n != 1 ){
      
      if( n % 2 == 0 ) n /= 2;
      else n = 3*n + 1;
      cnt++;

      }
    cout << cnt << endl;
  }
    return 0;
}

Measured memory_bytes: 1164
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int64_t> A(N);
  rep(i, N) cin >> A[i];

  rep(i, N - K) {
    if (A[i] < A[i + K])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}


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

alice = []
bob = []

a.sort(reverse=True)

for i in range(n):
    if i % 2 == 0:
        alice.append(a[i])
    else:
        bob.append(a[i])

ans = sum(alice) - sum(bob)

print(ans)

Measured memory_bytes: 3064
import itertools
import sys
def input(): return sys.stdin.readline()
def inpl(): return [int(i) for i in input().split()]
def f(y):
    return abs(x-A[y])
N, Q = inpl()
A = inpl()
SA = list(itertools.accumulate(A))
if N%2 :
    B = [v for i, v in enumerate(A) if not i%2]
    B = [0] + list(itertools.accumulate(B))
else:
    B = [v for i, v in enumerate(A) if i%2]
    B = [0] + list(itertools.accumulate(B))
    
for _ in range(Q):
    x = int(input())
    lo = 1
    hi = -(-N//2) + 1
    while hi - lo >1:
        mid = (lo+hi)//2
        if mid == 1:
            continue
        if max(f(N-mid-1), f(N-2*mid+1)) <= f(N-mid):
            lo = mid
        else:
            hi = mid    
    print(SA[N-1] - SA[N-lo-1] + B[-((2*lo-N)//2)])
    

Measured memory_bytes: 64748
#include<stdio.h>
int main(){
  int n,r = 0,b = 0;
  scanf("%d",&n);
  char s[n + 1];
  scanf("%s",&s);
  for(int i = 0;i < n;i++){
    if(s[i] == 'R'){
      r++;
    }else{
      b++;
    }
  }
  if(r > b){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}
//for(int i = 0;i < n;i++){
//printf("%d");

Measured memory_bytes: 128
import numpy as np
d, g = map(int ,input().split())
points = [list(map(int,input().split())) for _ in range(d)]

def min_q(comp_flg, target_score): # comp_flag[i]=True以外の問題iについて、compポイントを無視してtarget_scoreを超えるには最低いくつの問題数が必要かを返す
    score = 0
    q_num = 0
    for i in range(d-1,-1,-1):
        if comp_flg[i]:
            continue
        if target_score>score+points[i][0]*(i+1)*100:
            score += points[i][0]*(i+1)*100
            q_num += points[i][0] 
        else:
            q_num += np.ceil((target_score-score)/(100*(i+1)))
            break
    return q_num


mn = float('inf')
for i in range(1<<d):
    complete_flg = [False]*d
    tmp_q_num = 0
    tmp_point = 0
    for j in range(d):
        if i&(2**j) != 0:
            tmp_point += points[j][0] * 100*(j+1) + points[j][1]
            complete_flg[j] = True
            tmp_q_num += points[j][0]
    if tmp_point < g:
        tmp_q_num += min_q(complete_flg, g-tmp_point)
    if mn>tmp_q_num:
        mn = tmp_q_num

print(int(mn))

Measured memory_bytes: 12488
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int main()
{
  int h, w; cin >> h >> w;
  vecstr g(h);
  REP(i,h) cin >> g[i];
  // cout << endl;
  // REP(i,h){
  //   cout << g[i] << endl;
  // }



  vec2int dp(h, vecint(w, 0));
  ////start
  if(g[0][0] == '#'){
    dp[0][0] = 1;
  }
  ////dp[0][j]
  REP(j, w - 1){
    int yoko = dp[0][j];
    if(g[0][j + 1] == '#'){
      if(g[0][j] == '.'){
	yoko ++;
      }
    }
    dp[0][j + 1] = yoko;
  }
  ////dp[i][0]
  REP(i, h - 1){
    int tate = dp[i][0];
    if(g[i + 1][0] == '#'){
      if(g[i][0] == '.'){
	tate ++;
      }
    }
    dp[i + 1][0] = tate;
  }
  REP(i,h - 1){
    REP(j,w - 1){
      int tate = dp[i][j + 1];
      int yoko = dp[i + 1][j];
      if(g[i + 1][j + 1] == '#'){
	if(g[i][j + 1] == '.'){
	  tate += 1;
	}
	if(g[i + 1][j] == '.'){
	  yoko += 1;
	}
      }
      // if(i == 0){
      // 	cout << "i,j" << i << " " << j << " " << tate << " " << yoko << endl;
      // }
      dp[i + 1][j + 1] = min(tate, yoko);
    }
  }
  // REP(i,h){
  //   REP(j,w){
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  cout << dp[h - 1][w - 1] << endl;
}


Measured memory_bytes: 256
// " --- IN THE NAME OF ALLAH --- " // ;)
// ------------sphr_agz------------ // ;)
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

typedef long double ld;
typedef long long int lli;
typedef pair <lli, lli> pii;
#define pb push_back
#define recout(x) return cout << (x), 0
#define f first
#define s second
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define stp(x) cout << setprecision(x) << fixed
#define mk make_pair
#define all(x) x.begin(), x.end()
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
const lli N = 3e3 + 10, N2 = 2e5, delta = 46639, mod = 1e9 + 7, oo = 1e18, LOG = 20, SQ = 300;
const ld PI = 3.141592653589793;

ld p[N], dp[N][N];

int32_t main() {
	fast;
	stp(9);
	lli n;
	cin >> n;
	for (lli i = 1; i <= n; i++)
		cin >> p[i];
	dp[0][0] = 1;
	for (lli i = 1; i <= n; i++)
		for (lli j = 0; j <= i; j++)
			dp[i][j] = dp[i - 1][j] * ((ld) 1 - p[i]) + (j? dp[i - 1][j - 1] * p[i]: 0);
	ld ans = 0;
	for (lli i = n; i > n / 2; i--)
		ans += dp[n][i];
	cout << ans << '\n';
	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    rep (i, n + 1) {
        double res = i * 1.08;
        int x = (int)res;
        if (x == n) {
            cout << i << endl;
            return 0;
        } 
    }
    cout << ":(" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long lint;
typedef pair<int, int> P;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

const int MAX = 1000000;

// 1<=k<=n<=10^7
// p:素数
int fac[MAX], finv[MAX], inv[MAX];

//前処理Ｏ(n)
void CombInit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算Ｏ(1)_nCk
int nCk(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//重複組み合わせＯ(1)_nHk
int nHk(int n, int k) { return nCk(n + k - 1, k); }

map<int, int> prime_factor(int n) {
  map<int, int> res;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) {
        res[i]++;
        n /= i;
      }
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

signed main() {
  int N, M;
  cin >> N >> M;
  map<int, int> mp = prime_factor(M);
  CombInit();

  int ans = 1;
  for (auto x : mp) {
    if (x.second != 0) {
      ans *= nHk(N, x.second);
      ans %= MOD;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 23680
while(1):
    up=raw_input()
    if up=='-':    break
    left=raw_input()
    down=raw_input()
    
    cen=left[0]
    idu=0
    idd=0
    idl=0
    ans=''
    for i in range(len(up)+len(left)-1):
        if down[idd]==cen: #moved down
            cen=up[idu]
            idu+=1
            idd=min(idd+1,len(down)-1)
        else:
            ans+=cen
            idl+=1
            cen=left[idl]
    ans+=cen
    print ans

Measured memory_bytes: 6244
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=1000010;
const ll mod=1e9+7;

template<typename T>
T extgcd(T a,T b,T& x,T& y){
  T d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
 
template<typename T>
T mod_inverse(T a,T mod){
  T x,y;
  extgcd(a,mod,x,y);
  return (x%mod+mod)%mod;
}

template<typename T, size_t sz>
struct Combination{
  using ll = long long;
  array<T, sz> fact;

  T mod;
  Combination(T mod):mod(mod){init();}

  void init(){
    fact[0]=1;
    for(int i=1;i<(int)sz;i++)
      fact[i]=(ll)fact[i-1]*i%mod;
  }

  T mod_fact(T n,T& e){
    e=0;
    if(n==0) return 1;
    T res=mod_fact(n/mod,e);
    e+=n/mod;
    if(n/mod%2!=0)return res*(mod-fact[n%mod])%mod;
    return res*fact[n%mod]%mod;
  }

  T mod_comb(T n,T k){
    if(n==k||k==0) return 1;
    T e1,e2,e3;
    T a1=mod_fact(n,e1),a2=mod_fact(k,e2),a3=mod_fact(n-k,e3);
    if(e1>e2+e3) return 0;
    return a1*mod_inverse<ll>((ll)a2*a3%mod,mod)%mod;
  }
};

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> as(n);
  rep(i,n) as[i]=s[i]-'1';

  Combination<int,mx> C(2);
  int is_one=0;
  for(int i=0;i<n;i++)
    if(as[i]&1) is_one^=C.mod_comb(n-1,i);

  if(is_one){
    cout<<1<<endl;
    return 0;
  }

  for(int i=0;i<n;i++){
    if(as[i]==1){
      cout<<0<<endl;
      return 0;
    }
    as[i]/=2;
  }

  int is_two=0;
  for(int i=0;i<n;i++)
    if(as[i]&1) is_two^=C.mod_comb(n-1,i);

  cout<<is_two*2<<endl;
  return 0;
}

Measured memory_bytes: 9220
#include<iostream>
#include <cstdio> 
using namespace std;
long long  a[200];
long long  n;
long long  x;
int main()
{
	//a[0] = 10001;
	long long  all = 0;
	long long  min=10000;
	scanf("%lld%lld", &n,&x);
 
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
		if (min > a[i])
			min = a[i];
		all += a[i];
	}
	long long  t = n +(x-all) / min;
	printf("%lld\n", t);
 
    return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


//-----------------------------------------------------------------------------

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

	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=a+b,y=c+d;
	cout<<(x<y?"Right":x==y?"Balanced":"Left")<<endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
V = [int(x) for x in input().split(' ')]
C = [int(x) for x in input().split(' ')]

def check(i,cc):
  if i == N:
    return cc
  c1 = check(i+1,cc)
  c2 = check(i+1,cc+(V[i] - C[i]))
  return max(c1,c2)

print(check(0,0))


Measured memory_bytes: 2940
# num = int(input())
# h, w = list(map(int, input().split()))
# arr = list(map(int, input().split()))

# y = goukei - x
# y - x = goukei - x - x = goukei - 2*x

num = int(input())
org_list = list(map(int, input().split()))

goukei = sum(org_list)

pre_min_diff = 10**12
wip_sum = 0

for i in range(num-1):
     wip_sum += org_list[i]
     min_diff = abs(goukei - wip_sum*2)
     if min_diff < pre_min_diff:
         pre_min_diff = min_diff

print(pre_min_diff)


Measured memory_bytes: 24800
open Array
let n, m = Scanf.scanf "%d %f\n" @@ fun a b -> a, b
let a = init n @@ fun _ -> Scanf.scanf "%f " @@ fun d -> d
let m4 = (fold_left (+.) 0. a) /. (4.*.m)
let ans =
  if (List.length (List.filter (fun x -> x >= m4) (to_list a))) >= int_of_float m
  then "Yes" else "No"
let () = print_endline ans

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, K;
  cin >> N >> K;
  vl p(N);
  REP(i, N) cin >> p[i];
  long double ans = 0;
  long double score = 0;
  REP(j, K) { score += (long double)(1 + p[j]) / 2; }
  ans = max(ans, score);
  FOR(i, K, N) {
    // cout << K << endl;
    score -= (long double)(1 + p[i - K]) / 2;
    score += (long double)(1 + p[i]) / 2;
    ans = max(ans, score);
  }
  cout << SP(20) << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
 
int main(void)
{
  
  int x,y,i,a;
  
  scanf("%d%d",&x,&y);
  
  for(i=0;i<=x;i++){
      a=x-i;
      if(4*i+2*a==y){
         printf("Yes\n");
         return 0;
      }
  }
  printf("No\n");
  
  return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
	int n;
	cin >> n;
	if (n < 30) cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 3640
from sys import stdin

a = stdin.readline().rstrip()
a = [i for i in a]

b = stdin.readline().rstrip()
b = [i for i in b]

c = stdin.readline().rstrip()
c = [i for i in c]

ima = "a"
while True:
    if ima == "a":
        ima = a.pop(0)
    elif ima == "b":
        ima = b.pop(0)
    else:
        ima = c.pop(0)

    if ima == "a" and not a:
        print("A")
        exit()
    elif ima == "b" and not b:
        print("B")
        exit()
    elif ima == "c" and not c:
        print("C")
        exit()

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
int main()
{
  int n,k;
  cin >> n >> k ;
  long long int ans=k;
  n--;
  while(n--)
  {
    ans*=(k-1);
  }
  cout << ans ;
}  

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		int a[10] = {0};
		char str[10];
		scanf("%s",str);
		for(int i = 0; i < 8; i++){
			a[i] = str[i] - '0';
		}
		sort(a,a+8);
		char x[9] = {0},y[9] = {0};
		for(int i = 0; i < 8; i++){
			x[i] = a[i] + '0';
			y[i] = a[8-1-i] + '0';
		}
		int min,max;
		sscanf(x,"%d",&min);
		sscanf(y,"%d",&max);
		printf("%d\n",max-min);
	}
	return 0;
}

Measured memory_bytes: 1052
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		long ok = Long.MAX_VALUE / 3;
		long ng = 0;
		while (ok - ng > 1) {
			long m = (ok + ng) / 2;
			if (f(m) > X) {
				ok = m;
			} else {
				ng = m;
			}
		}
		System.out.println(ok - 1);
	}

	static int f(long n) {
		if (n <= 2)
			return 0;
		return 1 + f((n - 1) / 2);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 21972
#! python3
# coding:utf-8
 
def main():
    a,b,c,d = map(int,input().split())

    while ((a>0) and (c>0)):
        c = c - b
        if c <= 0:
            print("Yes")
            break
        a = a - d
        if a <= 0:
            print("No")

if __name__ == "__main__":
    main() 

Measured memory_bytes: 9148
n = int(input())
ret = {}
for i in range(0, n):
    a = int(input())
    ret[i] = [[], []]
    for j in range(a):
        x, y = map(int, input().split())
        x -= 1
        if y == 1:
            ret[i][0].append(x)
        elif y == 0:
            ret[i][1].append(x)
 
ans = 0
import itertools
lst = list(itertools.product([0, 1], repeat=n))
for s in lst:
    var = True
    for i in range(len(s)):
        if s[i] == 1:
            for j in ret[i][0]:
                if s[j] != 1:
                    var = False
                    break
            for j in ret[i][1]:
                if s[j] != 0:
                    var = False
                    break
    if var:
        # print(s)
        ans = max(ans, s.count(1))
print(ans)

Measured memory_bytes: 8820
def Main(N, H):
    dp = [0]*N
    dp[1] = abs(H[0]-H[1])
    for i in range(2, N):
        dp[i] = min(abs(H[i]-H[i-1])+dp[i-1], abs(H[i]-H[i-2])+dp[i-2])
    return dp[N-1]

def main():
    N = int(input())
    H = list(map(int, input().split()))
    print(Main(N, H))

if __name__ == '__main__':
    main()

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

vector<int> e[100010];
long long dp[100010];
long long sp[100010];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    for (int i = 0; i < n-1; i++) {
        int x, y; cin >> x >> y;
        e[x].emplace_back(y);
        e[y].emplace_back(x);
    }
    auto dfs = [&](auto f, int curr, int prev) -> void {
        dp[curr] = 1;
        int cnt = 0;
        for (auto &to: e[curr]) {
            if (to == prev) continue;
            f(f, to, curr);
            cnt++;
            dp[curr] = dp[curr] * (dp[to] + 1) % m;
        }
    };
    auto calc = [&](auto f, int curr, int prev) -> void {
        vector<long long> v; vector<int> w;
        for (auto &to: e[curr]) {
            if (to == prev) continue;
            v.emplace_back(dp[to] + 1);
            w.emplace_back(to);
        }
        int sz = v.size();
        vector<long long> pre(sz+1, 1), suf(sz+1, 1);
        for (int i = 0; i < sz; i++) {
            pre[i+1] = pre[i] * v[i] % m;
        }
        for (int i = sz-1; i >= 0; i--) {
            suf[i] = v[i] * suf[i+1] % m;
        }
        for (int i = 0; i < sz; i++) {
            sp[w[i]] = sp[curr] * pre[i] % m * suf[i+1] % m + 1;
            dp[w[i]] = dp[w[i]] * sp[w[i]] % m;
            f(f, w[i], curr);
        }
    };
    dfs(dfs, 1, -1);
    sp[1] = 1;
    calc(calc, 1, -1);
    for (int i = 1; i <= n; i++) {
        cout << dp[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 26880
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	vector<int> a(3);
	REP(i, 3) cin >> a[i];
	sort(a.begin(), a.end());
	int res = max(10 * a[2] + a[1] + a[0], a[2] + 10 * a[1] + a[0]);
	cout << res << "\n";

	return 0;
}
		

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

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

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

  string ans = "Yes";
  while (b <= a) {
    if (k == 0) {
      ans = "No";
      break;
    }
    b *= 2;
    k--;
  }
  if (ans == "Yes") {
    while (c <= b) {
      if (k == 0) {
        ans = "No";
        break;
      }
      c *= 2;
      k--;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

void solve()
{
	int N, M;
	while(cin >> N >> M, N || M)
	{
		vector<int> grid(N);
		for(int i = 0; i < N; ++i)
		{
			cin >> grid[i];
		}
		vector<int> dice(M);
		for(int i = 0; i < M; ++i)
		{
			cin >> dice[i];
		}
		int pos = 0;
		for(int i = 0; i < M; ++i)
		{
			pos += dice[i];
			if(pos >= N - 1)
			{
				cout << i + 1 << endl;
				break;
			}
			else
			{
				pos += grid[pos];
				if(pos >= N - 1)
				{
					cout << i + 1 << endl;
					break;
				}
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1200
import java.util.*;
import java.io.*;
public class Main { //atcoder ABC128E -
	public static void main(String[] args) throws Exception {
		
//		int N = 52; long count = 0;
//		for(int i = 0; i <= N; i++){
//			for(int j = 0; j <= N; j++){
//				if((i + j) <= N && (i + j) == (i ^ j)) {
//					count++;
//				}
//			}
//		}
//		System.out.println(count);
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//		StringTokenizer st = new StringTokenizer(br.readLine());
		char[] s = br.readLine().toCharArray();
		long tot = 1, two = 1;
		for(int c: s){
			if(c == '1'){
				two = mult(two, 2);
				tot = mult(tot, 3);
			}
			else{
				tot = sum(mult(sub(tot, two), 3), two);
			}
		}
		System.out.println(tot);
	}
	static long MOD = 1000000007;
	static long sum(long a, long b){
		return (a+b)%MOD;
	}
	static long mult(long a, long b){
		return (a*b) % MOD;
	}
	static long sub(long a, long b){
		return sum(a, MOD-b);
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <map>
#include <cmath>
using namespace std;
#define LL long long

//nを素因数分解してmapに格納する
//mapでは，first^second の形式で入れていく
class Solve{
  //素因数分解した結果を格納する
  //この問題では，.secondは使わない
public:map<int, int> m;
  
  //numを素因数分解してメンバmに格納する
public:void prime_fact(LL num){
  int div;
  double N = sqrt(num);
  for(div=2; div<=N; div++){
    //divで割れるなら，割り切れなくなるまで割り続ける
    //素因数divの数も一応数えておく (今回の問題は不要)
    while(num % div == 0){
      num = num/div;
      m[div]++;
    }
  }
  //最後に残ったnumが素数であるとき
  if(num != 1)
    m[num]++;
  
} //prime_fact
  
}; //class Solve


int main(void){
  LL A, B;
  cin >> A >> B;
  //ここまで入力

  Solve a, b;
  a.prime_fact(A);
  b.prime_fact(B);
  
  //共通の素因数をカウントする
  //1(素数でない)も数えるため，初期値は1にしておく
  LL count = 1;

  //写像a.mに入っている要素数分見ていく
  for(auto prime: a.m)
    //写像b.mの中にa.mと共通のものがあるとき
    if(b.m.find(prime.first) != b.m.end() )
      count++;
  
  cout << count << endl;
  
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

char s[15];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    int n = strlen(s);
    ll ans = 0;
    for(int i=0;i<(1<<(n-1));i++){
        ll sum = 0;
        for(int j=0;j<n;j++){
            sum = sum*10 + (s[j]-'0');
            if((i>>j)&1){
                ans += sum;
                sum = 0;
            }
        }
        ans += sum;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define int   long long int  
#define pb push_back
#define BOOST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debugL(i)  cout<<"line no-> "<<i<<" working"<<endl
#define debugVL(i,l)  cout<<"val at line no."<<i<< " ->"<<l<<endl
#define  init(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
const int M=1e9 + 7;
using namespace std;
int N=200000;
int32_t main() {
	BOOST;
    int n;cin>>n;
    int ans=0;
    int* a=new int[n];
    for(int i=0;i<n-1;i++)cin>>a[i];
    int prev=a[0];
    ans+=a[0];
    for(int i=1;i<n-1;i++)
    {
    	ans+=min(prev,a[i]);
    	prev=a[i];
	}
	ans+=prev;
	cout<<ans<<endl;
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

int Profit(vector<vector<int> > a, vector<vector<int> > dp, int i, int j){
    if(i==n)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    int ans = 0;
    if(j==0)
        ans = a[i][j] + max(Profit(a,dp,i+1,1), Profit(a,dp,i+1,2));
    else if(j==1)
        ans = max(ans, a[i][j] + max(Profit(a,dp,i+1,0), Profit(a,dp,i+1,2)));
    else
        ans = max(ans, a[i][j] + max(Profit(a,dp,i+1,0), Profit(a,dp,i+1,1)));
    return dp[i][j] = ans;
}

int ProfitBU(vector<vector<int> > a){
    vector<vector<int> > dp(n, vector<int>(3,0));
    dp[0][0] = a[0][0]; dp[0][1] = a[0][1]; dp[0][2] = a[0][2];
    for(int i=1;i<n;i++){
        dp[i][0] = a[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = a[i][2] + max(dp[i-1][0], dp[i-1][1]);
    }
    return max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}

int main(){
    cin>>n;
    vector<vector<int> > a(n, vector<int>(3,0));
    for(int i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    cout<<ProfitBU(a)<<endl;
    return 0;
}

/*int main(){
    cin>>n;
    vector<vector<int> > a(n, vector<int>(3,0)), dp(n, vector<int>(3,-1));
    for(int i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    cout<<max(Profit(a,dp,0,0), max(Profit(a,dp,0,1), Profit(a,dp,0,2)))<<endl;
    return 0;
}*/


Measured memory_bytes: 19536
#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
ll m,n;
ll a[200];
int main()
{
	scanf("%lld%lld",&n,&m);
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	sort(a,a+n);
	bool flag=true;
	if(sum>a[n-m]*4*m)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
A = Counter(a)

X = 0
for x, y in A.items():
    X += y * (y-1) // 2

for i in range(n):
    N = a[i]
    ans = X
    if A[N] >= 2:
        ans -= A[N] * (A[N]-1) // 2 
        ans += (A[N]-1) * (A[N]-2) // 2
    print(ans)

Measured memory_bytes: 26780
N, Q = map(int, input().split())

graph = [[] for _ in range(N+1)]

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

val = [0] * (N+1)
for i in range(Q):
    p, x = map(int, input().split())
    val[p] += x

stack = [1]
parent = [0] * (N+1)
while stack:
    x = stack.pop()
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)
        val[y] += val[x]

print(' '.join(map(str,val[1:])))


Measured memory_bytes: 66880
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(auto &I:a){cin>>I;}
    priority_queue<pll> Q;
    for(int i=0;i<n;i++){
        Q.push({a[i],n-i});
    }
    ll cnt=1;
    pll mi=Q.top();
    Q.pop();
    vector<ll> ans(n,0);
    while(!Q.empty()){
        pll w=Q.top();
        Q.pop();
        if(n-w.S>n-mi.S){
            ans[n-mi.S]+=cnt*(mi.F-w.F);
            mi.F=w.F; cnt++;
        }
        else{
            ans[n-mi.S]+=cnt*(mi.F-w.F);
            mi=w; cnt++;
        }
    }
    ans[n-mi.S]+=cnt*(mi.F);
    for(auto &I:ans){cout<<I<<endl;}
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 4212
import sys
# N = int(input())
# a = [int(input()) for _ in range(N)]
S = sorted(list(input()))
L = len(S)
# T = str(input())
num0 = 0
for i in range(L):
    if(S[i] == "1"):
        num0 = i
        break
print(min((L-num0)*2,num0*2))


Measured memory_bytes: 4980
export default solve;

// =================================================
// ABC086B
// =================================================

// reader
if (!process.env.LOCAL_DEBUG) {
  require('fs').readFile('/dev/stdin', 'utf8', (err: any, data: string) => {
    if (err) console.error(err);
    main(data.trim().split('\n'));
  });
}

// main
function main(lines) {
  console.log(solve(lines));
}

// solver
function solve(lines: string[]): string {
  const { a, b } = parseLines(lines);

  const n = +[a, b].join('');
  return Math.sqrt(n)
    .toString()
    .includes('.')
    ? 'No'
    : 'Yes';
}

// helpers
function parseLines(lines: string[]) {
  const [a, b] = lines[0].split(' ').map(s => +s);
  const obj = { a, b };
  debug(obj);
  return obj;
}

// general helpers
function debug(message?: any, ...optionalParams: any[]) {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
}


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

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

	vector<double> vec(n);
	for (auto& e : vec) {
		cin >> e;
	}

	vector<int> dp(n);
	int sum = -1;
	int index = 0;

	for (int i = 0; i < k; i++) {
		dp.at(0) += vec.at(i);
	}
	for (int i = 1; i <= n - k; i++) {
		dp.at(i) = dp.at(i - 1) + vec.at(i + (k - 1)) -vec.at(i - 1);

		if (sum < dp.at(i)) {
			sum = dp.at(i);
			index = i;
		}
	}
	double exp = 0;
	for (int i = index; i < index + k; i++) {
		exp += (vec.at(i) + 1) / 2;
	}

	cout << fixed << setprecision(10);
	cout << exp << endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
	        
			long h = sc.nextLong();
			long w = sc.nextLong();
			
			if(h==1L || w==1L) {
				System.out.println(1);
				return;
			}
			
			if(h%2L==0L) {
				System.out.println(w*(h/2L));
			}else {
				System.out.println(w*(h/2L)+((w+2L-1L)/2L));
			}
		}
	}


Measured memory_bytes: 35852
import java.util.*;
 
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);


        int N = Integer.parseInt(sc.next());
        String s1 = sc.next();
        char[] c1 = s1.toCharArray();


        int max = 0;
        int a = 0;
        for(int i=0;i<N;i++){
            
            if( c1[i] == 'I' ) a++;
            else a--;
            
            if(a>max) max = a ;
            
        }



        System.out.print(max);
        System.out.println();
    }

}

Measured memory_bytes: 9556
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>

int main()
{
    while (true) {
        std::size_t n;
        std::cin >> n;
        if (n == 0) {
            break;
        }

        int score[n];
        int sum = 0;
        for (std::size_t i = 0; i < n; ++i) {
            std::cin >> score[i];
            sum += score[i];
        }

        double average = (double)(sum) / n;

        double v = 0.0;
        for (std::size_t i = 0; i < n; ++i) {
            v += (score[i] - average) * (score[i] - average);
        }

        double sd = sqrt(v/n);

        std::cout << std::fixed << std::setprecision(20) << sd << std::endl;
    }


    return 0;
}


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

int main()
{
    ll X, K, D; cin >> X >> K >> D;
    X = abs(X);
    ll sho = X / D;
    if (K <= sho) {
        cout << X - (K * D) << endl;
        exit(0);
    }
    X -= (sho * D);
    K -= sho;
//    cout << "X = " << X << " K = " << K << " D = " << D << endl;
    if (K % 2 == 0) {
        cout << X << endl;
    }
    else {
        cout << abs(X - D) << endl;
    }



}


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

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var c = Console.ReadLine();

        long ans = 0;

        // 後ろから貪欲的に
        int i = 0;
        int j = n - 1;

        while (i < c.Length && c[i] == 'R')
            i++;
        while (j >= 0 && c[j] == 'W')
            j--;

        while (true)
        {
            if (i >= j || i >= c.Length || j <= 0) break;

            ans++;
            i++;
            j--;

            while (i < c.Length && c[i] == 'R')
                i++;
            while (j >= 0 && c[j] == 'W')
                j--;
        }

        Console.WriteLine(ans);
    }

    public static bool isOK(char[] target)
    {
        if (target.All(t => t == 'R')) return true;
        if (target.All(t => t == 'W')) return true;

        bool isRed = true;
        for (int i = 0; i < target.Length; i++)
        {
            if (isRed)
            {
                if (target[i] == 'R') continue;
                else
                {
                    isRed = false;
                }
            }
            else
            {
                if (target[i] == 'W') continue;
            }
        }

        return true;
    }
}

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

int main(){
  int n,l;
  int ans=-1;
  cin >> n;
  int p[n];
  int q[n];
  for(int i=0;i<2*n;i++) {
    cin >> l;
    if(i<n) p[i] = l;
    else q[i-n] = l;
  }
  int temp[n];
  for(int i=0;i<n;i++){
    if(p[i]<q[i]) break;
    else if(p[i]>q[i]){
      for(int j=0;j<n;j++){
        temp[j] = p[j];
        p[j] = q[j];
        q[j] = temp[j];
      }
      break;
    }
  }  
  
  int count=0;
  do {
    for(int i=0;i<n;i++){
      if(p[i]!=q[i]) {
        count++;
        break;
      }else{
        if(i+1==n){
          ans = count;
          break;
        }
      }
    }
    if(ans>=0) break;
  } while (next_permutation(p,p+n));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

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

Measured memory_bytes: 3636
n=int(input())
a=[int(i) for i in input().split()]
ans=None
a_pos=[abs(i) for i in a]
a_min=min(a_pos)
a_neg=sum([1 if i<0 else 0 for i in a])
if a_neg%2==0:
    ans=sum(a_pos)
else: ans=sum(a_pos)-2*a_min
print(ans)

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

int main(){
  int n, a, b;
  string s;
  cin>>n>>a>>b>>s;
  int f_counter=0, total=0;
  for(int i=0; i<n; ++i){
    if((s[i]=='a')&&(total<(a+b))){
     cout<<"Yes"<<endl;
     ++total;
   }
    else if((s[i]=='b')&&(total<(a+b))&&(f_counter<b)){
      cout<<"Yes"<<endl;
      ++f_counter; 
      ++total;
    }
    else cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n,r;
	while(cin>>n>>r and n>0){
		int a[n]; rep(i,n) a[i]=n-i;
		rep(i,r){
			int p,c; cin>>p>>c;
			rotate(a,a+p-1,a+p+c-1);
		}
		cout<<a[0]<<endl;
	}
	return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)a[i]-=i+1;
    sort(a.begin(),a.end());
    ll center=a[n/2];
    ll ans=0;
    for(int i=0;i<n;i++)ans+=abs(a[i]-center);
    if(!n%2){
        ll ans2=0;
        center=a[n/2-1];
        for(int i=0;i<n;i++)ans2+=abs(a[i]-center);
        if(ans2<ans)ans=ans2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int a,b,i;
  cin >> a >> b;
  int c=1;
  for(i=0;;i++){
    if(c>=b){
      cout << i << endl;
      return 0;
    }
    c+=a-1;
  }
  return 0;
}

Measured memory_bytes: 3620
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    int N;
    int[] A;
    private void Scan()
    {
        N = int.Parse(Console.ReadLine());
        A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }

    public void Solve()
    {
        Scan();
        int rand = 0;
        bool[] b = new bool[8];
        foreach (int i in A)
        {
            if (i >= 3200)
            {
                rand++;
                continue;
            }
            b[i / 400] = true;
        }
        int min = b.Count(bo => bo);
        if (min == 0)
        {
            Console.WriteLine("1 {0}", rand);
        }
        else
        {
            Console.WriteLine("{0} {1}", min, min + rand);
        }
    }
}

Measured memory_bytes: 13396
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
    
a=[]
for i in range(55555):
	if i % 5 == 1:
		if is_prime(i):
			a.append(i)	
N=int(input())
for i in range(N):
	print(a[i], end=' ')

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

int main(){
  string N;
  cin >> N;
  ll ans=0;
  int a=N.size();
  string b;
  for(ll i=0;i<a;i++){
    b=N[i];
    ans+=atoi(b.c_str());
  }
  if(ans%9==0){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}
    
  

Measured memory_bytes: 3692
// B - Multiplication 2
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	int n; cin>>n;
	ll inf = 1e18;
	ll ans = 1;
	bool ng = false;
	while(n--){
		ll a; cin>>a;
		if(a == 0){ puts("0"); return 0; }
		if(ng || (inf+1)/a < ans || inf < ans*a) ng = true;
		else ans *= a;
	}
	if(ng) puts("-1");
	else cout<< ans <<endl;
}


Measured memory_bytes: 3636
N=int(input())
A=[None]*N

for i in range(N):
    A[i]=int(input())

Ans=0
A.sort()
A+=[-1]
j=1
for i in range(1,N+1):
    if A[i]==A[i-1]:
        j+=1
    else:
        if j%2==1:
            Ans+=1
        j=1

print(Ans)

Measured memory_bytes: 7472
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  char c[2][3];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }
  if (c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int ndigit(int x)
{
  int n = 1;
  while (x >= 10) {
    x /= 10;
    n++;
  }
  return n;
}

int main()
{
  int a, b, x;
  while (scanf("%d%d", &a, &b) != EOF) {
    x = a + b;
    printf("%d\n", ndigit(x));
  }

  return 0;
}

Measured memory_bytes: 600
K=int(input())
import math
ans=0
for a in range(1,K+1):
  for b in range(1,K+1):
    g=math.gcd(a,b)
    if g==1:
      ans += K
      continue
    for c in range(1,K+1):
      ans += math.gcd(g,c)
print(ans)


Measured memory_bytes: 9156
#include<bits/stdc++.h>
#define C getchar()
#define ll long long
using namespace std;
int read()
{
	int x=0,l=1;char c=C;
	for (;c<'0'||c>'9';c=C) if (c=='-') l=-1;
	for (;c>='0'&&c<='9';c=C) x=(x<<1)+(x<<3)+(c^48);
	return x*l;
}

int n,m,ans=0,xx,yy;
int v[100500]={0,1};
int rp[100500]={};
int cp[100500]={};

void fnp(int x,int y)
{
	rp[y]++;
	cp[x]++;
	if (v[x]) v[y]=1;
	if (rp[x]<cp[x]) v[x]=0;
}

int main()
{
	n=read();
	m=read();
	for (int i=1;i<=m;i++)
		{
			xx=read();
			yy=read();
			fnp(xx,yy);			
		}
	for (int i=1;i<=n;i++) ans+=v[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

const int MAX_N = 1<<17;

int n, dat[2*MAX_N-1];

void init(int n_){
  n=1;
  while(n<n_) n*=2;
  for(int i=0;i<2*n-1;i++) dat[i] = INT_MAX;
}

void update(int k,int a){
  k+=n-1;
  dat[k]=a;
  while(k>0){
    k=(k-1)/2;
    dat[k]=min(dat[k*2+1],dat[k*2+2]);
  }
}

int query(int a,int b,int k,int l,int r){
  if(r<=a||b<=l) return INT_MAX;
  if(a<=l&&r<=b) return dat[k];
  else{
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
}

int m, s, t, d[MAX_N];
P ab[MAX_N];

int main(){

  cin>>n>>m>>s>>t;
  
  s--, t--;
  
  for(int i=0;i<n;i++) cin>>d[i];
    
  for(int i=0;i<m;i++){
    cin>>ab[i].first>>ab[i].second;
    ab[i].first--;
    ab[i].second--;
  }

  sort(ab,ab+m);
  
  init(n);
  
  update(s,0);

  for(int i=0;i<m;i++){

    int A=ab[i].first;
    int B=ab[i].second;

    int cost=query(A,n,0,0,n)+d[B];
    
    if(query(B,B+1,0,0,n)>cost) update(B,cost);
    
  }
  
  cout<<query(t,n,0,0,n)<<endl;
  
  return 0;  
}

Measured memory_bytes: 5256