akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a / gcd(a, b) * b; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    ll n,k;
    cin>>n>>k;

    ll m = n/k;

    cout<<min(abs(n - (k * m)),abs(n - (k * (m + 1))))<<endl;




    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

const ll mod = 1000000007LL;

// aのb乗を求める.
ll modpow(ll a, ll b) {
	if (a > mod) a %= mod;
	if (b == 0LL) return 1LL;
	ll tmp = modpow(a, b / 2);
	if (b & 1LL)
		return tmp * tmp % mod * a % mod;
	return tmp * tmp % mod;
}

// aの逆元を求める.
ll inverse(ll a) {
	return modpow(a, mod - 2);
}

int main() {
	int N; cin >> N;
	// Nの階乗を計算
	ll N_fact = 1;
	int nx = 2;
	while (nx <= N)
		N_fact = (N_fact * nx++) % mod;
	// 答えの計算
	ll res = 0;
	ll tmp = 0;
	for (int i = 1; i <= N; ++i)
		tmp = (tmp + inverse(i)) % mod;
	for (int i = 1; i <= N; ++i) {
		int a; cin >> a;
		res += a * N_fact % mod * tmp % mod;
		res %= mod;
		tmp += (inverse(i + 1LL) - inverse(N - (ll)i + 1LL) + mod) % mod;
		tmp %= mod;
	}
	cout << res << endl;
	return 0;
}

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

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

using namespace std;

int dsf(SINT32 hukasa, vector<SINT32>TAKE,vector<SINT32>DATA);

SINT32 N = 0;
SINT32 A,B,C;

int main() {


	SINT32 ANS;
	cin >> N;
	cin >> A >> B >> C;

	vector<SINT32> DATA(N);
	vector<SINT32> TAKE(N);

	
	for (SINT32 i = 0; i < N; i++) {
		cin >> DATA[i];
	}

	ANS = dsf(0,TAKE,DATA);


	cout << ANS << endl;
	return 0;
}

int dsf(SINT32 hukasa, vector<SINT32>TAKE,vector<SINT32>DATA) {
	if (hukasa == N) {
		SINT32 MP = 0;
		SINT32 AL = 0;
		SINT32 BL = 0;
		SINT32 CL = 0;
		for (SINT32 i = 0; i < N; i++) {
			if (TAKE[i] == 0) {
				if (AL != 0) {
					MP = MP + 10;
				}
				AL = AL + DATA[i];

			} else if (TAKE[i] == 1) {
				if (BL != 0) {
					MP = MP + 10;
				}
				BL = BL + DATA[i];
			} else if (TAKE[i] == 2) {
				if (CL != 0) {
					MP = MP + 10;
				}
				CL = CL + DATA[i];
			}
		}

		if ((AL == 0) || (BL == 0) || (CL == 0)) {
			return 1000000000;
		} else {
			return MP + ABS(A-AL) + ABS(B-BL) + ABS(C-CL);
		}
	}

	SINT32 BUFA;
	SINT32 BUFB;
	SINT32 BUFC;
	SINT32 BUFN;

	TAKE[hukasa] = 0;
	BUFA = dsf(hukasa+1, TAKE, DATA);
	TAKE[hukasa] = 1;
	BUFB = dsf(hukasa+1, TAKE, DATA);
	TAKE[hukasa] = 2;
	BUFC = dsf(hukasa+1, TAKE, DATA);
	TAKE[hukasa] = 3;
	BUFN = dsf(hukasa+1, TAKE, DATA);

	return MIN(MIN(BUFA,BUFB),MIN(BUFC,BUFN));
}


//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();

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

int main(void) {
	int w, a, b;
	int left, right;
	cin >> w >> a >> b;
	if ((a + w - b >= 0) && (b + w - a >= 0)) {
		cout << 0 << endl;
	}
	else if (a + w - b < 0) {
		cout << b - (a + w) << endl;
	}
	else if (b + w - a < 0) {
		cout << a - (b + w) << endl;
	}
	return 0;
}

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

const int N = 4005;
const long long mod = 998244353;

long long C[N][N];
long long pow2[N];

void init(){
	C[0][0] = C[1][0] = C[1][1] = 1;
	for (int i = 2; i <= 4000; i++){
		C[i][0] = 1;
		for (int j = 1; j < i; j++) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
		C[i][i] = 1;
	}
	pow2[0] = 1;
	for (int i = 1; i <= 4000; i++) pow2[i] = pow2[i - 1] * 2 % mod;
}

int main(){
	init();
	int n, k, num1, num2, num3;
	long long ans;
	scanf("%d %d",&k,&n);
	for (int i = 2; i <= k * 2; i++){
		ans = 0;
		num1 = (min(i - 1, k) - max(i - k, 1) + 1) / 2;
		num2 = 1 - i & 1;
		num3 = k - num1 * 2 - num2;
		for (int p = 0; p <= num2; p++){
			for (int j = 0; j <= num1; j++){
				ans += C[num1][j] * pow2[j] % mod * C[n - 1 - p + num3][j + num3 - 1] % mod;
				ans %= mod;
			}
		}
		printf("%I64d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 124032
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
#define INF 1e10
using namespace std;

int n;
int a[22];
double dp[200001][21];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<=200000;i++){
		dp[i][0]=0;
		for(int j=1;j<=n;j++){
			dp[i][j]=INF;
		}
	}
	for(int i=1;i<=200000;i++){
		for(int j=0;j<n;j++){
			double cost=(double)abs(a[j]-i)/a[j];
			for(int k=1;k*k<=i;k++){
				if(i%k==0){
					dp[i][j+1]=min(dp[i][j+1],dp[i/k][j]);
					dp[i][j+1]=min(dp[i][j+1],dp[k][j]);
				}
			}
			dp[i][j+1]=max(dp[i][j+1],cost);
		}
	}
	double res=INF;
	for(int i=1;i<=200000;i++){
		res=min(res,dp[i][n]);
	}
	printf("%.10f\n",res);
	return 0;
}

Measured memory_bytes: 33880
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll a,b,m,ans=INT_MAX,mn=INT_MAX;
    cin>>a>>b>>m;
    ll arr[a],brr[b];
    ll t=min(a,b);
    ll c[t];
    for(int i=0;i<a;i++)
    {
        cin>>arr[i];
    }
    for(int i=0;i<b;i++)
    {
        cin>>brr[i];
    }
    //sort(arr,arr+a);
    //sort(brr,brr+b);
    for(int i=0;i<t;i++)
    {
        c[i]=arr[i]+brr[i];
    }
     for(int i=0;i<m;i++)
     {
        ll p,u,v;
        cin>>u>>v>>p;
        u--;
        v--;
        ll temp=arr[u]+brr[v]-p;
        ans=min(ans,temp);

     }
     for(int i=0;i<t;i++)
     {
          mn=min(mn,c[i]);
     }
     sort(arr,arr+a);
    sort(brr,brr+b);
    ll res=brr[0]+arr[0];
     cout<<min(mn,min(res,ans))<<endl;
    
}
return 0;
}   

Measured memory_bytes: 2560
def main():
    n = int(input())
    s = input()

    all_east = 0
    all_west = 0

    for i in range(n):
        if s[i] == 'W':
            all_west += 1
        else:
            all_east += 1

    count = 10 ** 6

    now_west = 0
    for i in range(n):
        if s[i] == 'E':
            all_east -= 1
        count = min(count, all_east + now_west)
        if s[i] == 'W':
            now_west += 1

    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 41692
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr ll INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int X;cin >> X;
    cout << X*X << endl;
}

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

int main(){
    int N,ans=0;
    string S;
    cin>>N>>S;
    for(int i=0;i<N-2;i++){
        if(S.at(i)=='A'&&S.at(i+1)=='B'&&S.at(i+2)=='C'){
            ++ans;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
use text_io::*;
use std::process::exit;

fn main(){
    let mut n:usize = read!();
    let mut m:usize = read!();
    let mut g:Vec<usize> = Vec::new();
    let mut v:Vec<usize> = Vec::new();
    for i in 0..n {
        let c:usize = read!();
        v.push(c);
        g.push(1);
    }
    for i in 0..m {
        let mut x:usize = read!();
        let mut y:usize = read!();
        if v[x-1]<=v[y-1] {
            g[x-1] = 0;
        }
        if v[y-1]<=v[x-1] {
            g[y-1] = 0;
        }
    }
    let mut mm:usize = 0;
    for i in 0..n {
        mm+=g[i];
    }
    println!("{}",mm);
}

Measured memory_bytes: 3836
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static int[][] mtx;
        static List<int>[] tm;
        static int n;
        static int[] results;
        static List<string> cons = new List<string>();
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long k = long.Parse(s[1]);
            //         string[] s2 = Console.ReadLine().Split(' ');
            //         int cnt = 0;
            var res = PrimeFactors(Gcd(n, k));
            res.Add(1);
            Console.WriteLine(res.Count);

        }


        static int rec(int[] n, int i, int j, int x)
        {
            if (i + 1 == j)
            {
                return Math.Min(n[j], x);
            }
            return rec(n, i + 1, j, n[i]) + rec(n, i, j - 1, n[j]);
        }

        public static long Gcd(long a, long b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

        public static HashSet<long> PrimeFactors(long n)
        {
            HashSet<long> res = new HashSet<long>();
            long i = 2;
            long tmp = n;

            while (i * i <= n) //※1
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    res.Add(i);
                }
                else
                {
                    i++;
                }
            }
            res.Add(tmp);
            return res;
        }
    }

}

Measured memory_bytes: 13396
# AOJ 1008: What Color Is The Universe?
# Python3 2018.7.4 bal4u

import sys
from sys import stdin
input = stdin.readline
 	
from collections import Counter
while True:
	n = int(input())
	if n == 0: break
	a = tuple(map(int, input().split()))
	x, w = Counter(a).most_common()[0]
	print(x if w>(n>>1) else "NO COLOR")


Measured memory_bytes: 122280
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns #-}
module Main where

data WP = Sunny | Cloudy | Rainy deriving (Show, Read, Eq, Ord, Enum)

main :: IO ()
main = do
  !wp <- readLn :: IO WP
  print (next wp)

next :: WP -> WP
next Sunny  = Cloudy
next Cloudy = Rainy
next Rainy  = Sunny


Measured memory_bytes: 508
import java.io.*;

class Main
{
   public static void main(String[] args) throws IOException
   {

      BufferedReader br =
       new BufferedReader(new InputStreamReader(System.in));

      String str1 = br.readLine();
      String str2[] = str1.split(" ");
      int a = Integer.parseInt(str2[0]);
      int b = Integer.parseInt(str2[1]);
      int c = a*b;
      int d = 2*(a+b);
      System.out.println( c + " " + d );

    }
}

Measured memory_bytes: 24148
#include<stdio.h>
#include<string.h>
int length(char[], char[]);

int main(){
  int n,i;
  char X[1001],Y[1001];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
  scanf("%s",&X[0]);
 
  scanf("%s",Y);
 length(X,Y);
  }


  return 0;
}

int length(char X[],char Y[]){
  int m,n,i,j;
  m=strlen(X);
  n=strlen(Y);
  int c[m+1][n+1];
  for(i=1;i<=m;i++)
    c[i][0]=0;
  for(j=0;j<=n;j++)
    c[0][j]=0;
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i-1]==Y[j-1])
	c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1])
	c[i][j]=c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }
  printf("%d\n", c[m][n]);
  return 0;
}




Measured memory_bytes: 5720
#include<bits/stdc++.h>
using namespace std;
int bs(int a[], int key, int n){
    int l=0,h=n-1,mid;
    while(l<h){
        mid = l + (h-l+1)/2;
        // cout<<mid;
        // if(a[mid] == key) return mid;
        if(a[mid] <= key)
            l=mid;
        else
            h=mid-1;
    }
    return l;
}
int main(){
    int n,k,i,j;
    cin>>n>>k;
    int a[n];
    bool dp[k+1] = {0};
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=a[0];i<=k;i++){
        int index = bs(a,i,n);
        // cout<<"i "<<i<<" index "<<index<<endl;
        bool ans = true;
        for(j=0;j<=index;j++)
            ans &= dp[i-a[j]];
        dp[i] = !ans;
    }
    if(dp[k]) cout<<"First";
    else
        cout<<"Second";
}

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

int main()
{
    int A[10001];
    int n,i=0;
    while (cin >> n) {
        if (n == 0)break;
        A[i] = n;
        i++;
    }
    for (int j = 0; j < i; j++) {
        cout << "Case " << j + 1 << ": " << A[j] << endl;
    }
    return 0;
}

Measured memory_bytes: 3020
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int n;
    cin>>n;
    map<int, int> cnt;
    rep(i, n) {
        int a;
        cin>>a;
        cnt[a]++;
    }

    int m = 0;
    rep(i, 100000) {
        chmax(m, cnt[i] + cnt[i + 1] + cnt[i + 2]);
    }
    cout<<m<<endl;
}

Measured memory_bytes: 4992
n,m=map(int,input().split())
a=list(map(int,input().split()))
s = sum(a)
a.sort()
a.reverse()

for i in range(n):
    if i >= m:
        print('Yes')
        exit()
    if a[i]*4*m < s:
        print('No')
        exit()
print('Yes')

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int dir = 0;
  int prev = a[0];
  int ans = 1;
  for (int i = 1; i < n; ++i) {
    int cur = a[i];
    if (dir == 0) {
      if (cur != prev) {
        dir = cur > prev ? 1 : -1;
      }
    } else if (dir == 1) {
      if (cur < prev) {
        ++ans;
        dir = 0;
      }
    } else if (dir == -1) {
      if (cur > prev) {
        ++ans;
        dir = 0;
      }
    }
    prev = cur;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 640
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     loopR(n,i,a)    for(int i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define		vii 			vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
#define     test(i)        cout<<i<<endl
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=3e2+10,oo=0x3f3f3f3f,mod=998244353;
const double PI = 3.14159265358979323846;

void solve(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int cnt=0;
    while(b<=a)
        b*=2,cnt++;
    while(c<=b)
        c*=2,cnt++;
    if(cnt<=k)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,i,j,count;
    cin >> n;
    vector<int> A(n);
    for(i=0;i<n;i++) cin >> A.at(i);
    int flag = 1;
    count = 0;
    while(flag){
        flag = 0;
        for(j=n-1;j>0;j--){
            if(A.at(j)<A.at(j-1)){
                swap(A.at(j),A.at(j-1));
                flag = 1;
                count++;
            }
        }
    }
    for(i=0;i<n;i++){
        if(i) cout << " " ;
        cout << A.at(i);
    }
    cout << endl << count << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    int x, y;
    cin >> x >> y;
    vector<int> a = {300000, 200000, 100000};
    vector<int> b = {300000, 200000, 100000};

    x--; y--;
    int ans = 0;
    if(x==0 and y==0){
        ans += 400000;
    }

    cout << ans + a[x] + b[y] << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>

using namespace std;

typedef long long INT;


bool f(INT N, INT H[]) {
    INT a = H[0];

    for(INT i=1; i<N; ++i) {
	INT b = H[i];

	if (b < a){
	    return false;
	}

	a = max(a, b-1);
    }

    return true;
}


int main() {
    static INT N, H[100000];
    cin >> N;

    for(INT i=0; i<N; ++i) {
	cin >> H[i];
    }
	
    cout << (f(N, H)? "Yes": "No") << endl;

    return 0;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

int ans[100000]; 

void judge(double x, double y, double n) {
    if (((x+y)*(x+y) + 4*(n-(x*x+y*y+x*y))) < 0) return;
    double z = (-(x+y) + sqrt((x+y)*(x+y) + 4*(n-(x*x+y*y+x*y)))) / (double)2;
    int intz = int(z);
    if ((intz == z) && (intz > 0)) {
        ans[(int)n]++;
    }
}

void solve() {
    int N; cin >> N;

    for (int n = 1; n <= N; n++) {
        for (int x = 1; x <= sqrt(n); x++) {
            for (int y = 1; y <= sqrt(n); y++) {
                judge((double)x, (double)y, (double)n);
            }
        }
        cout << ans[n] << '\n';
    }
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3592
//此程序使用了qt专属名称，请勿模仿。侵权必究！！！
//我真是太菜了…… 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1010,P=1<<30;
int n,a[N],ans=0;
inline int read()
{
	int sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();
	for(int i=1;i<=n;++i)
	{
		a[i]=read();
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=i+1;j<=n;++j)
		{
			ans+=a[i]*a[j];
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    s = str(s)
    p = int(p)
    l.append([s, p, i+1])
l = sorted(l, key=lambda x: (x[0], -x[1]))
for i in range(n):
    print(l[i][2])


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	if ((B - 1) % (A - 1) > 0)cout << (B - 1) / (A - 1) + 1;
	else cout << (B - 1) / (A - 1);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
long long int cal_pattern(int l, int r) {
	long long int n = r - l + 1;
	return n * (n + 1) / 2;
}
int main() {
	int n;
	std::cin >> n;
	std::vector<int> num(n);
	for (auto &a : num) std::cin >> a;
	int flag = num.front();
	auto l = 0;
	auto r = 0;
	int prev_r = -1;
	long long int sum = 0;
	while (true) {
		while (r + 1 < n && ((flag & num[r + 1]) == 0)) {
			flag |= num[++r];
		}
		sum += cal_pattern(l, r);
		if (l <= prev_r) sum -= cal_pattern(l, prev_r);
		prev_r = r;
		if (n == r + 1) break;
		while (l < n && ((flag & num[r + 1]) != 0)) {
			flag ^= num[l++];
		}
		if (n == l) break;
		flag |= num[++r];
	}
	std::cout << sum << std::endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

long long GCD(long long a, long long b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
    int K; cin >> K;
    ll sum = 0;
    srep(i,1,K+1)srep(j,1,K+1)srep(k,1,K+1) sum+=GCD(i,GCD(j,k));
    cout << sum << endl;
    return 0;
}
































Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    REP(i,1,9)REP(j,1,9){
        if(i*j==n){
            cout<<"Yes"<<endl;
            return;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 998244353
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}

vector<int> a;
int n,s;

int dp[3100][3100];

ll get(int i, int k){

    if(k==0 && i>=0) return power(2,i);
    if(i<0 || k<0) return 0;
    else{
        if(dp[i][k]!=-1) return dp[i][k];
        ll ans = 0;

        ans = ( ans + ( 2LL*get(i-1 , k) )%MOD )%MOD;

        ans = ( ans + get(i-1, k - a[i]))%MOD;
        return dp[i][k] = ans;
    }
}

void __sol(){
    cin >> n >> s; 
    a.assign(n+2,0);
    forr(i,n) cin >> a[i+1];
    memset(dp,-1,sizeof(dp));
   // forr(i,n) cout << a[i+1] <<" ";
     cout << get(n,s);
    return;
}


int main(){
    fastio
    ll tc=1;// cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 41368
import sys

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

S = s()

prev = S[0]
for i in range(1, len(S)):
    if prev == S[i]:
        print('Bad')
        sys.exit()
    prev = S[i]

print('Good')


Measured memory_bytes: 38448
#include<stdio.h>

int main()
{
    int a,b,c,count=0,i;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0)
            count++;
    }
    printf("%d\n",count++);
    return 0;
}



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

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

n = int(input())
a = readln()
c = sorted([[-a[i],i]for i in range(0,n)])
ans = [0 for i in range(0,n)]
front = c[0][1]
for i in range(1,n):
    ans[front] = ans[front] + i * (c[i][0] - c[i-1][0])
    if front > c[i][1]:
        front = c[i][1]

ans[front] = ans[front] + n * (-c[n-1][0])
for a in ans:
    print(a)


Measured memory_bytes: 27884
#pragma GCC optimize("O3")
#include <iostream>
#include <climits>
#include <stdlib.h>

using namespace std;

int main(void) {
    int a,b,k;

    cin >> a >> b;

    if ((a+b)%2) cout << "IMPOSSIBLE";
    else cout << (a+b)/2;

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

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

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

int main() {
  int s,t;
  cin >> s;
  t = 1;
  
  
  if(s == 1){
    cout << 4 << endl;
  }
  
  else if(s == 2){
    cout << 4 << endl;
  }
  
 else{
  for(int i=1; i<1e6+2; i++){
    if(s == 1){
      t++;
      break;
    }
    if(s%2 == 0){
      s /= 2;
      t++;
    }
    else{
      s = 3*s+1;
      t++;
    }
  }
   cout << t << endl;
 }
  
	return 0;
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  char a[] ={};
  cin >> a;
  
  char s,t,u,v;
  s = a[2];
  t = a[3];
  v = a[4];
  u = a[5];
  
  if(s == t && u ==v){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  
  }
  

  return 0;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,x,i,ans,count,l;cin >> n >> x;ans = 1;count = 0;
  for (i=0;i<n;i++){
    cin >> l;
    count += l;
    if (count <= x) ans += 1;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;

#[fastout]
fn main() {
    input! { ns: Chars }
    let sum = ns.iter().fold(0usize, |acc, &x| acc + (x as usize - 48));
    println!("{}", if sum % 9 == 0 { "Yes" } else { "No" });
}


Measured memory_bytes: 3040
D = int(input())
c = list(map(int, input().split()))
sdi = [list(map(int, input().split())) for i in range(D)]

#import numpy as np

lastdi = [0 for i in range(26)]
ans_c = []

d = 0
while True:
  if d == D:
    break
  if d > D - 2:
    day_s = sdi[d]
    
    sloss = [day_s[i] + c[i]*(d - lastdi[i]) for i in range(26) ]
    ans = sloss.index(max(sloss))
    ans_c.append( ans+1 )
    
    for i in range(26):
      if i != ans:
        lastdi[i] += 1
    lastdi[ans] = d
    d += 1
    
  else:
    
    a = [sdi[d][i] + sdi[d+1][i2] - sum([c[k]*( 2*d-lastdi[k]+1) for k in range(26) if k not in [i,i2]] ) -c[i] -c[i2]*(d-lastdi[i2]) for i in range(26) for i2 in range(26) ]
    idx = a.index(max(a))
    best_i2 = idx % 26 + 1
    best_i1 = (idx // 26) % 26 + 1
    
    ans_c.append(best_i1)
    ans_c.append(best_i2)
    lastdi[best_i1-1] = d
    lastdi[best_i2-1] = d+1
    
    d += 2

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

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int f(int a){
  int k=1;
  while (true){
    if (a%(int)powf(2,k)!=0) break;
    k++;
  }
  return k-1;
}

int main(){
  int N,ans;
  ans=0;
  cin>>N;
  for (int i=0;i<N;i++){
    int a;
    cin>>a;
    ans+=f(a);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "-1" << endl;return 0
#define MM <<" "<<
#define Endl endl

int N;
int A[214514];
    
bool BSsolve(int S){
    int B[214514];
    int D[214514]={};
    int El[214514]={},Er[214514]={};
    REP(i,2*N-1){
        if(S<=A[i]){
            B[i]=1;
        }else{
            B[i]=0;
        }
    }
    //REP(i,2*N-1){cout << B[i] << " ";}cout<< " " << S;cout << endl;
    REP(i,2*N-3){
        if((B[i]-B[i+1])*(B[i+1]-B[i+2])==-1){
            D[i+1]=2;
        }
    }
    REP(i,2*N-1){
        if(D[i]==2){
            B[i]=2;
        }
    }
    REP(i,2*N-1){
        El[i]=i;
        Er[i]=i;
    }
    REP(i,2*N-1){
        if(i==0||i==2*N-2)continue;
        if(B[i]==2){
            El[i]=El[i-1];
        }
    }
    RREP(i,2*N-1){
        if(i==0||i==2*N-2)continue;
        if(B[i]==2){
            Er[i]=Er[i+1];
        }
    }
    REP(i,2*N-1){
        if(B[i]==2){
            if(abs(i-El[i])<abs(i-Er[i])){
                B[i]=B[El[i]];
            }else{
                B[i]=B[Er[i]];
            }
        }
    }
    
    //REP(i,2*N-1){cout << D[i] << " ";}cout << endl;
    //REP(i,2*N-1){cout << B[i] << " ";}cout << endl;
    return !!B[N-1];
}

int BinarySearch(int m,int M,int count){
    int L=min(m,M),R=max(m,M),mid;
    L--;
    while(abs(R-L)>1&&count>0){
        mid=(L+R)/2;
        if(BSsolve(mid)){
            L=mid;
        }else{
            R=mid;
        }
        count--;
    }
    return L;
}

signed main(){
    cin >> N;
    REP(i,2*N-1){
        cin >> A[i];
        A[i]--;
    }
    //REP(i,2*N-1){cout << A[i] << " ";}cout << endl;
    cout << BinarySearch(0,2*N-2,INF)+1 << endl;
    return 0;
}   


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

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

    int A, B, C, D, train, bas;
    cin >> A >> B >> C >> D;

    if (A > B)
    {
        train = B;
    }
    else
    {
        train = A;
    }

    if (C > D)
    {
        bas = D;
    }
    else
    {
        bas = C;
    }

    cout << bas + train << endl;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	n = n - (n % 3);
	n /= 3;
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n,n){
        int sum = 0;
        for(int i = 1; i * i <= n; i++){
            if(n % i == 0 && i != n){
                sum+=i;
                if(n / i != i && n / i != n) sum+=n/i;
            }
        }
        if(sum > n){
            cout << "abundant number" << endl;
        }else if(sum < n){
            cout << "deficient number" << endl;
        }else{
            cout << "perfect number" << endl;
        }
    }
}

Measured memory_bytes: 1156
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
long long n; long long a[100009];
int main() {
	cin >> n;
	long long sum = 0;
	for (int i = 0; i < n; i++) cin >> a[i], sum += a[i];
	bool flag = true;
	if (sum % (n * (n + 1) / 2) != 0) flag = false;
	else {
		long long d = sum / (n * (n + 1) / 2);
		for (int i = 0; i < n; i++) {
			long long z = a[(i + 1) % n] - a[i];
			if (z > d) {
				flag = false;
			}
			else {
				long long w = (d - z) % n, x = (d - z) / n;
				if (w != 0 || x > d) {
					flag = false;
				}
			}
		}
	}
	cout << (flag ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
bool comp(int a,int b){
return a>b;
}
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
double dp[310][310][310];
int s[4],n;

double dfs(int a,int b,int c)
{
	if(a+b+c==0)
	return 0.0;
	if(dp[a][b][c]>-0.5)
	return dp[a][b][c];
	 double ks=(double)n/(a+b+c);
	 double res=0.0;
	 if(a){
	 	res+=(double)(dfs(a-1,b,c)+ks)*a/(a+b+c);
	 }
	 if(b){
	 		 	res+=(dfs(a+1,b-1,c)+ks)*b/(a+b+c);

	 }
	 if(c)
	 {
	 		 	res+=(dfs(a,b+1,c-1)+ks)*c/(a+b+c);

	 }
	 
	 return dp[a][b][c]=res;
	
}
int main()
{
	fast;
	//int n;
	cin>>n;
//	int s[4];
s[1]=0,s[2]=0,s[3]=0;
	rep(i,0,n)
	{
		int h;
		cin>>h;
		s[h]++;

	}
rep(i,0,310){

rep(j,0,310)
{
rep(k,0,310)
{
dp[i][j][k]=-1;
}}}//cout<<s[1]<<endl;
	double res=dfs(s[1],s[2],s[3]);
 	printf("%.12f\n",res);
	
	
	
	
	


}



Measured memory_bytes: 233088
#include<stdio.h>
int main(void){
  int l,i,cnt=0;
  scanf("%d",&l);
  int num[l];
  for(i=0;i<l;i++){
    scanf("%d",&num[i]);
  }
  for(i=1;i<l-1;i++){
    if(num[i-1]<num[i]&&num[i]<num[i+1]){
      cnt++;
    }else if(num[i-1]>num[i]&&num[i]>num[i+1]){
      cnt++;
    }else{
      continue;
    }
  }
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//解説AC 
int main() {
int n;
cin >> n;
vector <vector<int>> v(n+1,vector<int>(3));
vector <vector<int>> dp(n+1,vector<int>(3,0));

for (size_t i = 1; i <= n; i++)
{
cin >> v.at(i).at(0) >> v.at(i).at(1) >> v.at(i).at(2);
}


for (size_t i = 1; i <= n; i++)//1-indexedにする(1はじまり)
{
  //a
  dp[i][0]=max(dp[i-1][1],dp[i-1][2])+v[i][0];
  //b
  dp[i][1]=max(dp[i-1][0],dp[i-1][2])+v[i][1];
  //c
  dp[i][2]=max(dp[i-1][0],dp[i-1][1])+v[i][2];  
}

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

return 0;
}


Measured memory_bytes: 11136
N, M = map(int, input().split())
S = input()
T = input()
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

gc = gcd(max(N, M), min(N, M))
for i in range(gc):
    if S[i*N//gc] != T[i*M//gc]:
        print(-1)
        exit()
print(N*M//gc)

Measured memory_bytes: 3316
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func main() {
  text := nextLine()
  
  n, _ := strconv.Atoi(text)

  as := []int{}
  sortas := []int{}
  for i := 1; i <= n; i++ {
    t := nextLine()
    a, _ := strconv.Atoi(t)
    as = append(as, a)
    sortas = append(sortas, a)
  }
  
  sort.Ints(sortas)
  max := sortas[len(sortas)-1]
  nextMax := sortas[len(sortas)-2]
  	
  for i := 0; i <= n-1; i++ {
    target := as[i]
    
    if max == target {
      fmt.Println(nextMax)
    } else {
      fmt.Println(max)
    }
  }
}

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

long f(long x);

int main(void)
{
    long h, w;
    cin >> h >> w;

    if(h==1||w==1)
    {
        cout << 1 << endl;
        return 0;
    }

    cout << f(w) * f(h) + f(w - 1) * f(h - 1) << endl;
    return 0;
}

long f(long x)
{
    return (x + (x % 2)) / 2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N,p,q,x,min=-1,count=0;
  cin>>N;
  for(int i=0;i<N;i++)
  {
    cin>>x;
    if(x==1){p=i+1;min=1;count=1;break;}
  }
  q=p;
  for(int i=0;i<N-q;i++)
  {
    cin>>x;
    if(x==min+1){min++;p=i+q;if(x!=p+2){count++;}}
  }
  if(min==-1){cout<<-1<<endl;}
  else{cout<<N-count<<endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll findTrailingZeros(ll n)
{
    ll cnt = 0;
    for (ll i = 5; n / i >= 1; i *= 5)
        cnt += n / i;

    return cnt;
}
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll t;
	t=1;
	while(t--)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        swap(a,b);
        swap(a,c);
        cout<<a<<" "<<b<<" "<<c;

    }
}


Measured memory_bytes: 256
// A - Connection and Disconnection
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll f(const string &S){//文字列の操作回数を求める
	ll c = 0;
	for(int i=1; i < S.size(); ++i) if(S[i-1] == S[i]) c++, i++;
	return c;
}

int main(){
	string S; cin>>S;
	ll K; cin>>K;

	ll s1 = f(S);//K=1 のときの操作回数
	ll s2 = f(S+S);//K=2 のときの操作回数
	ll s3 = f(S+S+S);//K=3 のときの操作回数

	ll d1 = s2 - s1;//K=2 と K=1 の操作回数の差分
	ll d2 = s3 - s2;//K=3 と K=2 の操作回数の差分
	ll d = d1 + d2;

	ll ans = 0;
	//ここからは等差数列の問題
	if(d1 == d2) ans = s1 + d1 * (K-1);
	else
		if(K % 2) ans = s1 + d * ((K+2-1)/2-1);//(k/2):roundup
		else ans = s2 + d * (K/2-1);
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#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>;

vector<bool> dislike(10, false);

bool isOK(int p) {
  while (p) {
    int d = p % 10;
    if (dislike[d]) return false;
    p /= 10;
  }
  return true;
}

int main() {
  int n, k;
  cin >> n >> k;
  rep(i, k) {
    int d;
    cin >> d;
    dislike[d] = true;
  }

  int pay = n;
  while (!isOK(pay)) pay++;
  cout << pay << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <utility>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if(b==c)
      cout << a << "\n";
    if(c==a)
      cout << b << "\n";
    if(a==b)
      cout << c << "\n";
    return 0;
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    
    int N;
    cin >> N;
    int a;
    a = N-N/2;
    cout << (float)a/N << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
#define maxn 200005
struct Node
{
    int x;
    int num;
    bool operator < (const Node &a)
    {
        return num>a.num;
    }
};
map<int,int> vis;
Node node[maxn];
int main()
{
    int n,k,x,cnt;
    scanf("%d%d",&n,&k);
    cnt=0;
    for(int i=0; i<n; i++)
    {
        scanf("%d",&x);
        if(!vis[x])
        {
            node[cnt++].x=x;
        }
        vis[x]++;
    }
    if(cnt<=k)
        printf("0\n");
    else
    {
        for(int i=0; i<cnt; i++)
        {
            node[i].num=vis[node[i].x];
        }
        sort(node,node+cnt);
        int sum=0;
        for(int i=k;i<cnt;i++)
            sum+=node[i].num;
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    while(n)
    {
        int k=n%10;
        if(k==7)
        {
            cout<<"Yes";
            return 0;
        }
        n=n/10;
    }
    cout<<"No";
    return 0;
}

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

using namespace std;
typedef long long ll;

ll N, A, B;

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

    cin >> N >> A >> B;
    ll cans = N / (A + B) * A;
    cout << cans + min (A, N % (A + B)) << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    int num[n];
    rep(i,n){
        int p;
        cin >> p;
        p--;
        num[p] = i;
    }
    rep(i,n){
        cout << num[i]+1 << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 3920