akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> vec(n, 0);
	long long s = 0;
	for(int i = 0; i < n; ++i){
		cin>>vec[i];
		s += vec[i];
	}
	sort(vec.begin(), vec.end());
	long k = s / n;

	auto x = lower_bound(vec.begin(), vec.end(), k);
	auto y = lower_bound(vec.begin(), vec.end(), k);

	int t = x - vec.begin();
	int r = y - vec.begin();

	if(t == r){
		if(n % 2 == 0){
			cout<<vec[n/2]-vec[n/2-1]<<endl;
		}
		else{
			cout<<0<<endl;
		}
	}
	else{
		cout<<vec[r] - vec[t]<<endl;
	}
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[] C = new int[N - 1];
		int[] S = new int[N - 1];
		int[] F = new int[N - 1];
		for (int i = 0; i < N - 1; i++) {
			C[i] = in.nextInt();
			S[i] = in.nextInt();
			F[i] = in.nextInt();
		}
		for (int i = 0; i < N - 1; i++) {
			int t = S[i] + C[i];
			for (int j = i + 1; j < N - 1; j++) {
				if (t % F[j] == 0) {
					t += S[j] <= t ? C[j] : S[j] - t + C[j];
				} else {
					t += S[j] <= t ? F[j] - t % F[j] + C[j] : S[j] - t + C[j];
				}
			}
			System.out.println(t);
		}
		System.out.println(0);
		in.close();
	}
}

Measured memory_bytes: 25908
// D - Bouquet
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N,A,B;
ll MOD = 1000000007;

// a^n mod m を計算する(二分累乗法:O(logn))
ll modpow(ll a, ll n, ll m) {
	ll res = 1;
	while(n > 0){
		if(n & 1) res = res * a % m;
		a = a * a % m;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod m : 逆元を求める(非再帰)
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while(b){
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if(u < 0) u += m;
	return u;
}

// nCr mod m
ll nCr(ll n, ll r, ll m){
	ll ret = 1;
	for(ll i=0; i<r; ++i) ret = (ret * (n-i))%m * modinv(r-i,m) % m;
	return ret;
}

ll solve(){
	ll sum_nCr = modpow(2, N, MOD) - 1;
	ll nca = nCr(N, A, MOD);
	ll ncb = nCr(N, B, MOD);
	ll ans = (sum_nCr - (nca + ncb)%MOD)%MOD;
	if(ans < 0L) ans += MOD;
	return ans;
}

int main(){
	cin>>N>>A>>B;
	cout<< solve() <<endl;
}

Measured memory_bytes: 256
n = int(input())
l = len(str(n))
sum = 0
#print(l)
if l%2 ==0:
  for i in range(int(l/2)):
    sum += 9*(10**(2*i))
else:
  for i in range(int(l//2)):
    sum += 9*(10**(2*i))
  sum += n -10**(l-1) +1
print(sum)

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

int main(void)
{
	int n, i;
	int s[1000];
	double m, sum;
	double siguma;
	
	for(; ; ) {
		scanf("%d", &n);
		if(n==0) break;
		else {
			m=0; sum=0;
			for(i=0; i<n; i++) {
				scanf("%d", &s[i]);
				m+=s[i];
			}
			m=(double)m/n;
			
			for(i=0; i<n; i++)
				sum+=pow(s[i]-m, 2);
			sum/=n;
			siguma=sqrt(sum);
			printf("%f\n", siguma);
		}
	}
	
	return 0;
}


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

using namespace std;

template<typename T>
vector<int> Zalgorithm(T S){
    vector<int> res(S.size());
    res[0] = S.size();
    int i = 1, j = 0;
    while (i < S.size()) {
        while (i+j < S.size() && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < S.size() && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k; j -= k;
    }
    return res;
}

int main(){
    int N;
    while(cin >> N){
        vector<int> a(N), b(N);
        for(auto& t : a) cin >> t;
        for(auto& t : b) cin >> t;
        vector<int> xa(N), xb(N);
        for(int i=0;i<N;i++){
            xa[i] = a[i]^a[(i+1)%N];
            xb[i] = b[i]^b[(i+1)%N];
        }
        vector<int> z = xb;
        z.push_back(-1);
        z.insert(z.end(), xa.begin(), xa.end());
        z.insert(z.end(), xa.begin(), xa.end());
        auto len = Zalgorithm(z);
        for(int i=0;i<N;i++){
            if(len[N+1+i] == N) cout << i << " " << (a[i]^b[0]) << endl;
        }
    }
}

Measured memory_bytes: 11292
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>



using namespace std;


int main() {
	int n;
	cin >> n;
	long long sum = 0;
	vector<int> a(n + 1);
	for (int i = 0; i < n+1; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < n; i++) {
		int b;
		cin >> b;
		if (a[i] > 0) {
			if (a[i] > b) {
				a[i] -= b;
				sum += b;
				b = 0;
			}
			else {
				b -= a[i];
				sum += a[i];
				a[i] = 0;
			}
		}

		if (b > 0) {
			if (a[i + 1] > b) {
				a[i + 1] -= b;
				sum += b;
				
			}
			else {
				sum += a[i + 1];
				a[i + 1] = 0;
				
			}
		}
	}


	
	cout << sum;

}

Measured memory_bytes: 640
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let x = iter.next().unwrap().parse::<i32>().ok().unwrap();
	let a = iter.next().unwrap().parse::<i32>().ok().unwrap();
	if x < a {
		println!("0");
	}else{
		println!("10");
	}
}

Measured memory_bytes: 2072
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc = new Scanner (System.in);
		
		int [] pasta = new int [3];
		int [] juice = new int [2];
		
		int i, j;
		
		int sum = 0;
		int min = 9999;
		
		for (i = 0; i < 3; i++) {
			pasta[i] = sc.nextInt();
		}
		
		for (i = 0; i < 2; i++) {
			juice[i] = sc.nextInt();
		}
		
		for (i = 0; i < 3; i++) {
			for (j = 0; j < 2; j++) {
				sum = pasta[i] + juice[j] - 50;
				if (sum < min) {
					min = sum;
				}
			}
		}
		
		System.out.println(min);
		
	}

}

Measured memory_bytes: 17164
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int cnt = 0;
        int n = s.length();

        for(int i = 0; i < n; i++){
            if(s.charAt(i) == '1'){
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		// std::ios::sync_with_stdio(false);
		// #ifndef ONLINE_JUDGE
  //   // for getting input from input.txt
	 //    freopen("input.txt", "r", stdin);
	 //    // for writing output to output.txt
	 //    freopen("output.txt", "w", stdout);
		// #endif
		// cin>>T;
		// // cin.ignore(); must be there when using getline(cin, s)
		// while(T--)
		// {
			
		// }
		// return 0;
		string s;
		cin >> s;
		if(s[2]==s[3] && s[4]==s[5]){

			cout << "Yes" << endl;
		} 
		else{
			cout << "No" << endl;
		}
	}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair <int,int> PII;
typedef pair <ll, ll> PLL;
typedef pair <int,string> PIS;
typedef vector <int> vec;
typedef priority_queue<int> PQ;
#define endl '\n'
#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fori(z,n)  for(int i=z;i<n;i++)
#define fork(z,n)  for(int k=z;k<n;k++)
#define forii(z,n) for(int i=z;i<=n;i++)
#define forkk(z,n) for(int k=z;k<=n;k++)
#define mod 1000000007
int maxElement(int arr[],int n)
{
    int maxi=arr[0];
    for(int i=1;i<n;i++)
    {
        if(arr[i]>maxi)
            maxi=arr[i];
    }
    return maxi;
}
int minElement(int arr[],int n)
{
    int mini=arr[0];
    for(int i=1;i<n;i++)
    {
        if(arr[i]<mini)
            mini=arr[i];
    }
    return mini;
}
string trim(const string& str)
{
    size_t first = str.find_first_not_of(' ');
    if (string::npos == first)
    {
        return str;
    }
    int last = str.find_last_not_of(' ');
    return str.substr(first, (last - first + 1));
}
int main() 
{ 
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;cin>>n>>k;
    vector<int> arr(n+1);
    fori(1,n+1) cin>>arr[i];
    ll dp[n+1][k+1];
    dp[0][0]=1;
    fori(1,k+1) dp[0][i]=0;
    fori(1,n+1) dp[i][0]=1;
    fori(1,n+1)
    {
        ll sum[k+1];
        sum[0]=1;
        for(int p=1;p<=k;p++)
            sum[p]=((sum[p-1]%mod)+(dp[i-1][p]%mod))%mod;
        for(int p=0;p<=k;p++)
        {
            if(p-arr[i]-1>=0)
                dp[i][p]=(sum[p]-sum[p-arr[i]-1]+mod)%mod; // subtraction may lead to negative number.
            else
                dp[i][p]=sum[p];
        }
    }
    /* fori(0,n+1) */
    /* { */
    /*     for(int p=0;p<=k;p++) */
    /*         cout<<dp[i][p]<<" "; */
    /*     cout<<endl; */
    /* } */
    cout<<dp[n][k]<<endl;
    cerr<<"Time elapsed"<<1.0*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}


Measured memory_bytes: 80000
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    
    if(N < 1200){
        cout << "ABC\n";
    }
    else if(N < 2800){
        cout << "ARC\n";
    }
    else{
        cout << "AGC\n";
    }
}

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

string a,b,c;

int main(){
	cin >> a >> b >> c;
	
	int x='A'-'a';
	cout << (char)(a[0]+x) << (char)(b[0]+x) << (char)(c[0]+x) << endl;
	
	return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 9

using namespace std;

typedef unsigned long long ull;

const string Y = "YES", N = "NO";
int n,field[MAX][MAX],V;
vector<int> V_sum;
vector<int> coor;

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

inline bool isValid(int x,int y){ return 0 <= x && x < n && 0 <= y && y < n; }

bool check(ull used,int cur,int x,int y){
  int sp_x = x, sp_y = y;

  REP(i,cur,V){
    ull tmp_used = used;
    if( i != cur ) sp_x = coor[i] % n, sp_y = coor[i] / n;
    deque<int> deq;
    deq.push_back(sp_x+sp_y*n);
    bool ok = false;
    int score = V_sum[i];
    if( score == 0 ) ok = true;
    while(!deq.empty()){
      int p = deq.front(); deq.pop_front();
      int cx = p % n, cy = p / n;
      if(ok)break;
      rep(j,4){
	int nx = cx + dx[j];
	int ny = cy + dy[j];
	if(!isValid(nx,ny))continue;
	if((tmp_used>>(nx+ny*n))&1)continue;
	tmp_used |= (1ULL<<(nx+ny*n));
	score += field[ny][nx];
	if( score >= 0 ){
	  ok = true;
	  break;
	}
	deq.push_back(nx+ny*n);
      }
    }
    if(!ok)return false;
  }
  return true;
}

bool dfs(ull used,int cur,int pre,int x,int y,int sum){

  if( cur >= V ){
    //if( used == (1ULL<<(n*n))-1ULL ) return true;
    //return false;
    return true;
  }

  //if(!check(used,cur,x,y))return false;

  rep(i,4){
    //if( i == pre ) continue;
    int nx = x + dx[i];
    int ny = y + dy[i];
    if( !isValid(nx,ny) ) continue;
    if( (used>>(nx+ny*n)) & 1 ) continue;
    if( field[ny][nx] < 0 ) continue;
    if( sum + field[ny][nx] > V_sum[cur] ) continue;

    int ncur = cur;
    int npre = ( i + 2 ) % 4;
    int nsum = sum + field[ny][nx];
    ull nused = used | (1ULL<<(nx+ny*n));
    if( sum + field[ny][nx] == V_sum[cur] ){
      ncur++;
      npre = -1;
      nsum = 0;
      nx = coor[ncur] % n;
      ny = coor[ncur] / n;
    }
    if( dfs(nused,ncur,npre,nx,ny,nsum) ) return true;
  }

  return false;  
}

int main(){

  while( scanf("%d",&n), n ){
    ull initial_state = 0ULL;
    V = 0;
    coor.clear();
    V_sum.clear();
    int sum = 0;
    rep(i,n)rep(j,n){
      scanf("%d",&field[i][j]);
      sum += field[i][j];
      if( field[i][j] < 0 ){
	V++;
	ull tmp = (1ULL<<(j+i*n));
	coor.push_back(j+i*n);
	initial_state |= (1ULL<<(j+i*n));
	V_sum.push_back(-field[i][j]);
      }
    }

    if( sum != 0 ){
      cout << N << endl;
      continue;
    }

    bool res = dfs(initial_state,0,-1,coor[0]%n,coor[0]/n,0);
    cout << (res?Y:N) << endl;
  }

  return 0;
}

Measured memory_bytes: 1236
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        int count = 0;
        int max = 0;
        h[0] = sc.nextInt();
        for(int i =1;i<n;i++){
            h[i] = sc.nextInt();
            if(h[i]<=h[i-1]){
                count ++;
            } else {
                max = Math.max(max,count);
                count = 0;
            }
        }
      	max = Math.max(max,count);
        System.out.println(max);
}
}


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

ll f(map<ll,ll> &mp,ll n, ll &a, ll &b, ll &c, ll &d){
  if(n == 0) return 0;
  if(n == 1) return d;
  if(mp[n] != 0) return mp[n];
  ll ans = INF;
  vector<int> v = {2,3,5};
  for(int i=0; i<3; ++i){
    ll l = n/v[i];
    ll r = n/v[i]+1;
    if(n < 2001001001) ans = min(ans, n*d); 
    ans = min(ans, f(mp,l,a,b,c,d) +(n -l*v[i]) *d +((v[i]==2)?a:(v[i]==3)?b:c));
    if(r == n) continue;
    ans = min(ans, f(mp,r,a,b,c,d) +(r*v[i] -n) *d +((v[i]==2)?a:(v[i]==3)?b:c));
  }
  //if(n<100) cout << "n:" << n << " ans:" << ans << endl;
  return mp[n] = ans;
}

int main(){
  int t;
  cin >> t;
  for(int i=0; i<t; ++i){
    ll n;
    ll a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    map<ll,ll> mp;
    ll ans = f(mp, n, a, b, c, d);
    cout << ans << endl;
  }
}

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

int main(){
	int n;
	cin >> n;
	vector<int> w(n);
	rep(i,n){
		cin >> w[i];
	}
	int sum = 0;
	rep(i,n-1){
		w[i+1] += w[i];
	}
	
	int val = abs(2*w[0] - w[n-1]);
	
	
	int ans = 0;
	rep(i,n){
		val = min(val,abs(2*w[i]-w[n-1]));
	}
	
	cout << val << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

void swap(int &x,int &y);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
    
//system("pause");
return 0;

}

void swap(int &x,int &y){
	int tmp=x;
	x=y;
	y=tmp;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
#define MOD 1000000007ll

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

typedef long long ll;
typedef complex<double> P;
typedef complex<double> Vec;
typedef pair<int, int> pii;
typedef pair<int, pii> p;

int main() {
	ll n;
	cin >> n;
	
	ll ans = n / 11 * 2; n = n % 11;
	while (n > 0) {
		if (n > 0) {
			n -= 6;
			ans++;
		}
		if (n > 0) {
			n -= 5;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,m = get_nums_l()
s = input()
s = s[::-1]

now = 0
steps = []
while now < n:
    for i in range(m,0,-1):
        if now+i > n:
            continue
        if s[now+i] == "0":
            now += i
            steps.append(i)
            break
    else:
        print(-1)
        exit()

print(" ".join(map(str, reversed(steps))))


Measured memory_bytes: 49972
#include <algorithm>
#include <iostream>
using namespace std;
int main(void) {
  string x;
  cin >> x;
  transform(x.begin(), x.end(), x.begin(), ::tolower);

  int cnt = 0;
  while (true) {
    string t;
    cin >> t;
    if ( t == "END_OF_TEXT" ) break;
    transform(t.begin(), t.end(), t.begin(), ::tolower);

    if ( t==x ) {
      cnt++;
    }
  }

  cout << cnt << endl;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N, A, B;
  string s;
  cin >> N >> A >> B >> s;

  int tuuka = 0, kaigai = 0;

  rep(i, N) {
    if(s[i] == 'a') {
      if(tuuka < A + B) {
        tuuka ++;
        cout << "Yes" << endl;
        continue;
      }
    }
    if(s[i] == 'b') {
      if(tuuka < A + B) {
        if(kaigai < B) {
          tuuka ++,
          kaigai ++;
          cout << "Yes" << endl;
          continue;
        }
      }
    }

    cout << "No\n";
  }
  
  return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define task "LUCKYSQ"
#define pll pair<ll, ll>
#define pii pair<ll, pll>
#define fi first
#define se second
using namespace std;
const ll mod = 998244353;
const ll N = 2e5 + 5;
const ll mxn = 1e6 + 5;

ll n, m, u, v, st[N*4], t, k, T, ans, tong, a[N], b[N], d[N];
vector<ll> kq;
void build(ll id, ll l , ll r)
{
    if(l > u || u > r)return;
    if(l == r)
    {
        st[id] += 1;
        return;
    }
    ll mid = (l + r) / 2;
    if(mid >= u)build(id*2, l, mid);
    else build(id*2+1, mid+1, r);
    st[id] = st[id*2] + st[id*2+1];
}
ll get(ll id, ll l, ll r)
{
    if(u > r || l > v)return 0;
    if(u <= l && r <= v)return st[id];
    ll mid = (l + r) / 2;
    return get(id*2, l ,mid) + get(id*2+1, mid+1, r);
}
ll f(ll u)
{
    return lower_bound(kq.begin(), kq.end(), u) - kq.begin() + 1;
}
bool ck(ll x)
{
    kq.clear();
    memset(st, 0, sizeof(st));
    tong = 0;
    for(int i = 1; i <= n; i ++)
    {
        d[i] = d[i-1];
        if(a[i] >= x) ++ d[i];
        kq.pb(2*d[i] - i);
    }
    kq.pb(0);
    sort(kq.begin(), kq.end());
    kq.erase(unique(kq.begin(), kq.end()), kq.end());
    u = f(0);
    build(1, 1, n+1);
    for(int i = 1; i <= n; i ++)
    {
        u = 1, v = f(2*d[i]-i);
        tong += get(1, 1, n+1);
        u = f(2*d[i]-i);
        build(1, 1, n+1);
    }
    //cout << x <<" "<<tong<<endl;
    return tong >= ans;
}
inline void sol()
{
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b+1, b+1+n);
    ll lf = 1, rt = n, mid;
    ans = n * (n + 1) / 2;
    ans = (ans + 1) / 2;
    while(lf <= rt)
    {
        mid = (lf + rt) / 2;
        if(ck(b[mid]))lf = mid + 1;
        else rt = mid - 1;
    }
    cout << b[rt];
}
int main()
{
    if(fopen(task".INP", "r")){
       freopen(task".INP", "r", stdin);
       freopen(task".OUT", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    sol();
}






Measured memory_bytes: 12732
#include <iostream>
#include <vector>
using namespace std;
#define MOD 1000000007
#define NMAX 1000

int main() {
  int n;
  cin >> n;
  vector<int> a(NMAX+1, 1);
  for (int i = 2; i <= n; i++) {
    int p = i;
    for (int j = 2; j*j <= i; j++) {
      if (p % j == 0) {
        p /= j;
        a[j]++;
        j--;
      }
    }
    a[p]++;
  }
  int ans = 1;
  for (int i = 2; i <= n; i++) {
    ans = 1LL * ans * a[i] % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<map>
#include<cmath>
#include<set>
using namespace std;
#define rep(i,n) for(int i =0;i < n;i++)
int main() {
	int n, m, a, b;
	cin >> n >> m;
	vector<vector<char>> c(n + 2, vector<char>(m + 2,'#'));
	for (int i = 1;i <= n;i++) {
		for (int j = 1;j <= m;j++) {
			cin >> c[i][j];
		}
	}
	rep(i, n + 2) {
		rep(j, m + 2) {
			cout << c[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M ((ll)(1e9)+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
int h,w;char ch[21][21];int a[21][21],v[21][21];
void dfs(int i,int j,int c)
{
    if(i<0||j<0||i>=h||j>=w||ch[i][j]=='#')
    return;
    if(v[i][j]==1)
    {
        if(c>=a[i][j])
        return;
    }
    a[i][j]=c;
    v[i][j]=1;
    dfs(i-1,j,c+1);
    dfs(i+1,j,c+1);
    dfs(i,j-1,c+1);
    dfs(i,j+1,c+1);
}
void solve()
{
    cin>>h>>w;
    for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
    cin>>ch[i][j];
    int ma=0;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(ch[i][j]=='.')
            {
                for(int k=0;k<h;k++)
                for(int l=0;l<w;l++)
                a[k][l]=v[k][l]=0;
                
                dfs(i,j,0);
                //cout<<1<<endl;
                int ma1=0;
                for(int k=0;k<h;k++)
                for(int l=0;l<w;l++)
                ma1=max(ma1,a[k][l]);
                ma=max(ma,ma1);
            }
        }
    }
    cout<<ma<<endl;
}

int main()
{
    solve();
}

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


int main(void) {
    int n, d, x;
    cin >> n >> d >> x;
    
    int ary[n];
    
    for (int k = 0; k < n; k++) {
        cin >> ary[k];
    }
    
    int total_choco = 0;
    for (int i = 0; i < n; i++) {
        total_choco++;
        for (int j = 1; j < 100; j++) {
            if (j * ary[i] + 1 > d) {
                break;
            }else
                total_choco++;
        }
    }
    
    cout << total_choco + x << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        2019
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	ll val=0,n=s.size(),pw=1;
	mi m;
	m[0]++;
	ll ans=0;
	for(ll i=n-1;i>=0;i--){
		val = ((s[i]-'0')*pw +val )%mod;
		ans+= m[val];
		m[val]++;
		pw= (pw*10)%mod;
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int A[100];
int N,v;
void insertionSort(int A[], int N);
void print(int A[], int N);
int main()
{
	//cout << "????????\??°?????????N:" << endl;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
	//	scanf("%d", &A[i]);
		cin >> A[i];
	}
	insertionSort(A, N);
}
void insertionSort(int A[], int N)
{
	for (int i = 0; i < N; i++)
	{
		v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j]>v)
		{
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		print(A, N);
	}
}
void print(int A[], int N)
{
	for (int i = 0; i < N; i++)
	{
		if (i >0)
		{
			cout << " ";
		}
		cout << A[i];
		
	}
	cout << endl;
}
/*scanf  ?????????
???????????\?????°
?????? #include<stdio.h>    //???????????\????????´?????¶
??????
scanf("????????§??¶????¬????",??°????????¨);
??????
scanf("%d %f",&a,&b);
?????¢ %d  ??¨??? ?¬¬?????? ?????\??°??? ??? ????????¶
       %f  ??¨???  ?¬¬???????????\??°??????  ????????°
        &a ??¨??? a?????°???
      &b ??¨??? b??? ??°???
&a[i] ????????´??°????????°???*/

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n;
    vector<long double> arr(n+1);
    vector<vector<long double>> dp(n+1,vector<long double>(n+1,0));
    for(int i=1; i<=n;i++)
        cin>>arr[i];
    dp[0][0] = 1;
    for(int i=1; i<=n;i++){
        for(int j=0; j<=i; j++){
            dp[i][j] = dp[i-1][j]*(1.00000 - arr[i]);
            if(j>0)
                dp[i][j] += dp[i-1][j-1]*arr[i];
        }
    }
    long double ans = 0;
    for(int i=0; i<=n; i++){
        if(i>n-i)
            ans += dp[n][i];
    }
    cout<<fixed<<setprecision(15)<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 141056
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}

#define maxn 100 + 5
#define max_sqrt_k 35000
#define mod 1000000007

int dp[2][max_sqrt_k][2], n, k, sqrt_k, i, j, t, ret, pref, sum0, sum1, count_lr[max_sqrt_k], le, ri, l, p;

void upd (int &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}

int main (int argc, char * const argv[]) {
    scanf("%d %d", &k, &n);
    while (sqrt_k * sqrt_k < k) ++sqrt_k;
    for(i = 1; i <= sqrt_k; i++) dp[1][i][0] = 1;
    for(i = 1; i < sqrt_k; i++) {
        le = k / (i + 1) + 1;
        ri = k / i;
        if (ri <= sqrt_k) continue;
        le = max(le, sqrt_k + 1);
        count_lr[i] = ri - le + 1;
    }
    for(i = 1; i < sqrt_k; i++) dp[1][i][1] = count_lr[i];
    l = 1;
    for(i = 2; i <= n; i++) {
        p = l;
        l ^= 1;
        sum0 = sum1 = 0;
        for(j = 1; j <= sqrt_k; j++) {
            upd(sum0, dp[p][j][0]);
            upd(sum1, dp[p][j][1]);
        }
        t = sqrt_k;
        for(j = 1; j <= sqrt_k; j++) {
            while (j * t > k) upd(sum0, mod - dp[p][t--][0]);
            dp[l][j][0] = sum1 + sum0;
            if (dp[l][j][0] >= mod) dp[l][j][0] -= mod;
            upd(sum1, mod - dp[p][j][1]);
        }
        pref = 0;
        for(j = 1; j < sqrt_k; j++) {
            upd(pref, dp[p][j][0]);
            dp[l][j][1] = (count_lr[j] * 1LL * pref) % mod;
        }
    }
    for(j = 1; j <= sqrt_k; j++) {
        upd(ret, dp[l][j][0]);
        upd(ret, dp[l][j][1]);
    }
    printf("%d\n", ret);
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c,d,l,r;
  	cin >> a>>b>>c>>d;
  	l=a+b;
  	r=c+d;
  	if(l==r){
    	cout << "Balanced"<<endl;
    }else if(l>r){
    	cout << "Left"<< endl;
    }else{
    	cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	char s[100];
	while(cin>>s)
	{int l=strlen(s); 
	if(l<4)cout<<"No"<<endl; 
	else 
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	} 
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  no1
//
//  Created by Kae on 2015/04/23.
//  Copyright (c) 2015??´ Kae. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    while(cin >> n,n!=0){
    int max;
    int min;
    max = 0;
    min = 1005;
    int sum = 0;
    int x;
    for (int i = 0;i < n;i = i+1){
        cin >> x;
        sum = sum + x;
        if(x > max){
            max = x;}
        if(x < min){
            min = x;}
    }
    cout << (sum - max - min) / (n-2)<< endl;
    }return 0;
}

Measured memory_bytes: 1160
import java.util.stream.*;
import java.io.*;

public class Main {
  
  static int n;
  static long[] dp, h;

  static long max(long a, long b, long c){
    return Math.max(Math.max(a, b), c);
  }

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

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

    String[] in;
    in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);

    in = br.readLine().split(" ");
    h = Stream.of(in).mapToLong(Long::parseLong).toArray();

    br.close();

    dp = new long[n+1];
    dp[2] = Math.abs(h[1] - h[0]);
    for(int i = 3; i <= n; i++){
      dp[i] = Math.min(dp[i-1] + Math.abs((h[i-1] - h[i-2])), dp[i-2] + Math.abs((h[i-1] - h[i-3])));
    }
    
    System.out.println(dp[n]);
  }
}

Measured memory_bytes: 37344
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		System.out.println(A*B);
		
	}
}

Measured memory_bytes: 26972
#include<stdio.h>
#include<string.h>

int main()
{

char S[1002];
int x,i;
gets(S);
x=strlen(S);
for(i=0;i<x;i++)
printf("%c",S[i]);

if(S[strlen(S)-1]!='s')
printf("s\n");
else 
printf("es\n");
    

    return 0;
}
    

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

int main(void){
    int K, A, B;

    scanf("%d", &K);
    scanf("%d %d", &A, &B);

    if(A/K < B/K) {
        cout << "OK" << endl;
    }else{
        if(A % K != 0){
            cout << "NG" << endl;
        }else{
            cout << "OK" << endl;
        }
    }

    return 0;
}

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


int main() {
  int A, B, K;
  vector<int> nums;
  cin >> A >> B >> K;

  int i = 1;
  for (; i <= min(A, B); i++) {
    if (A % i == 0 && B % i == 0) {
      nums.insert(nums.begin(), i);
    }
  }

  cout << nums.at(K-1) << endl;

  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toInt)
    val x = readLine()!!.split(' ').map(String::toLong)
    println((0..(x.size - k)).map{x[it + k - 1] - x[it] + Math.min(Math.abs(x[it + k - 1]), Math.abs(x[it]))}.min())
}

Measured memory_bytes: 51924
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

vector<vector<tuple<int,llint,int>>>go;
vector<vector<int>>reve;
llint solve(int ter,int per){
	llint ans=1;
	for(auto it:go[ter]){
		if(get<0>(it)==per){continue;}
		ans*=solve(get<0>(it),ter);
		ans%=mod;
	}
	ans++;ans%=mod;
	for(auto it:go[ter]){if(get<0>(it)==per){
		get<1>(go[per][get<2>(it)])=ans;
	}}
	return ans;
}
vector<llint>ans;
void resol(int ter,int per){
	int i,z=go[ter].size();
	vector<llint>L(z+1,1);
	vector<llint>R(z+1,1);
	for(i=0;i<z;i++){L[i+1]=L[i]*get<1>(go[ter][i])%mod;}
	for(i=z-1;i>=0;i--){R[i]=R[i+1]*get<1>(go[ter][i])%mod;}
	ans[ter]=L[z];

	for(i=0;i<z;i++){
		int ait=get<0>(go[ter][i]);
		if(ait==per){continue;}
		get<1>(go[ait][get<2>(go[ter][i])])=(L[i]*R[i+1]+1)%mod;
		resol(ait,ter);
	}
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	llint i,n,gen;cin>>n>>mod;go.res(n);
	reve.res(n);
	//なんでmodが自由なの～?
	//逆元を阻害したかった?
	//codeforces
	for(i=0;i<n-1;i++){
		int x,y;cin>>x>>y;x--;y--;
		int sx=go[x].size();
		int sy=go[y].size();
		go[x].pub(mt(y,0LL,sy));
		go[y].pub(mt(x,0LL,sx));
		
	}
	ans.res(n);
	solve(0,-1);
	resol(0,-1);
	for(i=0;i<n;i++){cout<<ans[i]<<endl;}
	return 0;
}


Measured memory_bytes: 24448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;			
int main() {
 	ios::sync_with_stdio(false);
  			cout.tie(nullptr);
  			cin.tie(nullptr);
  int n,c=0;
  cin >> n;
  cin.ignore();
  string a[n],b[n];
  for(int i=0;i<n;i++){
    getline(cin,a[i]);
  }
  sort(a,a+n);
for(int i=0;i<n;i++){
    if(a[i]!=a[i+1]) c++;
      }
  cout << c;

}

Measured memory_bytes: 16148
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<deque>
#include<map>
#include<set>

#define MN 200007

using namespace std;

int x_1, y_1, x_2, y_2;
int N, N2;
//vector<pair<int, int>> P;
vector<pair<int, pair<int, int>>> X, Y;// Xは(x,y,i)，Yは(y,x,i)で格納．
vector<int> ify2;
map<int, int> ifx;

void showVec(vector<int> &v, const char *s){
  int n = static_cast<int>(v.size());
  cout << s << endl;
  for( int i = 0; i < n; i++ ){ cout << v[i] << endl; }
}

void showVecPP(vector<pair<int, pair<int, int>>> &v, const char *s){
  int n = static_cast<int>(v.size());
  cout << s << endl;
  for( int i = 0; i < n; i++ ){
	cout << v[i].second.second << ":" << v[i].first << "," << v[i].second.first << endl;
  }
}

int input(){
  int x, y;
  cin >> x_1 >> y_1 >> x_2 >> y_2;
  
  if( (x_1 > x_2) || (x_1 == x_2 && y_1 > y_2) ){
	x = x_1; x_1 = x_2; x_2 = x;
	y = y_1; y_1 = y_2; y_2 = y;
  }
  
  int py = (y_1 <= y_2 ? 1 : -1);
  cin >> N;
  //P.reserve(MN);
  for( int i = 0; i < N; i++ ){
	cin >> x >> y;
	if( x < x_1 || x_2 < x ){ continue; }
	if( (y < y_1 && y < y_2) || (y_1 < y && y_2 < y) ){ continue; }
	//P.push_back(pair<int, int>(x, y));
	y *= py;
	X.push_back(pair<int, pair<int, int>>(x, pair<int, int>(y, i)));
	Y.push_back(pair<int, pair<int, int>>(y, pair<int, int>(x, i)));
  }
  y_1 *= py;
  y_2 *= py;
  //sort(P.begin(), P.end());
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  N2 = static_cast<int>(X.size());
  //NF.resize(N2);
  ify2.resize(N2);
  for( int i = 0; i < N2; i++ ){
	ifx.insert(pair<int, int>(X[i].second.second, i));
  }
  for( int i = 0; i < N2; i++ ){
	ify2[i] = ifx.at(Y[i].second.second);
  }
  
  return 0;
}

int dp[MN];
#define INF 1e+9

long solve() {
  fill(dp, dp+N2, INF);
  for (int i=0; i<N2; ++i) {
	*lower_bound(dp, dp+N2, ify2[i]) = ify2[i];
  }
  long ret = lower_bound(dp, dp+N2, INF) - dp;
  return ret;
}

/*
int getNF(){
  for( int i = 0; i < N2; i++ ){
	
  }
  return NF[N2-1];
}
*/

double calcDiffDist(int num_fountain){
  return (10 * M_PI / 2 - 20) * num_fountain;
}

// 噴水はできるだけ通りたい．
int main(){
  input();

  // 噴水の数を求める．
  int nf = static_cast<int>(solve());
  int dx = abs(x_2-x_1), dy = abs(y_2-y_1);
  int min = (dx < dy ? (dx+1==nf ? 1 : 0) : (dy+1==nf ? 1 : 0));
  //cout << "nf: " << nf << endl;
  
  double ret = 100.0 * (dx + dy);
  ret += calcDiffDist(nf-min);
  ret += min * (10*M_PI - 20);

  //cout << ret << endl;
  printf("%.16lf\n", ret);
  return 0;
}

Measured memory_bytes: 17000
#include <bits/stdc++.h>
using namespace std;
int m[256];
int main(){
    string s;
    cin>>s;
    for(char c:s){
        m[c]++;
    }
    for(int i=0;i<256;i++){
        if(m[i]%2){
            cout<<"No"; 
            return 0;
        }
    }
cout<<"Yes"; 
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
class JNum{
	static constexpr uint64_t mod = 1000000007;
	uint64_t num;
public:
	JNum(uint64_t x):num(x%mod){}
	JNum operator+(const JNum& j)const{
		return (num + j.num)%mod;
	}
	JNum operator*(const JNum& j)const{
		return (num * j.num)%mod;
	}
	void operator+=(const JNum& j){
		num += j.num;
		num %= mod;
	}
	void operator*=(const JNum& j){
		num *= j.num;
		num %=mod;
	}
	uint64_t out()const{return num;}
};
using namespace std;
#define REP(i, n) for(int i=0;i<n;i++)
template<typename T>
void get(T& t){cin >> t;}
int main(void){
	int N;
	get(N);
	vector<int> a(N + 2);
	a[0] = 0;
	a[N + 1] = 0;
	REP(i, N)get(a[i + 1]);
	int sum = 0;
	for(int i=0;i<=N;i++){
		sum += abs(a[i + 1] - a[i]);
	}
	for(int i=1;i<=N;i++){
		int s = sum - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i+1] - a[i-1]);
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;
using Graph = vector<vector<int>>;

signed main() {

  int a, b, c;
  cin >> a >> b >> c;
  if(c-a-b <= 0){
    cout << "No" << endl;
  }
  else{
    if(4*a*b < (c-a-b)*(c-a-b)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

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

int main(int argc, char const *argv[])
{
	int a,b,c,k;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	printf("%d\n",min(a,k)-max(0,k-a-b) );
	return 0;
}


Measured memory_bytes: 3712
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <cmath>
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  int kekka = 0,check = 0;

  if(A>=K){
    kekka = kekka + K;
    check = 1;
  }else{
    kekka = kekka + A;
    K = K - A;
  }
  if(check == 0 && B >= K){
    kekka = kekka;
    check = 1;
  }else if(check == 0 && B < K){
    K = K - B;
  }
  if(check == 0){
    kekka = kekka - K;
  }
  cout << kekka << endl;
}


Measured memory_bytes: 3624
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
jobs = [[] for _ in range(M+1)]
for _ in range(N):
    a, b = lr()
    if a > M:
        continue
    jobs[a].append(b)

answer = 0
candidate = []
for i in range(1, M+1):
    for job in jobs[i]:
        heappush(candidate, -job)
    if candidate:
        answer += heappop(candidate)

answer *= -1
print(answer)
# 31

Measured memory_bytes: 23748
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100+5;
ll gcd(ll a,ll b){return a%b?gcd(b,a%b):b;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll ans;
int main()
{
	int n;
	cin>>n;
	n--;
	cin>>ans;
	while(n--)
	{
		ll a;
		cin>>a;
		ans=lcm(ans,a);
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;

ll power(int i, ll j)
{
    ll ret = 1;
    while (j > 0)
    {
        ret *= i;
        j--;
    }
    return ret;
}

int main(int argc, char const *argv[])
{
    ll N, P;
    ll ans = 1;
    cin >> N >> P;
    if (N == 1)
    {
        cout << P << endl;
        return 0;
    }
    if (N >= 40)
    {
        cout << 1 << endl;
        return 0;
    }
    for (int i = 2; power(i, N) <= P; i++)
    {
        while (P % power(i, N) == 0)
        {
            ans *= i;
            P /= power(i, N);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

count = 0
while True:
    flag = True
    for i in range(N):
        if A[i] % 2 != 0:
            flag = False
    if flag == False:
        break
    for i in range(N):
        A[i] //= 2
    count += 1
    
print(count)

Measured memory_bytes: 3060
def count_div(start, end, div):
    # [start, end)
    return (end - 1) // div - (start - 1) // div


def calc_start(mid):
    cnt, i = 0, 1
    while 10 ** i < mid:
        d, p = 10 ** i, 10 ** (i - 1)
        fif, three, five = count_div(p, d, 15), count_div(p, d, 3), count_div(p, d, 5)
        cnt += i * (d - p) + (three + five) * 4 - (three + five - fif) * i
        i += 1
    d = 10 ** (i - 1)
    fif, three, five = count_div(d, mid, 15), count_div(d, mid, 3), count_div(d, mid, 5)
    cnt += i * (mid - d) + (three + five) * 4 - (three + five - fif) * i
    return cnt


N = int(input()) - 1
left, right = 1, 10 ** 18
while left + 1 < right:
    mid = (left + right) // 2
    start = calc_start(mid)
    if start <= N:
        left = mid
    else:
        right = mid
ans = ''
for i in range(left, left + 9):
    tmp = ''
    if i % 3 == 0:
        tmp += "Fizz"
    if i % 5 == 0:
        tmp += "Buzz"
    if not tmp:
        tmp = str(i)
    ans += tmp
start = calc_start(left)
print(ans[N - start:N - start + 20])

Measured memory_bytes: 7780
#include <stdio.h>

int main(void)
{
  int n, s[10000];
  int q, t[500];
  int i, j, count = 0;

  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &s[i]);
  scanf("%d", &q);
  for (i = 0; i < q; i++) scanf("%d", &t[i]);

  for (i = 0; i < q; i++) {
    for (j = 0; j < n; j++) {
      if (s[j] == t[i]) {
        count++;
        break;
      }
    }
  }
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int d,t,s;
    cin>>d>>t>>s;
    double t1,t2;
    t1=t;
    t2=d/s;
    if(t1==t2){
        if(d%s==0){
            cout<<"Yes"<<"\n";
        }
        else {
            cout<<"No"<<"\n";
        }
    }
    else if(t1>t2){
        cout<<"Yes"<<"\n";
    }    
    else{
        cout<<"No"<<"\n";
    }
}

Measured memory_bytes: 3628
#include <stdio.h>
#define mod 1000000007

int main(void){
  int i,j;
  int n;
  long long k;
  int a[2000];
  long long ans=0;

  scanf("%d %lld", &n, &k);
  int R[n];
  int L[n];
  //R[n]はa[n]の右にあるa[n]より小さい値

  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
  }

  for(i=0; i<n; i++){
    R[i]=0;
    L[i]=0;
    //R[i],L[i]を求める
    //L[i]
    for(j=0; j<i; j++){
      if(a[j]<a[i]){
        L[i]++;
      }
    }
    //R[i]
    for(j=i+1; j<n; j++){
      if(a[j]<a[i]){
        R[i]++;
      }
    }
    // printf("L=%d R=%d\n", L[i], R[i]);
    //R[i]*(k+(k-1)+...+1)
    //右を見て

    // ans+=(R[i]*(k%mod)*((k+1)%mod)/2)%mod;
    ans+=(R[i]*(((k*(k+1))/2)%mod))%mod;
    ans%=mod;
    // ans+=(L[i]*(k%mod)*((k-1)%mod)/2)%mod;
    ans+=(L[i]*(((k*(k-1))/2)%mod))%mod;
    ans%=mod;
  }
  ans%=mod;
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 128
import Control.Applicative
import Data.List
import Data.Ratio
import Debug.Trace

main = do
  n <- readLn :: IO Integer
  xs <- map read . words <$> getLine :: IO [Integer]
  let s = sum xs

  print $ head [k | k<-[s-n*(n-1)..s], k>=0, (sum $ map (\x -> ceiling $ (x+k-(n-1)) % (n+1)) xs) == k]



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

int N, M, Q;
vector<int> a, b, c, d;

int score(vector<int> A) {
    int res = 0;
    rep(i, Q) if (A[b[i]] - A[a[i]] == c[i]) res += d[i];
    return res;
}

int main(){
    // AとBはインデックスを表すので0インデックスに揃えておく
    // CとDはスコアなので関係ない
    cin >> N >> M >> Q;
    a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
    rep(i, Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
  // next_permutationするためのvector
  // 辞書順で生成しておく必要があるため最初のM-1個を0に初期化する
  // vector自体は1で初期化しておいて後から最初のM-1個を0に初期化する
  // ボールが0で仕切り棒が1を表す
  vector<int> X(N+M-1, 1);
  rep(i, M-1) X[i] = 0;

  // 最終的なアウトプットを管理する変数
  int ans = 0;
  // next_permutationのdo部分
  do{
    // A_iは最小でも1
    int cnt = 1;
    // next_permutationによって生成されたAを管理するvector
    vector<int> Y;
    // next_permutationされたXをYに対応させる
    // 仕切り棒が出てきたらYにそれまでのボールの個数を追加する
    rep(i, X.size()){
      if (X[i]==1) Y.push_back(cnt);
      else cnt++;
    }

    // 問題文の条件を記述する
    ans = max(ans, score(Y));
  }

  // next_permutationのwhile部分
  while (next_permutation(X.begin(), X.end()));

  // 解答出力
  cout << ans << endl;
}

Measured memory_bytes: 3600
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

A, B, M = getNM()
# それぞれ冷蔵庫の値段
ref_a = getList()
ref_b = getList()
# 一枚だけ使える
ticket = [getList() for i in range(M)]

ans = min(ref_a) + min(ref_b)
for i in ticket:
    opt = ref_a[i[0] - 1] + ref_b[i[1] - 1] - i[2]
    ans = min(ans, opt)
print(ans)

Measured memory_bytes: 101824
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

int main(){
    ll x; cin >> x;
    ll now=100;
    int ans=0;
    for(;;){
        now+=now/100;
        ans++;
        if(x<=now){
            cout << ans << endl;
            return 0;
        }
    }
return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main()
{
	int a;
	scanf("%d",&a);
	long long int s = 0;
	for(int i=1;i<=a;i++)
	{
		long long int c = (a/i);
		s += i*c*(c+1)/2;
	}
	printf("%lld",s);
}

Measured memory_bytes: 1728