akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
 
int main(void){
    int N, M;
    cin >> N >> M;
    int a[M], b[M];
    int checka[M];
    int checkb[M];
    int counta = 0;
    int countb = 0;
    int ans = 0;
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
        if(a[i]==1){
            checkb[countb]=b[i]; countb++;        
        }
        if(b[i]==N){
            checka[counta]=a[i]; counta++;
        }
    }
    sort(checkb, checkb+countb); sort(checka, checka+counta);
    int s, l, k;
    for(int i = 0; i < counta; i++){
        l=countb-1; s=0;
            while(l>=s){
                k = (l+s)/2;
                if(checka[i]>checkb[k]) s=k+1;
                else if(checka[i]<checkb[k]) l=k-1;
                else{
                    ans++; break;
                }
            }
    }
    if(ans!=0)
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr>void dump(Itr begin, Itr end) {
  for(;begin != end; ++begin) clog << ' ' << *begin;
  clog << LF;
}

signed main()
{
  int N, A, B;
  int cnt[3] = {};

  cin >> N >> A >> B;
  for (int i = 0; i < N; i++) {
    int p; cin >> p;
    if (p <= A) ++cnt[0];
    else if (p <= B) ++cnt[1];
    else ++cnt[2];
  }

  cout << min({cnt[0], cnt[1], cnt[2]}) << endl;


  return 0;
}



Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ n, t ] <- readInts
	ps <- map mp <$> replicateM n readInts
	let
		res = minimum $ ( 9999 : ) $ map fst $ filter ( ( <= t ) . snd ) ps
	if res == 9999
		then putStrLn "TLE"
		else print res

Measured memory_bytes: 508
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>k>>x;
    rrep(i,x-k+1,x+k){
        if(i==x+k-1)Cout(i);
        else cout<<i<<" ";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long[] abc = new long[3];
        boolean div2 = false;
        for(int i = 0; i < 3; i++){
            abc[i] = sc.nextLong();
            if(abc[i] % 2 == 0){
                div2 = true;
            }
        }
        Arrays.sort(abc);
        System.out.println(div2 ? 0 : abc[0] * abc[1]);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int x = (a + b) / 2;
  if ((a + b) % 2 == 0) {
  	cout << x << endl;
  }else {
  	cout << x + 1 << endl;
  }
}

Measured memory_bytes: 256
n = int(input())

alp = [chr(v) for v in range(ord("a"), ord("z") + 1)]

def bitcount(v):
    cnt = 0
    for i in range(n + 1):
        cnt += bool(v & (1 << i))
    return cnt

results = []
def f(i=0, s=""):
    if len(s) == n:
        results.append(s)
        return

    for j in range(i + 1):
        if i != j:
            f(i, s + alp[j])
    f(i + 1, s + alp[i])
f()
print(*results, sep="\n")


Measured memory_bytes: 65916
#include<stdio.h>
#include<stdlib.h>
#pragma warning(disable:4996)

int main()
{
	int a = 0;
	scanf("%d", &a);
	int matrix[101][101] = { 0 };
	for (int i = 0; i < a; i++) {
		int row = 0;
		int column = 0;
		int count = 0;
		scanf("%d", &row);
		scanf("%d", &count);
		for (int j = 0; j < count; j++) {
			scanf("%d", &column);
			matrix[row-1][column - 1] = 1;
		}
	}
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < a; j++) {
			if (j < a - 1) {
				printf("%d ", matrix[i][j]);
			}
			else {
				printf("%d", matrix[i][j]);
			}
		}
		printf("\n");
	}
}


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

long long lucas(int N,vector<long long> &memo){
  if (N==0){
    return 2;
  }
  else if (N==1){
    return 1;
  }
  else if (memo[N]!=-1){
    return memo[N];
  }
  else {
    memo[N]=lucas(N-1,memo)+lucas(N-2,memo);
    return memo[N];
  }
}

int main() {
  int N;
  cin >> N;
  vector<long long>memo(90,-1);
  cout << lucas(N,memo) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int n, x, m[1002], min = 1001, sum = 0;

	cin >> n >> x;

	for (int i = 0; i < n; i++) {
		cin >> m[i];
		sum += m[i];
		if (min > m[i])
			min = m[i];
	}

	cout << (x - sum) / min + n << endl;
	

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}




int main(){
  int N;
  cin>>N;
  int L[N];
  for(int i=0;i<N;i++){
    cin>>L[i];
  }
  sort(L,L+N);
  int sum=0;
  for(int i=0;i<N-1;i++){
    sum+=L[i];
  }
  if(sum>L[N-1]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }







  


}


  
  


  




Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
  int d, e, d_ori;
  double ans, tmp;
  
  while(scanf("%d%d", &d, &e), d){
    ans=100;
    d_ori=d;
    while(d>=d_ori/2){
      tmp=sqrt(d*d+(d_ori-d)*(d_ori-d))-e;
      if(tmp<0){
	tmp*=(-1);
      }
      if(tmp<ans){
	ans=tmp;
      }
      //      printf("%f\n", tmp);
      d--;
    }
    printf("%.10f\n", ans);
    
  }
  
  return 0;
}

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

int main()
{
    int x,a,b;
    cin >> x >> a >> b;
    int ad = abs(a-x);
    int bd = abs(b-x);
    if(ad <= bd){
        cout << 'A' << endl;
    }else if(ad > bd){
        cout << 'B' << endl;

    }
}


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

template <typename T>
inline void Read(T &x)
{
    x=0;T f=1;char a=getchar();
    while(a<'0'||'9'<a) {if (a=='-') f=-f; a=getchar();}
    while('0'<=a&&a<='9') x=x*10+(a-'0'),a=getchar();
    x*=f;
}
long long a,b;
long long Or(long long a)
{
  	if(a%4==1) return 1;
	if(a%4==2) return a+1; 
	if(a%4==3||a==0) return 0;
	return a;
}

int main()
{
    Read(a),Read(b);
    if (a==0) a++;
    cout<<(Or(a-1)^Or(b))<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
    #include <bits/stdc++.h>
    using namespace std;
     
    #define rep(i, n) REP(i, 0, n)
    #define ALL(v) v.begin(), v.end()
    #define MSG(a) cout << #a << " " << a << endl;
    #define REP(i, x, n) for (int i = x; i < n; i++)
    #define OP(m) cout << m << endl
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<int, int> pii;
     
    int main()
    {
        int n;
        cin >> n;
        int ans = 0;
        for (ll i = 0; i <= 100000; i++)
        {
            if (i * i <= n)
                ans = i * i;
        }
        OP(ans);
        return 0;
    }

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N = int(input())
  S = input()
  ans = 'Yes'
  if N%2==1:
    ans = 'No'
  else:
    L = len(S)//2
    for i in range(L):
      if S[i] != S[L+i]:
        ans = 'No'
        break
  print(ans)
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline int ri() {int x; scanf("%d", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/


const int maxn = 100010;
LL p[maxn], n;


int sp[maxn];
vector<LL> prime;
int main() {
  #ifdef _TEST_
  freopen("input.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  #endif
  scanf("%lld", &n);
  rep(i, n) scanf("%lld", &p[i]);
  unordered_map<LL, int> s;
  rep(i, n) {
    for (LL j = 2; j * j * j <= p[i]; j ++) {
      LL t = j * j * j;
      while (p[i] % t == 0) p[i] /= t;
    }
    s[p[i]] ++;
  }
  int res = s.count(1);
  s.erase(1);

  rep(i, 2, maxn) if (!sp[i]) {
    prime.pb(i);
    for (int j = i + i; j < maxn; j += i)
      sp[j] = 1;
  }
  //for (auto i : s) {
    //cout << i.fr << ' ' << i.sc << endl;
  //}
  for (auto i : s) {
    LL t = i.fr, r = 1;
    for (LL c: prime) {
      if (t % c == 0) {
        if (t % (c * c) == 0) r *= c, t /= c * c;
        else r *= c, t /= c;
      }
      if (c * c * c > t) break;
    }
    LL root = round(sqrt(t));
    if (root * root == t) r *= root;
    else r *= t;
    if (r > 1e7) {
      res += i.sc;
      continue;
    }
    r = (r * r) / i.fr * r;
    auto it = s.find(r);
    if (it != s.end()) res += max(it->sc, i.sc), s.erase(it);
    else res += i.sc;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 5796
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define Mod 1000000007
#define M 998244353

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

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

    //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

    ll ans=0;
    for (int i = 0; i <= k; ++i) {
        ans+=(m*mpow(m-1,n-i-1)%M)*(comb(n-1,i)%M)%M;
        ans%=M;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
	int n,h,w,s = 0;
	cin >> n >> h >> w;
	while(n--){
		int a,b;
		cin >> a >> b;
		if(a >= h && b >= w)
			s++;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * B - TAKOYAKI FESTIVAL 2019
 * https://atcoder.jp/contests/abc143/tasks/abc143_b
 **/
#include<iostream>
#include<vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0;i<N;i++) {
        cin >> d[i];
    }
    int ans;
    for(int i=0; i<N-1; i++) {
        for(int j=i+1; j<N; j++) {
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
s=input()
n=len(s)
pcnt,gcnt=0,0
ans=[""]*n
for i in range(n):
    if s[i]=="g":
        if gcnt>pcnt:
            ans[i]="p"
            pcnt+=1
        else:
            ans[i]="g"
            gcnt+=1
    if pcnt==n//2 or gcnt==-(-n//2):
        break
i,j=0,0
#print(gcnt,pcnt)
while -(-n//2)>gcnt:
    if ans[i]=="":
        ans[i]="g"
        gcnt+=1
    i+=1
while n//2>pcnt:
    if ans[j]=="":
        ans[j]="p"
        pcnt+=1
    j+=1
score=0
#print(ans)
for i in range(n):
    if ans[i]=="p" and s[i]=="g":
        score+=1
    elif ans[i]=="g" and s[i]=="p":
        score-=1
print(score)

Measured memory_bytes: 9876
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    int a, b;

int N=1000000000;
int s=0;
while(N--){s+=N;}

    while( scanf("%d %d", &a, &b) != EOF ){
        printf("%d\n", a + b+s-s);
    }    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	ini(n);
	int mo = 1e9+7;
	vi morty;
	FOR(i,0,n){
		ini(x);
		morty.push_back(x);
	}
	int rick = 0;
	FOR(i,0,60){
		int tmp1 = 0;
		int tmp = 0;
		FOR(i1,0,n){
			if((morty[i1]>>i)&1)tmp1++;
			else tmp++;
		}
		rick+=((1LL<<i)%mo)*((tmp1*tmp)%mo);
		rick%=mo;
	}
	out(rick);














	return 0;
}

Measured memory_bytes: 6512
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int check(char a,char b,char c){
  if( a == b && b == c){
    return 0;
  }
  else if(a == b && a != c){
    return 1;
  }
  else if(a != b && b == c){
    return 1;
  }
  else if(a == c && a != b){
    return 1;
  }
  else{
    return 2;
  }
  return 0;
}
int main(){
  int n,ii,sum = 0,cnt;
  string a,b,c;

  cin >> n >> a >> b >> c;

  for(ii = 0; ii < n; ii++){
    cnt = check(a[ii],b[ii],c[ii]);
    sum += cnt;
    // cout << cnt << endl;
  }
  cout << sum << endl;;
  
  return 0;
}


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

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1156
package main

import (
	"fmt"
	"sort"
)

func main() {
	var P, Q, R int
	fmt.Scan(&P, &Q, &R)

	list := []int{P, Q, R}
	sort.Sort(sort.IntSlice(list))

	fmt.Println(list[0] + list[1])
}


Measured memory_bytes: 1836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
const ll maxi = 1000001;
int main(){
  string s;
  cin >> s;
  ull len = s.size();
  vector<ll> vec(len+1,0);
  bool dow = true;
  ll tmp = 0;
  ll ans = 0;
  rep(i,len){
    if(s[i] == '<'){
      tmp++;
      chmax(vec[i+1],tmp);
    }else{
      tmp = 0;
    }
  }
  tmp = 0;
  rep(i,len){
    if(s[len-1-i] == '>'){
      tmp++;
      chmax(vec[len-1-i],tmp);
    }else{
      tmp = 0;
    }
  }
  rep(i,len+1){
    ans += vec[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 500010;

typedef pair<pi,int> pii;
const int len = 800;

int n,q;
int A[maxn];
int co[maxn];
int rans = 0;

struct query {
	int l,r,index,ans;
	void read(int _l, int _r, int _index) {
		l = _l; 
		r = _r;
		index = _index;
		ans = 0;
	}
};

vector <query> queries;


bool cmp(const query &a, query &b) {
	int buc1 = a.l/len, buc2 = b.l/len;
	if (buc1 == buc2) return a.r < b.r;
	else return buc1 < buc2;
}

bool cmpind(const query &a, const query &b) {
	return a.index < b.index;
}

void add(int x) {
	co[A[x]]++;
	if (co[A[x]] == 1) rans++;
}

void rem(int x) {
	co[A[x]]--;
	if (co[A[x]] == 0) rans--;
}

int32_t main() {
	FAST
	cin >> n >> q;
	for (int i =0;i<n;i++) cin >> A[i];
	for (int i =0;i<q;i++) {
		int l,r; cin >> l >> r;
		queries.push_back(query());
		queries[i].read(--l,--r,i);
	}
	
	sort(queries.begin(),queries.end(),cmp);

	//cout << "HELLO\n";
	//for (auto i: queries) {
		//cout << i.l << " " << i.r << "\n";
	//}

	int ql = 1, qr = 0;
	for (int i =0;i<q;i++) {
		int l = queries[i].l, r = queries[i].r;
		while (ql > l) add(--ql);
		while (ql < l) rem(ql++);
		while (qr < r) add(++qr);
		while (qr > r) rem(qr--);
			
		queries[i].ans = rans;
	}
	
	sort(queries.begin(),queries.end(),cmpind);
	for (int i =0;i<q;i++) {
		cout << queries[i].ans << "\n";
	}
}




Measured memory_bytes: 27296
#include <iostream>
using namespace std;
int s[16][17],dp[(1<<16)],n,L;
int main(void){
    while(1){
    cin>>n;
    if(n==0)return 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n+1;j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<(1<<16);i++)dp[i]=1e9;
    dp[0]=0;
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<n;j++){
            if(((i>>j)&1)==0){
                L=s[j][0];
                for(int k=1;k<=n;k++){
                    if(((i>>(k-1))&1)==1){
                        L=min(L,s[j][k]);
                    }
                }
                //cout<<(i|(1<<j))<<" "<<i<<" "<<j<<" "<<dp[i]+L<<endl;
                dp[i|(1<<j)]=min(dp[i|(1<<j)],dp[i]+L);
            }
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
}
}



Measured memory_bytes: 3348
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <bitset>
#include <fstream>

#define ll long long
#define scani(x) scanf("%i", &x)
#define scanll(x) scanf("%I64d", &x)
#define scanfl(x) scanf("%f", &x)
#define scanch(x) scanf("%c", &x)
#define scans(x) scanf("%s", x);
#define printi(x) printf("%i", x);
#define printll(x) printf("%I64d", x);
#define printfl(x) printf("%f", x);
#define printch(x) printf("%c", x);
#define prints(x) printf("%s", x);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define INFI (1 << 29)
#define INFL (1LL << 62)
#define sz(x) int(x.size())
#define fi first
#define se second
#define forn(i, n) for(ll i = 0; i < n; i++)
#define for1(i, n) for(ll i = 1; i <= n; i++)
#define ford(i, n) for(ll i = (n - 1); i >= 0; i--)
#define fori(i, n) for(ll i = n; i >= 1; i--)
#define fore(i, l, r) for(ll i = l; i <= r; i++)
#define get_bit(mask, x) (bool)(mask & (1LL << x))
#define set_bit(mask, x) (mask |= (1LL << x))
#define reset_bit(mask, x) (mask &= ~(1LL << x))
#define toggle_bit(mask, x) (mask ^= (1LL << x))

using namespace std;

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

    ll a;
    string s;

    cin >> a >> s;

    if(a >= 3200)
        cout << s << "\n";
    else
        cout << "red\n";

    return 0;
}


Measured memory_bytes: 256
import std.stdio,
       std.string,
       std.conv;

void main() {
  string N = readln.chomp;
  int a, b;
  
  foreach (c; N) {
    a += c - '0';
  }

  b = N[0] - 1 - '0';
  foreach (c; N[1..N.length]) {
    b += '9' - '0';
  }

  writeln(a > b ? a : b);
}


Measured memory_bytes: 256
import itertools
import math

N = int(input().strip())
al = list(map(int,input().strip().split(" ")))

pos = 1 #アライグマのとる最初のcardのindex

diff = 1000000000
asum = sum(al)
tmp_sum = 0

diff = []
for a in al[:-1]:
    tmp_sum += a
    diff.append(abs(asum - tmp_sum * 2))

print(min(diff))

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

ll INF = 1e18;
int N;
vector<vector<ll>> dp;
vector<ll> a(N);

ll rec(int l = 0,int r = N){
    if(l==r) return 0;
    ll &ret = dp[l][r];
    if(ret != INF) return ret;
    if((N - (r-l) )% 2==0){ //%の計算順序は意外と早い
        ret = max(a[l]+rec(l+1,r),a[r-1]+rec(l,r-1));
    }else{
        ret = min(rec(l+1,r)-a[l],rec(l,r-1)-a[r-1]);
    }

    return ret;
}

int main(){
    cin >> N;
    a.assign(N, 0);//grobal scope の　vectorはすべてこれで初期化しよう
    rep(i,N) cin >> a[i];
    dp.assign(N+1,vector<ll>(N+1,INF));

    ll ans = rec(0,N);

    cout << ans << endl;

    
}

Measured memory_bytes: 73896
public class Main {


		public static void main(String[] args) {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int a;
		int b;
		int c;
		int i = 1;
		int t = 0;
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();
		
		if(a <= b && 1<=a && a <=10000 && 1<=b && b <=10000 && 1<=c && c<= 10000){
		for(i = a; i <= b ; i++){
			if(c % i == 0){
				
				t += 1;
			}
		}
		}System.out.println(t);
		
			




		}
}

Measured memory_bytes: 26340
n = int(input())
h = list(map(int,input().split()))

for i in range(n-1,0,-1):
    diff = h[i] - h[i-1]
    if diff < -1:
        print("No")
        break
    elif diff == -1:
        h[i-1] -= 1
else:
    print("Yes")


Measured memory_bytes: 63856
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;
using ll = long long;

int main() {
	int x, y;
	cin >> x >> y;
	bool flag = false;
	for (int i = 0;i <= x;i++) {
		if (2 * i + 4 * (x - i) == y) {
			flag = true;
			break;
		}
	}
	if (flag) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 3632
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		
		StringBuilder sb = new StringBuilder(str);
		System.out.println(sb.reverse());
		
	}
}

Measured memory_bytes: 25744
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/******************************define**********************************/

/*****************************functions********************************/

/****************************main function*****************************/
int main(void){
    int n,m;cin>>n>>m;
    vector<int> x(n),d(n-m+1);
    for(int i = 0;i <n;i++) cin >> x[i];
    for(int i=0;i<n-m+1;i++) d[i]=x[i+m-1]-x[i]+min(abs(x[i+m-1]),abs(x[i]));
    sort(all(d));
    cout<<d[0]<<endl;
    return 0;
}

Measured memory_bytes: 896
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i,N) cin >> A[i];

    vector<vector<bool>> dp1(N,vector<bool>(K,false));
    vector<vector<bool>> dp2(N,vector<bool>(K,false));

    //左から
    dp1[0][0] = true;
    if(A[0]<K) dp1[0][A[0]] = true;
    REP(i,N-1){
        REP(k,K){
            if(dp1[i][k]) dp1[i+1][k] = true;
            if(dp1[i][k] && k+A[i+1]<K) dp1[i+1][k+A[i+1]] = true;
        }
    }
    
    //右から
    dp2[N-1][0] = true;
    if(A[N-1]<K) dp2[N-1][A[N-1]] = true;
    for(int i=N-2; i>=0; i--){
        REP(k,K){
            if(dp2[i+1][k]) dp2[i][k] = true;
            if(dp2[i+1][k] && k+A[i]<K) dp2[i][k+A[i]] = true;
        }
    }

    int ans=N;
    REP(i,N){
        if(A[i]>=K){ ans--; continue; }
        if(0<i && i<N-1){
            vector<int> cumsum(K+1,0);
            REP(k,K)
                cumsum[k+1] = cumsum[k] + dp1[i-1][k];
            // (K-A[i] <= 右で作れる数 + 左で作れる数 < K) になるものが一つでもあれば必要な数
            REP(k,K){
                if(dp2[i+1][k]){
                    if(cumsum[K-k] - cumsum[max(0,K-k-A[i]) ]){ ans--; break; }
                }
            }
        }else{
            if(i)
                for(int k=K-A[i]; k<K; k++){ 
                    if(dp1[i-1][k]){ ans--; break;}
                }
            else
                for(int k=K-A[i]; k<K; k++){
                    if(dp2[i+1][k]){ ans--; break;}
                }
        }
    }


    cout << ans << endl;
}

Measured memory_bytes: 6912
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <string.h>
#include <cassert>
 
#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif
 
#define sz(a)  int((a).size())
#define FOREACH(it, c) for (typeof((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define FOR(i,count) for (int i = 0; i < (count); i++)
 
using namespace std;
typedef long long ll;
const int MODULO = 1000000007;
 
typedef pair<int,int> Pii;
// begin
 
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

int main()
{
	int p,q;
	while(cin>>p>>q){
		map<int,int> mp;
		int circle_pt = -1;
		int cnt = 1;
		mp[p] = 0;
		while(true){
			p *= 10;
			int div = p/q;
			p -= q*div;
			putchar(div+'0');
			if(p == 0){
				break;
			} else if(mp.find(p) != mp.end()){
				puts("");
				int a = mp[p];
				for (int i = 0; i < cnt; i++){
					putchar(i < a ? ' ' : '^');
				}
				break;
			}
			mp[p] = cnt++;
		}
		puts("");
	}
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    double s=0,r;
    cin>>a;
    int b[a];
    for(int i=0;i<a;i++){
        cin>>b[i];
    }
    for(int i=0;i<a;i++){
        s=s+1.0/b[i];
    }
    r=1.0/s;
    cout<<r<<endl;
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
S = [list(input().split()) for _ in range(H)]

l = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

for i in range(H):
    for j in range(W):
        if S[i][j] == 'snuke':
            print(l[j] + str(i + 1))
            exit()


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

int N;
vector<int>a;
vector<int>b;
vector<int>c;
int check;
vector< vector<int >>MEMO;
int INF=1e9;



int max_ha(int index, int check)
{
	if(index>N)
		return -INF;
	else if(index==(N))
		return 0;
	if(MEMO[index][check]!=-1)
		return(MEMO[index][check]);

	if(check==0)
		MEMO[index][check]=max({ max_ha(index+1,1)+a[index] , max_ha(index+1,2)+b[index] , max_ha(index+1,3)+c[index] });
    else if(check==1)
    	MEMO[index][check]=max({ max_ha(index+1,2)+b[index] , max_ha(index+1,3)+c[index]  });
    else if(check==2)
    	MEMO[index][check]=max({ max_ha(index+1,1)+a[index] , max_ha(index+1,3)+c[index]  });
    else
    	MEMO[index][check]=max({ max_ha(index+1,1)+a[index] , max_ha(index+1,2)+b[index]  });

    return MEMO[index][check];


}


int main()
{
	cin>>N;
	MEMO.assign(N,vector<int>(4,-1));
	int i;
	int temp1,temp2,temp3;
	for(i=0;i<N;i++)
	{
		cin>>temp1>>temp2>>temp3;
		a.emplace_back(temp1);
		b.emplace_back(temp2);
		c.emplace_back(temp3);
	}
	cout<<max_ha(0,0);
	return 0;

}

Measured memory_bytes: 14956
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

const int timeLimit = 1980;

i64 xor128()
{
  static i64 x = 123456789, y = 362436069, z = 521288629, w = 88675123;
  i64 t = (x ^ (x << 11));
  x = y;
  y = z;
  z = w;
  return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

i64 D;
i64 c[26];
i64 s[365][26];
vector<i64> ans;

i64 eval(vector<i64> &ans)
{
  i64 score = 0;
  i64 last[26] = {};
  for (i64 i = 0; i < D; i++)
  {
    score += s[i][ans[i]];
    last[ans[i]] = i + 1;
    for (i64 j = 0; j < 26; j++)
      score -= c[j] * (i + 1 - last[j]);
    cout << score << endl;
  }
  return score;
}

void solve()
{
  chrono::system_clock::time_point start = chrono::system_clock::now();
  chrono::system_clock::time_point end = start + chrono::milliseconds(timeLimit);
  i64 bestScore = 0, loop = 0;
  while (chrono::system_clock::now() < end)
  {
    i64 t[3] = {xor128() % D, xor128() % 26};
    t[2] = ans[t[0]];
    ans[t[0]] = t[1];
    i64 score = eval(ans);
    if (bestScore < score)
    {
      bestScore = score;
    }
    else
    {
      ans[t[0]] = t[2];
    }
    loop++;
  }
  cerr << "score: " << bestScore + (i64)(1e6) << endl
       << "loop: " << loop << endl;
}

void input()
{
  cin >> D;
  for (i64 i = 0; i < 26; i++)
    cin >> c[i];
  for (i64 i = 0; i < D; i++)
    for (i64 j = 0; j < 26; j++)
      cin >> s[i][j];
  ans.resize(D);
}

void output()
{
  for (i64 i = 0; i < D; i++)
    cout << ans[i] + 1 << endl;
}

int main()
{
  // input();
  // solve();
  // output();
  cin >> D;
  for (i64 i = 0; i < 26; i++)
    cin >> c[i];
  for (i64 i = 0; i < D; i++)
    for (i64 j = 0; j < 26; j++)
      cin >> s[i][j];
  ans.resize(D);
  for (i64 i = 0; i < D; i++)
  {
    cin >> ans[i];
    ans[i]--;
  }
  eval(ans);
  return 0;
}


Measured memory_bytes: 3692
#include <stdio.h>

long a[10000];
int main(void)
{
	int i, j, n;
	long sum, max;
	
	while (scanf("%d", &n), n != 0){
		for (i = 0; i < n; i++){
			scanf("%ld", &a[i]);
		}
		
		max = -100000000;
		for (i = 0; i < n; i++){
			sum = 0;
			for (j = i; j < n; j++){
				sum += a[j];
				if (sum > max) max = sum;
			}
		}
		printf("%ld\n", max);
	}
	
	return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];

    vl dp(n+1,INF);
    rep(i,n){
        ll idx=lower_bound(all(dp),a[i])-dp.begin();
        dp[idx]=a[i];
    }
    rep(i,n+1){
        if(dp[i]==INF){
            cout<<i<<endl;
            return;
        }
    }
}

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



Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 4050
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=k;i<=n+1;i++){
        ll a=(ll)i*(i-1)/2;
        ll b=(ll)i*(2*n+1-i)/2;
        ans+=(ll)(b-a+1);
        ans%=MOD;
    }
    OUT(ans);
    return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == ',')
            s[i] = ' ';
    }
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 256
from itertools import product
s = list(input())
n = len(s)

pattern = list(product(['+', '-'], repeat=n-1))

for i in range(2 ** (n-1)):
    formula = s[0]
    for j, k in zip(pattern[i], s[1:]):
        formula += (j + k)
    if eval(formula) == 7:
        print("{}=7".format(formula))
        break


Measured memory_bytes: 9024
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  double v[n],mi,tmp;
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  sort(v,v+n);
  tmp = (v[0]+v[1])/2.0;
  for(int i=2;i<n;i++){
    tmp = (tmp+v[i])/2.0;
  }
  mi = tmp;
  sort(v,v+n,greater<double>());
  tmp = (v[0]+v[1])/2.0;
  for(int i=2;i<n;i++){
    tmp = (tmp+v[i])/2.0;
  }
  mi = max(mi,tmp);
  printf("%.7lf\n",mi);
}


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

using namespace std;

long long solve(const vector<int>& A){
    long long res = 1;
    long long rest = 1 - A[0];
    if(rest < 0) return -1;
    vector<long long> req(A.size(), 0);
    req.back() = A.back();
    for(int i=A.size()-2;i>=0;i--) req[i] = req[i+1] + A[i];
    for(int i=1;i<A.size();i++){
        rest = min(req[i], 2*rest);
        if(rest < A[i]) return -1;
        res += rest;
        rest -= A[i];
    }
    return res;
}

int main(){
    int N; cin >> N;
    vector<int> A(N+1);
    for(auto& a : A) cin >> a;
    cout << solve(A) << endl;
}

Measured memory_bytes: 4580
#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<int> s;
vector<int> c;
int n, m;
bool ok(string str) {
    if (str.size() != n) return false;
    for (int i = 0; i < m; ++i) if (str[s[i]] != (char)(c[i] + '0')) return false;
    return true;
}

string solve() {
    for (int i = 0; i <= 999; ++i) {
        stringstream ss; ss << i;
        string str = ss.str();
        if (ok(str)) return str;
    }
    return "-1";
}
int main(){
    cin >> n >> m;
    s.resize(m); c.resize(m);
    rep(i,m){
        cin >> s[i] >> c[i];
        s[i]--;
    }
    string ans = solve();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
#ifdef __MINGW32__
typedef double rn;
#else
typedef long double rn;
#endif

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b==c or b+c==a or c+a==b){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


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

int main() {
  int n;
  cin >> n;
  map<ll, int> mp;
  vector<ll> res;
  rep(i, n){
    ll a;
    cin >> a;
    mp[a]++;
  }
  for(auto i : mp){
    if(i.second >= 4){
      res.push_back(i.first);
      res.push_back(i.first);
    }else if(i.second >= 2){
      res.push_back(i.first);
    }
  }
  if(res.size() < 2){
    cout << 0 << endl;
  }else{
    cout << res[res.size() - 1] * res[res.size() - 2] << endl;
  }
  return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m), sum(m);
    rep(i, n)cin >> a[i];
    rep(i, m)cin >> b[i];
    sum[0] = b[0];
    REP(i, m-1)sum[i] += sum[i-1] + b[i];
    ll cnt = 0;
    ll ans = upper_bound(all(sum), k) - sum.begin();
    rep(i, n){
        cnt += a[i];
        if(cnt > k)break;
        ll it = upper_bound(all(sum), k-cnt) - sum.begin();
        ans = max(ans, i+1+it);
    }
    cout << ans << endl;
}

Measured memory_bytes: 7956
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

using namespace std;

int main()
{
	int n,ans;

	while(scanf("%d",&n)!=EOF){
		ans=0;
		for(int a=0;a<10;a++){
			for(int b=0;b<10;b++){
				for(int c=0;c<10;c++){
					for(int d=0;d<10;d++){
						if(a+b+c+d==n) ans++;
					}
				}
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define maxn 220

int a[maxn],b[maxn];
int cnt,hh1,tt1,hh2,tt2,x[maxn];
long long n;

void init(){
	while ( n >= 1 ){
		if ( n == 2 ){ x[++cnt] = 1; break; }
		if ( n & 1 ) x[++cnt] = 1 , n--;
		else x[++cnt] = 2 , n >>= 1;
	}
}
int main(){
	cin>>n , n++;
	init();
	tt1 = hh1 = 100 , tt2 = hh2 = 100;
	for (int i = cnt ; i >= 1 ; i--){
		if ( x[i] == 1 ){
			a[--hh1] = i , b[tt2++] = i;
		}	
		else{
			a[tt1++] = i , b[tt2++] = i;
		}
	}
	cout<<tt1 - hh1 + tt2 - hh2<<endl;
	for (int i = hh1 ; i < tt1 ; i++) cout<<a[i]<<" ";
	for (int i = hh2 ; i < tt2 ; i++) cout<<b[i]<<" ";
	return 0;
}



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

using namespace std;

int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    if (R==1 && G==1 && B==1) {
        long abc = 0;
        for (int i = 1; i <= N+1; i++) {
            abc += i;
        }
        cout << abc << endl;
        return 0;
    }

    long ans = 0;
    for (int r = 0; r <= N/R; r++) {
        for (int g = 0; g <= N/G; g++) {
            if (r*R + g*G > N) break;
            for (int b = 0; b <= N/B; b++) {
                if (r*R + g*G + b*B > N) break;
                if (r*R+g*G+b*B==N) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+10;
ll sum[N],x[N];
ll a[N];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
		cin>>a[i];
    sum[1]=x[1]=a[1];
    for(int i=2;i<=n;i++)
		sum[i]=sum[i-1]+a[i],x[i]=x[i-1]^a[i];
    ll ans=0;
	int l=1;
    for(int r=1;r<=n;r++)
	{
        for(;sum[r]-sum[l-1]!=(x[r]^x[l-1]);l++);
	    ans+=(r-l+1);
    }
    cout<<ans<<endl;
    return 0;
}

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


int main(){
    long long int MOD =1000000000 + 7;
    int n,k;
    cin >> n >> k;
    long long int sum = 0;
    if(k == 1){
        sum += n+1;
        k = 2;
    }
    long long int dp[n+1][2] = {};
    dp[0][0] = 1;
    dp[0][1] = n + n-1;
    for(int i = 1; i < n+1; i++){
        dp[i][0] += i+1 + dp[i-1][0];
        dp[i][1] += n-i-1 + dp[i-1][1];
    }
    for(int i = k-2; i < n+1; i++){
        if(dp[i][1] - dp[i][0] + 1 > -1){
            sum += (dp[i][1] - dp[i][0] + 1) % MOD;
        }
    }
    cout << sum % MOD << endl;
    return 0;
}


Measured memory_bytes: 6688
import sys
input = sys.stdin.readline
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
b=sorted([v[0]+v[1] for v in a],reverse=1)
ans=0
for i in a:
    ans-=i[1]
for i in range(n):
    if i%2==0:
        ans+=b[i]
print(ans)

Measured memory_bytes: 32660
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <numeric>
#include <vector>

#include <deque>

using namespace std;

// Convenience function to read a vector of values from standard input
template <typename T>
auto readVector(T N) {
    vector<T> A;
    for (T i = 0; i < N; i++) {
        T Ai;
        cin >> Ai;
        A.push_back(Ai);
    }
    return A;
}

auto solve(const vector<int>& h, unsigned int K) {
    uint64_t best = h.back() - h.front();
    deque<int> window;
    for (auto hi: h) {
        window.push_back(hi);
        if (window.size() > K) {
            window.pop_front();
        }
        if (window.size() == K) {
            best = min(best, static_cast<uint64_t>(window.back() - window.front()));
        }
    }
    return best;
}

// Read parameters from standard input and call main solution function
int main() {
    int N, K;
    cin >> N >> K;
    auto h = readVector(N);
    sort(h.begin(), h.end());
    cout << solve(h, K) << endl;
    return 0;
}

Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main() {
	string S;
	int Q;
	cin >> S >> Q;
	int T, F;
	string C;
	deque<string>ans;
	ans.push_back(S);
	int shf=0;
	for (size_t i = 0; i < Q; i++)
	{
		cin >> T;
		if (T == 1)shf++;
		else {
			cin >> F >> C;
			if ((shf + F) % 2) {
				ans.push_front(C);
			}
			else {
				ans.push_back(C);
			}
		}
	}
	if (shf % 2) {
		while (!ans.empty()) {
			S = ans.back();
			reverse(S.begin(), S.end());
			cout << S;
			ans.pop_back();
		}
	}
	else {
		while (!ans.empty()) {
			cout << ans.front();
			ans.pop_front();
		}
	}
}


Measured memory_bytes: 11648
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
#print(a)
lm = [0] * n
rm = [0] * n

for i in range(1, n):
    lm[i] = max(a[i-1], lm[i-1])

for i in range(n-2, -1, -1):
    rm[i] = max(a[i+1], rm[i+1])


for i in range(n):
    print(max(lm[i], rm[i]))

Measured memory_bytes: 15656