akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 500010;
const int MOD = (ll)1e9 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

typedef pair<int, int>P;

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


typedef pair<string, string>P2;

long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

int A[100010];
signed main() {
	int N; cin >> N;
	REP(i, N) {
		cin >> A[i];
	}
	int ans = A[0];
	FOR(i, 1, N) {
		ans = gcd(ans, A[i]);
	}
	print(ans);
}	


Measured memory_bytes: 1024
def main():
    H, W = map(int, input().split())

    def calc(h, w):
        ret = 10 ** 10
        for r1 in range(1, h):
            ma = max(r1, h - r1)

            r2 = ma // 2
            r3 = ma - r2

            ret = min(ret, (max(r1, r2, r3) - min(r1, r2, r3)) * w)

            c2 = w // 2
            c3 = w - c2

            s1 = r1 * w
            s2 = ma * c2
            s3 = ma * c3
            ret = min(ret, max(s1, s2, s3) - min(s1, s2, s3))
        return ret

    ans = min(calc(H, W), calc(W, H))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		
		double a = 0;
		
		for(long i = 1; i <= N; i++) {
			int x = 1;
			if(i >= K) {
				a += 1.0 / (double)N;
			} else {
				long y = i * 2;
				while(y < K) {
					y *= 2;
					x++;
				}
				a += (1.0 / (double)N) * Math.pow(0.5, x);
			}
			
		}
		System.out.println(a);
		
	}
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e18;

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

  int N;
  cin >> N;
  VL xs(N);
  cin >> xs;

  VL dp(N, INF);
  dp[0] = 0;

  REP(i,N){
    if(i+1<N) mini(dp[i+1], dp[i] + abs(xs[i+1] - xs[i]));
    if(i+2<N) mini(dp[i+2], dp[i] + abs(xs[i+2] - xs[i]));
  }

  cout << dp.back() << endl;

  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,c,d,n;
    cin>>a>>b>>c>>d>>n;
    
    if(a*2<b) b=a*2;
    if(b*2<c) c=b*2;
    if(c*2<d) d=c*2;
    
    ll ans=n/2*d;
    if(n%2) ans+=c;
    cout1(ans)
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using llu = long long unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

stack<char> s;
stack<char> ts;
void dfs( int dep, char m ){
    if( dep == 1 ) {
        while( s.size() ){
            ts.push(s.top());
            s.pop();
        }
        while( ts.size() ){
            s.push(ts.top());
            printf ("%c", s.top());
            ts.pop();
        }
        printf ("\n");
    }
    else{
        Repe(ci,m+2,'a'){
            s.push(ci);
            dfs( dep-1, max( m,(char)ci ) );
            s.pop();
        }
    }
}

int main() {

    int  N;
    Scd(N);
    s.push('a');
    dfs( N, 'a' );

    return 0;
}




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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back
const int mod = 1e9+7;

ll f1[2000005], f2[2000005];
ll pow2(ll a, ll b){
    ll res = 1;
    while(b){
        if(b%2 == 1) res = res*a%mod;
        a = a*a%mod;
        b/=2;
    }
    return res;
}

ll f(int r, int c){
    ll ans = 0;
    for(int i=1;i<=r+1;i++){
        ll res = f1[i+c]*f2[i]%mod*f2[c]%mod;
        ans = (ans + res)%mod;
    }
    return ans;
}

int main(){
    f1[0] = f2[0] = 1;
    for(int i=1;i<=2000001;i++) f1[i] = f1[i-1]*i%mod;
    for(int i=1;i<=2000001;i++) f2[i] = pow2(f1[i], mod-2);
    int r1, c1, r2, c2;
    scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
    printf("%lld\n", (f(r2, c2) - f(r2, c1-1) + mod - f(r1-1, c2) + mod + f(r1-1, c1-1))%mod);
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;
const ll INF = 1000000000;

ll cs(vector<ll> s, vector<ll> t, int n, int m) {
    vector<vector<ll>> dp(n+1, vector<ll>(m+1));
    dp[0][0] = 1;
    REP(i,n+1) {
        REP(j,m+1) {
            if(i>0 && j>0 && s[i-1]==t[j-1]) dp[i][j] += dp[i-1][j-1];
            if(i>0) dp[i][j] += dp[i-1][j];
            if(j>0) dp[i][j] += dp[i][j-1];
            if(i>0 && j>0) dp[i][j] += MOD - dp[i-1][j-1];
            dp[i][j] %= MOD;
        }
    }
    return dp[n][m];
}

int main() {
    int n,m; cin >> n >> m;
    vector<ll> s(n), t(m);
    REP(i,n) cin >> s[i];
    REP(i,m) cin >> t[i];
    ll ans = cs(s,t,n,m);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  cin >> N >> K;
  int num[210000];
  for (int i = 0; i < 210000; i++) {
    num[i] = 0;
  }
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    num[a]++; 
  }
  vector<int> S;
  for (int i = 0; i < 210000; i++) {
    if (num[i] != 0) {
      S.push_back(num[i]);
    }
  }
  int ans = 0;
  sort(S.begin(),S.end());
  reverse(S.begin(),S.end());
  for (int i = 0; i < (int)S.size(); i++) {
    if (i >= K) {
      ans += S[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5028
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)



def solve():
    n, m = getList()
    li = []
    ans = []
    for i, c in enumerate(getS()):
        if c == "0":
            li.append(i)
    cur = n
    while True:
        # print(ans)
        ins = cur - m
        ind = bisect_left(li, ins)
        tgt = li[ind]
        if cur == tgt:
            print(-1)
            return

        ans.append(cur - tgt)
        if tgt == 0:
            break
        cur = tgt

    ans.reverse()
    print(*ans)





def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()







Measured memory_bytes: 82308
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

const int MAX = 10000000;

int main(){
    int n,m;
    while(cin >> m >> n,n||m){
        static bool es[MAX] = {0};
        memset(es,0,sizeof(es));

        int i = m;
        while(true){
            if(not es[i]){
                n--;
                if(n < 0){
                    cout << i << endl;
                    break;
                }
                for(int j = i + i; j < MAX; j+=i){
                    es[j] = 1;
                }
            }
            i++;
        }
    }
}

Measured memory_bytes: 12836
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n, k;
  cin >> n >> k;
  if (n % k == 0)
    cout << 0 << endl;
  else
    cout << 1 << endl;

  return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int X, A; cin >> X >> A;
	if (X < A) cout << 0 << endl;
	else cout << 10 << endl;

	return 0;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Tue Dec 25 03:29:25 2018
//
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	ans := 0
	now := 0
	from, to := 0, 0
	for i := range arr {
		for now&arr[i] != 0 && from <= i {
			now &= ^arr[from]
			from++
		}
		now |= arr[i]
		to = i
		ans += to - from + 1
	}

	fmt.Println(ans)
}


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

int minnum(int a, int b){
	if(a>b)	return b;
	else return a;
}

int main(void){
	int n;
	scanf("%d", &n);
	char a[2*n+1], b[n+1];
	scanf("%s %s", &a, &b);
	
	char c[2*n+1];
  	strcat(a,b);
   	strcpy(c,a);
	for(int i=0;i<n;i++){
		c[2*i]=a[i];
		c[2*i+1]=b[i];
	}
	printf("%s", c);

}

Measured memory_bytes: 128
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int wl=0;
    int wr=sc.nextInt();
    int hd=0;
    int hu=sc.nextInt();
    int n=sc.nextInt();
    for(int i=0;i<n;i++){
      int x=sc.nextInt();
      int y=sc.nextInt();
      int a=sc.nextInt();
      if(a==1){
        wl=Math.max(x,wl);
      }else if(a==2){
        wr=Math.min(x,wr);
      }else if(a==3){
        hd=Math.max(y,hd);
      }else{
        hu=Math.min(y,hu);
      }
    }
    System.out.println(Math.max(wr-wl,0)*Math.max(hu-hd,0));
  }
}

Measured memory_bytes: 21844
n, a, b = gets.split.map(&:to_i)

result = 0
1.upto(n) do |m|
  array = m.to_s.split('').map(&:to_i)
  sum = array.inject(0) { |x, y| x + y }
  if (a..b) === sum
    result += m
  end
end
puts result


Measured memory_bytes: 2172
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

/// Number of k-combinations
T combination(T = long)(T n, T k)
{
    assert(0 <= k);
    assert(0 <= n);
    if (n < k)
        return 0;
    k = min(n - k, k);
    if (k == 0)
        return 1;
    if (k == 1)
        return n;
    return memoize!combination(n - 1, k - 1) + memoize!combination(n - 1, k);
}

void main()
{
    long N = lread();
    auto H = aryread();
    long ans;
    long c = 0;
    foreach (i; 1 .. N)
    {
        if (H[i - 1] < H[i])
        {
            c = i;
        }
        else
        {
            ans = ans.max(i - c);
        }
    }
    writeln(ans);
}


Measured memory_bytes: 4040
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
  int n;
  int a, b, c, d;

  scanf("%d", &n);
  a = n / 1000;
  b = (n-1000*a) / 100; 
  c = (n-1000*a-100*b) / 10; 
  d = n-1000*a-100*b-10*c; 

  //  printf("a = %d, b = %d, c = %d, d = %d\n", a, b, c, d);
  if(a == b && b== c){
    printf("Yes");
  }else if(b == c && c == d){
    printf("Yes");
  }else{
    printf("No");
  }
  
  /*
 // 数値を降順にソート
  for (int i=0; i< n*2-1; i++) {
    for (int j=i+1; j<n*2; j++) {
      if (L[i] > L[j]) {
        tmp =  L[i];
        L[i] = L[j];
        L[j] = tmp;
      }
    }
  }
*/

  printf("\n");

  return 0;
}


Measured memory_bytes: 128
function Main(input) {
	var times = new Array(26)
	for (var i = 0; i < 26; ++i) {
		times[i] = 0;
	}
	for (var i = 0; i < input.length; ++i) {
		var index = input.charCodeAt(i) - "a".charCodeAt(0)
		++times[index]
	}
	
	for (var i = 0; i < 26; ++i) {
		if (times[i] % 2 == 1) {
			console.log("No")
			return;
		}
	}
	console.log("Yes")
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main ( ) {
	int n ;
	
	cin >> n ;
	
	int t = n , sum = 0 ;
	
	while ( t ) 
		sum += t % 10 , t /= 10 ;
	
	if ( n % sum == 0 ) 
		cout << "Yes" << endl ;
	else
		cout << "No" << endl ;
		
	return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,q,s[100000],cnt=0; cin>>n;
  for(int i=0;i<n;++i) cin>>s[i];
  cin>>q;
  for(int i=0;i<q;++i){
    int t,left=0,right=n;
    cin>>t;
    while(left!=right-1){
      int mid=(left+right)/2;
      if(s[mid]>t) right=mid;
      else left=mid;
    }
    if(s[left]==t) ++cnt;
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3384
import java.util.Scanner;
import java.util.ArrayList;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<Integer>();
        int num = sc.nextInt();
        list.add(num);
        int count = 0;
        while(true){
            if(list.get(count) % 2 == 0){
                list.add(list.get(count)/2);
                count += 1;
            }else{
                list.add(list.get(count)*3 + 1);
                count += 1;
            }
            for(int i = 0; i < list.size() - 1; i++){
                if(list.get(i) == list.get(count)){
                    System.out.println(count + 1);
                    return;
                }
            }
        }
    }
}

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

int main() {
  int a[5];
  for(int i=0;i<5;i++)cin>>a[i];
  for(int i=0;i<5;i++){
    if(a[i]==0){
      cout<<i+1<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>

int main (void){

	/*?????°?????£?¨???¨?????????*/

	int n = 0 ;
	int x = 0 ;		//1??????n?????§????????¶??°?????????????????????3??????????????????x?????????????????????????????°??????

	int cnt = 0 ;	//??????????????¨?????°

	int i = 0 ;
	int j = 0 ;
	int k = 0 ;		//???????????°

	do{
		/* n,x????????? */
		scanf("%d" , &n);
		scanf("%d" , &x);

		cnt = 0 ;	//????????????????????¢



	/*??¨?????????????????????????????????????????????????????§??????*/

		for( i = 1 ; i <= n ; i++){
			for( j = i ; j <= n ; j++){
				for( k = 1 ; k <= n ; k++ ){

				/*????¨????x??§?????????????????? i < j < k ????????¶??¨????????????????????¢???????????????
				 ??§?°???¢???????????¶??¨???????????¨??§???????????¨????????????(1,2,3??¨1,3,2??????)????????????????????¨?????§??????*/
					if( (( i + j + k ) == x) && ( i < j) && ( j < k ) ){

						cnt++;					}

				}
			}
		}

		/*????????????????????¨??? ????????????n??¨x?????¨??????0?????´????????¨????????????*/
	if( n || x ){
		printf("%d\n" , cnt);
	}

	}while( n || x );		//n??¨x?????¨??????0????????°??????

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

ll rep_power_modM(ll a, ll n, ll M = MOD){
    if(n == 0)return 1;
    if(n%2 == 0){ll tmp = rep_power_modM(a,n/2,M); return tmp*tmp%M;}
    return a*rep_power_modM(a,n-1,M)%M;
}

ll comb_modM(ll n, ll r, ll M = MOD){
    ll ans = 1; rep(i,r){ans *= (n-i)%M; ans%=M;}
    ll divisor = 1; rep(i,r){divisor *= (i+1)%MOD; divisor %=M;}
    ans = ans * rep_power_modM(divisor,M-2,M)%M; if(ans<0)ans+=M;
    return ans;
}

int main(){
	int N,K; cin>>N>>K;
	REP(i,K){
		ll ans = comb_modM(K-1, i-1);
		if(i-1 > N-K){cout<<0<<endl; continue;}
		ans *= comb_modM(N-K+1, N-K-i+1);
		ans %= MOD;
		if(ans < 0)ans += MOD;
		cout<<ans<<endl;
	}
	return 0;
}

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

long long inved(long long x){
  long long p = mod - 2;
  long long y = 1;
  long long base = x;
  while (p != 0){
    if (p % 2 == 1){
      y *= base;
      y %= mod;
    }
    base *= base;
    base %= mod;
    p /= 2;
  }
  return y;
}
vector<vector<long long>> encryptic(vector<vector<long long>> left, vector<vector<long long>> mat){
  vector<vector<long long>> cont(0, vector<long long>(5));
  for (int i=0;i<left.size();i++){
    for (int j=0;j<mat.size();j++){
      vector<long long> tm = {left.at(i).at(0) * mat.at(j).at(0)};
      for (int k=1;k<5;k++){
        tm.push_back(left.at(i).at(k) + mat.at(j).at(k));
      }
      cont.push_back(tm);
    }
  }
  return cont;
}
int main(){
  vector<int> X(6), Y(6);
  for (int i=0;i<6;i++){
    cin >> X.at(i);
  }
  for (int i=0;i<6;i++){
    cin >> Y.at(i);
  }
  vector<vector<vector<long long>>> F = {
    {
      {1, 0, 0, Y.at(5)-Y.at(4)+1, 0}, 
      {-1, 0, 0, 0, 0}
    },
    {
      {1, X.at(5)-X.at(4)+1, 0, 0, 0}, 
      {-1, 0, 0, X.at(5)-X.at(4)+1, 0}
    },
    {
      {1, 0, 0, Y.at(3)-Y.at(2)+1, 0}, 
      {-1, 0, 0, 0, Y.at(3)-Y.at(2)+1}
    },
    {
      {1, 0, X.at(3)-X.at(2)+1, X.at(3)-X.at(2)+1, 0}, 
      {-1, X.at(3)-X.at(2)+1, 0, 0, X.at(3)-X.at(2)+1}
    },
    {
      {1, 0, 0, 0, Y.at(1)-Y.at(0)+1}, 
      {-1, 0, 0, 0, 0}
    },
    {
      {1, 0, 0, 0, X.at(1)-X.at(0)+1}, 
      {-1, 0, X.at(1)-X.at(0)+1, 0, 0}
    },
    {
      {1, X.at(2)-X.at(5)-1, X.at(0)-X.at(3)-1, X.at(4)+Y.at(4)-X.at(3)-Y.at(3), X.at(2)+Y.at(2)-X.at(1)-Y.at(1)}
    }
  };
  vector<long long> fact(2000001, 1);
  vector<long long> invf(2000001, 1);
  for (int i=0;i<2000000;i++){
    fact.at(i+1) = (fact.at(i) * (i+1)) % mod;
  }
  invf.at(2000000) = inved(fact.at(2000000));
  for (int i=2000000;i>0;i--){
    invf.at(i-1) = (invf.at(i) * i) % mod;
  }
  vector<vector<long long>> Poly = {{1, 0, 0, 0, 0}};
  for (int i=0;i<7;i++){
    Poly = encryptic(F.at(i), Poly);
  }
  long long S = 0;
  for (int i=0;i<64;i++){
    vector<long long> p = Poly.at(i);
    int a = -p.at(1), b = -p.at(2), c = p.at(3), d = p.at(4);
    int s = (mod + p.at(0)) % mod;
    long long tmp = 0;
    long long M = min(b, c-a-2);
    for (int j=0;j<=M;j++){
      long long pix = j + 1;
      pix *= invf.at(j+a+2);
      pix %= mod;
      pix *= invf.at(c-j-a-2);
      pix %= mod;
      pix *= invf.at(b-j);
      pix %= mod;
      pix *= invf.at(d-b+j);
      pix %= mod;
      tmp += pix;
      tmp %= mod;
    }
    tmp *= fact.at(c);
    tmp %= mod;
    tmp *= fact.at(d);
    tmp %= mod;
    S += s * tmp;
    S = (S + mod) % mod;
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 31616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Globalization;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            List<char> O = Console.ReadLine().ToList();
            List<char> E = Console.ReadLine().ToList();
            E.Add('\0');

            var OE = new List<char>();

            for (int i = 0; i < O.Count; i++)
            {
                OE.Add(O[i]);
                OE.Add(E[i]);
            }
            OE.Remove('\0');
            String str = new string(OE.ToArray());
            Console.WriteLine(str);
        }
    }
}


Measured memory_bytes: 13140
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int cnt = 0;
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		for(int i=0;i<n;i++){
			int a = sc.nextInt();
			if(q.isEmpty() || q.peek()<a){
				q.push(a);
				cnt++;	
			}else{
				while(true){
					int b = q.peek();
					if(b>a) q.pop();
					else if(b==a) break;
					else if(b<a){
						q.push(a);
						cnt++;
						break;
					}
					if(q.isEmpty()){
						q.push(a);
						cnt++;
						break;
					}
				}
			}
		}
		
		System.out.println(cnt);
	}	
}

Measured memory_bytes: 100656
#include <bits/stdc++.h>
using namespace std;
int set_elem(bool r1, bool ror, bool c1, bool cor,int a,int b){
    int i=(!ror)*8+(r1)*4+(!cor)*2+(c1);
    vector<int> table={0,0,0,-1,0,1,a,1,0,b,0,1,-1,1,1,1};
    return table[i];
}
int main() {
    int N;
    cin>>N;
    vector<bool> row_or(N);
    vector<bool> column_or(N);
    vector<bitset<64>> U(N);
    vector<bitset<64>> V(N);
    vector<vector<bitset<64>>> mat(N,vector<bitset<64>>(N));
    for (int i = 0; i < N; i++){
        bool S;
        cin>>S;
        row_or[i]=S;
    }
    for (int i = 0; i < N; i++){
        bool T;
        cin>>T;
        column_or[i]=T;
    }
    for (int i = 0; i < N; i++){
        long long unsigned int u;
        cin>>u;
        U[i]=u;
    }
    for (int i = 0; i < N; i++){
        long long unsigned int v;
        cin>>v;
        V[i]=v;
    }
    for (int bit = 0; bit < 64; bit++){
        vector<vector<int>> row_count(2,vector<int>(2,0));
        vector<vector<int>> column_count(2,vector<int>(2,0));        
        for (int i = 0; i < N; i++){
            row_count[U[i][bit]][row_or[i]]++;
            column_count[V[i][bit]][column_or[i]]++;
        }
        int a,b;
        bool c=0;bool d;
        bool use_c=false;
        int row_0=row_count[0][0]+row_count[0][1];
        int column_0=column_count[0][0]+column_count[0][1];
        if(row_0==N&&column_0==0){
            if(row_count[0][0]==1||column_count[1][1]==1){
                cout<<-1<<endl;
                return 0;
            }
            use_c=true;
        }else if(row_0==0&&column_0==N){
            if(row_count[1][1]==1||column_count[0][0]==1){
                cout<<-1<<endl;
                return 0;
            }
            use_c=true;
        }
        if(row_0>0)a=1;
        else if(column_0<N)a=0;
        if(row_0<N)b=0;
        else if(column_0>0)b=1;
        for (int i = 0; i < N; i++){
        d=c;
            for (int j = 0; j < N; j++){
                if(use_c){
                    a=d;b=d;
                }
                int tmp=set_elem(U[i][bit],row_or[i], V[j][bit],column_or[j],a,b);
                if(tmp==-1){
                    cout<<-1<<endl; return 0;
                }
                mat[i][j][bit]=tmp;
                if((V[j][bit]==1&&column_or[j])||(V[j][bit]==0&&!column_or[j]))d=!d;

            }
            if((U[i][bit]==1&&row_or[i])||(U[i][bit]==0&&!row_or[i]))c=!c;
        }
    }
    for (int i = 0; i < N; i++){
        for (int j = 0; j < N; j++){
            cout<<mat[i][j].to_ullong()<<" ";
        }
        cout<<endl;
    }

}

Measured memory_bytes: 7560
#include<bits/stdc++.h>
using namespace std;
vector<int> g[100001];
int visited[100001];
int dp[100001];
void dfs(int node)
{
	dp[node] = 0;
	visited[node] = 1;
	for (auto child : g[node])
	{
		if (!visited[child])
		{
			dfs(child);
		}
		dp[node] = max(dp[node], 1 + dp[child]);
	}
}
int main()
{
	int n, m, i, j, k; cin >> n >> m;
	for (i = 0; i < m; i++) cin >> j >> k, g[j].push_back(k);
	memset(visited, 0, sizeof(visited));
	for (i = 1; i <= n; i++)
		if (!visited[i])
			dfs(i);
	int ans = 0;
	for (i = 1; i <= n; i++) ans = max(ans, dp[i]);
	cout << ans << endl;


}



Measured memory_bytes: 12536
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long
int a[114514];
int main(){
    int n;
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    map<int,int>mp;
    rep(i,n){
        mp[a[i]]++;
    }
    int ans=0;
    for(auto p: mp){
        int x=p.first;
        int n=p.second;
        if(n<x)ans+=n;
        else ans+=n-x;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5120
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://cf16-exhibition-final-open.contest.atcoder.jp/tasks/cf16_exhibition_final_a>
問題文============================================================
 一次元の世界に N 個のパソコンと N 個の電源があります。
 i 番目のパソコンの座標は ai であり、 i 番目の電源の座標は bi です。
 これらの 2N 個の座標は相異なることが保証されています。
 
 すぬけ君は、それぞれのパソコンをケーブルで電源につなぎたいです。
 それぞれの電源は一つのパソコンにのみつなぐことができます。
 
 何通りの方法で、ケーブルの長さの合計を最小化できるでしょうか？ 答えを modulo 10^9+7 で求めてください。
=================================================================

解説=============================================================

================================================================
*/
const ll MOD = 1e9+7;
ll solve(){
    ll N; cin >> N;
    vector<ll> a(N),b(N);
    for(auto &in:a) cin >> in;
    for(auto &in:b) cin >> in;
    sort(a.begin(),a.end()); sort(b.begin(),b.end());
    
    vector<pll> event(2*N);
    for(int i = 0; i < N;i++){ event[i] = {a[i],0}; }
    for(int i = 0; i < N;i++){ event[i+N] = {b[i],1}; }
    
    sort(event.begin(),event.end());

    ll ret = 1;
    
    ll cnt1 = 0, cnt2 = 0;
    for(int i = 0; i < 2*N;i++){
        if(event[i].second == 0){
            if(cnt2 != 0){
                (ret *= cnt2)%=MOD;
                cnt2--;
            }else{
                cnt1++;
            }
        }else{
            if(cnt1 != 0){
                (ret *= cnt1)%=MOD;
                cnt1--;
            }else{
                cnt2++;
            }
        }
    }
    
    return ret;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}

int main(){
    int a,b,k;cin >> k >> a >> b;
    for(int i=a;i<=b;++i){
        if(i%k==0){
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
}

Measured memory_bytes: 3632
a,b,k = map(int, input().split())

if a>k:
  print(str(a-k)+' '+str(b))
else:
  if k < a+b:
    if k >= a:
      print('0 ' + str(b-(k-a)))
    else:
      print(str(k-a)+' '+str(b))
  else:
    print('0 0')


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
int sasum[100005]={0},sbsum[100005]={0},tasum[100005]={0},tbsum[100005]={0};
int md(int p,int m){
  int ret=p%m;
  if(ret==0&&p>=m) ret=m;
  return ret;
}
void out(bool f){
  if(f) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}
int main(){
  string s,t;
  cin>>s>>t;
  for(int i=1;i<=s.length();i++){
    sasum[i]=sasum[i-1];
    sbsum[i]=sbsum[i-1];
    if(s[i-1]=='A') sasum[i]++;
    else sbsum[i]++;
  }
  for(int i=1;i<=t.length();i++){
    tasum[i]=tasum[i-1];
    tbsum[i]=tbsum[i-1];
    if(t[i-1]=='A') tasum[i]++;
    else tbsum[i]++;
  }
  int query;
  cin>>query;
  for(int i=0;i<query;i++){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int p=sasum[b]-sasum[a-1],q=sbsum[b]-sbsum[a-1];
    int r=tasum[d]-tasum[c-1],s=tbsum[d]-tbsum[c-1];
    p=md(p,3);
    q=md(q,3);
    r=md(r,3);
    s=md(s,3);
    if((p-q-r+s)%3==0) out(true);
    else out(false);
  }
}


Measured memory_bytes: 2432
//jinhaonan
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef double db;
template<class T>inline void read(T &x){
	x=0;char c=getchar();bool f=0;
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';x=(x<<1)+(x<<3)+c-'0',c=getchar());
	x=f?-x:x;
}
template<class T>inline void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)write(x/10);
	putchar(x%10+48);
}
template<class T>inline bool chkmax(T &a,T const &b){
	return a<b?a=b,1:0;
}
template<class T>inline bool chkmin(T &a,T const &b){
	return a>b?a=b,1:0;
}
void Main(){
	string s;
	cin>>s;
	int ans=1,pre=0;
	for(size_t i=1;i<s.length();++i){
		if(s[i]==s[pre]&&i-pre==1){
			pre=i;
			if(++i<s.length()){
				++ans;
			}
		}else{
			pre=i;
			++ans;
		}
	}
	cout<<ans<<'\n';
}
int main(){
	// freopen("in.txt","r",stdin);
	// int test;read(test);
	// while(test--){
		Main();
	// }
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int N=6666;
ll n,k;
ll c[N][N];
ll C(ll n,ll m)
{
    if(c[n][m]) return c[n][m];
    if(m==0||n==m) return 1;
    if(m==1) return n;
    return c[n][m]=(C(n-1,m-1)+C(n-1,m))%mod;
}
int main()
{
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=k;i++)
    {
        if(i>n-k+1)
        {
            printf("0\n");
            continue;
        }
        ll ans = 1;
        ans = C(k-1,i-1) * C(n-k+1,i) % mod;
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 102912
h, w = [ int(v) for v in input().split() ]

if h % 3 == 0 or w % 3 == 0:
    ans = 0
else:
    ans = 10**12
    s = h * w
    for p in [h//3, h//3 + 1]:
        s1 = w * p
        s2 = (w // 2) * (h - p)
        s3 = (w - (w // 2)) * (h - p)
        ans = min(ans,(max(s1,s2,s3)-min(s1,s2,s3)))

    for p in [w//3, w//3 + 1]:
        s1 = h * p
        s2 = (h // 2) * (w - p)
        s3 = (h - (h // 2)) * (w - p)
        ans = min(ans,(max(s1,s2,s3)-min(s1,s2,s3)))

    s1 = w * (h//3)
    s2 = w * (h//3+1)
    ans = min(ans,(max(s1,s2)-min(s1,s2)))
    s1 = h * (w//3)
    s2 = h * (w//3+1)
    ans = min(ans,(max(s1,s2)-min(s1,s2)))
    
print(ans)
     

Measured memory_bytes: 38256
def maxHeapify(a, i)
  h = a.size
  l = 2 * i + 1
  r = 2 * i + 2
  largest = i
  largest = l  if l < h && a[l] > a[i]
  largest = r if r < h && a[r] > a[largest]

  if largest != i then
    a[i], a[largest] = a[largest], a[i]
    maxHeapify(a, largest)
  end
end
def buildMaxHeap(a)
  h = a.size
  (h/2-1).downto(0){|i|
    maxHeapify(a, i)
  }
end

gets.to_i
a = gets.split.map(&:to_i)

buildMaxHeap(a)

puts " #{a.join(" ")}"

Measured memory_bytes: 64712
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
//__int128


signed main() {
  // freopen("in.txt", "r", stdin);
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(10);
  int n;
  cin >> n;
  cout << (n - 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll unsigned long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cerr << (#x) << " is " << (x) << endl
#define INF 1e13
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
bool check(ll i,ll j,ll n){return (i>=0 && i<n && j>=0 &&  j<n);} //matrix boundary checking
 
 
ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
 
// max({a, b, c, d})
// cout << fixed for removing e notation
 
bool comp(pair<ll, ll>a, pair<ll, ll>b)
{
    if(a.se*b.fi + b.se > b.se*a.fi + a.se) return true;
    else return false;
}
 
void convert(int arr[], int n) 
{ 
    int temp[n+1];
    for(int i=1;i<=n;i++)
        temp[i] = arr[i]; 
    // memcpy(temp, arr, n*sizeof(int)); 
  
    sort(temp+1, temp+n+1);   
    unordered_map<int, int> umap;
    int val = 1; 
    for (int i = 1; i <= n; i++) 
        umap[temp[i]] = val++;
    for (int i = 1; i <= n; i++) 
        arr[i] = umap[arr[i]]; 
}
 
bool prime[10000005];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime)); 
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
    }
}

int foo(int a, int b, int c)
{
    return (abs(a-b) + abs(b-c) + abs(a-c));
}


ll getFirstSetBitPos(ll n) 
{ 
    return log2(n & -n) + 1; 
} 

int main()
{
    int n;
    cin >> n;

    ll a[n+1];

    for(int i=1;i<=n;i++)
        cin >> a[i];

    ll b[n+1];

    for(int i=1;i<=n;i++)
    {
        b[a[i]] = i;
    }

    for(int i=1;i<=n;i++) cout << b[i] << " ";
    cout << "\n";
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define N 100001
using namespace std;
vector<int>G[N];
int n,m;

int used[N],low[N],cnt=1;
vector<int> AP;
int dfs(int pos,int pre){
  low[pos]=used[pos]=cnt++;
  int &res=low[pos];
  int mn=-1,f = 0;
  for(int i=0;i<G[pos].size();i++){
    int nx = G[pos][i];
    if(nx==pre)continue;
    if(used[nx]!=0) res=min(res,used[nx]);
    else res=min(res,dfs(nx,pos)),mn=max(mn,low[nx]),f++;
    
  }
  if(pre!=-1&&mn>=used[pos]) AP.push_back(pos); 
  if(pre==-1&&f>1) AP.push_back(pos);
  return res;
}


int main(){
  
  cin>>n>>m;
  for(int i=0,a,b;i<m;i++){
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(0,-1);
  sort(AP.begin(),AP.end());
  for(int i=0;i<AP.size();i++) cout<<AP[i]<<endl;

  return 0;
}

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

int main() {

	ll n, k, r, s, p; cin >> n >> k >> r >> s >> p;
	string t; cin >> t;
	vector<bool> skip(n, false);
	ll ans = 0;
	for (int i = 0; i < t.size(); i++) {
		if (k <= i && t[i] == t[i - k] && !skip[i - k]) {
			skip[i] = true;
			continue;
		}
		if (t[i] == 'r') {
			ans += p;
		}
		else if (t[i] == 's') {
			ans += r;
		}
		else if (t[i] == 'p') {
			ans += s;
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <tuple>
#define FOR0(var, max) for (ui (var) = 0; (var) < (max); ++(var))
#define FOR_INV(var, min, max) for (ui (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

int main(void) {
  int R, G;
  cin >> R;
  cin >> G;
  cout << 2 * G - R << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

 using namespace std;

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = i % 3600 /60;
   s = i % 3600 %60;
   cout << h << ":" << m << ":" << s << endl;

   return 0;
}


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

int main(){
  long long A,B,N,X=0,MINI=10;
  cin >> N;
  B=N;
  for(long long A=1;A<min(N,(long long)100000);A++){
      B=N/A;
      if(N%A==0 && B>=A){
      while(B!=0){
        B/=10;
        X++;
      }
      if(MINI>X){
        MINI=X;
      }
      X=0;
    }
  }
  if(N==1){cout << 1 << endl;}
  else{cout << MINI << endl;}
  return 0;
}


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

typedef long long int ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vll> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpl;
typedef unordered_set<ll> usl;
typedef set<ll> sl;
typedef unordered_map<ll, ll> uml;
typedef map<ll, ll> ml;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

#define loop(i, s, n) for(ll i = s; i < n; ++i)
#define all(v) v.begin() , v.end()
#define ceil(a, b) (a + b - 1) / b
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll inf = 1e9 + 7;
const ll mod = 998244353;
const double pie = 3.14159265358979323846;
const char nl = '\n';
const char spc = ' ';

template<typename Type>
istream &operator>>(istream &in, vector<Type> &v)
{
    ll n = v.size();
    for (int i = 0; i < n; i++)
        in >> v[i];
    return in;
}

template<typename Type>
ostream &operator<<(ostream &out, vector<Type> &v)
{
    for (auto value : v)
        out << value << ' ';
    out << nl;
    return out;
}

bool isPrime (ll n)
{
    if (n < 4)
        return true;
    if (n % 2 == 0)
        return false;
    ll i = 3;
    while (i * i <= n)
    {
        if (n % i == 0)
            return false;
        i += 2;
    }
    return true;
}

void solve ()
{
   ll n;
   cin >> n;
   vll a(n);
   cin >> a;
   ll stool = 0;ll m = 0;
   for (ll i = 0; i < n; ++i)
   {
        m = max (m, a[i]);
        stool += m - a[i];
   }
   cout << stool << nl;
}

int main()
{
    IOS
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll t;
    t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

const ll YMAX = (1ll << 31) - 1;
vector<ll> dat;
int N;

void update(int k, int a) {
  k += N - 1;
  dat[k] = a;
  while (k > 0) {
    k = (k - 1) / 2;
    dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
  }
}

int find(int a, int b, int k, int l, int r) {
  // [a, b) での最小値。[l, r) と節点kが対応
  if (r <= a || b <= l) return YMAX;
  if (a <= l && r <= b) return dat[k];
  else {
    int vl = find(a, b, k * 2 + 1, l, (l + r) / 2);
    int vr = find(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
}

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

  cin >> N;
  ll Q; cin >> Q;
  ll N_ = N;
  N = 1;
  while (N < N_) N *= 2;
  dat = vector<ll>(2 * N - 1, YMAX);

  for (ll i = 0; i < Q; i++) {
    int q, x, y;
    cin >> q >> x >> y;
    if (q == 0) {
      update(x, y);
    } else {
      int ans = find(x, y + 1, 0, 0, N);
      cout << ans << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 4860
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B;
    cin >> A >> B;
    if(0 < A && A< 10 && 0<B && B<10){
        cout << A * B << endl;
    }else
    {
        cout << -1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#h,w=map(int,input().split())
import string
al=string.ascii_lowercase
n=int(input())
ss=[]
for i in range(n):
    s=input()
    t=[]
    for i in al:
        t.append(s.count(i))
    ss.append(t)

ans=[]
for i in range(26):
    mi=10**10
    for j in ss:
        mi=min(j[i],mi)
    ans+=[mi]

t=''
for i in range(26):
    t+=al[i]*ans[i]
print(t)


Measured memory_bytes: 40944
n = int(input())
s = input()
mod = 10**9 + 7
"""
a~zの全てのアルファベットが1回以下使われる組み合わせ(複数ある場合は区別される)
を求めれば良い。
なお、部分列であるので、連続である必要はない。
Ex.
aが文字列に２つ含まれる場合。
どちらか片方を使う　で2通り
どちらも使わない　　で1通り
　　　　　　　　　　計3通りある。
なお、全ての組み合わせを求めた後、それには「全てを使わない」選択肢が含まれているので
全ての組み合わせ-1が答えとなる。
"""

import collections

c = collections.Counter(s)

c_value_lst = list(c.values())

ans = 1

for i in c_value_lst:
    ans *= (i+1)
    ans = ans%mod
print(ans-1) 

Measured memory_bytes: 40560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
//26

int a[1000000];
signed main(){
	int n, x = 0, s = 0, ans = 0, cnt = 0;
	scanf("%lld", &n);
	rep(i,n)scanf("%lld", &a[i]);
	rep(i,n){
		if(i > 0){
			x ^= a[i-1];
			s -= a[i-1];
		}
		repi(j,i+cnt,n){
			int y = x^a[j], z = s+a[j];
			if((int)(x xor a[j]) != z)break;
			x ^= a[j];
			s += a[j];
			cnt++;
		}
		ans += cnt;
		cnt--;
	}
	printf("%lld\n", ans);
	return 0;
}




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

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

Measured memory_bytes: 256
r1, c1, r2, c2 = map(int, input().split())
mod = 10 ** 9 + 7

fac = [1]
inv = [1]
for i in range(1, r2 + c2 + 10) :
  fac.append(fac[-1] * i % mod)
  inv.append(pow(fac[-1], mod - 2, mod))

def comb(n, r) :
  return fac[n] * inv[n-r] % mod * inv[r] % mod

def g(x, y) :
  return comb(x + y, y)

ret = g(r2+1, c2+1) - g(r2+1, c1) - g(r1, c2+1) + g(r1, c1)
ret %= mod

print(ret)

Measured memory_bytes: 135792