akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  priority_queue<pair<int, int>> que;
  rep(i, n) cin >> a[i];
  rep(i, n) {
    cin >> b[i];
    if (b[i] != a[i])
      que.push({b[i], i});
  }
  ll ans = 0;
  while (!que.empty()) {
    int tmp, idx;
    tie(tmp, idx) = que.top();
    que.pop();
    int l = (idx+n-1)%n, r = (idx+n+1)%n;
    if (b[l] == a[l] && b[r] == a[r]) {
      if ((b[idx]-a[idx])%(b[l]+b[r])) {
        cout << -1 << endl;
        return 0;
      }
      ans += (b[idx]-a[idx])/(b[l]+b[r]);
      b[idx] = a[idx];
    } else {
      int sub = b[idx]-max(b[l], b[r]);
      int num = (sub+b[l]+b[r]-1)/(b[l]+b[r]);
      b[idx] -= (b[l]+b[r])*num;
      ans += num;
      if (sub <= 0 || b[idx] < a[idx]) {
        cout << -1 << endl;
        return 0;
      }
      if (b[idx] > a[idx])
        que.push({b[idx], idx});
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int, int> pii;
const int mod = (int)1e9 + 7;


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	replace(all(s),',',' ');
	cout <<  s <<endl;
	
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<ll,ll>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  for(int i=0;i<5;i++) {
    int x; cin>>x;
    if (x != i+1) cout<<i+1<<endl;
  }
}

Measured memory_bytes: 3580
n,k = map(int,input().split())
ans = 0
dev = [[] for _ in range(k+1)]
for i in range(1,k+1):
  l = int(i**.5)
  for j in range(1,l+1):
    if i % j == 0:
      dev[i].append(j)
      dev[i].append(i // j)
  if l**2 == i:
    dev[i].pop()
  #print(i,l,dev[i])
#print(dev)
cnt = [0 for _ in range(k+1)]
mod = 10 ** 9 + 7
for d in range(1,k+1):
  p = k // d
  double = [p]
  now = 1
  for i in range(20):
    double.append(double[-1]**2%mod)
  #print(d,p,double)
  m = int(n)
  i = 0
  while m:
    if m % 2 != 0:
      now *= double[i]
    m //= 2
    i += 1
  #print(p,n,now)
  cnt[d] = now
#print(cnt)
for i in range(1,k+1)[::-1]:
  for x in dev[i]:
    if x != i:
      cnt[x] -= cnt[i]
#print(cnt)
for i in range(k+1):
  ans += i * cnt[i]
  ans %= mod
#print(sum(cnt))
print(ans)

Measured memory_bytes: 113596
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  vector<int> c(n, 1);
  for(int i = 0; i < n; i++) {
    cin >> h[i];
  }
  vector<int> a(m), b(m);
  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    if(h[a[i]] > h[b[i]]){
      c[b[i]] = 0;
    }else if(h[a[i]] == h[b[i]]){
      c[a[i]] = 0;
      c[b[i]] = 0;
    }else{
      c[a[i]] = 0;
    }
  }
  int cnt = 0;
  for(int i = 0; i < n; i++){
    cnt += c[i];
  }
  cout << cnt << endl;
  return 0;
}

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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"NO\n"
#define CY cout<<"YES\n"

using namespace std;
using ll = long long;
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
// #define MAXN 1000001 
// ll sieve[MAXN]; 
// void makesieve()
// {
//     sieve[1] = 1; 
//     for (int i = 2; i < MAXN; i++) 
//         sieve[i] = i; 
//     for (int i = 4; i < MAXN; i += 2) 
//         sieve[i] = 2; 
//     for (int i = 3; i * i < MAXN; i++) { 
//         if (sieve[i] == i) { 
//             for (int j = i * i; j < MAXN; j += i) 
//                 if (sieve[j] == j) 
//                     sieve[j] = i; 
//         } 
//     } 
// }
ll powerflow(ll x, ll n)
{
    ll res;
    if (n == 0) {
        return 1;
    }
    res = powerflow(x, n-1);             // recurse
    if(INT_MAX / res < x) {          // check for overflow
        return -1; //LONG_MAX;
    }
    return x * res;
}
ll mod=1000000007;
ll power(ll a,ll b,ll m)
{
    ll res=1;
    while(b!=0)
    {
        if(b&1)
        res=(res*a)%mod;
        b=b/2;
        a=(a*a)%mod;
    }
    return res;
}
struct compare  
 {  
   bool operator()(const int& l, const int& r)  
   {  
       return l > r;  
   }  
 };
 ll recur(int n)
 {
    if(n==0) return 1;
    if(n<=2) return 0;
    ll ans=0;
    for(int i=3;i<=9;i++)
        ans+=recur(n-i);
    return ans;

 }
void solve()
{
    ll n; cin>>n;
    if(n==1) cout<<"0\n";
    else
    {
        ll k1=power(10,n,mod),k2=power(8,n,mod);
        ll k3=power(9,n,mod);
        k3=(k3*2)%mod;
        ll ans=(k1+k2)%mod;
        ans=(ans-k3+mod)%mod;
        cout<<ans;
    }
}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
    //cin>>t;
    while(t--)
        {solve();}
    return 0;
}


Measured memory_bytes: 3616
S = input()
k = []
for i in range(len(S)):
    k.append(S[i])
position = 0
ans = 0
for i in range(10**6):
    if position >= len(S)-1:
        break
    else:
        if k[position] == k[position+1]:
            if k[position+1] == "0":
                k[position+1] = "1"
            else:
                k[position+1] = "0"
            ans += 1
        position += 1
print(ans)

Measured memory_bytes: 3956
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    x,y,z=INTM()
    print((x-z)//(y+z))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	double A, B;
	cin >> A >> B;

	double ans = -1;
	double i = 0;
	while (i < 1009)
	{
		if ((int)(i * 0.08) == A && (int)(i * 0.1) == B)
		{
			ans = i;
			break ;
		}

		i++;
	}

	cout << ans << '\n';
	return 0;
}


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

void solve(){
  long long h; cin >> h;
  long long cnt = 1, ans = 0;
  while(h != 0){
    ans += cnt;
    cnt *= 2;
    h /= 2;
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
inline char nc() {
//	return getchar();
	static char buf[100000], *l = buf, *r = buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x) {
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f;
}
const int maxn = 1e5 + 5;
int n;
int f[maxn];
	int head[maxn];
vector<int> rec[maxn];
struct edge {
	int to, nex;
	edge(int to=0,int nex=0):to(to),nex(nex){} 
};
vector<edge> G;
inline void addedge(int u, int v) {
	G.push_back(edge(v, head[u])), head[u] = G.size() - 1;
}
void dfs(int u) {
	for(int i = head[u]; ~i; i = G[i].nex) {
		int v = G[i].to;
		dfs(v);
		rec[u].push_back(f[v]);
	}
	sort(rec[u].begin(), rec[u].end());
	for(unsigned int i = 0; i < rec[u].size(); ++i) {
		f[u] = max(f[u], rec[u][i]) + 1;
	}
}
int main() {
	read(n);
	memset(head, -1, sizeof(head));
	for(int i = 2; i <= n; ++i) {
		int fa; read(fa);
		addedge(fa, i);
	}
	dfs(1);
	printf("%d\n", f[1]);
	return 0;
} 

Measured memory_bytes: 12020
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main(){
	ll n;
	scanf("%lld",&n);
	ll sum=0;
	for(ll i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0){
			sum+=i;
		}
	}
	printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 3824
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
import java.util.Map.Entry;

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

    void solve(Scanner sc) {
        int n = sc.nextInt();
        Map<Integer, Integer> aMap = new TreeMap<>((x, y) -> y - x);
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            Integer count = aMap.getOrDefault(a, 0) + 1;
            aMap.put(a, count);
        }

        long x = 0;
        for (Entry<Integer, Integer> e : aMap.entrySet()) {
            if (e.getValue() >= 4 && x == 0) {
                System.out.println((long)e.getKey() * e.getKey());
                return;
            }

            if (e.getValue() >= 2 && x == 0) {
                x = e.getKey();
                continue;
            }

            if (e.getValue() >= 2) {
                System.out.println(x * e.getKey());
                return;
            }
        }
        System.out.println(0);
    }
}


Measured memory_bytes: 61788
H, W = map(int, input().split())
N = int(input())
A = [int(x) for x in input().split()]
q = []

for i, a in enumerate(A, 1):
  q += [str(i)] * a
  
for h in range(H):
  row = []
  for _ in range(W):
    row.append(q.pop(0))
  if h % 2 != 0:
    row.reverse()
  print(' '.join(x for x in row))
  

Measured memory_bytes: 3700
n=int(input())
l=list(map(int,input().split()))
count=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            
            if l[i]!=l[j] and l[j]!=l[k] and l[i]!=l[k]:
                
                if l[i]+l[j]>l[k] and l[i]+l[k]>l[j] and l[j]+l[k]>l[i]:
                    count+=1
    
print(count) 

Measured memory_bytes: 9208
//#pragma GCC diagnostic error "-std=c++11"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const ll inf = 0x3f3f3f3f3f;



int main(){
	map<ll,ll>mp;
	for(int i=1;i<=3;i++)
	{
		ll x;
		cin>>x;
		mp[x]++;
	}	
	if(mp[5]==2&&mp[7]==1) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,v,p;
ll m;
const int Maxn=1e5+5;
ll a[Maxn];
bool check(int index){
	while(index>1&&a[index]==a[index-1]){
		index--;
	}
	if(index<=p)return true;
	int automatic=p+n-index;
//	cout<<automatic<<endl;
	if(automatic>=v){
		return a[index]+m>=a[p];
	}
	ll still_need_per_judge=v-automatic;
	ll still_to_add=m*still_need_per_judge;
	ll target=a[index]+m;
	for(int i=p;i<index;i++){
		ll take=min(m,target-a[i]);
		take=min(take,still_to_add);
		take=max(take,0LL);
		if(a[i]+take>target){
//			cout<<"prprpr"<<endl;
			return false;
		}
//		cout<<take<<' ';
		still_to_add-=take;
	}//cout<<endl;
//	cout<<still_to_add<<endl;
	return still_to_add==0;
}
int main(){
	cin>>n>>m>>v>>p;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
//	for(int i=1;i<=n;i++)cout<<a[i]<<' ';cout<<endl;
	int l=1,r=n+1;
	while(r-l>1){
		int mid=(l+r)/2;
//		cout<<l<<' '<<r<<' '<<mid<<endl;
		if(check(mid))l=mid;
		else r=mid;
	}
	cout<<l<<endl;
//	cout<<check(4)<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;
int main (){
    int h,n;
    cin >> h >> n;
    int s=0;
    int t;
    for (int i = 0; i < n; i++){
        cin >> t;
        s+=t;
    }
    if(s<h) cout << "No\n";
    else cout << "Yes\n";
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $A, $B);
echo lcm($A, $B);

//最大公約数
function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}
 
//最小公倍数
function lcm($m, $n){
    return $m * $n / gcd($m, $n);
}


Measured memory_bytes: 4604
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
*/
//入力終了→Ctrl+D
import java.util.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];
        Point[] p=new Point[h*w];
        for (int i = 0; i < n; i++) {
            a[i]=sc.nextInt();
        }
        int count=0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if(i%2==0){
                    p[count++]=new Point(i,j);
                }else {
                    p[count++]=new Point(i,w-1-j);
                }
            }
        }
        int[][] c=new int[h][w];
        count=0;
        for (int i = 0; i < n; i++) {
            int color=i+1;
            for (int j = 0; j < a[i]; j++) {
                c[p[count].x][p[count].y] = color;
                count++;
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                out.print(c[i][j]);
                if(j<w-1)out.print(" ");
            }
            out.println();
        }
    }

    static class sc {
        static Scanner s = new Scanner(in);

        static String next() {
            return s.next();
        }

        static int nextInt() {
            return Integer.parseInt(s.next());
        }

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

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

Measured memory_bytes: 30396
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
    int a,b;
    cin>>a>>b;
    int ans[16]={0};
    int mx=max(a,b);
    for(int i=0;i<16;i++){
        if(i%2==0 && mx>0){
            ans[i]=1;
            mx--;
        }    
    }
    int count=0;
    for(int i=0;i<16;i++){
        if(ans[i]==0)count++;
    }
    if(count>=b && mx==0)cout<<"Yay!";
    else cout<<":(";
}


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

int main(){
    int H,W;
    while(1){
    cin >> H >> W;
    if( H == 0 && W == 0) break;
    
    for( int i = 0; i < H; i++){
        for( int j = 0; j < W; j++){
            cout << "#";
        }
        cout << "\n";
    }
    cout << endl;
}
return 0;
}


Measured memory_bytes: 3084
N = int(input())
A = list(map(int,input().split(" ")))
total = 1
A.sort()

for i in A:
  if i == 0:
    total = 0
    break
  elif total > 10**18:
    break
  total = total * i
if total > 10**18:
  print(-1)
else:
  print(total)

Measured memory_bytes: 21572
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	string s; cin >> s;
	string t = s;
	rep(i, 0, s.size()) {
		int x = s[i] - 'A';
		x += N;
		x %= 26;
		t[i] = 'A' + x;
	}
	cout << t << endl;

	return 0;
}


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

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

	ll ans = 0;
	ll memo[31]; memo[0] = 1;
	rep(i, 1, 31) memo[i] = memo[i - 1] * 2;
	rep(i, 0, n) {
		rep(j, 0, 31) {
			if (a[i] % memo[j] != 0) {
				ans += j - 1;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    stack<int> S1;
    stack<pair<int, int> > S2;
    vector<int> ss;
    char a;
    int count = 0,sum = 0;
    while(scanf("%c",&a) != EOF){
        count++;
        if(a == '\\'){
            S1.push(count);
        }else if(a == '/' && S1.size() > 0){
            int j = S1.top(); S1.pop();
            sum += count - j;
            int b = count - j;
            while(S2.size() > 0 && S2.top().first > j){
                b += S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,b));
        }
    }
    while(S2.size() > 0){
            ss.push_back(S2.top().second);
            S2.pop();
        }
        cout << sum << endl;
        cout << ss.size();
        reverse(ALL(ss));
        for(int i = 0; i < ss.size(); i++){
            cout << " ";
            cout << ss[i];
        }
        cout << endl;
    return 0;
}


Measured memory_bytes: 3324
// This is the start of the template//
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long int
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
void input(){
#ifndef ONLINE_JUDGE 
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout); 
#endif
}
#define mod 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define sortall(a) sort(a.begin(),a.end())
#define cases ll t; cin>>t; while(t--)
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;
//this is the end of my template //
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	input();
	ll n,k,curr=1,prev=1;
	cin>>n>>k;
	array(a,n);
	rep(i,k,n)
	{

		if(a[i]*1.0/a[i-k]>1.0)
		{
			cout<<"Yes\n";
		}
		else
			cout<<"No\n";
		
		
	}
}	




Measured memory_bytes: 4784
n = gets.to_i
arr = []
n.times { arr << gets.chomp.split.map(&:to_i) }
current = [0, 0, 0]
can = true

arr.each do |nums|
  ct = current[0]
  cx = current[1]
  cy = current[2]
  
  nt = nums[0]
  nx = nums[1]
  ny = nums[2]

  time = nt - ct
  distance = (nx - cx).abs + (ny - cy).abs
  if distance > time || time.even? != distance.even?
    can = false
    break
  end
  current = nums
end

puts can ? "Yes" : "No"


Measured memory_bytes: 9468
#include <iostream>

using namespace std;



int main(){
	while(1){
		int a,b;
		char ch;

		cin>>a>>ch>>b;
		if(ch=='?')break;
		else if(ch=='+')cout<<a+b<<endl;
		else if(ch=='-')cout<<a-b<<endl;
		else if(ch=='*')cout<<a*b<<endl;
		else if(ch=='/')cout<<a/b<<endl;


	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

const int N = 2e5 + 10;
int ans[N];
vi arr;
vvi graph;
vi cur;

void dfs(int me, int p = -1) {
    ans[me] = cur.size();
    for (auto u : graph[me]) {
        if (u == p) continue;
        pp pos;
        bool used = false;
        auto it = lower_bound(all(cur), arr[u]);
        if (it == cur.end()) cur.pb(arr[u]);
        else {
            used = true;
            pos.first = it-cur.begin();
            pos.second = *it;
            cur[pos.first] = arr[u];
        }
        dfs(u,me);
        if (used) {
            cur[pos.first] = pos.second;
        }
        else cur.pop_back();
    }
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    arr = vi(n);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    graph = vvi(n);
    for (int i = 0; i < n -1; ++i) {
        int a, b; cin >> a >> b;
        a--,b--;
        graph[a].pb(b);
        graph[b].pb(a);
    }

    cur.pb(arr[0]);
    dfs(0);
    for (int i = 0; i < n; ++i) {
        cout << ans[i] << '\n';
    }
    return 0;
}



Measured memory_bytes: 30108
N,K = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(N)]
#print(lst)
#print(lst.sort())
lst.sort(key=lambda l:l[0])
#print(lst)

sm = 0
for x in lst:
    sm += x[1]
    #print(lst[i][1])
    if sm >= K:
        print(x[0])
        break

Measured memory_bytes: 28504
#include <bits/stdc++.h>
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) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N;
int dp[212345], A[212345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", A + i);
	
	fill(dp, dp + N + 1, INF);
	
	dp[0] = 0;
	REP(i, N) {
		if (dp[A[i] - 1] != INF) dp[A[i]] = A[i];
	}
	
	int ans = 0;
	REP(i, N + 1) if (dp[i] != INF) chmax(ans, i);
	ans = N - ans;
	if (ans == N) ans = -1;
	
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    s = s.erase(n-1);
    n = n-1;
    if (n%2==1){
        s = s.erase(n-1);
        n = n-1;
    }
    while (n >= 2){
        string front = s.substr(n/2,n/2);
        string back = s.substr(0,n/2);
        if (front == back){
            cout << n << endl;
            return 0;
        }
        s = s.erase(n-2,2);
        n = n - 2;
    }
    

    return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << res << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int a[13][13] = {};
int c[13] = {};
int acv[13] = {};

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	ll res = LINF;
	FOR(i, 1, n) {
		cin >> c[i];
		FOR(j, 1, m) {
			cin >> a[i][j];
		}
	}
	int bit = 0;
	for (bit = 0; bit < (1 << n); bit++) {
		ll sumcost = 0;
		bool isok = true;
		FOR(i, 1, m) {
			acv[i] = 0;
		}

		FOR(i,1,n){
			if (bit&(1 << (i - 1))) {
				sumcost += c[i];
				FOR(j, 1, m) {
					acv[j] += a[i][j];
				}
			}
		}

		FOR(i, 1, m) {
			if (acv[i] < x) {
				isok = false;
			}
		}
		if (isok) {
			res = min(res, sumcost);
		}
	}
	if (res != LINF) {
		pv(res);
	}
	else {
		ps(-1);
	}
	return(0);
}

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

int main(){
  int N;
  cin >> N;
  int sum = 0;
  int tmpmax = 0;
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    sum += tmp;
    if(tmp > tmpmax){
      tmpmax = tmp;
    }
  }
  
  if(tmpmax >= sum - tmpmax){
    cout << "No" << endl;
  } else { 
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
h,w,n = map(int, input().split())
stage = [input() for i in range(h)]
starts = [str(i) for i in range(n)]
goals = [str(i+1) for i in range(n)]
starts_y = [0 for i in range(n)]
starts_x = [0 for i in range(n)]
goals_y = [0 for i in range(n)]
goals_x = [0 for i in range(n)]

starts[0] = "S"
for y in range(h):
    for x in range(w):
        if stage[y][x] in starts:
            starts_y[starts.index(stage[y][x])] = y
            starts_x[starts.index(stage[y][x])] = x
        if stage[y][x] in goals:
            goals_y[goals.index(stage[y][x])] = y
            goals_x[goals.index(stage[y][x])] = x

move_y = [1,-1,0,0]
move_x = [0,0,1,-1]
sum = 0

for start_y, start_x, goal_y, goal_x in zip(starts_y, starts_x, goals_y, goals_x):
    bfs_map = [[-1 for j in range(w)] for i in range(h)]
    data_y = [start_y]
    data_x = [start_x]
    bfs_map[start_y][start_x] = 0
    goal = False

    while len(data_y) != 0 and not goal:
        y = data_y.pop(0)
        x = data_x.pop(0)
        goal = False

        for i in range(4):
            y += move_y[i]
            x += move_x[i]

            if y >= 0 and y < h and x >= 0 and x < w:
                if bfs_map[y][x] == -1 and stage[y][x] != "X":
                    bfs_map[y][x] = bfs_map[y-move_y[i]][x-move_x[i]]+1
                    data_y.append(y)
                    data_x.append(x)
                if bfs_map[goal_y][goal_x] != -1:
                    sum += bfs_map[goal_y][goal_x]
                    goal = True
                    break
            y -= move_y[i]
            x -= move_x[i]

print(sum)


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,A,B,C,D;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B>>C>>D;
	B-=A;
	N--;
	for(int add=0;add<=N;add++) {
		ll lowest=C*add-(N-add)*D;
		ll highest=D*add-(N-add)*C;
		if(lowest<=B && B<=highest) return _P("YES\n");
	}
	_P("NO\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
	int n;
	cin >> n;
	for (int i = 3; i <= n; ++i) {
		string s = to_string(i);
		if (i % 3 == 0 || s.find('3') != string::npos)
			cout << " " << i;
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3228
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int person[2][4];

int main(){
	double n;
	int i=0;
	while(cin>>n){
		if(n>=1.1){
			person[i&1][0]++;
		}else if(n>=0.6){
			person[i&1][1]++;
		}else if(n>=0.2){
			person[i&1][2]++;
		}else{
			person[i&1][3]++;
		}
		++i;
	}
	
	for(int i=0;i<4;i++){
		printf("%d %d\n",person[0][i],person[1][i]);
	}
}

Measured memory_bytes: 0
# n=int(sys.stdin.readline())
# a,b=map(int, sys.stdin.readline().split())
# c=list(map(int, sys.stdin.readline().split()))
# s=[list(map(int,list(sys.stdin.readline()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import math
import sys

#sys.stdin = open("input.txt")
N, M=map(int, sys.stdin.readline().split())

# 各スイッチがどの電球につながっているかの情報をビットで保持する配列
# 1番目のスイッチが2番目と3番目の電球につながっていた場合以下のようになる
# (1 << 1) | (1 << 2) = (110)b   ※ zero index
bulb_list = [0 for _ in range(N)]

for bulb_idx in range(M):
    switches = list(map(int, sys.stdin.readline().split()))
    bulb_bit = 1 << bulb_idx # つながっている電球を二進数で表す

    # switchesの2番目以降の要素には、スイッチの番号が入っている
    for sw in switches[1::]:
        sw_idx = (sw - 1) # スイッチの番号をzero indexに変換する
        bulb_list[sw_idx] = bulb_list[sw_idx] | bulb_bit

bulb_conds = list(map(int, sys.stdin.readline().split()))

bulb_cond = 0
for i, bc in enumerate(bulb_conds):
    bulb_cond |= bc << i

light_num = 0
# N = 3 の時
# 000, 001, 010, 011, 100, 101, 110, 111 の8パターンで、
# スイッチを押す全てのパターンを表現することが出来る
for bit_ptn in range(1 << N):
    t = 0 # tはbit_ptnが表すスイッチの組み合わせを全て押したときの電球の状態を表す(最初は全部消えている)
    for i in range(N):
        if bit_ptn >> i & 1:
            t = t ^ bulb_list[i]
    if t == bulb_cond:
        light_num += 1

print(light_num)


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

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

    vector<int> left(N, 0), right(N, 0);
    for(int i=1; i<N; i++){
        left[i] = max(A[i-1], left[i-1]);
    }
    for(int i=N-2; i>=0; i--){
        right[i] = max(A[i+1], right[i+1]);
    }
    for(int i=0; i<N; i++){
        cout << max(left[i], right[i]) << endl;
    }
}


Measured memory_bytes: 3968
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   IT.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); } 
long double dp[3000][3000];
long double find(vector<long double>&v,ll head,ll tail,ll pos){
	if(pos<0){
		if(head>tail) return 1.0;
		return 0;
	}
	long double &ans=dp[pos][head];
	if(ans!=-1.0) return ans;
	long double ans1=find(v,head+1,tail,pos-1)*v[pos];
	long double ans2=find(v,head,tail+1,pos-1)*(1.0-v[pos]);
	ans=ans1+ans2;
	// ans=ans/2;
	return ans;
}
int  main(){
	FastRead;
	ll t=1;
	// cin>>t;
	while(t--){
		ll n;
		cin>>n;
		vector<long double>v(n);
		for(int i=0;i<n;i++){
			cin>>v[i];
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				dp[i][j]=-1.0;
			}
		}
		cout<<std::setprecision(11) <<find(v,0,0,n-1)<<endl;
	}
}

Measured memory_bytes: 141184
#include<stdio.h>

int main(void){
  int i,h,a,b,m1=0,m2=0,m3=0;
  for(i=0;i<10;i++){
    scanf("%d",&h);
    if(h>m3){
      if(h>m2){
        if(h>m1){
          a=m1;
          m1=h;
          b=m2;
          m2=a;
          m3=b;
        }
        else{
          a=m2;
          m2=h;
          m3=a;
        }
      }
      else{
        m3=h;
      }
    }
  }
  printf("%d\n",m1);
  printf("%d\n",m2);
  printf("%d\n",m3);
  return 0;
}


Measured memory_bytes: 1808
object Main{
  def check(a:Int, b:Int) = {
    if(a > b)
      println("a > b")
    else if(a == b)
      println("a == b")
    else if(a < b)
      println("a < b")
  }
  def main(args:Array[String]) ={
    val scanner = new java.util.Scanner(System.in)
    val a = scanner.nextInt
    val b = scanner.nextInt
    check(a, b)
  }
}

Measured memory_bytes: 44948
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    string A, B;
    cin >> A >> B;

    int length_A = A.size();
    int length_B = B.size();

    string ans;
    if (length_A > length_B)
    {
        ans = "GREATER";
    }
    else if (length_A < length_B)
    {
        ans = "LESS";
    }
    else
    {
        for (int i = 0; i < length_A; i++)
        {
            if (A[i] > B[i])
            {
                ans = "GREATER";
                break;
            }
            else if (A[i] < B[i])
            {
                ans = "LESS";
                break;
            }
            else if (i == length_A - 1)
            {
                ans = "EQUAL";
                break;
            }
        }
    }

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

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left
from heapq import heappush, heappop
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M, R = MAP()
r = LIST()
ABC = [LIST() for _ in range(M)]

dist = [[INF]*N for _ in range(N)]

for i in range(N):
    dist[i][i] = 0

for A, B, C in ABC:
    dist[A-1][B-1] = C
    dist[B-1][A-1] = C

graph = csr_matrix(dist)
dist_mat = floyd_warshall(graph, directed=False)

ans = INF
for n in permutations(r):
    tmp = 0  
    for i in range(1, len(r)):
        tmp += dist_mat[n[i-1]-1][n[i]-1]
    ans = min(ans, tmp)
print(int(ans))


Measured memory_bytes: 24112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, a[20000], s[20000], x[20000], y[20000];
int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i]; s[a[i]-1] = i;
  }
  x[0] = 0; y[0] = s[0];
  for(int i=1;i<n;i++){
    if (s[i-1] < s[i]){
      y[i] = y[i-1]-1; x[i] = s[i] - y[i];
    }else{
      x[i] = x[i-1]+1; y[i] = s[i] - x[i];
    }
  }
  ll dx = 1 - x[0], dy = 1 - y[n-1];
  for(int i=0;i<n;i++){
    x[i] += dx; y[i] += dy;
  }
  for(int i=0;i<n;i++) cout << x[i] << ((i+1<n) ? " " : "\n");
  for(int i=0;i<n;i++) cout << y[i] << ((i+1<n) ? " " : "\n");
  return 0;
}

Measured memory_bytes: 1152
use std::collections::HashMap;

use proconio::fastout;
use whiteread::parse_line;

#[fastout]
fn main() {
    let s: String = parse_line().unwrap();
    let s: Vec<char> = s.chars().collect();

    let mut map: HashMap<char, Vec<usize>> = HashMap::new();
    for i in 0..s.len() {
        let c = s[i];
        let entry = map.entry(c).or_insert(vec![]);
        entry.push(i);
    }

    for c in (b'a'..=b'z').map(char::from) {
        if !map.contains_key(&c) || map[&c].len() == 1 {
            continue;
        }

        let mut left: usize = 0;
        let mut right: usize = map[&c].len() - 1;
        let mut removed = 0;

        loop {
            if left == right {
                break;
            }

            if (map[&c].len() - removed) * 2 > (map[&c][right] - map[&c][left] + 1) {
                println!("{} {}", map[&c][left] + 1, map[&c][right] + 1);
                return;
            }

            if map[&c][left + 1] - map[&c][left] > map[&c][right] - map[&c][right - 1] {
                left += 1;
            } else {
                right -= 1
            }
            removed += 1;
        }
    }

    println!("-1 -1");
}


Measured memory_bytes: 3752
#include<set>
#include <unordered_set>
#include <unordered_map>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <string.h>

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%I64d",&x)
#define mod 1000000007
#define eps 1e-6
#define infi 1e9
#define infll 1e18
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

ll x,y;
int dp[1000][1000];

int solve(ll x,ll y) {
    
    
    if(dp[x][y] != -1) return dp[x][y];
    
    si S;
    lp(i, 1, x/2) S.insert(solve(x-2*i,y+i));
    
    lp(i, 1, y/2) S.insert(solve(x+i,y-2*i));
    
    
    lp(i, 0, infi) if(!S.count(i)) return dp[x][y] = i;
    return dp[x][y];
}
int main(){
    scanf("%lld%lld" ,&x,&y);
    
    if(abs(x-y) < 2) printf("Brown\n");
    else printf("Alice\n");
    
    return 0;
}
/*
 abcda
 
 */

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

int main(void){
    int n,k;
    cin >> n >> k;
    vector<int>h;
    rep(i,n){
        int x;
        cin >> x;
        h.push_back(x);
    }
    sort(h.begin(),h.end(),greater<int>());
    ll ans = 0;
    if(k>=n){
        ans = 0;
    }
    else{
        for(int i=k;i<n;i++){
            ans += h[i];
        }
        
    }
    cout << ans <<endl;
    
    return 0;
        
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    



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

using lint = long long;
constexpr lint INF = 1LL << 60;

void solve() {
    int n;
    std::cin >> n;

    std::vector<lint> dp(3, -INF);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        lint x;
        if (i == 0) {
            std::cin >> x;
        } else {
            char c;
            std::cin >> c >> x;
            if (c == '-') x = -x;
        }

        for (int j = 0; j <= 2; ++j) {
            dp[j] += x * (j == 1 ? -1 : 1);
        }

        // close
        for (int j = 1; j >= 0; --j) {
            dp[j] = std::max(dp[j], dp[j + 1]);
        }

        if (x < 0) {
            // open
            for (int j = 1; j >= 0; --j) {
                dp[j + 1] = std::max(dp[j + 1], dp[j]);
            }
        }
    }

    std::cout << dp[0] << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();// 操作回数
        int k = sc.nextInt();// 操作Bの加算する値

        int ans = 1;
        for (int i = 1; i <= n; i++) {
            if (ans * 2 < ans + k) {
                ans *= 2;
            } else {
                ans += k;
            }
        }

        System.out.println(ans);
    }
}


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

int main() {

  int N;
  cin >> N;
  
  if (N / 100 % 10 == N / 10 % 10 && N / 10 % 10 == N % 10 ) {
    cout << "Yes" << endl;
  }
  
  else if (  N / 1000 == N / 100 % 10 && N / 100 % 10 == N / 10 % 10 ) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  
}


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

	cin >> N;
	rep(i, N) {
		cin >> l >> r;
		ans += (r+1) - l;
	}

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

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi x(n), y(n), z(n);
	rep(i, n) cin >> x[i] >> y[i] >> z[i];
	rep(i, 101) rep(j, 101){
		//(i, j) is our guess
		int f1 = 1;
		int h;
		int used = -1;
		rep(k, n) if(z[k]){
			h = z[k] + abs(x[k] - i) + abs(y[k] - j);
			used = k;
			break;
		}
		assert(used != -1);
		rep(k, n) if(k != used){
			int al = max(0, h - abs(x[k] - i) - abs(y[k] - j));
			if(al != z[k]){
				f1 = 0;
				break;
			}
		}
		if(f1){
			cout << i << " " << j << " " << h << endl;
			return 0;
		}
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX_NUM = 100000000;

int main() {
    int H, N;
    cin >> H >> N;

    int A[N], B[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }

    int maxa = 0;
    rep(i,N) maxa = max(maxa, A[i]);

    int dp[H+maxa+1];
    rep(i,H+maxa+1) dp[i] = MAX_NUM;

    rep(i,H+maxa+1)rep(j,N) {
        if (A[j] >= i) dp[i] = min(dp[i], B[j]);
        else dp[i] = min(dp[i], dp[i - A[j]] + B[j]);
    }

    int ans = MAX_NUM;
    for (int i = H; i < H + maxa + 1; i++) ans = min(ans, dp[i]);

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long i, j;
		i = sc.nextLong();
		j = sc.nextLong();
		if (i ==1) {
			System.out.println(1);
		} else if (j ==1) {
			System.out.println(1);
		} else {
			System.out.println((i*j)/2+(j*i)%2);
		}
		
	}
}

Measured memory_bytes: 21332