akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define pw(x) (1LL<<(x))
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define NEWL EVAL({cout << '\n';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
#define DIE EVAL({cout << -1 << '\n'; exit(0);})
//------------------------------------------------------------------------------------------------------

const int N = 1000 + 10;
int n;

LD x[N], y[N], r[N];

LD getdis(int u, int v) {
    LD sq = (x[u] - x[v]) * (x[u] - x[v]) + (y[u] - y[v]) * (y[u] - y[v]);
    LD ret = sqrt(sq);
    if(ret > r[u] + r[v] + eps) {
        return (ret - r[u]) - r[v];
    }
    return 0;
}

int main() {
    cin >> x[0] >> y[0];
    cin >> x[1] >> y[1];
    cin >> n;
    REP(i, n) {
        cin >> x[i+2] >> y[i+2] >> r[i+2];
    }
    n += 2;
    vector<LD> dis(n, -1);
    dis[0] = 0;
    set<pair<LD, int>> pq;
    pq.insert({0, 0});
    while(!pq.empty()) {
        int u = pq.begin()->second;
        pq.erase(pq.begin());
        REP(v, n) {
            if(u == v) continue;
            LD d = getdis(u, v);
            if(dis[v] == -1 || dis[u] + d + eps < dis[v]) {
                if(dis[v] != -1) {
                    pq.erase({dis[v], v});
                }
                dis[v] = dis[u] + d;
                pq.insert({dis[v], v});
            }
        }
    }
    cout << dis[1] << '\n';
}






























Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder
{
    class QuestionA
    {
        public static void Main(string[] args)
        {
            // 入力の読み込み
            string c1 = Console.ReadLine();
            string c2 = Console.ReadLine();
            string c3 = Console.ReadLine();


            Console.WriteLine(c1.Substring(0,1) + c2.Substring(1, 1) + c3.Substring(2, 1));
        }
    }
}


Measured memory_bytes: 11092
use std::io::{stdin, Read};
use std::ops::Range;
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>();
    let mut ans: u64 = 0;
    let operator_positions = make_set(s.len() - 1);
    for pos in operator_positions {
        let mut left = 0;
        for right in pos {
            let num: u64 = s[left..right + 1].parse().unwrap();
            ans += num;
            left = right + 1;
        }
        let num: u64 = s[left..].parse().unwrap();
        ans += num;
    }
    println!("{}", ans);
}

fn make_set(n: usize) -> Vec<Vec<usize>> {
    let width = 1 << n;
    let mut result_set = vec![];
    for bits in 0..width {
        let mut row = vec![];
        for i in 0..n {
            if bits >> i & 1 == 1 {
                row.push(i)
            }
        }
        result_set.push(row)
    }
    result_set
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a;
  cin >> a;
  
  cout << a*(a+1)/2 << endl;
  
}


Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
k=int(input())
ans=0
first=k*(k+1)//2
second=0

for i in range(1,k):
    for j in range(i+1,k+1):
        second+=gcd(i,j)*6

thir=0
for i in range(1,k-1):
    for j in range(i+1,k):
        for h in range(j+1,k+1):
            tmp=gcd(gcd(i,j),h)
            thir+=tmp*6

if k==1:
    print(first)
elif k==2:
    print(first+second)
else:
    print(first+second+thir)

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

string s;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> s;
    rep(S, 1<<3) {
        int now = s[0]-'0';
        rep(i, 3) {
            if ((S>>i)&1) now += s[i+1]-'0';
            else now -= s[i+1]-'0';
        }
        if (now==7) {
            cout << s[0]-'0';
            rep(i, 3) {
                if ((S>>i)&1) cout << '+';
                else cout << '-';
                cout << s[i+1]-'0';
            }
            cout << "=7" << endl;
            exit(0);
        }
    }
}

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


int main()
{
   long long a, b, k; cin >> a >> b >> k;

   if(a >= k){
       cout << a - k <<" " << b << endl;
    }else if(k <= a + b){
       cout << 0 << " " << b - (k - a) << endl;
    }else{
        cout << 0 << " " << 0 <<  endl;
    } 
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String b = sc.next();
 
      if(b. equals ("A")){
    System.out.println("T");
      }if(b. equals ("T")){
    System.out.println("A");
      }else if(b. equals ("C")){
	System.out.println("G");
      }else if(b. equals ("G")){
	System.out.println("C");
      }
      }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N, M; cin >> N >> M;
    vector<pair<int, int>> student(N), check(M);
    for(int i = 0; i < N; i++) {
        int a, b; cin >> a >> b;
        student[i].first = a;
        student[i].second = b;
    }
    for(int i = 0; i < M; i++) {
        int c, d; cin >> c >> d;
        check[i].first = c;
        check[i].second = d;
    }
    for(int i = 0; i < N; i++) {
        int m = inf;
        int move = -1;
        for(int j = 0; j < M; j++) {
            int mdist = abs(student[i].first - check[j].first) + abs(student[i].second - check[j].second);
            if(mdist < m) {
                move = j + 1;
                m = mdist;
            }
        }
        cout << move << endl;
    }
	return 0;
}

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

int main(){
    random_device rd;
    mt19937_64 mt(rd());

    string s, t;
    cin >> s >> t;
    vector<ll>S(256, 0), T(256, 0);
    for(ll i = 0; i < s.size(); i++){
        ll hash = mt();
        S[s[i]] ^= hash;
        T[t[i]] ^= hash;
    }
    sort(S.begin(), S.end());
    sort(T.begin(), T.end());
    ll flg = 1;
    for(ll i = 0; i < 256; i++){
        if(S[i] != T[i])flg = 0;
    }
    cout << (flg ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

vector<vector<ll>> C(100,vector<ll>(100,1));
void comb_init(){
  for(int i = 2;i <= 60;i++){
    for(int j = 1;j < i;j++){
      C[i][j] = C[i-1][j-1]+C[i-1][j];
    }
  }
}

int main(){
  
  cout << fixed << setprecision(20);
  comb_init();
  int n,a,b;
  cin >> n >> a >> b;
  vector<pair<ll,int>> v;
  ll res = 0;
  {
    vector<ll> g(n);
    rep(i,n)cin >> g[i];
    sort(ALL(g),greater<ll>());
    v.push_back(make_pair(g[0],1));
    for(int i = 1;i < n;i++){
      if(v.back().first == g[i])v.back().second++;
      else v.push_back(make_pair(g[i],1));
    }
  }
  vector<P> g(100);
  vector<ll> k(100,0);
  for(int i = a;i <= b;i++){
    ll sum = 0;
    int rest = i;
    rep(j,100){
      if(rest <= 0)break;
      if(rest > v[j].second)sum += v[j].first*v[j].second,rest -= v[j].second;
      else sum += v[j].first*rest,g[i] = make_pair(v[j].second,rest),rest = 0;
    }
    k[i] = sum;
  }
  int mx = a;
  for(int i = a;i <= b;i++)if(mx*k[i] > i*k[mx])mx = i;
  cout << 1.0*k[mx]/mx << endl;
  vector<int> pos;
  pos.push_back(mx);
  for(int i = a;i <= b;i++)if(mx != i && mx*k[i] == i*k[mx])pos.push_back(i);
  for(int au : pos)res += C[g[au].first][g[au].second];
  cout << res << endl;

  

  return 0;
}

Measured memory_bytes: 3776
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

void solve(long long N, long long A, long long B, long long C, long long D,
           long long E) {
  long long x = min({A, B, C, D, E});
  long long r = N % x;
  long long d = N / x;
  if (r > 0) {
    d += 1;
  }
  cout << 5 + d - 1 << endl;
}

int main() {
  long long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  solve(N, A, B, C, D, E);
  return 0;
}


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

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

  int n;
  cin >> n;

  if (n < 1000) {
    cout << "ABC" << endl;
  } else {
    cout << "ABD" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import sys

n=int(input())
A=list(map(int,input().split()))
now=1
s=sum(A)
ans=1
if n==0:
    if A[0]!=1:
        print(-1)
    else:
        print(1)
    sys.exit()
if A[0]!=0:
    print(-1)
    sys.exit()
for i in range(1,n+1):
    if A[i]>2*now:
        print(-1)
        sys.exit()
    if s>=2*now:
        ans+=2*now
        now=2*now-A[i]

    else:
        ans+=s
        now=s-A[i]
    s-=A[i]
print(ans)    


Measured memory_bytes: 20060
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d%d",&A,&B);

    if(A==1 && B==2 || A==2  && B==1)
    {
        printf("3");
    }
    else if(A==1 && B== 3 || A==3 && B==1)
    {
        printf("2");
    }
    else if(A==2 && B== 3 || A==3 && B==2)
    {
        printf("1");
    }
}


Measured memory_bytes: 128
n = gets.to_i
h = gets.split(" ").map(&:to_i)
cnt = 1

(n-1).times do |x|
  ok = 0
  (x+1).times do |y|
    ok +=1 if h[y] <= h[x+1]
  end
  cnt += 1 if ok == (x+1)
end

p cnt
    

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <map>
#include <cmath>
typedef long long int ll;
using namespace std; 
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll n,k;cin>>n>>k;
	ll arr[n];
	for(int i=0;i<n;i++){
		ll h;cin>>h;
		arr[i] = h;
	}
	sort(arr,arr+n);ll sum=0;
	for(int i=0;i<n-k;i++){
		sum += arr[i];
	}
	cout<<sum<<endl;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  string result;
  if (a == 5 && b == 5 && c == 7) {
    result = "YES";
  } else if (a == 5 && b == 7 && c == 5) {
    result = "YES";
  } else if (a == 7 && b == 5 && c == 5) {
    result = "YES";
  } else {
    result = "NO";
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define  inf 1e18
using namespace std;
inline void max_self(long long &a, long long b){
	a = max(a,b);
}
inline void min_self(long long &a, long long b){
	a = min(a,b);
}

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, w;
	cin>>n>>w;
	vector<int> wt(n),val(n);
	for (int i=0; i<n;i++)cin>>wt[i]>>val[i];
	
	int sum_value = 0;
	for(int x: val)
		sum_value += x;
	
	vector<long long> dp(sum_value+1, inf);
		dp[0]=0;
	    for(int item = 0; item < n; ++item) {
        	for(int value_already = sum_value - val[item]; value_already >= 0; --value_already) {
        		//~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            	min_self(dp[value_already+val[item]], dp[value_already] + wt[item]);
        }
    }

	int ans = 0;
	for (int i=0; i<=sum_value; i++)
		if(w >= dp[i])
			ans = i;
	cout<<ans;
	return 0;
};


Measured memory_bytes: 3960
mymin :: Int -> Int -> Int
mymin =  \r l -> if r<l then r else l

main :: IO ()
main = do
    input <- getContents --ここ間違ってた
    let [a, b, c, d, e, f] = map read $ words input
    putStrLn $ show $ a + b + c + d + e + f - (mymin (mymin a b) (mymin c d)) - (mymin e f)


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

    a1 = math.pi / 6 * (H + M / 60)
    a2 = math.pi * M / 30
    diff_a = a1 - a2

    ans = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(diff_a))
    print(ans)

main()

Measured memory_bytes: 9436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,K;
  cin >> N >> K;
  
  vector<int> h(N);
  for(int i=0; i<N; i++){
    cin >> h.at(i);
  }
  
  int t=0;
  for(int i=0; i<N; i++){
    
    if(h.at(i)>=K){
      t++;
    }
  }
  
  cout << t << endl;
  
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>
#include <queue>
#include <set>
using namespace std;

typedef long long ll;

#define INF 100000000;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define eps 1.0e-14;
#define mod 1e9 + 7;

int main(){
	int x,n; cin >> x >> n;
	vector<int> d(102);
	rep(i,n){
		int p;
		cin >> p;
		d[p] = 1;
	}
	pair<int,int> ans(1000000,-1);
	for (int i = 0; i <= 101; i++){
		if (d[i] == 1) continue;
		int dif = abs(x - i);
		ans = min(ans,pair<int,int>(dif,i));
	}
	cout << ans.second << endl;
	return 0;
}


Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
n=int(input())
TXY=[[0,0,0]]+[list(map(int,input().split())) for _ in range(n)]

for i in range(1,n+1):
  dift=abs(TXY[i][0]-TXY[i-1][0])
  difx=abs(TXY[i][1]-TXY[i-1][1])
  dify=abs(TXY[i][2]-TXY[i-1][2])
  if (dift-(difx-dify))%2!=0 or dift<(difx+dify):
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 28108
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int x;
  cin >> n >> x;
  int a[n];
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i] = abs(x - a[i]);
  }
  int ans = a[0];
  for(int i = 1; i < n; ++i) {
    ans = __gcd(ans, a[i]);
    //cout << ans << " " << a[i] << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1000;

int H, W;

ll dp[MAX_N + 1][MAX_N + 1];
bool wall[MAX_N + 1][MAX_N + 1];

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

    cin >> H >> W;

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            char c;
            cin >> c;
            if (c == '.') {
                wall[i][j] = true;
            }
        }
    }
    dp[0][1] = 1;

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (wall[i][j]) {
                dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % MOD;
            }
        }
    }

    cout << dp[H][W] << "\n";

    return 0;
}

Measured memory_bytes: 12424
n=int(input())
s=[]
for i in range(n):
    s.append(input())
march =[0,0,0,0,0]

for s_ in s:
    if   s_[0] == 'M':
        march[0]+=1
    elif s_[0] == 'A':
        march[1]+=1
    elif s_[0] == 'R':
        march[2]+=1
    elif s_[0] == 'C':
        march[3]+=1
    elif s_[0] == 'H':
        march[4]+=1
#print(march)
while 0 in march:
    march.remove(0)
#print(march)

rsl=0
cnt1=0
for c1 in march:
    cnt2=cnt1+1
    for c2 in march[cnt1+1:]:
        for c3 in march[cnt2+1:]:
            rsl+=c1*c2*c3
#            print(c1,c2,c3,':',rsl)
        cnt2+=1
    cnt1+=1

print(rsl)


Measured memory_bytes: 9772
A,B,K = map(int,input().split())
if A+K-1>=B-K+1:
    while A<=B:
        print(A)
        A+=1
else:
    i=0
    while i<=K-1:
        print(A+i)
        i+=1
    while B-K+1<=B:
        print(B-K+1)
        K-=1


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

int main() {
    long long L, R;
    cin >> L >> R;

    if (R - L >= 2019) {
        cout << 0 << endl;
        return 0;
    }

    int res = 2019;
    for (long long i = L; i <= R; i++) {
        for (long long j = i + 1; j <= R; j++) {
            res = min(res, (int)((i * j) % 2019));
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>
#include <random>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFR INT_MAX
#define INFL (long long)(4e18)
#define INFLR LLONG_MAX
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

// デバッグ用変数ダンプ関数
void dump() {
	cout << endl;
}
template <class Head, class... Tail>
void dump(Head&& head, Tail&&... tail)
{
	cout << head << ", ";
	dump(std::move(tail)...);
}

string YN(bool y) { return (y ? "YES" : "NO"); }
string yn(bool y) { return (y ? "Yes" : "No"); }
string ON(bool y) { return (y ? "OK" : "NG"); }

int dir4[4][2] = { { 0,-1 },{ -1,0 },{ 1,0 },{ 0,1 } };
int dir8[8][2] = { { -1,-1 },{ 0,-1 },{ 1,-1 },{ -1,0 },{ 1,0 },{ -1,1 },{ 0,1 },{ 1,1 } };

// [a,b]の乱数
int irand(int a, int b) {
	static mt19937 Rand(static_cast<unsigned int>(time(nullptr)));
	uniform_int_distribution<int> dist(a, b);
	return dist(Rand);
}

// [a,b)の乱数
double drand(int a, int b) {
	static mt19937 Rand(static_cast<unsigned int>(time(nullptr)));
	uniform_real_distribution<double> dist(a, b);
	return dist(Rand);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}
//=======ここまでテンプレート===============================================



int main(void) {
	ll a, b;
	cin >> a >> b;
	ll n = a;
	int ans = 0;
	while (n <= b) {
		ans++;
		n *= 2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        s: String
    }
    let mut out = s;
    while let Some(i) = out.find("B") {
        out.remove(i);
        if let Some(si) = i.checked_sub(1) {
            out.remove(si);
        }
    }
    println!("{}", out);
}


Measured memory_bytes: 2116
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s =scan.next();
		scan.close();
		char c[]=s.toCharArray();
		char sc[]=new char[2];
		int cnt[]= {1,0};
		sc[0]=c[0];
		int suffix=0;
		for(int i=1;i<c.length;i++) {
			if(c[i]==sc[0]) {
				cnt[0]++;
			}else {
				if(suffix==0) {
					sc[1]=c[i];
					cnt[1]++;
					suffix=1;
				}else {
					if(c[i]==sc[1])cnt[1]++;
				}
			}
		}
		if(cnt[0]==2&&cnt[1]==2)System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
  string s;
  cin >> s;
  cout << (s <= "2019/04/30" ? "Heisei" : "TBD") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int n,a[111];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	int ans=1145141919;
	for(int i=1;i<n;i++){
		int A=0,B=0;
		rep(j,i)A+=a[j];
		for(int j=i;j<n;j++)B+=a[j];
		ans=min(ans,abs(A-B));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
def c_kth_substring(S, K):
    tmp = []
    for i in range(len(S)):
        for j in range(i + 1, i + K + 1):
            if j <= len(S)+1:
                tmp.append(S[i:j])
    tmp = sorted(set(tmp))
    ans = tmp[K - 1]
    return ans

S = input().strip()
K = int(input())
print(c_kth_substring(S, K))

Measured memory_bytes: 5068
N = int(input())
W = list(map(int, input().split()))
S = float('inf')
all = sum(W)
for i in range (1,N+1):
  A = sum(W[0:i])
  s_t = abs(all - 2*A)
  if s_t < S:
    S = s_t
print(S)

Measured memory_bytes: 3060
N = int(input())
MOD = 10**9+7
memo = [{} for _ in range(N+1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1],t[i] = t[i],t[i-1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True

def dfs(cur,last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'AGCT':
        if ok(last3+c):
            ret = (ret + dfs(cur+1,last3[1:]+c)) % MOD
    memo[cur][last3] = ret
    return ret

print(dfs(0,'TTT'))

Measured memory_bytes: 3848
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << a * h + (b - a) * h * 0.5 << endl;
  return 0;
}


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

using namespace std;

int main(){
	int ans = 0;
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++){
		if (S[i] != S[S.size() - 1 - i]) ans++;
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict as dd

n = int(input())
_s = list(map(ord, list(input())))
s,t = _s[:n], _s[:n-1:-1]
d = dict()
mod = 10**9 + 9

def get(st):
  for bit in range(1<<n):
    u = v = 0
    for j,e in enumerate(st):
      if bit & (1<<j):
        u = (u*100 + e)%mod
      else:
        v = (v*100 + e)%mod
    yield (u,v)

ans = 0
d = dd(int)
for x in get(s): d[x] += 1
for x in get(t): ans += d[x]
print(ans)

Measured memory_bytes: 94552
fun main(args: Array<String>) {
    val n = readLine()!!.toInt() - 1
    if (n == 0) {
        println(0)
        return
    }

    val cs = LongArray(n)
    val ss = LongArray(n)
    val fs = LongArray(n)
    (0 until n).forEach { i ->
        val (ci, si, fi) = readLine()!!.split(" ").map { it.toLong() }
        cs[i] = ci
        ss[i] = si
        fs[i] = fi
    }

    (0 until n).forEach {
        var t: Long = 0
        (it until n).forEach { i ->
            t = maxOf(t, ss[i])

            val rem = t % fs[i]
            if (rem != 0L) t += fs[i] - rem
            
            t += cs[i]
        }
        println(t)
    }
    println(0)
}

fun maxOf(a: Long, b: Long) = if (a > b) a else b

Measured memory_bytes: 38844
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> A(5, 0);
    rep(i, N) {
        string S;
        cin >> S;
        if (S[0] == 'M') ++A[0];
        if (S[0] == 'A') ++A[1];
        if (S[0] == 'R') ++A[2];
        if (S[0] == 'C') ++A[3];
        if (S[0] == 'H') ++A[4];
    }
    
    long long ans = 0;
    rep(i, 5) for(int j = i + 1; j < 5; ++j) for(int k = j + 1; k < 5; ++k) ans += A[i] * A[j] * A[k];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

//Ruins
public class Main{

	class R{
		int a, b;
		public R(int a, int b) {
			this.a = a; this.b = b;
		}
	}

	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		List<R>[] l = new List[10001];
		for(int i=1;i<=10000;i++)l[i] = new ArrayList<R>();
		for(int i=1;i<=10000;i++)for(int j=1;j*j<=i;j++){
			if(i%j==0)l[i].add(new R(j, i/j));
		}
		for(;;){
			int a = sc.nextInt(), b = sc.nextInt();
			if((a|b)==0)break;
			int min = 1<<29;
			int[] t = new int[4];
			for(R p:l[a])for(R q:l[b]){
				t[0]=p.a; t[1]=p.b; t[2]=q.a; t[3]=q.b;
				Arrays.sort(t);
				min = Math.min(min, (t[1]-t[0])*(t[1]-t[0])+(t[2]-t[1])*(t[2]-t[1])+(t[3]-t[2])*(t[3]-t[2]));
			}
			System.out.println(min);
		}
	}

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

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

int main(){
  set<int> S;
  int N; 
  cin >> N;
  for(int i=0; i<N; i++){
    int x=0;
    cin >> x;
    S.insert(x);
  }
  cout << S.size() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) x.begin(), x.end()
#define PI 3.141592653589793

int main() {
    int N;
    cin >> N;
    vector<ll> A;
    ll sum = 0;
    ll i = 0;
    while (true) {
        sum += i;
        A.push_back(i);
        if (sum >= N)
            break;
        i++;
    }

    ll diff = sum - N;
    for (auto p : A) {
        if (p == 0 || p == diff)
            continue;
        cout << p << endl;
    }
}

Measured memory_bytes: 384
#include<stdio.h>
int f[5][5],i,j,a,y,x,p;
int main()
{
	for(;i<9;++i){
		char s[6];
		scanf("%s",s);
		for(j=0;j<4+i%2;++j){
			a=s[j]-48;
			f[i/2][j]|=a<<(1+i%2);
			f[i/2+i%2][j+!(i%2)]|=a<<3-i%2*3;
		}
	}
	do{
		while(!((f[y][x]>>(p=(p+1)%4))&1));
		putchar("URDL"[p]);
		x+=p?2-p:0;
		y+=p==3?0:p-1;
		p=(p+2)%4;
	}while(y!=0||x!=0||f[0][0]==6&&p==3);
	return !puts(""); 
}

Measured memory_bytes: 0
#include <stdio.h>

int main (){
	
	long long int a; 
	long long int ans = 1;
	scanf ("%lld", &a);
	long long arr[a + 10];
	long long int batas = 1e18;
	for (long long int i = 0 ; i < a ; i++){
		scanf ("%lld", &arr[i]);
	}
	
	for (long long int i = 0 ; i < a ; i++){
		if (arr[i] == 0){
			printf ("0\n");
			return 0;
		}
	}
	
	for (long long int i = 0 ; i < a ; i++){
		if (batas/ans < arr[i]){
			printf ("-1\n");
			return 0;
		}
		ans *= arr[i];
	}
	printf ("%lld\n", ans);
	
	
	return 0;
}

Measured memory_bytes: 2436
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P  pair<int,int>
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

const int mod = 1000000007;
class mint {
  long long x;
  public:
  mint(long long x=0) : x((x%mod+mod)%mod) {}
  mint operator-() const {
    return mint(-x);
  }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const  mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint& a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint& a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint& a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint& a) const {
    mint res(*this);
    return res/=a;
  }
 
  friend ostream& operator<<(ostream& os, const mint& m){
    os << m.x;
    return os;
  }
};
 
struct combination{
  vector<mint> fact,ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1;i <= n;i++) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1;i--) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n,int k){
    if(k < 0 || n < k) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

signed main(){
  int n,k;
  cin >> n >> k;
  vint A(n);
  rep(i,0,n) cin >> A[i];
  sort(A.begin(),A.end());
  combination comb(n+10);
  mint ans;
  rep(re,0,2){
    rep(i,k-1,n){
      if(re){
        ans -= (mint)A[i]*comb(i,k-1);
      }
      else{
        ans += (mint)A[i]*comb(i,k-1);
      }
      //cout << ans << endl;
    }
    reverse(A.begin(),A.end());
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)(j);i <= (int)(k);i ++)
#define debug(x) cerr<<#x<<":"<<(x)<<endl
#define fix cout<<fixed<<setprecision(20);
#define int long long
const int maxn=(int)1e6+5;
int a[maxn],b[maxn],idx[maxn];
bool cmp(int i,int j){//逻辑较复杂
    if(b[i]==a[i] and a[j]==b[j]){
        return a[i]<b[j];
    }
    if(b[i]==a[i])return b[j]-a[j]<0;
    if(b[j]==a[j])return b[i]-a[i]>0;
    if((b[i]-a[i])*(b[j]-a[j])<0){
        return b[i]-a[i]>0;
    }
    if(b[i]-a[i]>0){
        return a[i]<a[j];
    }
    return b[i]>b[j];
}
string ss[maxn];

signed main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    rep(i,1,n){
        string s;cin>>s;
        int now=0;
        int mx=0,mn=0;
        for(auto c:s){
            if(c==')')now++;else now--;
            mx=max(mx,now);
        }
        reverse(s.begin(),s.end());
        now=0;
        for(auto c:s){
            if(c=='(')now++;else now--;
            mn=max(mn,now);
        }
        a[i]=mx,b[i]=mn;
        reverse(s.begin(),s.end());
        ss[i]=s;
    }
    rep(i,1,n)idx[i]=i;
    sort(idx+1,idx+1+n,cmp);
    int now=0;
    int flag=1;
    rep(i,1,n){
        int j=idx[i];
        //debug(j);
        //debug(a[j]),debug(b[j]);
        for(auto c:ss[j]){
            if(c=='(')now++;else now--;
            if(now<0)flag=0;
        }
        //debug(now);
    }
    if(now!=0)flag=0;
    cout<<(flag?"Yes":"No")<<endl;
}
/* 
4
)))((
)))(
))(((
)(((

需要查询区间最大值的位置，单点删除

换种思路，
1.删除多余的，必定剩下 ))(((， 否则在后缀的)会被消掉
2。 前面放（多的，
3.前面）越少越前面，后面（越少越后面
 */

Measured memory_bytes: 58256
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
P = rl()
Q = rl()

import itertools
a, b = 0, 0
for i, p in enumerate(itertools.permutations(list(range(1,N+1)))):
    if a > 0 and b > 0: break
    if list(p) == P:
        a = i+1
    if list(p) == Q:
        b = i+1
print(abs(a-b))


Measured memory_bytes: 40432
#include <iostream>
#include <cstdlib>
using namespace std;
int Minimum(int a,int b)
{
    return a<b?a:b;
}
int FindMin(int n,int arr[])
{
    int min[n];
    min[n-1]=0;
    min[n-2]=abs(arr[n-1]-arr[n-2]);
    for(int i=n-3;i>=0;i--)
    {
        min[i]=Minimum(min[i+1]+abs(arr[i]-arr[i+1]),min[i+2]+abs(arr[i]-arr[i+2]));
    }
    return min[0];
}
int main()
{
    int n;
    cin>>n;
    int arr[n];
    {
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
        }
    }
    int ans;
    ans=FindMin(n,arr);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

//復習
//覚えていることもあり方針を思いつけたが、以下は覚えておきたい。
// 1. 余りは各桁（10^n倍することに注意）の余りの和で表せる。
//
public class Main {
	static int mod = (int) 1e9 + 7;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		String S = fs.next();
		int len = S.length();
		
		long dp[][] = new long[len+1][13];
		dp[len][0] = 1;
		int mul = 1;
		for(int i=len-1;i>=0;i--) {
			char nowC = S.charAt(i);
			if(nowC != '?') {
				int now = nowC - '0';
				now *= mul;
				for(int j=0;j<13;j++) {
					int next = (j + now )% 13;
					dp[i][next] += dp[i+1][j];
					dp[i][next] %= mod;
				}
			}else {
				for(int k = 0;k<=9;k++ ) {
					int now = k*mul;
					for(int j=0;j<13;j++) {
						int next = (j + now )% 13;
						dp[i][next] += dp[i+1][j];
						dp[i][next] %= mod;
					}
				}
			}
			mul *= 10;
			mul %= 13;
		}
		System.out.println(dp[0][5]);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

#define int 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; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
    int a,b,n; cin >> a >> b >> n;
    int max=0;
    /*
    for(int i=n; i>=n-b&&i>0; i--){
        if(max<floor(a*i/b)-a*floor(i/b)){
            max=floor(a*i/b)-a*floor(i/b);
        }
    }
    */
    int x=min(n,b-1);
    cout<<floor(a*x/b)-a*floor(x/b)<<endl;
    //cout<<max<<endl;
}

Measured memory_bytes: 3772
#include <stdio.h>

int main (void) {
  int N, V[20], C[20], i, ans;
  int X = 0;
  int Y = 0;
  
  scanf ("%d", &N);
  for (i = 0; i < N; i++) {
    scanf ("%d", &V[i]);
  }
  for (i = 0; i < N; i++) {
    scanf ("%d", &C[i]);
  }

  for (i = 0; i < N; i++) {
    if (V[i] > C[i]) {
      X = X + V[i];
      Y = Y + C[i];
    }
  }

  ans = X - Y;

  printf ("%d", ans);

}

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

int main(){
    char c[6];
    for(int i=0;i<6;i++){
        cin>>c[i];
    }
    int num=0;
    if(c[2]==c[3]){
        num++;
        //cout<<"同じ";
    }
    if(c[4]==c[5]){
        num++;
        //cout<<"同じ";
    }

    if(num==2){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int s;
  cin >> s;
  int count = 1;
  while(s>4 || s==3){
    if(s%2==0){
      s = s/2;
  } else {
    s = 3*s+1;
  }
  count++;
  }
  cout << count + 3 << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

fail = False
result = {}

for i in range(0, m):
    s, c = map(int, input().split())
    key = n-s
    if key in result and result[key] != c:
        fail = True
        break
    result[key] = c

if n > 1:
    if n-1 in result and result[n-1] == 0:
       fail = True
    if not(n-1 in result):
        result[n-1] = 1

if fail:
    print(-1)
else:
    res = 0
    for i in range(0, n):
        if i in result:
            res += 10 ** i * result[i]
    print(res)


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

using namespace std;

typedef long long ll;

#define FOR(_i, _a, _b) for (int _i=_a; i<_b; ++_i)

const int INF = 1e9+7;

int main()
{
    int n;
    cin >> n;
    vector <vector <ll>> a(n+1, vector <ll> (3));
    vector <vector <ll>> dp(n+1, vector <ll> (3, 0));

    FOR (i, 1, n+1)
        cin >> a[i][0] >> a[i][1] >> a[i][2];

    FOR (i, 1, n+1)
    {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + a[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + a[i][2];
    }

    cout << max(dp[n][2], max(dp[n][0], dp[n][1]));
    return 0;
}


Measured memory_bytes: 11136
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
ll fang(ll a){
  return a > 1 ? fang(a - 1) + a : 1;
}
int v[10000][1000];
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  cin >> n;
  int tmp;
  int ans = 0;
  rep(i,n){
    cin >> tmp;
    while(tmp % 2 == 0){
      tmp /= 2;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int main(){
    int n, k; cin >> n >> k;
    lint ans = 0;
    For(r, k, n){
        int t = (n-r) / (r+1);
        rep(q, t+1){
            if(q == 0 && r != 0) ans += n - r;
            else if(q != 0) ans += (n-r) / q - r;
        }
    }
    cout << ans << endl;
}

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

void Input(int *X, int *Y, int n)
{
	for (int i = 0; i < n; i++) {
		cin >> X[i];
	}

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

//ミンコフスキー距離
double Minkowski(int *X, int *Y, int n, int p)
{
	double total = 0;

	for (int i = 0; i < n; i++) {
		total += pow(abs(X[i] - Y[i]), p);
	}
	
	total = pow(total, (double)1 / p);

	return total;
}

//チェビチェフ距離
double ChebyshevDistance(int *X, int *Y, int n)
{
	double max = 0;

	for (int i = 0; i < n; i++) {
		if (max < abs(X[i] - Y[i])) {
			max = abs(X[i] - Y[i]);
		}
	}

	return max;
}

int main()
{
	int n, X[100], Y[100];
	cin >> n;

	Input(X, Y, n);

	for (int i = 1; i <= 3; i++) {
		cout << fixed <<setprecision(6) << Minkowski(X, Y, n, i) << endl;
	}

	cout << fixed << setprecision(6) << ChebyshevDistance(X, Y, n) << endl;

	return 0;
}


Measured memory_bytes: 3440
N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
x=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

for i in range(0,N-K+1):
    length=0
    d_flag=0 #負が遠ければ-1、正なら1
    if x[i+K-1]>0 and x[i]<0: 
        if x[i+K-1] > x[i]*(-1):
            d_flag=1
        else:
            d_flag=-1
    
    if d_flag==-1:
        length=abs(x[i+K-1])*2+abs(x[i])
    elif d_flag==1:
        length=abs(x[i+K-1])+abs(x[i])*2
    else:
        if abs(x[i+K-1])>abs(x[i]):
            length=abs(x[i+K-1])
        else:
            length=abs(x[i])
    if i==0:
        len_min=length
    elif length<len_min:
        len_min=length
        
print(len_min)

Measured memory_bytes: 14480
#include<stdio.h>
int main()
{
	int x,y,z,X,Y,Z;
	scanf("%d %d %d",&x,&y,&z);
	X=x;Y=y;Z=z;
	x=Z;
	y=X;
	z=Y;
	printf("%d %d %d",x,y,z);
 } 

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
using namespace std;
struct word{
	int len;
	int num;
	char w[32];
};
int main(){
	word vo[1000];
	char vol[32];
	int k = 0,max[2]={0,0};
	while(cin>>vol){
		int i;
		for(i=0; i<k; i++){
			if(strcmp(vo[i].w,vol) == 0){
				vo[i].num++;
				break;
			}
		}
		if(i == k){
			strcpy(vo[k].w,vol);
			vo[k].num = 1;
			vo[k].len = strlen(vo[k].w);
			k++;
		}
	}
	for(int i=1; i<k; i++){
		if(vo[max[0]].len<vo[i].len){max[0] = i;}
		if(vo[max[1]].num<vo[i].num){max[1] = i;}
	}
	cout <<vo[max[1]].w<<" "<<vo[max[0]].w<<endl;
	return 0;
}

Measured memory_bytes: 0
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	s, t = reverse(s), reverse(t)

	ti := 0
	ng := true
	for i := 0; i < len(s); i++ {
		if s[i] == '?' || s[i] == t[0] {
			ok := true
			for j := 0; j < len(t); j++ {
				if len(s)-1 < i+j {
					ok = false
					break
				}
				if s[i+j] == '?' {
					continue
				}

				if s[i+j] != t[j] {
					ok = false
				}
			}
			if ok {
				ti = i
				ng = false
				break
			}
		}
	}

	if ng {
		fmt.Println("UNRESTORABLE")
		return
	}

	ans := ""
	for i := 0; i < len(s); i++ {
		if i == ti {
			for j := 0; j < len(t); j++ {
				ans += string(t[j])
			}
			i += len(t) - 1
		} else {
			if s[i] == '?' {
				ans += "a"
			} else {
				ans += string(s[i])
			}
		}
	}

	fmt.Println(reverse(ans))
}

func reverse(s string) string {
	t := ""
	for _, c := range s {
		t = string(c) + t
	}
	return t
}


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

#define ONE(vt) { \
	long long one = 0; \
	sort( vt.rbegin(), vt.rend() ); \
	for( int i = 0; i < m; i++ ) { \
		one += vt[i]; \
	} \
	if( tt < one ) tt = one; }


int main()
{
	long long tt = -(1LL << 62);

	// 111 110 101 100 011 010 001 000 
	vector<long long> t1;
	vector<long long> t2;
	vector<long long> t3;
	vector<long long> t4;
	vector<long long> t5;
	vector<long long> t6;
	vector<long long> t7;
	vector<long long> t8;
	
	int n,m;
	cin >> n >> m;
	long long x, y, z;
	for( int i = 0; i < n; i++ ) {
		cin >> x >> y >> z;
		t1.push_back( x+y+z );
		t2.push_back( x+y-z );
		t3.push_back( x-y+z );
		t4.push_back( x-y-z );
		t5.push_back( -x+y+z );
		t6.push_back( -x+y-z );
		t7.push_back( -x-y+z );
		t8.push_back( -x-y-z );
	}
	ONE(t1)
	ONE(t2)
	ONE(t3)
	ONE(t4)
	ONE(t5)
	ONE(t6)
	ONE(t7)
	ONE(t8)
	
	cout << tt << endl;
}


Measured memory_bytes: 384
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
macro_rules! chmax {
    ($ base : expr ,$ cmp : expr ) => {
        $base = max($base, $cmp);
    };
}
fn main() {
    input! {
       mut n:Chars,
    }
    let mut dp = vec![vec![-INF; 2]; 20];
    dp[0][1] = 0;
    pub fn charconv(c: char, base: char) -> i64 {
        return (c as u8 - base as u8) as i64;
    }

    for (i, &c) in n.iter().enumerate() {
        chmax!(dp[i + 1][1], dp[i][1] + charconv(c, '0'));
        chmax!(dp[i + 1][0], dp[i][0] + 9);
        chmax!(dp[i + 1][0], dp[i][1] + charconv(c, '0') - 1);
    }
    let mut ans = 0;
    let ln = n.len();
    chmax!(ans, dp[ln][0]);
    chmax!(ans, dp[ln][1]);
    println!("{}", ans);
}
const INF: i64 = 1 << 60;


Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
int a, b;

int main()
{
    scanf("%d%d",&a,&b);
    if(a<=0 && b>=0) puts("Zero");
    else if(a>0) puts("Positive");
    else if((a-b)%2==0) puts("Negative");
    else puts("Positive");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvll vector<vll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define pii pair<int, int>
#define vpli vector<pair<long long, int>>
#define deb(x) cout << "deb " << #x << " " << x << endl
#define all(x) x.begin(), x.end()
#define endl "\n"

void solve()
{
    int base = 7;
    int k;
    cin>>k;
    int mul = 10%k,cnt=1;
    int val = base%k;
    vi values(k);
    bool notposs = 0;
    values[val] = 1;
    while(val!=0)
    {
        val  = (val + (base*mul)%k)%k;
        if(values[val] == 0)
        {
            values[val] = 1;
        }
        else
        {
            notposs =1;
            break;
        }
        
        cnt++;
        mul = (mul*10)%k;
    }
    if(notposs) cout<<"-1\n";
    else cout<<cnt<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //pre();
    int t = 1;
    //cin >> t;
    //cout<<__gcd(-5,0)<<endl;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 7132