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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	string str;
	cin >> str;
	bool n,w,s,e;
	n = w = s = e = false;
	FOR(i,0,(int)str.size()){
		if(str[i] == 'N'){
			n = true;
		}else if(str[i] == 'W'){
			w = true;
		}else if(str[i] == 'S'){
			s = true;
		}else if(str[i] == 'E'){
			e = true;
		}else{
			return 1;
		}
	}
	Yes(n == s && w == e);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc,char *argv[]){
	int H,W,N,now = 0;
	scanf("%d\n",&H);
	scanf("%d\n",&W);
	scanf("%d",&N);
	int i;
	for(i = 0; i < H * W; i++){
		if(H >= W){
			now = H * i;
			if(now >= N){
				break;
			}
			continue;
		}
		else{
			now = W * i;
			if(now >= N){
				break;
			}
			continue;
		}
	}
	printf("%d\n", i);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
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; }
const ll INF=1LL<<60;

ll w,h,x,y;

int main(){
    cin>>w>>h>>x>>y;
    int ans;
    if(x*2==w && y*2==h) ans=1;
    else ans=0;
    cout<<fixed<<setprecision(12)<<h*w/2.0<<" "<<ans<<"\n";
    return 0;
}


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

#define rep(i, n) for(int i=0; i<n; i++) 

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

    int m = 0;
    int hm = 0;
    rep(i, n - 1) {
        if(h[i]<h[i+1]){
            m = 0;
        }else{
            m++;
        }
        hm = max(m, hm);
    }

    cout << hm << endl;
}

Measured memory_bytes: 640
N, M = map(int, input().split())
s = []
for i in range(M):
    s.append(list(map(int, input().split())))
p = list(map(int, input().split()))

switch = [['0'], ['1']]

for i in range(N-1):
    tmp = []
    for j in switch:
        tmp.append(j+['0'])
        tmp.append(j+['1'])
    switch = tmp #スイッチのonoffのマップ化

ans = 0

for i in switch:
    false = 0
    for j in range(M):
        cnt = 0 #onの個数
        for k in range(s[j][0]):
            if i[s[j][1+k]-1] == '1':
                cnt += 1
        if cnt%2 != p[j]:
            false += 1 #条件に合っていなかったらfalseに加算する
    if false == 0:
        ans += 1 #全て条件を満たしていたらansに加算する
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;
void get(ll arr[],ll n)
{
for(ll i=0;i<n;i++)
cin>>arr[i];
}
int main()
{
	ll n;
	cin>>n;
	ll ans=0;
	ll a=n/500;
	ans = a*1000;
	n=n%500;
	a= n/5;
	ans+=  a*5;
	cout<<ans;
}


Measured memory_bytes: 256
A, B, K = map(int, input().split())

for i in range(K):
  if i % 2 == 0:
    if A % 2 != 0:
      A -= 1
    B += A // 2
    A = A // 2
  else:
    if B % 2 != 0:
      B -= 1
    A += B // 2
    B = B // 2
print(A, B)

Measured memory_bytes: 3060
# import bisect
from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    d = list(map(int,ipti().split()))
    d_max = max(d)
    c = Counter(d)

    if d[0] != 0 or c[0] >= 2:
        print(0)
    else:
        ans = 1
        for i in range(d_max):
            if c[i] == 0:
                ans = 0
                break
            else:
                ans *= c[i] ** c[i+1]
        print(ans%998244353)


if __name__ == '__main__':
    main()

Measured memory_bytes: 63396
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() { 
  string a,b;
  cin >> a>> b;
  vector<string> S;
  S.push_back(a);
  S.push_back(b);
  sort(rng(S));
  if(a == b)cout<<"EQUAL"<<endl;
  else if(sz(a)>sz(b))cout<<"GREATER"<<endl;
  else if(sz(a)<sz(b))cout<<"LESS"<<endl;
  else if(a == S[0])cout<<"LESS"<<endl;
  else cout<<"GREATER"<<endl;
  return 0;
}

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

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

string dp[10001];

//                 1  2  3  4  5  6  7  8  9
int a2n[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

bool cmp(const string& a, const string& b)
{
  int f;
  f = a.size() - b.size();
  // dump(a, b, f);
  if (f < 0) {
    return 0;
  } else if (0 < f) {
    return 1;
  } else {
    for (int i = 0; i < a.size(); i++) {
      if (a[i] > b[i])
        return 1;
      else if (a[i] < b[i])
        return 0;
    }
    return 0;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (int i = 0; i < M; i++) {
    cin >> A[i];
  }
  for (int i = 0; i <= N; i++) {
    dp[i] = "0";
  }
  // dumpv(dp, 21);
  for (int i = 0; i < N; i++) {
    if (0 < i && dp[i] == "0")
      continue;
    for (int j = 0; j < M; j++) {
      int a = A[j];
      int n = a2n[a];
      string s = dp[i] == "0" ? to_string(a) : dp[i] + to_string(a);
      if (i + n <= N)
        dp[i + n] = cmp(dp[i + n], s) ? dp[i + n] : s;
    }
    // dumpv(i, dp, 21);
  }
  cout << dp[N] << endl;
  return 0;
}


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

int main(){
  int H, W;
  cin >> H >> W;
  string S[50];
  for(int i = 0; i < H; i++){
    cin >> S[i];
  }//Sの配置完了
  int idx[] = {1,1,0,-1,-1,-1,0,1};
 int idy[] = {0,1,1,1,0,-1,-1,-1};
 for(int i = 0; i  < H ; i++){//1
  for(int j = 0; j  < W ; j++){//2
     if(S[i][j] == '.'){//3
                            int cnt = 0;
     for(int k = 0; k  < 8 ; k++){//4
                                   int x = i + idx[k];
                                   int y = j + idy[k];
      
      if(x >= 0 && x < H && y >= 0 && y <  W && S[x][y] == '#')
         {cnt++;}
         }//4
      S[i][j] = '0' + cnt;}}}//3//2//1
   for(int i = 0; i < H; i++)
   {cout << S[i] <<endl;}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int n;
    cin>>n;
    vector<string> S(n);
    rep(i,n){
        cin>>S[i];
    }
    string ans="";
    //各アルファベットが各Siで最低何個使われてるかを格納する
    int a = (int)'a';//最初のアルファベット
    vector<pair<char,int>> cnt(26);
    rep(i,26){
        cnt.at(i)={(char)i+a,100000};//全部INFで初期化
    }
    int tmp=0;
    rep2(i,a,a+26){
        //アルファベットiが
        rep(j,n){
            tmp=0;
            //Siの中に
            rep(k,S[j].size()){
                //何個あるか
                if(S[j].at(k)==(char)i){
                    tmp++;
                }
            }
            cnt.at(i-a).second=min(cnt.at(i-a).second,tmp);
        }
    }
    //aから順にcnt個出力
    rep(i,cnt.size()){
        rep(j,cnt.at(i).second){
            ans+=(int)cnt.at(i).first;
        }
    }
    rep(i,26){
        // cout << "lt:"<<cnt.at(i).first<<" cnt:" << cnt.at(i).second<<endl;

    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int func(long a, long b){
  int res = 0;
  if(a > b){
    for(long long i=1; a%i!=a; i*=10 ) res += 1;
  }else{
    for(long long i=1; b%i!=b; i*=10 ) res += 1;
  }
  return res;
}

int main(){
  long n;
  cin >> n;
  int min = 9999999;
  for(long a=1; a<=static_cast<long long int>( sqrt(n) ); a++){
    if( n%a == 0){
      long b = n/a;
      int temp = func(a,b);
      if(min > temp){
        // cout << a << " " << b << endl;
        min = temp;
      }
    }
  }

  cout << min;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n, i;
    float  arr[50], temp;
    cin>>n;
    for(i = 0; i<n; i++)
    {
        cin>>arr[i];
    }
    for(i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++ )
        {
            if(arr[j]<arr[i])
            {
                temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
            }
        }
    }
    for(i=1; i<n; i++)
    {
        arr[i] = (arr[i] + arr[i-1]) / 2.0;
    }
    cout<<arr[n-1]<<endl;
}




Measured memory_bytes: 384
N,M,C = gets.split(" ").map{|i|i.to_i}
B = gets.split(" ").map{|i|i.to_i}
a = []
N.times do |i|
    a.push(gets.split(" ").map{|i|i.to_i})
end

c = 0
a.collect do | i |
    lst = []
    M.times do |j|
        lst.push(i[j] * B[j])
    end
    r = lst.reduce(:+)
    if r + C > 0 then
        c+=1
    end
end

puts c

Measured memory_bytes: 1788
import math
A, B, H, M = map(int, input().split())

t1 = math.radians(M * 360 / 60)
x1 = B * math.sin(t1)
y1 = B * math.cos(t1)

t2 = math.radians((H * 60 + M) * 360 / (12 * 60))
x2 = A * math.sin(t2)
y2 = A * math.cos(t2)

ans = math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
print(ans)

Measured memory_bytes: 9440
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
	public static void main(String[] args) {
		
		FastReader sc = new FastReader();
	int n = sc.nextInt();
	long[] a = new long[n];
	for(int i=0;i<n;++i) {
		a[i] = sc.nextLong();
	    
	 }
	long[] b = a.clone();
    long temp = 0;
	for(int i=0;i<n;++i) {
		if(i%2==0) temp+=a[i];
		else temp-=a[i];
	}
	a[0] = temp;
	for(int i=1;i<n;++i) {
		a[i] = 2*b[i-1]-a[i-1];
	}
			for(long x : a) out.print(x+" ");
	out.close();
		
	}
	
}

Measured memory_bytes: 46768
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);
    CIN(M);
    if(M%N == 0){
        COUT(M/N);
        return 0;
    }
    int h = M/N;
    int hoge = M/N + M%N;
    while(true){
        if(hoge % h == 0){
            COUT(h);
            return 0;
        }
        h--;
        hoge+=N-1;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;
 
long long  fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
 
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;
 
}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
 
	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;
 
		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
bool used[2][105];
int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	int sa,sb;
	bool flag;
	while(cin>>n>>m){
		if(!n)break;
		memset(used,false,sizeof(used));
		sa=sb=0;
		for(i=0;i<n;i++){
			cin>>a;
			used[0][a]=true;
			sa+=a;
		}
		for(i=0;i<m;i++){
			cin>>a;
			used[1][a]=true;
			sb+=a;
		}
		flag=false,a=sb-sa;
		if(a%2!=0){
			cout<<-1<<endl;
			continue;
		}
		a/=2;
		for(i=0;i<=100;i++){
			if(!used[0][i])continue;
			if(0<=i+a && i+a<=100 && used[1][i+a]){
				cout<<i<<" "<<i+a<<endl;flag=true;
				break;
			}
		}
		if(!flag)cout<<-1<<endl;
	}
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
//#include <chrono>
#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

void dfs1(int n, mat &G, vec &ord){
    int k(0);
    vector<int> iter(n, -1);
    stack<int> sta;
    rep(i, n) {
        if(iter[i] < 0) sta.push(i);
        while (!sta.empty()) {
            int v = sta.top();
            if ((++iter[v]) == G[v].size()) {
                ord[k++] = v;
                sta.pop();
            } else {
                int to = G[v][iter[v]];
                if(iter[to] < 0) sta.push(to);
            }
        }
    }
}
void dfs2(int n, mat &G, vec &ord, mat &res){
    int k(0);
    vector<bool> used(n, false);
    stack<int> sta;
    Rrep(i, n){
        int s = ord[i];
        if(!used[s]){
            used[s] = true;
            sta.push(s);
            while(!sta.empty()){
                int v = sta.top(); sta.pop();
                res[k].push_back(v);
                for(int to : G[v]) {
                    if(!used[to]) {
                        used[to] = true;
                        sta.push(to);
                    }
                }
            }
            ++k;
        }
    }
    res.resize(k);
}

void scc(mat &G, mat &res){
    int n = G.size();
    res.resize(n);
    mat G_rev(n, vec(0));
    rep(u, n) for(int v : G[u]) G_rev[v].push_back(u);
    vec ord(n);
    dfs1(n, G, ord);
    dfs2(n, G_rev, ord, res);
}

int main() {
    cin >> N >> K;
    mat G(N * 2, vec(0)), scc_list;
    vec x(N * 2), pos(N * 2);
    rep(i, N) cin>>x[i]>>x[i + N];
    rep(i, N * 2){
        rep(j, i) {
            if(abs(x[i] - x[j]) < K) {
                int i_inv = (i + N) % (N * 2), j_inv = (j + N) % (N * 2);
                G[i].push_back(j_inv);
                G[j].push_back(i_inv);
            }
        }
    }
    scc(G, scc_list);
    rep(i, (int)scc_list.size()){
        for(int v : scc_list[i]) pos[v] = i;
    }
    //rep(i, N) cout<<pos[i]<<' '<<pos[i + N]<<endl;
    bool ok = true;
    rep(i, N) if(pos[i] == pos[i + N]) ok = false;
    cout<<(ok ? "Yes" : "No")<<endl;
    if(ok){
        rep(i, N){
            cout<<(pos[i] > pos[i + N] ? x[i] : x[i + N])<<endl;
        }
    }
}



Measured memory_bytes: 3920
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
pair<int,int> s[100000+1];
int main(){
  int n;
  int a;
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    scanf("%d",&a);
    s[i].first=a;
    s[i].second=i;
  }
  sort(s+1,s+n+1);
  for(int i=1;i<=n;i++)printf("%d\n",s[i].second);
}


Measured memory_bytes: 1536
#include<stdio.h>
int main(void){
  int N; //人数
  scanf("%d",&N);
  int K; //身長制限
  scanf("%d",&K);
  int int_hight[N]; //身長

  for(int i=0; i<N; i++){
    scanf("%d",&int_hight[i]);
  }

  int CountHight=0;
  for(int i=0; i<N; i++){
    if(int_hight[i]>=K){
      CountHight++;
    }
  }
  printf("%d\n",CountHight);

}


Measured memory_bytes: 2036
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        vector<string> s(3);
        for(int i=0; i<3; ++i){
            cin >> s[i];
            if(s[i] == "0")
                return 0;
        }

        char win = ' ';
        for(int i=0; i<3; ++i){
            if(s[i][0] != '+' && s[i][0] == s[i][1] && s[i][1] == s[i][2])
                win = s[i][0];
            if(s[0][i] != '+' && s[0][i] == s[1][i] && s[1][i] == s[2][i])
                win = s[0][i];
        }
        if(s[0][0] != '+' && s[0][0] == s[1][1] && s[1][1] == s[2][2])
            win = s[0][0];
        if(s[2][0] != '+' && s[2][0] == s[1][1] && s[1][1] == s[0][2])
            win = s[2][0];

        if(win == ' ')
            cout << "NA" << endl;
        else
            cout << win << endl;
    }
}

Measured memory_bytes: 0
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func countChainingABC(n int, s string) (count int) {
	sr := []rune(s)
	for i := 0; i < n-2; i++ {
		if sr[i] != 'A' {
			continue
		}
		if string(sr[i:i+3]) == "ABC" {
			count++
			i += 2
		}
	}
	return
}

func main() {
	n, s := nextInt(), nextString()
	fmt.Println(countChainingABC(n, s))
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
 
#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
 
int main(){
    int a,b,c,x, cnt=0;
    cin >> a >> b >> c >> x;
    REP(i, a+1){
        REP(j, b+1){
            REP(k, c+1){
                if(i*500+j*100+k*50 == x){
                    cnt++;
                }
            }
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
class P:
    def __init__(self,name,time):
        self.name = name
        self.time = time
n,q = map(int,input().split())
LEN = 100004 #要素数nより少し大きければよい
head = 0
tail = n
Q = [P("",0) for _ in range(LEN)]
for i in range(n):
    Q[i].name,ti = input().split()
    Q[i].time = int(ti)
def enqueue(Q,x,tail):#末尾にクラスPの要素xを加える。ぐるっと回った場合
    Q[tail] = x       #以前dequeueで取り出したものが書き換えられる。
    if tail+1 == LEN:
        tail = 0
    else:
        tail += 1
    return tail
def dequeue(Q,head):
    x = Q[head]
    if head+1 == LEN:
        head = 0
    else:
        head += 1
    return x,head
totime = 0
while head != tail:
    x,head = dequeue(Q,head)
    if x.time <= q:
        totime += x.time
        print(x.name + " " + str(totime))
    else:
        totime += q
        x.time -= q
        tail = enqueue(Q,x,tail)




Measured memory_bytes: 25948
#include<bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define F first
#define S second
#define endl "\n"
#define MOD (lli)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
#define DEBUG if(0) cout << "aqui" << endl;
#define PI 2 * acos(0.0)
typedef pair<int,int> ii;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

int n, m;
string s;
vector<int> ans;

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

  cin >> n >> m;
  cin >> s;

  reverse(s.begin(), s.end());

  if(s[0] == '1'){
    cout << -1 << endl;
    return 0;
  }

  int a = 0;
  while(1){
    int atual = -1;
    for(int j=1;j<=m;j++){
      if((a + j) <= sz(s) and (s[a+j] == '0')) {
        atual = j;
      } 
    }
    if(atual == -1){
      cout << -1 << endl;
      return 0;
    }
    a += atual;
    ans.push_back(atual);
    // cout << a << endl;
    if(a == sz(s)-1) break;
  }

  // for(auto i : ans) cout << i << " ";
  // cout << endl;

  // int pos = 0;
  reverse(ans.begin(), ans.end());

  for(auto i : ans) cout << i << " ";
  cout << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll MAX = 10000000;
const int MAXN = 100010;

vector<int> g[MAXN * 2];

bool visited[MAXN * 2];

void bfs(int s){
    queue<int> Q;
    visited[s] = true;
    Q.push(s);
    while(!Q.empty()){
        int v = Q.front();
        // cout << v << endl;
        Q.pop();
        for(int r: g[v]){
            if(!visited[r]){
                visited[r] = true;
                Q.push(r);
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    for(int i=1;i<=N;i++){
        int k; cin >> k;
        for(int j=0;j<k;j++){
            int l; cin >> l;
            g[i].push_back(N+l);
            g[N+l].push_back(i);
        }
    }
    bfs(1);
    bool flag = true;
    for(int i=1;i<=N;i++){
        if(!visited[i]){
            flag = false;
            break;
        }
    }
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 8952
import math
A, B, C = list(map(int, input().split()))
K = int(input())
#A, B, C = [7, 6, 100]
#K = 3

i = max(math.ceil(math.log2((A+1)/B)),0)
K -= i
B = B * (2 ** i)
j = max(math.ceil(math.log2((B+1)/C)),0)
K -= j
C = C * (2 ** j)
if K >= 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
int x[3];
signed main() {
	int a, b;
	cin >> a >> b;
	x[0] = -1, x[1] = -1, x[2] = -1;
	f(i, b) {
		int z, y;
		cin >> z >> y;
		if (a != 1 && z == 1 && y == 0) {
			puts("-1");
			return 0;
		}
		if (x[z - 1] != -1 && x[z - 1] != y) {
			puts("-1");
			return 0;
		}
		x[z - 1] = y;
	}
	f(i, a) {
		if (x[i] == -1) {
			if (i || a == 1)cout << 0;
			else cout << 1;
		}
		else cout << x[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int k1 = k / 2;
		int k2 = k - k1;
		
		System.out.println(k1 * k2);
	  }
}




Measured memory_bytes: 23252
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll e   = lcm(c, d);
	ll ans = b - a + 1;
	ans -= b / c - (a - 1) / c;
	ans -= b / d - (a - 1) / d;
	ans += b / e - (a - 1) / e;
	dump(ans);
	return 0;
}


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

void to_int(char x, int &n) {
  
  if (x == '0') n = 0;
  else if (x == '1') n = 1;
  else if (x == '2') n = 2;
  else if (x == '3') n = 3;
  else if (x == '4') n = 4;
  else if (x == '5') n = 5;
  else if (x == '6') n = 6;
  else if (x == '7') n = 7;
  else if (x == '8') n = 8;
  else if (x == '9') n = 9;
  else cout << "error 'to_int' x different int" << endl;
}

int calc(int i, string a, string &A, vector<int> input) {
  if (i > 2) {
    
    int sum = input.at(0);
    
    for (int j = 0; j < 3; j++) {
      if (a.at(j) == '-') sum -= input.at(j + 1);
      if (a.at(j) == '+') sum += input.at(j + 1);
    }
    
    A = a;
    return sum;
  }
  
  if (7 == calc(i + 1, a, A, input)) return 7;
  
  a.at(i) = '+';
  if (7 == calc(i + 1, a, A, input)) return 7;
  
  return 1;
}

int main() {
  string X, A, a = "---";
  char x;
  vector<int> input(4);
  cin >> X;
  
  for (int i = 0; i < 4; i++) {
  	x = X.at(i);
    to_int(x, input.at(i));
  }
  
  calc(0, a, A, input);
  for (int i = 0; i < 4; i++) {
    cout << X.at(i);
    if (i < 3) cout << A.at(i);
  }
  
  cout << "=7";
  cout << endl;
  
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;

signed main() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << a[0] << b[1] << c[2] << endl;
  return 0;
}


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

towns = [0] * n
i = 0
cnt = 1
towns[0] = cnt
nums = [1]
while True:
    cnt += 1
    i = a[i] - 1
    if towns[i] == 0:
        towns[i] = cnt
        nums.append(i + 1)
    else:
        s_loop = nums.index(i + 1)
        m = len(nums)
        l = m - s_loop
        break

if k < len(nums):
    print(nums[k])
else:
    k -= m - 1
    k = (k - 1) % l
    print(nums[s_loop + k])

Measured memory_bytes: 32372
#include<iostream>
using namespace std;
long long a,b,c;
int main(){
	cin>>a>>b;
	if(a+b==15){
		cout<<"+"<<endl;
	}
	else if(a*b==15){
		cout<<"*"<<endl;
	}	
	else{
		cout<<"x"<<endl;
	}
	return 0;
}

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

void euclid(int a, int b);

int main(){
    int a,b;
    cin >> a >> b;
    euclid(a, b);
    
    return 0;
}

void euclid(int a, int b) {
    int t;
    if ( a < b ) swap(a, b);
    while ( b > 0 ) { //a返すから 計算してみる 54 20
        t = a % b;
        a = b;
        b = t;
    }  
    cout << a << endl;
}



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

int main()
{
	string s;
	cin >> s;
	int count_b=0;
	int count_e=0;
	for(int i=0; i<(int)s.size(); i++){
			if(s[i] == 'A'){
				count_b = i;
				break;
			}
	}
	for(int i=(int)s.size(); i>=0; i--)
			if(s[i-1] == 'Z'){
				count_e=i;
				break;
			}
	
	count_e -= count_b;

	cout << count_e << endl;
}

Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
N = INT()
ab = [LIST() for _ in range(N-1)]
graph = [[] for _ in range(N)]

for a, b in ab:
	graph[a-1].append(b-1)
	graph[b-1].append(a-1)

length = [len(x) for x in graph]
ans = max(length)

color = defaultdict(int)

q = deque([])
cnt = 1
for x in graph[0]:
	q.append((x, 0, cnt))
	cnt += 1

while q:
	n, previous, col = q.popleft()
	cnt = 1
	for x in graph[n]:
		if x == previous:
			color[(n, x)] = col
			color[(x, n)] = col
		else:
			if cnt == col:
				cnt += 1
			color[(n, x)] = cnt
			color[(x, n)] = cnt
			q.append((x, n, cnt))
			cnt += 1

print(ans)
for a, b in ab:
	print(color[(a-1, b-1)])


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

using namespace std;

int main(){
  int N =0;
  double money = 0;
  cin >> N;
  for(int i=0; i<N;++i){
    double money_part =0;
    string kind;
    cin >> money_part;
    cin >> kind;
    if(kind == "JPY"){
      money += money_part;
    }else{
      money += money_part*380000.0;
    }
  }
  
  cout << money << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_DISABLE_PERFCRIT_LOCKS
#define POPCNTI(a) __builtin_popcount(a)
#define fs  first  
#define sc  second
#define ARR array
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#include <bits/stdc++.h>
using namespace  __gnu_pbds; 
using namespace std;
 
 
// #ifndef _LOCAL_DEFINE
// inline int getchar_unlocked(){return _getchar_nolock();}
// inline void putchar_unlocked(char c) {_putchar_nolock(c);}
// #endif
 
typedef long long ll;  
inline void WRITE_CHAR(char c)  {putchar_unlocked(c);} 
template<typename T> 
inline bool READn (T &result) {
  int minus = 1;
  char ch;
  result=0;
  ch = (char) getchar_unlocked();
  while (!isdigit(ch) && ch!=EOF) minus = (ch == '-'? -1 : minus),ch= (char) getchar_unlocked();
 
  if(ch==EOF) return false;
  while (isdigit(ch))  result = result*10 + (int) (ch - '0'),ch = (char) getchar_unlocked();
  
  result *= minus;
  return ch != '\n';
}
template<typename T>
inline void WRITEn(T x) {
  if (x < 0) {putchar_unlocked('-'); x = -x; }
  char writeBuffer[20], *writePtr = writeBuffer;
  do {
    *writePtr++ = (char)('0' + x % 10);
    x /= 10;
  }
  while (x);
  do  { putchar_unlocked(*--writePtr); }
  while (writePtr > writeBuffer);
}
inline bool Read_CHAR(char &c)
{
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  c = READ_CHARACTER;
  return true;
} 
inline bool READ_CHAR_ARRAY(char *x) {
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  char *ptr = &x[0];
  while ((READ_CHARACTER != '\n' && READ_CHARACTER != '\t' && READ_CHARACTER != ' ' && READ_CHARACTER != EOF)) *ptr++ = READ_CHARACTER, READ_CHARACTER = (char)getchar_unlocked();
 
  *ptr = '\0';
  return true;
}
inline void WRITE_CHAR_ARRAY(const char *x) {
  while(*x != '\0')
    putchar_unlocked(*x++);
}
inline void WRITE_STRING(string &x) {
  for(char c: x) 
    putchar_unlocked(c);
}
const ll OOl = 1e18 ;
const int N = 1e6+1,OO = 1e9,OOm = 0x3f3f3f3f, MOD = 1e9 + 7;

int main()
{
  ll n;
  READn(n);
  ll tot = n + n*n + n*n*n;
  WRITEn(tot);  
  return 0; 
}

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

class Obj{
public:
	int h, p;
	Obj (int a, int b){
		h = a;
		p = b;
	}
	bool operator<(const Obj &o) const{
		return 1LL* (long long)h + (long long)p < 1LL*(long long)o.h + (long long)o.p;
	}
};
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	vector<Obj> li;
	int n;
	cin >> n;
	for(int i = 0; i<n; i++){
		int a, b;
		cin >> a >> b;
		li.push_back(Obj(a,b));
	}
	sort(li.begin(),li.end());
	int best[n+1];
	int inf = 2000000069;
	for(int i = 0; i<=n; i++){
		best[i] = inf;
	}
	best[0] = 0;
	for(int i = 0; i<n; i++){
		for(int j = n; j>0; j--){
			if(best[j-1]<=li[i].h){
				best[j] = min(best[j],best[j-1]+li[i].p);
			}
		}
	}
	for(int i = n; i>=0; i--){
		if(best[i]!=inf){
			cout << i << endl;
			return 0;
		}
	}
}

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

int main() {

	string t; cin >> t;
    for (int i = 0; i < t.size(); i++) {
        if (t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
	return 0;
}

Measured memory_bytes: 3740
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		//a==1 or b==n の時だけ考える
		boolean[] vis1 = new boolean[200010];
		boolean[] vis2 = new boolean[200010];
		Arrays.fill(vis1, false);
		Arrays.fill(vis2, false);
		for(int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a==1) {
				vis1[b]=true;
			} else if(b==n) {
				vis2[a]=true;
			}
		}
		for(int i = 0; i < 200005; i++) {
			if(vis1[i]==true&&vis2[i]==true) {
				System.out.println("POSSIBLE");
				return;
			}
		}
		System.out.println("IMPOSSIBLE");
	}
}

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

typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  vector<int> l(N);
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  cout << l[N / 2] - l[N / 2 - 1] << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	cin >> n;
	vector<ll> a(n);
	ll sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	ll l = 0; ll r = 0;
	ll res = INF;
	rep(i, n - 1) {
		l += a[i];
		r = sum - l;
		chmin(res, abs(l - r));
	}
	cout << res << endl;
}

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

int main() {
    int x1, x2, x3, x4, y1, y2, y3, y4;
    cin >> x1 >> y1 >> x2 >> y2;

    x3 = x2 - (y2 - y1);
    y3 = y2 + (x2 - x1);
    x4 = x1 - (y2 - y1);
    y4 = y1 + (x2 - x1);

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}


Measured memory_bytes: 3536
#include <iostream>
#include <cmath>
#include <complex>
using namespace std;
#define EPS 1e-7
typedef complex<double> P;

double dot(const P& a, const P& b){
	return a.real()*b.real() + a.imag()*b.imag();
}
double cross(const P& a, const P& b){
	return a.real()*b.imag() - a.imag()*b.real();
}

int main()
{
	double D,px,py,vx,vy;
	while( cin>>D, D!=0.0 ){
		cin >> px >> py >> vx >> vy;
		P p(px,py);
		P v(vx,vy);
		double ans;
		if( fabs(cross(p,v))>EPS ){
			puts("impossible"); continue;
		}
		if( dot(p,v)>0 ){
			ans = 2.0 - abs(p);
		}else{
			ans = abs(p);
		}
		printf( ans<=D ? "%10.8lf\n" : "impossible\n" , ans);
	}
	return 0;
}

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
string S;

bool is_kaibun(const string& a) {
  string b(a.rbegin(), a.rend());
  return a == b;
}

int main(int argc, char** argv) {
  cin >> S;

  int N = S.size();
  bool ok = true;
  ok = ok && is_kaibun(S);
  ok = ok && is_kaibun(S.substr(0, (N-1)/2));
  ok = ok && is_kaibun(S.substr(N/2+1));

  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main()
{
    int n;
    cin>>n;
    int arr[n+10];
    int maxx=INT_MIN,minn=INT_MAX;
    vector<pair<int,int> > vec;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        minn=min(arr[i],minn);
        maxx=max(arr[i],maxx);
        vec.pb({maxx,minn});
    }
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        //cout<<cnt<<" "<<arr[i]<<" "<<endl;
        int n1=vec[i].first;
        int n2=vec[i].second;
        if(n1>=arr[i] && n2>=arr[i])
            cnt++;
    }
    cout<<cnt<<endl;
return 0;
}


Measured memory_bytes: 2932
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n;
double x[1000],y[1000];
double dp[1001][1001];
double d(int i,int j)
{
	return hypot(x[i]-x[j],y[i]-y[j]);
}
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i]>>y[i];
	for(int j=1;j<n;j++)
	{
		for(int i=0;i<j;i++)
		{
			if(i==0&&j==1)dp[i][j]=d(i,j);
			else if(i==j-1)
			{
				dp[i][j]=1e15;
				for(int k=0;k<i;k++)dp[i][j]=min(dp[i][j],dp[k][i]+d(k,j));
			}
			else dp[i][j]=dp[i][j-1]+d(j-1,j);
		}
	}
	double ans=1e15;
	for(int i=0;i<n-1;i++)ans=min(ans,dp[i][n-1]+d(i,n-1));
	printf("%.9lf\n",ans);
}



Measured memory_bytes: 10156
N = int(input())
H = list(map(int,input().split()))

OK = [h == 0 for h in H]
T = [0] * N

ans = 0
while not all(OK):
  flg = False
  for i in range(N):
    if not OK[i]:
      T[i] += 1
      if T[i] == H[i]:
        OK[i] = True
      flg = True
    else:
      if flg:
        ans += 1
      flg = False
  
  if flg:
    ans += 1
    
print(ans)
       

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	int n, i, li;
	ll dp[100003][2] = {};
	string l;

	cin >> l;

	n = l.size();

	dp[0][0] = 1;
	dp[0][1] = 0;
	for (i = 0; i < n; i++) {
		li = l[i] - '0';
		dp[i + 1][0] = dp[i][0] * (li + 1) % mod;
		dp[i + 1][1] = (dp[i][0] * li + dp[i][1] * 3 % mod) % mod;
	}

	printf("%lld\n", (dp[n][0] + dp[n][1]) % mod);

	return 0;
}

Measured memory_bytes: 2048