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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<char> vc(n);
  int r_cnt = 0, w_cnt = 0;
  for (int i = 0; i < n; ++i) {
    cin >> vc[i];
    if (vc[i] == 'R') {
      r_cnt++;
    } else {
      w_cnt++;
    }
  }

  int nw_cnt = 0, nr_cnt = 0;
  for (int i = 0; i < r_cnt; ++i) {
    if (vc[i] != 'R') {
      nw_cnt++;
    }
  }

  for (int i = 0; i < w_cnt; ++i) {
    if (vc[vc.size() - i - 1] != 'W') {
      nr_cnt++;
    }
  }

  cout << min(nw_cnt, nr_cnt) << '\n';
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;
vvi g;
vi rg,vis,dp;

int dfs(int v){
	vis[v]=1;
	if(vis[rg[v]]) return v;
	return dfs(rg[v]);
}

int f(int v,int t){
	set<int> st;
	st.insert(t);
	for(auto u:g[v]) if(!vis[u]) st.insert(dp[u]);
	int I=0;
	while(st.find(I)!=st.end()) I++;
	return I;
}

void DFS(int v){
	for(auto u:g[v]) if(!vis[u]) DFS(u);
	dp[v]=f(v,-1);
}

int main(){
	cin>>n;
	g=vvi(n);
	rg=vis=dp=vi(n);
	for(int i=0;i<n;i++){
		cin>>rg[i];
		rg[i]--;
		g[rg[i]].push_back(i);
	}
	int C=dfs(0),c=C;
	vis=vi(n);
	do{vis[c]=1,c=rg[c];}while(c!=C);
	c=C;
	vi a,b;
	do{
		DFS(c);
		a.push_back(f(c,-1));
		b.push_back(f(c,a.back()));
		c=rg[c];
	}while(c!=C);
	int S=a.size(),A=a[0];
	bool B=0;
	for(int i=1;i<S;i++){
		if(a[i]==A) A=b[i];
		else A=a[i];
	}
	if(A!=a[0]) B=1;
	A=b[0];
	for(int i=1;i<S;i++){
		if(a[i]==A) A=b[i];
		else A=a[i];
	}
	if(A==a[0]) B=1;
	cout<<(B?"POSSIBLE":"IMPOSSIBLE")<<endl;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define BITSEARCH(i,n) for(int i=0;i<(1<<(n));++i)
#define BITCHK(i,j) (i) & (1<<(j))

/* BITSEARCH 使い方
 
BITSEARCH(i,n){
  vector<int> h;
  REP(j,n){
    if (BITCHK(i,j)){
      h.push_back(j+1);
    }
  }
}

*/

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int64_t l,r;
  cin >> l >> r;
  if (r - l > 2019){
    cout << 0 << endl;
    return 0;
  }else{
    int64_t t = INT_MAX;
    for(int64_t i=l;i<=r;i++){
      for(int64_t j=l;j<=r;j++){
        if (i!=j){
          int64_t tmp = (i * j) % 2019;
          t = min(t,tmp);
        }
      }
    }
    cout << t << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  
  cout <<setprecision(9)<< n * 2 * pi << endl;
  return 0;
}



Measured memory_bytes: 3788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

void solve(){
  int n;
  cin>>n;
  vector<int>a(n);
  map<int,int>mp;
  int maxv=0;
  rep(i,n)cin>>a[i],mp[a[i]]++,chmax(maxv,a[i]);
  vector<int>b=a;
  sort(b.rbegin(),b.rend());
  int se=b[1];
  rep(i,n){
    if(a[i]==maxv){
      if(mp[a[i]]!=1)cout<<maxv<<endl;
      else cout<<se<<endl;
    }
    else cout<<maxv<<endl;
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 8704
import scala.io.StdIn._
import scala.annotation.tailrec
import scala.collection._

object Main {

  def makeSoE_PrimesTo(top: Int) = {
    val topNdx = (top - 3) / 2 + 1
    val (cmpsts, sqrtLmtNdx) = (new Array[Int]((topNdx >>> 5) + 1), (Math.sqrt(top).toInt - 3) / 2)

    @inline def isCmpst(ci: Int): Boolean =
      (cmpsts(ci >>> 5) & (1 << (ci & 31))) != 0

    @inline def setCmpst(ci: Int): Unit =
      cmpsts(ci >>> 5) |= 1 << (ci & 31)

    @tailrec def forCndNdxsFrom(cndNdx: Int): Unit =
      if(cndNdx <= sqrtLmtNdx){
        if(!isCmpst(cndNdx)){
          val p = cndNdx + cndNdx + 3

          @tailrec def cullPrmCmpstsFrom(cmpstNdx: Int): Unit =
          if(cmpstNdx <= topNdx){
            setCmpst(cmpstNdx)
            cullPrmCmpstsFrom(cmpstNdx + p)
          }
          cullPrmCmpstsFrom((p * p - 3) >>> 1)
        }
        forCndNdxsFrom(cndNdx + 1)
      }
      forCndNdxsFrom(0)

    @tailrec def getNxtPrmFrom(cndNdx: Int): Int =
      if ((cndNdx > topNdx) || !isCmpst(cndNdx)) 2 * cndNdx + 3
      else getNxtPrmFrom(cndNdx + 1)

    Iterator.single(2) ++ Iterator.iterate(3)(p => getNxtPrmFrom((p - 1) >>> 1)).takeWhile(_ <= top)
  }

  @tailrec
  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(makeSoE_PrimesTo(n).size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit ={
    loop(readLine)
  }
}

Measured memory_bytes: 65156
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
int main(){
  string s;cin>>s;
  l a=0,k=1<<(s.size()-1),t=k;
  for(l i=s.size()-1;i>=0;i--) a+=(s[i]-'0')*k,k=k*5+t/2;
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
void minimize(int * N, int digit, int min){
    int i;
    for(i = 0; i <= digit; i++){
        N[i] = min;
    }
}

void calc(int * N, int K, int * D, int digit, int digit_max, int * moveup, int min, int max){
    if(digit > 0 && N[digit] <= max) calc(N, K, D, digit-1, digit_max, moveup, min, max);
    N[digit] += *moveup;
    if(digit == digit_max && N[digit] == 0) return;
    *moveup = 0;
    if(N[digit] == 10){
        *moveup = 1;
        minimize(N, digit, min);
        return;
    }

    while(1){
        int D_loop = 0;
        for(; D_loop < K; D_loop++){
            if(N[digit] == D[D_loop]) break;
        }
        if(D_loop == K) return;
        
        N[digit]++;
        minimize(N, digit-1, min);
        if(N[digit] == 10){
            *moveup = 1;
            N[digit] = min;
            return;
        }
    }
}


int main(void){
    int N_orig;
    int N_q = -1;
    int N[5] = {0, 0, 0, 0, 0};
    int K;
    int D[9] = {};
    int i;
    int min = 0;
    int max = 9;
    int N_ans = 0;
    
    scanf("%d %d", &N_orig, &K);
    for(i = 0; i < K; i++) scanf("%d", &D[i]);
    
    for(i = 0; i < K; i++){
        if(D[i] == min) min++;
        if(D[K-(i+1)] == max) max--;
    }
    
    N_q = N_orig;
    for(i = 0; N_q != 0; i++){
        N[i] = N_q % 10;
        N_q /= 10;
    }
    
    int moveup = 0;
    calc(N, K, D, i, i, &moveup, min, max);
    
    for(i = 4; i >= 0; i--){
        N_ans *= 10;
        N_ans += N[i];
    }
    printf("%d", N_ans);
}


Measured memory_bytes: 128
import sys,math
from collections import deque,defaultdict
import operator as op
from functools import reduce

sys.setrecursionlimit(10**6) 

I=sys.stdin.readline

 #s="abcdefghijklmnopqrstuvwxyz"

"""
x_move=[-1,0,1,0,-1,1,1,-1]
y_move=[0,1,0,-1,1,1,-1,-1]
"""
def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))
def mi():
	return map(int,I().strip().split())

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
def divi(n):
	if n==1:
		return 1
	cnt=2
	for i in range(2,int(n**.5)+1):
		if n%i==0:
			if i==n//i:
				cnt+=1
			else:
				cnt+=2
	return cnt


def main():
	cnt=0
	ans=0
	for i in range(ii()):
		a,b=mi()
		if a==b:
			cnt+=1
			if cnt==3:
				ans=1
				
		else:
			cnt=0
	if ans:
		print("Yes")
	else:
		print("No")
	

























	
	
	





if __name__ == '__main__':
	main()

Measured memory_bytes: 9568
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define EPS 0.00000000001
#define INF 1000000000
int main()
{
    int k,n,i;
    scanf("%d %d",&n,&k);
    int a[n];
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    sort(a,a+n);
    int ans=0;
    for(i=0;i<k;i++) ans=ans+a[i];
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 3828
#include <cstdio>
#include <cstring>
#define maxn 6
using namespace std;

char c[maxn][maxn];
int h, w, k;
int cnt = 0;

int main(int argc, char** argv)
{
	scanf("%d%d%d", &h, &w, &k);
	for(int i=0; i<h; i++)
		scanf("%s", c[i]);
	int m1 = 1 << h, m2 = 1 << w, ans = 0;
	for(int hs=0; hs<m1; hs++)
		for(int ws=0; ws<m2; ws++)
		{
			char tmp[maxn][maxn];
			memcpy(tmp, c, sizeof(c));
			for(int i=0; i<h; i++) // Row
				if(hs & (1 << i)) for(int j=0; j<w; j++) // Column
					tmp[i][j] = '.';
			for(int i=0; i<w; i++) // Column
				if(ws & (1 << i)) for(int j=0; j<h; j++) // Row
					tmp[j][i] = '.';
			int cnt = 0;
			for(int i=0; i<h; i++)
				for(int j=0; j<w; j++) if(tmp[i][j] == '#')
					cnt ++;
			if(cnt == k) ans ++;
		}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1700
#include <stdio.h>

int main()
{
    long long N,a[10000],b[10000],i;
    long long sum_a=0,sum_b=0,BA=0,AB=0,X;

    scanf("%lld",&N);

    for(i=0;i<N;i++){
        scanf("%lld",&a[i]);
        sum_a += a[i];
    }
    for(i=0;i<N;i++){
        scanf("%lld",&b[i]);
        sum_b += b[i];
        if(b[i]-a[i]>0){
            BA += ((b[i]-a[i])/2);
        }else{
            BA -= (a[i]-b[i]);
        }
    }

    X = sum_b-sum_a;

    if(sum_b < sum_a){
        printf("No\n");
    }else if(BA>=0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int answer = 1;
  for(int i = 0;i < N;i++) {
    if(i == 0) {
      answer = answer * K;
    }
    else {
      answer = answer * ( K - 1);
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
def isPrime(x):
    if x < 2:
        return False
    for i in range(2, int(x**0.5 + +1.5)):
        if x%i == 0 and i < x:
            return False
    return True

n = int(input())
cnt = 0
for _ in range(n):
    x = int(input())
    if isPrime(x):
        cnt += 1
print(cnt)


Measured memory_bytes: 5708
a,b,k = map(int,input().split())
# aの約数
a_divisor = []
# abの公約数
ab_divisor = []

# aで割れたら順次約数に追加
for i in range(1,a+1):
    if a % i == 0:
        a_divisor.append(i)

# aの約数でbが割れたら公約数に追加
for j in a_divisor:
    if b % j == 0:
        ab_divisor.append(j)
# リストの大きい方からK番目の数値を出力
print(ab_divisor[-k])

Measured memory_bytes: 9104
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int k = scanner.nextInt();
        long[] a = new long[k];
        for (int i = 0; i < k; i++) {
            a[i] = scanner.nextInt();
        }
        long min = 2;
        long max = 2;
        for (int i = k - 1; i >= 0; i--) {
            min = (min - 1) / a[i] * a[i] + a[i];
            max = max / a[i] * a[i] + a[i] - 1;
            if (min > max) {
                System.out.println(-1);
                return;
            }
        }
        System.out.printf("%d %d\n", min, max);
    }
}

Measured memory_bytes: 49020
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n;
  ll a[100000], b[100000];
  ll diff[100000];
  ll cnt = 0;
  ll invsum = 0;
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<n;i++)cin >> b[i];
  for(int i=0;i<n;i++){
    diff[i] = a[i] - b[i];
    if(diff[i] < 0){
      cnt++;
      invsum += diff[i];
    }
  }
  sort(diff, diff+n, greater<ll>());
  for(int i=0;i<n;i++){
    if(invsum>=0 || diff[i] <= 0) break;
    invsum += diff[i];
    cnt++;
  }
  if(invsum < 0) cout << -1 << endl;
  else cout << cnt << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 2000000000;

string s;
ll ans = 0;
int main(){
  cin >> s;
  rep(i,3) if(s.at(i) =='1') ans++;
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=1e9;
ll n,k,num[2000005],dp[2000005];
inline ll smax(ll x,ll y) {return x>y?x:y;}
inline ll smin(ll x,ll y) {return x<y?x:y;}
inline ll sabs(ll x) {return x>0?x:-x;}
int main() {
	cin>>n>>k;
	for (int i=1;i<=n;i++) cin>>num[i];
	for (int i=1;i<=n;i++) dp[i]=inf;
	dp[1]=0;
	dp[2]=dp[1]+sabs(num[1]-num[2]);
//	cout<<smax(1,10000)<<' '<<smin(1,10000)<<' '<<sabs(5-100);
	for (ll i=3;i<=n;i++) 
		for (ll j=i-1;j>=smax(1,i-k);j--) 
			dp[i]=smin(dp[i],dp[j]+abs(num[i]-num[j]));
	
//	for (int i=1;i<=n;i++) cout<<dp[i]<<' ';
//	cout<<endl;
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 5120
///age yekam bekeshi beham is no problem ._.
#include<bits/stdc++.h>
#define size(a) (int)a.size()
#define int long long
#define ld long double
#define F first
#define S second
#define pb push_back
using namespace std;
void null(){return ;}
const int maxn=3e5+7,INF=3e18+9237,mod=1e9+7;
int a[maxn];

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;cin>>n;n*=2;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	int sum=0;
	for(int i=0;i<n;i+=2)sum+=a[i];
	cout<<sum;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using     ll=long long;
using    vll=vector<   ll>;
using   vvll=vector<  vll>;
using  vvvll=vector< vvll>;
using vvvvll=vector<vvvll>;
constexpr ll INF = 1LL << 60;
struct Fast{ //cin,cout高速化のおまじない＋桁数指定
	Fast(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(std::numeric_limits<double>::max_digits10); }
} fast;
#define rep(i, S, E)  for (ll i = (S); i <= (E); i++)
#define dep(i, E, S)  for (ll i = (E); i >= (S); i--)
#define each(e, v) for (auto&& e : v)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }
template<class T> inline T MaxE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmax(m,v[i]); return m; }
template<class T> inline T MinE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmin(m,v[i]); return m; }
template<class T> inline T MaxE(vector<T> &v) { return MaxE(v,0,(ll)v.size()-1); }
template<class T> inline T MinE(vector<T> &v) { return MinE(v,0,(ll)v.size()-1); }
template<class T> inline T Sum(vector<T> &v,ll S,ll E){ T s=T(); rep(i,S,E)s+=v[i]; return s; }
template<class T> inline T Sum(vector<T> &v) { return Sum(v,0,v.size()-1); }
template<class T> inline ll sz(T &v){ return (ll)v.size(); }
template<class T> inline T POW(T a, ll n){ T r=1; for (; n>0; n>>=1, a*=a){ if (n&1)r*=a; } return r; }
inline ll POW(int a, ll n){ return POW((ll)a, n); }
inline ll CEIL(ll a, ll b){ return (a+b-1)/b; }



void solve()
{
	ll n;  cin >> n;
	rep(x,1,50000){
		ll m=x*108/100;
		if (n==m){
			cout << x << '\n'; return;
		}
	}
	cout << ":(" << '\n';
}


int main(){
#if 1
	solve();
#else
	ll t;  cin >> t;
	rep(i, 0, t-1){
		solve();
	}
#endif
	return 0;
}


Measured memory_bytes: 3640
#include <map>
#include <cstdio>
using namespace std;
typedef map<pair<int,int>,int> mpiii;

void solve(int T){
	mpiii m;
	char cmd[2];
	int n,k;
	for(;T--;){
		scanf("%s%d",cmd,&n);
		if(*cmd=='D'){
			for(mpiii::iterator it=m.begin();it!=m.end();){
				if(it->second==n){
					mpiii::iterator it2=it;
					++it;
					m.erase(it2);
				}else{
					++it;
				}
			}
		}else if(*cmd=='R'){
			mpiii::iterator it=m.lower_bound(make_pair(n,2000000000));
			if(it==m.begin()){
				puts("-1");
			}else{
				--it;
				printf("%d\n",it->first.first<=n&&n<=it->first.second ? it->second : -1);
			}
		}else if(*cmd=='W'){
			int cur=0;
			scanf("%d",&k);
			for(mpiii::iterator it=m.begin();it!=m.end();++it){
				int d=it->first.first-cur;
				if(d>k)d=k;
				if(d)m[make_pair(cur,cur+d-1)]=n;
				k-=d;
				if(k==0)break;
				cur=it->first.second+1;
			}
			if(k)m[make_pair(cur,cur+k-1)]=n;
		}
	}
}
int main(){for(int T;~scanf("%d",&T)&&T;puts(""))solve(T);}

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

int main(){
    string s;
    cin >> s;
    int size = s.size();
    bool appear[26];
    for(int i=0;i<26;++i){
        appear[i] = false;
    }
    for(int i=0;i<size;++i){
        appear[s[i]-'a'] = true;
    }
    for(int i=0;i<26;++i){
        if(!appear[i]){
            cout << (char)('a' + i) << "\n";
            return 0;
        }
    }
    cout << "None" << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> H)
{
    for (int i = N - 1; i >= 1; i--)
    {

        if (H[i - 1] - H[i] >= 2)
        {
            cout << NO << endl;
            return;
        }
        if (H[i - 1] - H[i] == 1)
        {
            H[i - 1]--;
        }
    }

    cout << YES << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> H(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
// input var
 
int N;
char S[101];
 
bool is_echo() {
    if (N%2 != 0) {
        return false;
    }
    for (int i = 0; i < N / 2; i++) {
        if (S[i] != S[N/2+i]) {
            return false;
        }
    }
    return true;
}
 
int main(void) {
    // N
    cin >> N;
    
    // S
    cin >> S;
 
    if (is_echo()) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
 
}

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

using namespace std;

int n, k, h[1000001], dp[1000001];

int main(void){
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> h[i];

    dp[0] = 0;
    for(int i = 1; i < n; i++){
        dp[i] = INT_MAX;
        for(int j = 1; j <= k && i - j >= 0; j++){
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

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

int main(){
    using namespace std;
    size_t N, H;
    cin >> N >> H;
    vector<unsigned long> a(N), b(N);
    for(unsigned long i = 0; i < N; ++i)cin >> a[i] >> b[i];
    sort(b.rbegin(), b.rend());
    auto A = *max_element(a.begin(), a.end());
    unsigned long ans{0};
    for(unsigned long i = 0; i < N && b[i] > A && H > 0; ++i){
        ++ans;
        if(H >= b[i])H -= b[i];
        else H = 0;
    }
    cout << ans + (H + A - 1) / A << endl;
    return 0;
}

Measured memory_bytes: 1792
//#include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;

#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+6;

ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}

// using namespace __gnu_pbds;
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set


int32_t main()
{
IOS

    
    int n;
    cin>>n;  
    vector<int> v;
    for(int i=1;i<=n;++i)
        v.push_back(i);
    int a[n+1];
    for(int i=1;i<=n;++i)
        cin>>a[i];
    int b[n+1];
    for(int i=1;i<=n;++i)
        cin>>b[i];
    int c=0;
    int an=0,an1=0;
    do{
        int ch=0;
        for(int i=1;i<=n;++i)
        {
            if(v[i-1]!=a[i])
            {
                ch=1;
                break;
            }
        }
        int ch1=0;
        for(int i=1;i<=n;++i)
        {
            if(v[i-1]!=b[i])
            {
                ch1=1;
                break;
            }
        }
        if(!ch)
            an=c;
        if(!ch1)
            an1=c;
        c++;
    }
    while(next_permutation(v.begin(),v.end()));
    cout<<abs(an-an1);

}    

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

int main() {
  int n;
  cin >> n;
  
  vector<int> x(101);
  x.at(4) = x.at(7) = 1;
  for(int i = 8; i <= 100; i++){
    if(x.at(i - 4) == 1 || x.at(i - 7) == 1){
      x.at(i) = 1;
    }
  }
  
  if(x.at(n)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = a.copy()
for i in range(1,n):
    a[i] += a[i-1]
ans = 0
for i in range(n-1):
    ans += b[i] * (a[-1]-a[i])
mod = 10**9 + 7
print(ans % mod)


Measured memory_bytes: 105372
K,S = map(int,input().split())
ans = 0
for x in range(max(0,S-2*K), K+1):
    rest = S - x
    y_min = max(0, rest-K)
    for y in range(y_min, K+1):
        z = rest - y
        if z <= K and z >= 0:
            ans += 1

print(ans)

Measured memory_bytes: 3060
import sys

s = [1,3,5,7,8,10,12]
t = [4,6,9,11]
r = [2]

arg = raw_input()
x = int(arg.split(" ")[0])
y = int(arg.split(" ")[1])

if (x in s and y in s) or (x in t and y in t) or (x in r and y in r):
    print "Yes";
else:
    print "No";


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

int main() {
    vector<string> s;
    int n,l=0;
    string  g= "";
    cin >> n>>l;
    for(int h=0;h<n;h++)
     {
        cin >>g;
        s.push_back(g);
     }
    sort(s.begin(),s.end());
    
    for(int o=0;o<n;o++)
    {
        cout <<s[o];
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
double pi = acos(-1.0);
const double EPS=1e-9;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define t() ll tt;cin>>tt;while(tt--) 


#define MOD 1000000007


int main()
{
    fastio;
    ll i,j,n,m;
    char x;
    cin>>n>>m;
    vector<vector<ll>>dp(n,vector<ll>(m,0));
    dp[0][0]=1;
    for(i=0;i<n;i++)
    for(j=0;j<m;j++)
    {
        cin>>x;
        if(x=='#') dp[i][j]=0;
        else{
            if(j>0) dp[i][j] = (dp[i][j]+dp[i][j-1])%MOD;
            if(i>0) dp[i][j] = (dp[i][j]+dp[i-1][j])%MOD;
        }
    }
    cout<<dp[n-1][m-1];


}

Measured memory_bytes: 11012
N = input()
N = int(N)
array = list(map(int,  input().split()))
cnt = 0
for i in range(N):
    # print(' '.join(map(str, array)))
    for j in range(N-1, i, -1):
        if array[j] < array[j-1]:
            array[j], array[j-1] = array[j-1], array[j]
            cnt += 1
print(' '.join(map(str, array)))
print("%d" % (cnt))


Measured memory_bytes: 5600
#include <iostream>
    using namespace std;
     
    int main() {
    	int N,count[4]={0,0,0,0};
    	cin>>N;
        for(int i=0;i<N;i++){
            string S;
            cin>>S;
            if(S=="AC")
                count[0]++;
            else if(S=="WA")
                count[1]++;
            else if(S=="TLE")
                count[2]++;
            else
                count[3]++;
        }
        
        cout<<"AC x "<<count[0]<<endl;
        
        cout<<"WA x "<<count[1]<<endl;
        
        cout<<"TLE x "<<count[2]<<endl;
        
        cout<<"RE x "<<count[3]<<endl;
        
    	return 0;
    }

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n,m,k;
    cin>>n>>m>>k;
    vector <int> a(n),b(m);
    loop(i,0,n) cin>>a[i];
    loop(i,0,m) cin>>b[i];
    int ans=0;
    int c=0;

    vector <int> p1(n);
    p1[0]=a[0];
    loop(i,1,n) p1[i]=p1[i-1]+a[i];
    vector <int> p2(m);
    p2[0]=b[0];
    loop(i,1,m) p2[i]=p2[i-1]+b[i];

    loop(i,0,n)
    {
        if(p1[i]<=k){
        auto it=lower_bound(all(p2),k-p1[i]);
        //cout<<i<< " ";
        //cout<<(*it)<< "\n";
        int l;
        if(it==p2.end())
        {
            c=max(c,i+1+m);
            continue;
        }
        if((*it)==k-p1[i])
        {
            l=it-p2.begin()+1;
            c=max(c,i+1+l);
        }
        else
        {
            l=it-p2.begin();
            c=max(c,i+1+l);
        }
        //cout<<c<< "\n";
        }
    }
    int x=c;
    c=0;
    loop(i,0,m)
    {
        if(p2[i]<=k){
        auto it=lower_bound(all(p1),k-p2[i]);
        //cout<<i<< " ";
        //cout<<(*it)<< "\n";
        int l;
        if(it==p1.end())
        {
            c=max(c,i+1+n);
            continue;
        }
        if((*it)==k-p2[i])
        {
            l=it-p1.begin()+1;
            c=max(c,i+1+l);
        }
        else
        {
            l=it-p1.begin();
            c=max(c,i+1+l);
        }
        //cout<<c<< "\n";
        }
    }

    cout<<max(x,c);

    return 0;
}


Measured memory_bytes: 9496
N, Y = map(int, input().split())

m_x, m_y, m_z = (-1, -1, -1)
for x in range(Y // 10000 + 1):
    for y in range(N - x + 1):
        z = N - x - y
        total = 10000 * x + 5000 * y + 1000 * z
        if total == Y:
            m_x, m_y, m_z = (x, y, z)
            break
        else:
            if total > Y:
                break
            else:
                continue

print(m_x, m_y, m_z)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mp  make_pair
using namespace std;

typedef unsigned long long  u64;
typedef pair <int,int>  PII;
int r,c,n,m,ans;
u64 Sed,v[100010],s[100010];
PII a[200010];

int Rnd()
{
	Sed^=Sed<<37;
	Sed^=Sed>>13;
	Sed^=Sed<<47;
	return Sed;
}

int point(int x,int y)
{
	if (x==0)  return y;
	if (y==c)  return c+x;
	if (x==r)  return 2*c+r-y;
	if (y==0)  return 2*c+2*r-x;
	return -1;
}

void work()
{
	scanf("%d %d %d",&r,&c,&n),Sed=19260817;
	for (int i=1,x1,y1,x2,y2; i<=n; i++)
		{
			scanf("%d %d %d %d",&x1,&y1,&x2,&y2),v[i]=Rnd();
			x1=point(x1,y1),x2=point(x2,y2);
			if ((~x1)&&(~x2))  a[++m]=mp(x1,i),a[++m]=mp(x2,i);
		}
	sort(a+1,a+m+1),ans=1;
	for (int i=1,x; i<=m; i++)
		if (!s[x=a[i].second])  s[x]=s[0],s[0]^=v[x];
		else  s[0]^=v[x],ans&=(s[0]==s[x]);
	puts(ans?"YES":"NO");
}

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


Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n); i >= 0; i--)
#define revrepr(i, a, b) for (int i = (a); i >= b; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

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

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

//kで割るとr余るn以下の整数の個数
int calc(int n, int k, int r) { return (n + (k - r) % k) / k; }

int main() {
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    repr(a, 1, n + 1) {
        int r = a % k;
        if (r == 0) {
            ll c = calc(n, k, r);
            ans += c * c;
        }
        else if (k % 2 == 0 && r == k / 2) {
            ll c = calc(n, k, r);
            ans += c * c;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
s=input()
s=s+"D"+"D"
i=0
lists=[]
add=""
while i<len(s):
    if s[i]=="A":
        add+="A"
        i+=1
    elif s[i]=="B"and s[i+1]=="C":
        i+=2
        add+="X"
    else:
        i+=1
        if add: 
            lists.append(add)
            add=""
        else:
            continue
cnt=0
for some in lists:
    somes=list(some)
    nums=len(some)
    if nums==1:
        continue
    elif nums>=2:
        emp=0
        point=0
        for k in range(nums):
            if somes[k]=="A":
                point+=1
            elif somes[k]=="X":
                emp+=point
        cnt+=emp
print(cnt)

Measured memory_bytes: 5280
from itertools import accumulate as acc
import sys

if __name__ == "__main__":
    s = sys.stdin.readlines()
    N, M, Q = map(int, s[0].split())
    LR = [[0]*N for _ in range(N)]
    for l, r in (map(int, e.split()) for e in s[1:M + 1]):
        LR[l - 1][r - 1] += 1

    S = [tuple(acc(reversed(s))) for s in zip(*(acc(x) for x in LR))]
    print('\n'.join(map(str, (S[q - 1][N - p] for p, q in (map(int, e.split()) for e in s[M + 1:])))))

Measured memory_bytes: 38468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{

 ll n,c=0; cin>>n;
 ll a[n+1];
 for(ll i=0;i<n;i++)
 {
     cin>>a[i];
 }
 sort(a,a+n);
 for(ll i=0;i<n;i++)
 {
     for(ll j=i+1;j<n;j++)
     {
         if(a[i]!=a[j]){
         for(ll k=j+1;k<n;k++)
         {
             if(a[j]!=a[k]){
                    if(a[i]+a[j]>a[k])
                    {
                        c++;
                    }
            }

}
}
     }
     }
      

cout<<c<<endl;

}

Measured memory_bytes: 3540
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b)
        printf("a < b\n");
    if(a>b)
        printf("a > b\n");
    if(a==b)
        printf("a == b\n");
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,p=0,A=0,B=0,C=0;
  cin >> n >> a >> b;
  for(int i=0;i<n;i++){
    cin >> p;
    if(p<=a){
      A++;
    }else if(a<p and p<=b){
      B++;
    }else{
      C++;
    }
  }
  cout << min(min(A,B),C) << endl;
  // char c[h][w];
  // bool f[h][w];
  // for(int i=0;i<h;i++){
  //   for(int j=0;j<w;j++){
  //     f[i][j]=true;
  //     cin >> c[i][j];
  //   }
  // }
  // int black[h][w]={},white[h][w]={};
  // for(int i=0;i<h;i++){
  //   for(int j=0;j<w;j++){
  //     int cnt=0;
  //     if(c[i][j]=='#'){
  //       black[i][j]++;
  //     }else{
  //       white[i][j]++;
  //     }
  //     if(i<h-1){
  //       if(c[i+1][j]!=c[i][j]){
  //         if(f[i][j]){
  //           black[i+1][j]+=black[i][j];
  //           white[i+1][j]+=white[i][j];
  //         }else{
  //           if(c[i][j]=='#'){
  //             black[i+1][j]++;
  //           }else{
  //             white[i+1][j]++;
  //           }
  //         }
  //         cnt++;
  //       }
  //     }
  //     if(j<w-1){
  //       if(c[i][j+1]!=c[i][j]){
  //         black[i][j+1]+=black[i][j];
  //         white[i][j+1]+=white[i][j];
  //         cnt++;
  //       }
  //     }
  //     if(cnt==2){
  //       f[i][j+1]=false;
  //     }
  //   }
  // }
  // for(int i=0;i<h;i++){
  //   for(int j=0;j<w;j++){
  //     if(c[i][j]=='#'){
  //       ans+=white[i][j];
  //       // cout << white[i][j] << ' ';
  //     }else{
  //       ans+=black[i][j];
  //       // cout << black[i][j] << ' ';
  //     }
  //     cout << black[i][j] << ',' << white[i][j] << ' ';
  //   }
  //   cout << endl;
  // }

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


Measured memory_bytes: 256
use std::cmp::{min, max};
// stdin
macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

// input
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

#[allow(dead_code)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        return x;
    }
    gcd(y, x % y)
}

#[test]
fn test_primes() {
    assert_eq!(primes(1), vec![1]);
    assert_eq!(primes(140), vec![1, 2, 2, 5, 7])
}

#[allow(dead_code)]
fn primes(num: i64) -> Vec<i64> {
    let mut ans = vec![1];
    let mut cur = num;
    for i in 2.. {
        if i * i > num { break; }
        if cur % i == 0 {
            while cur % i == 0 {
                ans.push(i);
                cur /= i;
            }
        }
    }
    if cur > 1 {
        ans.push(cur);
    }
    return ans;
}


test! {
r"3
2 4 3
" => r"3",

r"12
100 104 102 105 103 103 101 105 104 102 104 101
" => r"0"
}

fn solve(src: &str) -> String {
    input! {
        source=src,
        n:usize,
        a:[i64;n],
    }

    let mut right: Vec<i64> = a;
    let mut ans = 2020202020;

    let mut s = right.iter().sum();
    let mut l_sum = 0;

    while !right.is_empty() {
        let p = right.pop().unwrap();
        l_sum += p;
        s -= p;

        let tmp = max(l_sum, s) - min(l_sum, s);

        ans = min(ans, tmp);
    }


    format!("{}", ans)
}


fn main() {
    println!("{}", solve(&stdin!()));
}



Measured memory_bytes: 9464
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	Scanner sc;

	void run() {
		for (;;) {
			int n = sc.nextInt();
			int t = sc.nextInt();
			int l = sc.nextInt();
			int b = sc.nextInt();

			if ((n | t | l | b) == 0) {
				break;
			}

			n++;
			// int[] L = new int[l];
			boolean[] L = new boolean[n];
			boolean[] B = new boolean[n];
			for (int i = 0; i < l; i++) {
				L[sc.nextInt()] = true;
			}

			for (int i = 0; i < b; i++) {
				B[sc.nextInt()] = true;
			}

			double dp[][] = new double[n][2]; // 2 -> rest

			double ll = 0;

			dp[0][0] = 1;

			for (int j = 0; j < t; j++) {
				double[][] next = new double[n][2];
				for (int i = 0; i < n; i++) {
					next[i][0] += dp[i][1]; // rest to active
					
					if (i == n - 1) {
						next[n - 1][0] += dp[n - 1][0]; // stay in goal
					} else {
						for (int d = 1; d <= 6; d++) {
							int nd = i + d;
							if (nd > n-1 ) {
								nd = 2 * (n-1) - nd ;
							}

							int k = 0;
							if(L[nd]){
								k = 1;
							}
							if(B[nd]){
								nd =0;
							}
							next[nd][k] += dp[i][0]/6;
						}
					}
				}
				dp = next;
			}
			System.out.printf("%f\n",dp[n-1][0]);
		}
	}

	Main() {
		sc = new Scanner(System.in);
		try {
			sc = new Scanner(new File(""));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			// e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
int main(){
  double T,A,H,temp,min=1000;
  int N,i,count;
  scanf("%d",&N);
  scanf("%lf %lf",&T,&A);
  for(i=1;i<=N;i++){
    scanf("%lf",&H);
    temp=T-H*0.006;
    if(fabs(A-temp)<min){
      min=fabs(A-temp);
      count=i;
    }
  }
  printf("%d",count);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N, K, C;
  string S;
  cin >> N >> K >> C >> S;

  if (N == 1) {
    cout << 1 << endl;
    return 0;
  }
  
  vector<int> A(N);
  int prev = - C - 1;
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (i > prev + C and S[i] == 'o') {
      ++cnt;
      prev = i;
    }
    A[i] = cnt;
  }

  vector<int> B(N);
  int next = N + C;
  cnt = 0;
  for (int i = N - 1; i >= 0; --i) {
    if (i < next - C and S[i] == 'o') {
      ++cnt;
      next = i;
    }
    B[i] = cnt;
  }

  if (B[1] < K) {
    cout << 0 + 1 << endl;
  }
  for (int i = 1; i < N - 1; ++i) {
    if (A[i - 1] + B[i + 1] < K) {
      cout << i + 1 << endl;
    }
  }
  if (A[N - 2] < K) {
    cout << N - 1 + 1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3332
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
    // int d, t, s;

    // cin >> d >> t >> s;

    //it had better to use double or calculate as multiplier
    // if (d / s < t)
    // {
    //     cout << "Yes" << endl;
    // }
    // else if (d / s == t && d % s == 0)
    // {
    //     cout << "Yes" << endl;
    // }
    // else
    // {
    //     cout << "No" << endl;
    // }

    // string s, t;
    // cin >> s >> t;

    // int sum = 0, tmp;
    // for (int i = 0; i < s.length() - t.length() + 1; i++)
    // {
    //     tmp = 0;
    //     for (int j = 0; j < t.length(); j++)
    //     {

    //         if (s[i + j] == t[j])
    //         {
    //             tmp++;
    //         }
    //     }
    //     if (sum < tmp)
    //     {
    //         sum = tmp;
    //     }
    // }
    // cout << t.length() - sum << endl;
    int mod = 1000000007;
    int n;
    cin >> n;
    vector<int> v(n);
    vector<long long> sum(n + 1, 0);

    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        sum[i + 1] = sum[i] + v[i];
    }

    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        long long sum_n = (sum[n] - sum[i + 1]) % mod;
        ans += sum_n * v[i];
        ans %= mod;
    }

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

Measured memory_bytes: 5632
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

string S, T;
int A, B;
string U;

signed main()
{
	cin >> S >> T;
	cin >> A >> B;
	cin >> U;
	if (S == U)
	{
		cout << (A - 1) << " " << B << endl;
	}
	else
	{
		cout << (A) << " " << (B - 1) << endl;
	}
}


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

int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int ans = INT_MAX;

  for(int k=0; k<=max(x,y)*2; k++){
    int price =c*k + max(x-k/2,0)*a + max(y-k/2,0)*b;

    if(ans>= price){
      ans= price;
    }
  }
  cout<< ans <<endl;
  return 0;
}


Measured memory_bytes: 256