akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UI;

using namespace std;

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

    string s;
    cin >> s;
    
    sort(s.begin(), s.end());

    s.erase(unique(s.begin(), s.end()), s.end());

    char x = 'a';

    for(const char& item : s)
    {
        if (x != item)
        {
            cout << x << endl;
            return 0;
        }
        if (item == 'z')
        {
            cout << "None" << endl;
            return 0;
        }
        ++x;
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 512
import Control.Monad
import Data.Array.IO
import Data.Array.Unboxed

type Idx = (Int,Int,Int)
type IODp = IOUArray Idx Int

main = do
    [n,a] <- map read.words<$>getLine::IO[Int]
    xs <- map read.words<$>getLine::IO[Int]
    let nx = n * maximum (a:xs)
    dp <- newArray ((0,0,0),(n,n,nx)) 0 :: IO IODp
    forM_ [(j,k,s)|s<-[0..nx],k<-[0..n],j<-zip [0..] (0:xs)] $ \idx -> do
        case idx of
            ((j,_),0,0) -> writeArray dp (j,0,0) 1
            ((j,xj),k,s) | j>0, s<xj       -> readArray dp (j-1,k,s) >>= writeArray dp (j,k,s)
            ((j,xj),k,s) | j>0, k>0, s>=xj -> liftM2 (+) (readArray dp (j-1,k,s)) (readArray dp (j-1,k-1,s-xj)) >>= writeArray dp (j,k,s)
            otherwise -> return ()
    print.sum =<< mapM (\k -> readArray dp (n,k,k*a)) [1..n]

{-
dp(j,k,s) -> [x1..xj]からk集めた合計がsになる総数

dp(*,0,0) = 1
dp(j,k,s) = dp(j-1,k,s)                    , j>=1, s<xj
dp(j,k,s) = dp(j-1,k,s) + dp(j-1,k-1,s-xj) , k>=1, j>=1, s>=xj
other = 0
-}

Measured memory_bytes: 52220
n = int(input())
a = [int(i) for i in input().split()]
#pattern1
temp = a[0]
ans1 = 0
if temp <= 0:
    ans1 += abs(temp) + 1
    temp = 1
for i in range(1, n):
    if temp*(temp + a[i]) < 0:
        temp += a[i]
    else:
        if temp > 0:
            ans1 += (temp + a[i] + 1)
            temp = -1
        elif temp < 0:
            ans1 += abs(temp + a[i]) + 1
            temp = 1
#pattern2
temp = a[0]
ans2 = 0
if temp >= 0:
    ans2 += abs(temp) + 1
    temp = -1
for i in range(1, n):
    if temp*(temp + a[i]) < 0:
        temp += a[i]
    else:
        if temp > 0:
            ans2 += (temp + a[i] + 1)
            temp = -1
        elif temp < 0:
            ans2 += abs(temp + a[i]) + 1
            temp = 1
ans = min(ans1, ans2)
print(ans)

Measured memory_bytes: 14332
#include <stdio.h>
int main(){
    double f;
    int a,b,d,r;
    a=b=f=d=r=0;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double) a/(double) b;
    printf("%d ",d);
    printf("%d ",r);
    printf("%lf\n",f);
    return 0;
}

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

dist = [-1 for i in range(n)]
dist[0] = 0

now_town = 0
flg = 0  # ループが生じているかを判定するフラグ
for i in range(k):
    # print(i)
    next_town = a[now_town] - 1
    if dist[next_town] != -1:
        flg = 1
        diff = (i+1) - dist[next_town]
        const = dist[next_town]
        break
    dist[next_town] = i + 1
    now_town = next_town

# print(dist)
# print("diff", diff)
# print("const", const)

if flg == 0:
    print(next_town+1)
elif flg == 1:
    c = (k - const) % diff
    # print("c =", c)
    # print("next_town = ", next_town)
    if c == 0:
        print(next_town+1)
    else:
        now_town = next_town
        # print(now_town)
        for i in range(c):
            next_town = a[now_town] - 1
            now_town = next_town
            # print(now_town)
        print(now_town+1)


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


int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll money = 1000;

  for(int cur=0;cur+1<n;cur++) {
    int diff = a[cur+1] - a[cur];
    if(diff < 0) {
      continue;
    }
    // 買えるだけ買って次の日売る
    ll num = money / a[cur];
    money = money - num * a[cur] + num * a[cur+1];
  }
  cout << money << endl;
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b,int m) {
    if (b==0) return 1;
    ll c = power(a,b>>1,m);
    c = (c*c)%m;
    if (b&1) return (c*a)%m;
    return c;
}
ll powerwithoutmod(ll a,ll b) {
    if (b==0) return 1;
    ll c = powerwithoutmod(a,b>>1);
    c = (c*c);
    if (b&1) return (c*a);
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int Q = 301;
const int logN = 16;

string s;
int cnt[N],dp[N];
ll ret2(string s, int n) {
    ll ret = 0;
    REP(i,0,n-1) {
        if (s[i]%2==0) {
            ret += (i+1);
        }
    }
    return ret;
}
ll ret5(string s, int n) {
    ll ret = 0;
    REP(i,0,n-1) {
        if (s[i]=='0' || s[i]=='5') {
            ret += (i+1);
        }
    }
    return ret;
}
void solve() {
    int n,p;
    cin>>n>>p>>s;
    if (p==2) {
        cout<<ret2(s,n);
        return;
    }
    else if (p==5) {
        cout<<ret5(s,n);
        return;
    }
    reverse(all(s));
    int pv = 1;
    ll ans = 0;
    cnt[0]++;
    REP(i,1,n) {
        dp[i] = (dp[i-1] + (pv*(s[i-1]-'0')))%p;
        pv = (pv*10)%p;
        ans += cnt[dp[i]];
        cnt[dp[i]]++;
    }
    cout<<ans;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 1428
from sys import stdin
import sys
##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    N = ri()
    S = rs()
    l = []
    l.append(S[0])
    for i in range(1,N):
        if S[i] != l[len(l) - 1]: l.append(S[i])
    print (len(l))


if __name__ == "__main__":
    main()


Measured memory_bytes: 4092
n = m = int(input())
i = 2
while i ** 2 <= n:
    if n % i == 0:
        m = m // i * (i - 1)
        while n % i == 0:
            n //= i
    i += 1
if n != 1:
    m = m // n * (n - 1)
print(m)


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

char fi[105][105];
int n,m;
bool ix[105];
bool iy[105];

int main()
{
cin >> n >> m;
for(int i=1;i<=n;i++)
{
getchar();
for(int j=1;j<=m;j++)
{
scanf("%c",&fi[i][j]);
if(fi[i][j] == '#')
{
ix[i] = 1;
iy[j] = 1;
}
}
}
for(int i=1;i<=n;i++)
{
if(!ix[i]) continue;
for(int j=1;j<=m;j++)
{
if(!iy[j]) continue;
printf("%c",fi[i][j]);
}
printf("\n");
}
return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll x;
  cin >> x;

  ll A, B;

  for(ll a = -1000; a <= 1000; a++){
    for(ll b = -1000; b <= 1000; b++){

      if(a*a*a*a*a - b*b*b*b*b == x){
        A = a;
        B = b;
        break;
      }

    }
  }

  cout << A << " " << B << endl;

  
  return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#define PI 3.14159265358979323846

int main(void) {

	int A, B;
	scanf("%d%d", &A, &B);
	char S[12];
	scanf("%s", S);

	int count = 0;

	 if (S[A] == '-') {

		for (int i = 0; i < strlen(S); i++) {
			if (i != A) {
				if (S[i] >= 48 && S[i] <= 57) {
					count++;
				}
				else {
					printf("No");
					break;
				}
			}
		}
	}
	else {
		printf("No");
	}
	
	 if (count == A + B) {
		 printf("Yes");
	}
	
	
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int b, f, r, v;;
	int house[5][4][11];
	int i, n;

	for (b = 1; b <= 4; b++) {
		for (f = 1; f <= 3; f++) {
			for (r = 1; r <= 10; r++) house[b][f][r] = 0;
		}
	}
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d%d%d%d", &b, &f, &r, &v);
		house[b][f][r] += v;
	}

	for (b = 1; b <= 4; b++) {
		for (f = 1; f <= 3; f++) {
			for (r = 1; r <= 10; r++) printf(" %d", house[b][f][r]);
			putchar('\n');
		}
		if (b < 4) puts("####################");
	}
	return 0;
}



Measured memory_bytes: 2108
import sys


def inp():
    return sys.stdin.readline().strip()


n, q = map(int, inp().split())
s = inp()
a = [0] * n

for i in range(1, n):
    if s[i-1] == 'A' and s[i] == 'C':
        a[i] = a[i-1] + 1
    else:
        a[i] = a[i-1]

for _ in range(q):
    l, r = map(int, inp().split())
    print(a[r-1] - a[l-1])

Measured memory_bytes: 53336
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long int ll;

int main() {
  int A,B;
  cin>>A>>B;
  
  int ans=0;
  if(B!=1){
    for(int i=0;i<B;++i){
      int l=(A-1)*i+A;
      ++ans;
      if(l>=B)
        break;
    }
  }
  
  cout<<ans<<endl;
}


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

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var s = ReadLine();

            var lr = s.Substring(0, (s.Length-1) / 2);
            var ll = s.Substring(((s.Length+3)/2)-1);

            Console.WriteLine((lr==ll) ? "Yes" : "No");
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    string s;
    cin >> s;
    int n = s.length();
    int cnt0 = 0, cnt1 = 0;
    int res = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == '0'){
            ++cnt0;
            if(cnt0 < cnt1){
                res += 2 * cnt0;
                cnt1 -= cnt0;
                cnt0 = 0;
            }
            else{
                res += 2 * cnt1;
                cnt0 -= cnt1;
                cnt1 = 0;
            }
        }
        else{
            ++cnt1;
            if(cnt1 < cnt0){
                res += 2 * cnt1;
                cnt0 -= cnt1;
                cnt1 = 0;
            }
            else{
                res += 2 * cnt0;
                cnt1 -= cnt0;
                cnt0 = 0;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 512
k = int(input())
l= [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])

Measured memory_bytes: 3060
import std.stdio;
import std.algorithm;
import std.range;
import std.typecons;

void main(){
    int h, w;
    while(~scanf("%d%d", &h, &w)){
        int[1010][1010] to;
        int[1010][1010] g;
        alias Tuple!(int,int) idx;
        idx[] ds;
        foreach(i; 0..h){
            foreach(j; 0..w){
                scanf("%d", &g[i][j]);
                ds ~= idx(i, j);
            }
        }
        ds.sort!((a, b) => g[a[0]][a[1]] < g[b[0]][b[1]]);

        foreach(r; to) r[] = -1;

        int ans = 0;
        foreach(t; ds){
            int i = t[0], j = t[1];
            int[] s = [];
            foreach(d; [[0,1],[0,-1],[1,0],[-1,0]]){
                int ni = i + d[0];
                int nj = j + d[1];
                if(0 <= ni && ni < h && 0 <= nj && nj < w){
                    if(g[ni][nj] < g[i][j]){
                        s ~= to[ni][nj];
                    }
                }
            }
            s = uniq(sort(s)).array;
            if(s.length == 0){
                to[i][j] = g[i][j];
            } else if(s.canFind(-10)){
                to[i][j] = -10;
            } else {
                to[i][j] = s.length == 1 ? s[0] : -10;
            }
            ans += to[i][j] == -10;
        }
        writeln(ans);
    }
}

Measured memory_bytes: 23280
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> as;
  map<ll, ll> count;
  for (auto i = 0; i < N; i++) {
    ll x;
    cin >> x;
    if (count.find(x) == count.end()) count[x] = 0;
    count[x]++;
  }
  for (auto x : count) {
    as.push_back(x.second);
  }
  sort(as.begin(), as.end(), greater<ll>());
  ll res = 0;
  for (auto i = K; i < as.size(); i++) {
    res += as[i];
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 14964
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int inf = 1000000009;
int i, j, k, m, n, l;
int ans, a[1000];

int main() {
	//freopen("x.in", "r", stdin);
	cin >> n; n *= 2;
	F0(i, n) cin >> a[i];
	sort(a, a + n);
	for (int i = n - 2; i >= 0; i -= 2) ans += a[i];
	cout << ans << endl;

	return 0;
}


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

int main() {
  string s; cin>>s;
  ll bc=0, ans=0;
  rep(i,s.size()) {
    if (s[i] == 'B') bc++;
    else ans+=bc;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
N=int(input())
L=list(map(int,input().split()))
count=0 
for i in range(N):
	for j in range(i+1, N):
		for k in range(j+1, N):
			if L[i]!=L[j] and L[i]!=L[k] and L[j]!=L[k]:
				if L[i]+L[j]>L[k] and L[i]+L[k]>L[j] and L[k]+L[j]>L[i]:
					count+=1
print(count)

Measured memory_bytes: 68228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll L, N;
    cin >> N >> L;
    vector<string> S(N);
    rep(i, 0, N) cin >> S[i];
    sort(S.begin(), S.end());
    rep(i, 0, N) cout << S[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
# Problem C - Synthetic Kadomatsu

# input
N, A, B, C = map(int, input().split())
l_list = [0]*N
for i in range(N):
    l = int(input())
    l_list[i] = l

# dfs search
class DFS:

    def __init__(self, l_list, N, A, B, C):
        self.l_list = l_list
        self.N = N
        self.A = A
        self.B = B
        self.C = C
        self.INF = float('INF')
        self.ans = float('INF')

    def get_ans(self):
        return self.ans

    def dfs(self, n, a, b, c):
        if n==self.N:
            if not a==0 and not b==0 and not c==0:
                return abs(a-self.A) + abs(b-self.B) + abs(c-self.C)
            else:
                return self.INF

        # 今ある竹を利用しない場合
        self.ans = min(self.ans, self.dfs(n+1, a, b, c))

        # A, B, C を利用する場合
        if a==0:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a+self.l_list[n], b, c) + 10)

        if b==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b+self.l_list[n], c) + 10)

        if c==0:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]))
        else:
            self.ans = min(self.ans, self.dfs(n+1, a, b, c+self.l_list[n]) + 10)

        return self.ans

# calc
dfs_obj = DFS(l_list, N, A, B, C)
dfs_obj.dfs(0, 0, 0, 0)

# output
print(dfs_obj.get_ans())


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

int main()
{
vector<int>ans(3);
for(int i = 0; i < 3; i++ ){
    cin >> ans[i];
}
sort(ans.begin(),ans.end());
reverse(ans.begin(),ans.end());
int total =ans[0]*10+ans[1] + ans[2];

cout << total << endl;

}


Measured memory_bytes: 256
/*
 * 17-05-06_AGC014_A.cpp
 *
 *  Created on: 2017/05/06
 *      Author: ryoma
 */

#include<iostream>

using namespace std;

int A,B,C;
int A0,B0,C0,S;

int ans;

bool even(int a,int b,int c){
	return !(1&(a|b|c));
}

int main(){
	cin >> A0 >> B0 >> C0;
	A = A0;
	B = B0;
	C = C0;
	S =A0+B0+C0;
	while(even(A,B,C)){
		ans++;
		A = (S-A)/2;
		B = (S-B)/2;
		C = (S-C)/2;
		//cout << "A "<<A << "B "<<B << "C "<< C << endl;
		if(A==A0 && B == B0 && C == C0)
		{
			ans =-1;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int A, B, T;
    cin >> A >> B >> T;
    int X = T / A;
    cout << B*X;
}

Measured memory_bytes: 256
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
//ll a[MAX],b[MAX];

int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

string s,t;
cin >> s >> t;
ll ans = 0;
n = s.size();
fr(i,0,n)
	if(s[i]!=t[i])
		ans++;
cout << ans;
eNd();
  return 0;
 
}


Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>

using namespace std;

const int maxn = 102;

int n;
bool isPrime[maxn];

vector<int> p, freq;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
	if (n < 10) {
		cout << 0 << endl;
		return 0;
	}

	isPrime[2] = true;
	for (int i = 3; i <= n; i += 2)
		isPrime[i] = true;

	for (int i = 2; i <= n; ++i)
		if (isPrime[i]) {
			p.push_back(i);
			for (int j = i+i; j <= n; j += i)
				isPrime[j] = false;
		}

	freq = vector<int>(p.size());

	for (int i = 2; i <= n; ++i) {
		int cur = i;
		for (int j = 0; j < p.size(); ++j) {
			if (p[j] > cur)
				break;

			// if (cur % p[j] == 0)
			// 	printf("%d %d\n", i, p[j]);

			while (cur % p[j] == 0) {
				++freq[j];
				cur /= p[j];
			}
		}
	}

	int count2 = 0, count4 = 0, count14 = 0,
	 count24 = 0, count74 = 0;

	for (int i = 0; i < freq.size(); ++i) {
		if (freq[i] >= 74)
			++count74;

		if (freq[i] >= 24)
			++count24;

		if (freq[i] >= 14)
			++count14;
		
		if (freq[i] >= 4)
			++count4;
		
		if (freq[i] >= 2)
			++count2;
	}

	// printf("%d %d %d %d %d\n", count2, count4, count14, count24,count74);

	int ans = 0;
	if (count74)
		ans = count74;

	if (count24)
		ans += count24 * (count2 - count24) + count24 * (count24-1);

	if (count14)
		ans += count14 * (count4 - count14) + count14 * (count14-1);

	// if (count4 >= 3)
		// ans += count4 * (count4-1) * (count4-2) / 2;

	// if (count4 >= 2)
		// ans += count4 * (count4-1) * (count2 - count4) / 2;
	ans += count4 * (count4-1) * (count2 - 2) / 2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
typedef long long int lli;
typedef unsigned long long int uli;
using namespace std;
int main(){
  uli h,n,sum;
  cin>>h>>n;
  rep(i,0,n){
    uli a;
    cin>>a;
    sum+=a;
  }
  if(sum>=h){
    ou("Yes");
    return 0;
  }
  /*
  rep(i,0,n-1){
    rep(j,i+1,n){
      if(sum>=h){
        ou("Yes");
        return 0;
      }
    }
  }*/
  ou("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
  char s[200];
  int a;
  cin>>s;
  for(int i=0;i<10;i++){
    if(s[i]=='A'){
      a=i;
    }
    if(s[i]=='C')
      if(a+1==i){
	cout<<"Yes"<<endl;
	return(0);
      }
  }
  cout<<"No"<<endl;
  return(0);
}
    


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  ll n;
  cin >> n;
  
  ll ans = 10;
  FOR(i,1,sqrt(n)+1){
    if(n%i == 0){
      ll cnt = 0,num = n/i;
      while(num != 0){
        num /= 10;
        cnt++;
      }
      ans = min(ans,cnt);
    }
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
def inpl(): return list(map(int, input().split()))

N, K = inpl()
A = inpl()
MOD = 10**9+7
ans = 0
for i in range(N):
    d0 = 0
    d1 = 0
    for j in range(i):
        d0 += A[i] > A[j]
    for j in range(i, N):
        d1 += A[i] > A[j]
    ans = (ans + K*(d1 + d1*K)//2 + (K-1)*(d0 + d0*(K - 1))//2)%MOD

print(ans)

Measured memory_bytes: 42860
# #二項係数(mod)
def comb(n, k, mod, fac, finv):
    if n < k or n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod

# 階乗の逆元(mod)
def factorials_inv_mod(n, mod):
    inv = [1] * (n + 1)
    factorials_inv = [1] * (n + 1)
    for i in range(2, n + 1):
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        factorials_inv[i] = factorials_inv[i - 1] * inv[i] % mod
    return factorials_inv

# 階乗(mod)
def factorials_mod(n, mod):
    factorials = [1] * (n + 1)
    for i in range(2, n+1):
        factorials[i] = (factorials[i-1] * i) % mod
    return factorials

MOD = 1000000007
x, y = map(int, input().split())
if (x + y) % 3 != 0:
  print(0)
  exit()
k = (x + y) // 3
fac = factorials_mod(k, MOD)
finv = factorials_inv_mod(k, MOD)
print(comb(k, x-k, MOD, fac, finv))

Measured memory_bytes: 82164
#include <iostream>
#include <stdio.h>
using namespace std;

void selectionSort(int array[],int N,int& change_count) {
    int i, j;
    int swapCount = 0;
    int mini=0;
    for (i = 0; i < N - 1; i++) {
        mini = i;
        for (j = i+1; j < N; j++) {
            if (array[j] < array[mini]) {
                mini = j;
               
            }
        }
        if (i != mini) {
            swap(array[i], array[mini]);
            change_count++;
        }

    }
}

int main() {
    int N;
    int* a;
    int change_count = 0;
    cin >> N;
    a = new int[N];

    for (int i = 0; i < N; i++) cin >> a[i];

    selectionSort(a,N,change_count);
    for (int i = 0; i < N; i++) {
        if (i != N - 1) {
            printf("%d ", a[i]);
        }
        else {
            printf("%d\n", a[i]);
        }
    }
    printf("%d\n", change_count);
    delete[] a;

}


Measured memory_bytes: 3228
#include<stdio.h>

int main(){
	int s,t,a,b;
	s=0;
	t=0;
	for(a=0;a<4;a++){
		scanf("%d",&b);
		s+=b;
	}
	for(a=0;a<4;a++){
		scanf("%d",&b);
		t+=b;
	}
	if(s<t){
		printf("%d\n",t);
	}else{
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	nums := map[int]struct{}{}
	for i := 0; i < n; i++ {
		var a int
		fmt.Scanf("%d", &a)
		if _, ok := nums[a]; ok {
			delete(nums, a)
		} else {
			nums[a] = struct{}{}
		}
	}

	fmt.Printf("%d\n", len(nums))
}


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

int main(void) {
	int K; cin >> K;
	long long res = 0;
	for (int a = 1; a <= K; a++) {
		for (int b = 1; b <= K; b++) {
			for (int c = 1; c <= K; c++) {
				res += gcd(gcd(a, b), c);
			}
		}
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3636
s=list(input())
t=list(input())
flag=False
cnt=0
if sorted(s)==sorted(t):
  a=s.index(t[0])
  for i in range(len(s)):
    b=i+a
    if b>=len(s):
      b-=len(s)
    if s[b]==t[i]:
      cnt+=1

if cnt==len(s):
  flag=True
print('Yes' if flag else 'No')


Measured memory_bytes: 3064
from numpy import *
n,M=map(int,input().split())
l=n*3+1
d=zeros((l,n*5),int64)
d[0][0]=1
for i in range(1,l):j,k=i-1,i-2;d[i]=(d[i-3]*k*j+roll(d[k],-1)*j+roll(d[j],1))%M
print(sum(d[-1][:l])%M)


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

ll a[maxn], sub[maxn];

void solve() {
    ll k, n, res = 0;;
    cin >> k >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sub[n] = a[1] - a[n] + k;
    for (int i = 1; i < n; i++) sub[i] = a[i + 1] - a[i];
    for (int i = 1; i <= n; i++) res = max(res, sub[i]);
    cout << k - res << endl;
}

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


Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
struct a{
  string s;
  li x;
};

void longestpallindrome(string s)
{
  li i,j,k;
  li n=s.length();
  bool table[n][n];
  memset(table,0,sizeof(table));
  for(i=0;i<n;i++)
  table[i][i]=1;
  li maxlength=1;
  li start=0;
  for(i=0;i<n-1;i++)
  {
    if(s[i]==s[i+1])
    {
      table[i][i+1]=1;
      if(maxlength<2)
      {maxlength=2;
      start=i;
       }
    }
  }
  for(k=3;k<=n;k++)
  {
    for(i=0;i<n-k+1;i++)
    {
      li j=i+k-1;

      if(table[i+1][j-1]&&s[i]==s[j])
      {
        table[i][j]=1;
        if(k>maxlength)
        {
          maxlength=k;
          start=i;
        }
      }
    }
  }
  cout<<s.substr(start,maxlength);
}

int main()
{
fast_io
li n,m;
cin>>n>>m;
cout<<(n*(n-1))/2+(m*(m-1))/2;
return 0;
}


Measured memory_bytes: 256
S = input()
cnt = 0
s = S[0]
for i in range(1, len(S)):
    si = int(S[i])
    #print(s, si)
    if int(s) == int(si):
        #print("hit")
        s = 1 - si
        cnt += 1
    else:
        s = si

# reverse first
cnt2 = 1
s = 1 - int(S[0])
for i in range(1, len(S)):
    si = int(S[i])
    #print(s, si)
    if int(s) == int(si):
        #print("hit")
        s = 1 - si
        cnt2 += 1
    else:
        s = si

#print(cnt, cnt2)
print(min(cnt, cnt2))

Measured memory_bytes: 3316
/*
 *  C - Maximal Value
 * author: roy4801
 * (C++)
 */
#include <bits/stdc++.h>

using namespace std;

#define PROB "C"
#define TESTC ""

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;
#define F first
#define S second
#define INF 0x3f3f3f3f
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PPB pop_back
#define PF push_front
#define PPF pop_front
#define N 100
int n;
int b[N+5];
int main()
{
	#ifdef DBG
	freopen("./testdata/" PROB TESTC ".in", "r", stdin);
	freopen("./testdata/" PROB ".out", "w", stdout);
	#endif
	while(cin >> n)
	{
		for(int i = 1; i <= n-1 && cin >> b[i]; i++);

		int sum = 0;
		for(int i = 0; i < n; i++)
		{
			if(i == 0)
				sum += b[1];
			else if(i == n-1)
				sum += b[n-1];
			else
				sum += min(b[i], b[i+1]);
		}
		cout << sum << '\n';
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long[] cum = new long[n];
		a[0] = cum[0] = sc.nextLong();
		for(int i = 1; i < n; i++) {
			a[i] = sc.nextLong();
			cum[i] = cum[i - 1] + a[i];
		}
		long ans = Long.MAX_VALUE;
		for(int i = 0; i < n - 1; i++) {
			ans = Math.min(ans, Math.abs(cum[i] - cum[n - 1] + cum[i]));
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 80092
import java.util.Scanner;
public   class Main {
    
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int le[]=new int[n];
		int max_length=0;
		int max_number=-1;
		int sum=0;
		for (int i = 0; i < n; i++) {
			le[i]=sc.nextInt();
			sum+=le[i];
			if(le[i]>max_length) {
				max_length=le[i];
				max_number=i;
			}
		}
		sum-=max_length;
		System.out.println(sum>max_length?"Yes":"No");
		
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int n;
    cin>>n;
    vector<int> as(n);
    rep(i, n) cin>>as[i];
    int m;
    cin>>m;
    vector<int> bs(m);
    rep(i, m) cin>>bs[i];

    if (bs > as) cout<<1<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 3176
INF = 9999999

while (n = gets.to_i) != 0
  a,b,c = n.times.map{gets.split.map(&:to_i)}.transpose
  vs = 0
  for i in 0..(n-1)
    vs = [vs, a[i], b[i]].max
  end
  nds = Array.new(vs+1).map{Array.new(0)}
  for i in 0..(n-1)
    nds[a[i]].push([b[i], c[i]])
    nds[b[i]].push([a[i], c[i]])
  end
  
  dist = Array.new(vs+1).map{Array.new(vs+1, INF)}
  for i in 0..(n-1)
    dist[a[i]][b[i]] = c[i]
    dist[b[i]][a[i]] = c[i]
  end
  for id in 0..vs
    dist[id][id] = 0
  end
  
  for k in 0..vs
    for i in 0..vs
      for j in 0..vs
        if dist[i][j] > dist[i][k]+dist[k][j]
          dist[i][j] = dist[i][k]+dist[k][j]
        end
      end
    end
  end
  
  sum = Array.new(vs+1, 0)
  for i in 0..vs
    for j in 0..vs
      sum[i] += dist[i][j]
    end
  end
  
  anssum = INF
  minid = 0
  for i in 0..vs
    if anssum > sum[i]
      anssum = sum[i]
      minid = i
    end
  end
  puts "#{minid} #{anssum}"
end


Measured memory_bytes: 6868
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true) {
			int n=sc.nextInt();
			int x=sc.nextInt();
			int a=0;
			if(n==0 && x==0) {
				break;
			}else {
			for(int i=1;i<=n;i++) {
				for(int j=1;j<=n;j++) {
					for(int k=1;k<=n;k++) {
						if(i+j+k==x) {
							if(i<j && j<k) {
							a+=1;

							}
						}
					}
				}
			}System.out.println(a);
			}

		}
	}
}


Measured memory_bytes: 26900
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define mod(x) ((x % MOD) + MOD) % MOD
#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int,int> P;

const int INF = 1e18;
const int MOD = 1e9+7;
const int MAX_A = 1e9+1;

class BIT
{
  private:
    vector<int> bit;
    int a, b, len;
  public:
    BIT(int m, int n);
    void add(int i, int x);
    int sum(int i);
};

BIT::BIT(int m, int n) {
  a = m; b = n;
  len = b-a+2;
  bit = vector<int>(b-a+2);
}
void BIT::add(int i, int x) {
  i -= a-1;
  while (i <= len) {
    bit[i] += x;
    i += i & -i;
  }
}
int BIT::sum(int i) {
  i -= a-1;
  int s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

int inversion(vector<int>& S)
{
  int N = S.size();
  BIT bit(-N, N);
  int s = 0;
  for (int i = 1; i <= N; i++) {
    s += bit.sum(S[i-1]);
    bit.add(S[i-1], 1);
  }
  return s;
}

int count(vector<int> a, int x)
{
  int N = a.size();
  for(int i = 0; i < N; i++) {
    if (a[i] >= x) {
      a[i] = 1;
    } else {
      a[i] = -1;
    }
  }
  vector<int> S(N+1);
  S[0] = 0;
  for (int i = 1; i < N+1; i++) {
    S[i] = S[i-1] + a[i-1];
  }

  return inversion(S);
}

int binary(vector<int>& a, int N)
{
  int l = -1, r = MAX_A, m;
  while (r - l > 1) {
    m = (l + r) / 2;
    if (count(a, m) >= ((N*(N+1)/2)+1)/2) {
      l = m;
    } else {
      r = m;
    }
  }
  return l;
}


signed main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  cout << binary(a, N) << endl;

  return 0;
}


Measured memory_bytes: 4212
n, m = map(int, input().split())
a = set(int(input()) for _ in range(m))
m = 10**9+7

dp = [0 for _ in range(n+1)]
dp[0] = 1
dp[1] = 1
if 1 in a:
  dp[1] = 0

for i in range(2, n+1):
  dp[i] = 0 if i in a else (dp[i-2] + dp[i-1]) % m

print(dp[-1])


Measured memory_bytes: 61140
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cap,rev;};//ikisaki youryou gyakuhen
class MF{//max flow
	public:
	int n;
	vector<vector<edge> >G;//[MAX];
	vi level,iter;//[MAX];
	MF(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int from, int to, int cap){
		edge q={to,cap,int(G[to].size())};
		G[from].push_back(q);
		q={from,0,int(G[from].size()-1)};
		G[to].push_back(q);
	}
	void bfs(int s){
		level=vi(n,-1);
		queue<int>q;
		level[s]=0;
		q.push(s);
		while(!q.empty()){
			int v=q.front();q.pop();
			for(int i=0;i<G[v].size();i++){
				edge &e=G[v][i];
				if(e.cap>0&&level[e.to]<0){
					level[e.to]=level[v]+1;
					q.push(e.to);
				}
			}
		}
	}
	int dfs(int v,int t, int f) {
		if(v==t)return f;
		for(int &i=iter[v];i<G[v].size();i++){
			edge &e=G[v][i];
			if(level[v]>=level[e.to]||e.cap<=0) continue;
			int d =dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
		return 0;
	}
	int mf(int s,int t) {//from s to t,ford_fulkerson
		int flow=0;
		while(1){
			bfs(s);
			if(level[t]<0)return flow;
			iter=vi(n);
			int f;
			while((f=dfs(s,t,inf))>0)flow+=f;
		}
	}
};
signed main(){
	int n;
	cin>>n;
	MF mf(n+2);
	int s=n,t=n+1;
	ll sum=0;
	rep(i,n){
		ll a;cin>>a;
		if(a>0)sum+=a,mf.add_edge(i,t,a);
		else if(a<0)mf.add_edge(s,i,-a);
	}
	loop(i,1,n)loop(j,1,n+1)if(i*j<=n)mf.add_edge(i-1,i*j-1,inf);
	cout<<sum-mf.mf(s,t)<<endl;
}






Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;
        char c[n + 1];
        for (int i = 1; i <= n; ++i) {
            cin >> c[i];
        }

        int cnt[26] = {};
        int firstcnt = 0, secondcnt = 0; // 1位，2位の得票数
        int point = 0;
        char winner;
        bool win = false;
        for (int i = 1; i <= n; ++i) {
            cnt[c[i] - 'A']++;
            if (firstcnt + 1 == cnt[c[i] - 'A']) {
                if (secondcnt != 0 && c[i] != winner) {
                    secondcnt = firstcnt;
                }
                firstcnt = cnt[c[i] - 'A'];
                winner = c[i];
            } else if (secondcnt + 1 == cnt[c[i] - 'A']) {
                secondcnt = cnt[c[i] - 'A'];
            }
            if (firstcnt >= (n / 2 + 1) && win == false) {
                point = i;
                win = true;
            }
            if (i > n / 2 && firstcnt - secondcnt > n - i && win == false) {
                point = i;
                win = true;
            }
//            printf("%d %d %d\n", firstcnt, secondcnt, point);
        }

        if (firstcnt == secondcnt) {
            cout << "TIE" << endl;
        } else {
            cout << winner << " " << point << endl;
        }
    }
    return 0;
}


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

int main() {
  int a, b, c, d;
  cin >>a >>b;
  c =0;
  d =1;
  for(int i=0; i<1000; i++) {
  if (d<b){
  d = a-1 + d;
  c= c+1;
  }
  else {
  break;
  }
  } 
  cout <<c <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
 
int main(){
    int n;
    cin>>n;
 
    vector<int> h(n);
    bool judge=true;
    REP(i,n){
        cin>>h[i];
        if(i>0){
            if(h[i-1]==h[i]+1){
                h[i]++;
            }else if(h[i-1]>h[i]+1){
                judge=false;
                break;
            }
        }
    }
 
    cout<<(judge ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
	static long ans;
	static long n;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		n=sc.nextLong();
		dfs(0,false,false,false);
		System.out.println(ans);
	}
	static void dfs(long num,boolean c3,boolean c5,boolean c7){
		if(num>n){
			return;
		}
		if(c3 && c5 && c7 && num<=n){
			ans++;
		}
		
		dfs(num*10+3,true,c5,c7);
		dfs(num*10+5,c3,true,c7);
		dfs(num*10+7,c3,c5,true);
	}
}


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

int main(){
	int N, count = 0, tmp, minj;
	cin >> N;
	int *arr = new int[N];
	for(int i = 0; i < N; i++){
		cin >> arr[i];
	}

	for(int i = 0; i < N-1; i++){
		minj = i;
		for(int j = i; j < N; j++){
			if(arr[j] < arr[minj]){
				minj = j;
			}
		}
		tmp = arr[i];
		arr[i] = arr[minj];
		arr[minj] = tmp;
		//交換しないループ内ではカウントしない
		if(minj != i)	count++;
	}

	for(int i = 0; i < N; i++){
		cout << arr[i];
		if(i != N-1)	cout << " ";
	}

	cout << endl;
	cout << count << endl;

	return 0;
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)

#define lli long long
#define li long
#define vi vector<int>
#define vli vector<li>
#define vlli vector<lli>
#define pi pair<int,int>
#define pli pair<li, li>
#define vpi vector<pi>

using namespace std;

int main() {

    ios_base::sync_with_stdio(false);

    int p,q,r;

    cin >> p >> q >> r;

    int ans = p + q;

    ans = min(ans, p + r);
    ans = min(ans, q + r);
    
    cout << ans<<endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=2e5+5;
int main() {
	int n,k;
	long long num[maxn];
	cin>>n>>k;
	for(int i=0;i<n;i++) {
		cin>>num[i];
	}
	sort(num,num+n);
	long long sum=0;
	if(n>k) {
		for(int i=0;i<n-k;i++) {
			sum+=num[i];
		}
	}
	cout<<sum;
}

Measured memory_bytes: 1792
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
INF = 10**9+1

def solve():
    cycles = []
    memo = [False] * N
    i = 0
    while i < N-1:
        cycle = []
        j = i
        while not memo[j]:
            cycle.append(j)
            memo[j] = True
            j = P[j] - 1
        k = i
        for i in range(k, N):
            if not memo[i]:
                break
        cycles.append(cycle)

    ans = -INF

    for cycle in cycles:
        n = len(cycle)
        # q, r = divmod(K-1, n)
        # r += 1
        memo = [-INF] * n
        for i in range(n):
            s = 0
            for j in range(n):
                s += C[cycle[(i+j)%n]]
                memo[j] = max(memo[j], s)
        tmpmax = -INF
        imax = -1
        if K < n:
            for i in range(K):
                if tmpmax < memo[i]:
                    tmpmax = memo[i]
                    imax = i+1
        else:
            if memo[-1] > 0:
                for i in range(n):
                    q = (K-i-1) // n
                    tmpmax = max(tmpmax, memo[i] + memo[-1] * q)
            else:
                for i in range(n):
                    tmpmax = max(tmpmax, memo[i])

        ans = max(ans, tmpmax)
    return ans

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


Measured memory_bytes: 74412