akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  vector<vector<P>> evidences(n);
  rep(i, n) {
    int a;
    cin >> a;
    evidences[i].resize(a);
    rep(j, a){
      cin >> evidences[i][j].first >> evidences[i][j].second;
    }
  }

  int ans = 0;
  rep(i, 1 << n) {
    // 全ビット探索
    // 1 を 正直者とする
    bool ok = true;
    rep(j, n) {
      if (!(i >> j & 1)) {
        //printf("i: %d, skip: %d\n", i, j);
        // j は嘘つきと仮定して話を聞かない
        continue;
      }
      for(P p : evidences[j]) {
        if (i >> (p.first-1) & 1 ^ p.second) {
          //cout << "i: " << bitset<4>(i) << ", p.first: " << bitset<4>(p.first) << endl;
          ok = false;
          break;
        }
      }
    }
    if (ok) {
      int tmp = i;
      int count = 0;
      while(tmp!=0) {
        int r = tmp % 2;
        tmp = tmp / 2;
        if (r) count++;
      }
      ans = max(ans, count);
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

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

	double x[10];
	int u[10];
	string v;
	double sum = 0;

	for (int i = 0; i < n; i++) {
		cin >> x[i] >> v;
		if (v == "JPY") u[i] = 1;
		else u[i] = 380000;
		sum += x[i] * u[i];
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int[] x = new int[n];
        int[] y = new int[n];
        long[] h = new long[n];

        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            h[i] = sc.nextLong();
        }

        for (int cx = 0; cx <= 100; cx++) {
            for (int cy = 0; cy <= 100; cy++) {
                boolean flag = true;
                long hRel = 0;
                for (int i = 0; i < n; i++) {
                    if (h[i] > 0) {
                        hRel = h[i] + Math.abs(cx-x[i]) + Math.abs(cy-y[i]);
                    }
                }
                for (int i = 0; i < n; i++) {
                    long hTmp = Math.abs(cx-x[i]) + Math.abs(cy-y[i]);
                    if (0 <= hRel - hTmp) {
                        if (h[i] != hRel - hTmp) {
                            flag = false;
                            break;
                        }
                    } else {
                        if (h[i] != 0) {
                            flag = false;
                            break;
                        }
                    }
                }
                if (flag) {       
                    System.out.println(cx + " " + cy + " " + hRel);
                    return;
                }
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 24148
def main():
    direction = input()
    now = [0, 0]
    dir_count = {"N": 0, "E": 0, "S": 0, "W": 0}
    for d in direction:
        dir_count[d] += 1
        if d == "N":
            now[0] += 1
        elif d == "E":
            now[1] += 1
        elif d == "S":
            now[0] -= 1
        else:
            now[1] -= 1
    answer = False
    if ((now[1] < 0 and 0 < dir_count["E"]) or (0 < now[1] and 0 < dir_count["W"]) or now[1] == 0) and \
            ((now[0] < 0 and 0 < dir_count["N"]) or (0 < now[0] and 0 < dir_count["S"]) or now[0] == 0):
        answer = True
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()



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

#define MAXN (1010)
#define mod (1000000007)

int n;
std::vector<int> pri;
bool vis[MAXN];
int ans[MAXN];

void shai(){
	for(int i = 2; i < MAXN; ++ i){
		if(!vis[i]){
			vis[i] = true;
			pri.push_back(i);
		}
		for(int j = 0, sz = pri.size(); j < sz && pri[j] * i < MAXN; ++ j){
			vis[i * pri[j]] = true;
		}
	}
}

int main(){
	shai();
	scanf("%d", &n);
	int res = 1;
	for(int i = 0, sz = pri.size(); i < sz; ++ i){
		if(pri[i] > n) break;
		int k = n, alpha = 0;
		while(k){
			alpha += k / pri[i];
			k /= pri[i];
		}
		res = (1ll) * res * (alpha + 1) % mod;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
A,B=map(int, input().split())
cake_list=[0 for i in range(17)]
for i in range(1,17):
    if cake_list[i-1]!=1 and cake_list[i]==0 and cake_list.count(1)<A:
        cake_list[i]=1
    if cake_list[i-1]!=-1 and cake_list[i]==0 and cake_list.count(-1)<B:
        cake_list[i]=-1
if cake_list.count(1)==A and cake_list.count(-1)==B:
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3060
h, w = map(int, input().split())
s = [[' ' for i in range(w + 2)] for i in range(h + 2)]
for i in range(h):
    t = str(input())
    for j in range(w):
        s[i + 1][j + 1] = t[j]
# 周囲計算
for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == '#': continue
        cnt = 0
        for y in range(i-1, i+2):
            for x in range(j-1, j+2):
                if s[y][x] == '#': cnt += 1
        s[i][j] = str(cnt)
for i in range(h):
    for j in range(w):
        print(s[i+1][j+1], end="")
    print()


Measured memory_bytes: 3572
package main

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

var uft, rank, ch, ans []int

func find(x int) int {
	if uft[x] == x {
		return x
	}

	uft[x] = find(uft[x])
	return uft[x]
}

func union(a, b, i int) {
	ans[i-1] = ans[i]
	ar, br := find(a), find(b)
	if ar == br {
		return
	}

	ans[i-1] -= ch[ar] * ch[br]

	if rank[ar] < rank[br] {
		uft[ar] = br
		ch[br] += ch[ar]
		return
	} else if rank[ar] == rank[br] {
		rank[ar]++
	}
	uft[br] = ar
	ch[ar] += ch[br]
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, m)
	bs := make([]int, m)
	for i := 0; i < m; i++ {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		bs[i], _ = strconv.Atoi(sc.Text())
	}

	uft = make([]int, n+1)
	rank = make([]int, n+1)
	ch = make([]int, n+1)
	for i := range uft {
		uft[i] = i
		ch[i] = 1
	}

	ans = make([]int, m)
	ans[m-1] = n * (n - 1) / 2
	for i := m - 1; i >= 1; i-- {
		union(as[i], bs[i], i)
	}

	for _, v := range ans {
		fmt.Println(v)
	}
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
long long a[100000+10];
long long aa[100000+10];
int main()
{
	int n,k,q;
	cin>>n>>k>>q;
	for(int i=1;i<=n;i++)
	{
		a[i]=k;
	}
	for(int i=1;i<=q;i++)
	{
		int m;
		cin>>m;
		aa[m]++;
	}
	for(int i=1;i<=n;i++)
	{
		if((a[i]-q+aa[i])>0)
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
	}
}

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

// https://atcoder.jp/contests/abc136/tasks/abc136_a

int main(int argc, char *argv[]) {
    char buf[20];
    int a, b, c, ans;

    scanf("%d %d %d", &a, &b, &c);

    ans = c - (a - b);
    if (ans < 0) {
        ans = 0;
    }
    printf("%d\n", ans);

    return 0;
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> p(n);
  for (auto& v : p) cin >> v;
  vector<int> as(n, 0), bs(n, 500000000);
  for (int i = 0; i < n; i++)
    as[p[i] - 1] += i + 1;
  for (int i = 0; i < n; i++) {
    as[i] += 20001 * i;
    bs[i] -= 20001 * i;
  }
  cout << as[0];
  for (int i = 1; i < n; i++) {
    cout << ' ' << as[i];
  }
  cout << endl;
  cout << bs[0];
  for (int i = 1; i < n; i++) {
    cout << ' ' << bs[i];
  }
  cout << endl;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
char S[100002];
int L[100001],R[100001],V[100001];
int main(){
	int i,a,x;
	scanf("%s",&S),a=strlen(S),memset(L,63,sizeof L);
	for(int i=0;i<a;i++)if(S[i]=='L')L[i]=i;
		else R[i]=i;
	for(int i=1;i<a;i++)R[i]=max(R[i],R[i-1]);
	for(int i=a-1;i>=0;i--)L[i]=min(L[i],L[i+1]);
	for(int i=0;i<a;i++)if(S[i]=='L'){
		x=i-R[i];
		if(x&1)V[R[i]+1]++;
		else V[R[i]]++;
	} else {
		x=L[i]-i;
		if(x&1)V[L[i]-1]++;
		else V[L[i]]++;
	}
	for(int i=0;i<a;i++)printf("%d ",V[i]);
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 1000000007;


ll pow2(int n) {
	ll ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}

int main() {
	int n, p;

	cin >> n >> p;

	int odd = 0;
	int even = 0;

	rep (i, n) {
		int a;
		cin >> a;
		if (a & 1) {
			odd++;
		} else {
			even++;
		}
	}

	if (p == 1 && odd == 0) {
		cout << 0 << endl;
	} else if (p == 0 && odd == 0) {
		cout << pow2(n) << endl;
	} else {
		cout << pow2(n - 1) << endl;
	}



	return 0;
}


Measured memory_bytes: 1144
use std::cmp::min;
use std::collections::VecDeque;
use std::io::*;
use std::str::FromStr;

fn main() {
    let (h, w, k): (usize, usize, usize) = (read(), read(), read());
    let a: Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect()).collect();
    let mut s: (usize, usize) = (0, 0);
    for i in 0..h {
        for j in 0..w {
            if a[i][j] == 'S' {
                s = (i, j);
            }
        }
    }

    let mut que: VecDeque<(usize, usize)> = VecDeque::new();
    let inf: i64 = 1 << 62;
    let mut d: Vec<Vec<i64>> = vec![vec![inf; w]; h];
    que.push_back(s);
    d[s.0][s.1] = 0;
    let (dy, dx) = ([0, 0, 1, -1], [1, -1, 0, 0]);
    let mut ans = h * w;
    while !que.is_empty() {
        let (y, x) = que.pop_front().unwrap();
        ans = min(ans, min(min(x, w - x - 1), min(y, h - y - 1)));
        if d[y][x] == k as i64 {
            continue;
        }
        for i in 0..4 {
            let (ny, nx) = (y as i64 + dy[i], x as i64 + dx[i]);
            if nx < 0 || ny < 0 {
                continue;
            }
            let (ny, nx) = (ny as usize, nx as usize);
            if nx >= w || ny >= h || d[ny][nx] != inf || a[ny][nx] == '#' {
                continue;
            }
            d[ny][nx] = d[y][x] + 1;
            que.push_back((ny, nx));
        }
    }
    println!("{}", 1 + if ans % k == 0 { ans / k } else { ans / k + 1 });
}

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")
}


Measured memory_bytes: 12540
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;
const int MOD=1000000007;

int N,A;
int X[51];
int num[60];
int dp[51][2511];

int DP(int a,int b){
	if(dp[a][b]!=-1)return dp[a][b];
	if(a==N){
		if(b==0){
			return 1;
		}
		else{
			return 0;
		}
	}
	return dp[a][b]=DP(a+1,b)+DP(a+1,b+X[a]);
}

signed main(){
	cin>>N>>A;
	REP(i,N){
		cin>>X[i];
		X[i]-=A;
	}
	REP(i,51)REP(j,2511){
		dp[i][j]=-1;
	}
	int ans=DP(0,0);
	cout<<ans-1<<endl;
	return 0;
}


Measured memory_bytes: 1280
/*
 ____________________________________________________________
|                                                            |
|                   Author: ay2306                           |
|____________________________________________________________|

*/
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ord_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
const ll maxn = 1e5;

int main(){
    int a,b,t;
    cin >> a >> b >> t;
    cout << b*(t/a);
    return 0;
}

Measured memory_bytes: 256
include Math

loop {
    n, hx, hy, dx, dy = gets.split.map &:to_i
    break if n == 0

    points = [[hx, hy]] + (1..n).map { gets.split.map &:to_i }

    dist = (0..n).map{|i|
        (0..n).map{|j|
            x1, y1 = points[i]
            x2, y2 = points[j]
            sqrt((x1-x2)**2 + (y1-y2)**2)
        }
    }

    deadline = points.map{|x, y|
        sqrt((x - dx)**2 + (y - dy)**2)
    }

    stack = [[0, 0] + (1..n).to_a]
    success = false
    until stack.empty?
        t, i, *unreached = stack.pop
        if unreached == [] 
            success = true
            break
        end
        next if unreached.any?{|j| t + dist[i][j] >= deadline[j]}
        unreached.each{|j|
            stack << [t + dist[i][j], j, *(unreached - [j])]
        }
    end
    puts success ? 'YES' : 'NO'
}

Measured memory_bytes: 6524
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<pair<int,int>> r(n);
  rep(i,n)cin>>r[i].first>>r[i].second;
  vector<lint> x(n);
  vector<lint> y(n);
  rep(i,n){
    x[i]=r[i].first-r[i].second;
    y[i]=r[i].first+r[i].second;
  }
  lint res=0;
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  res=max(x[n-1]-x[0],y[n-1]-y[0]);
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 9596
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) REV(SORT(V)) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) for(int i = 0; i < (V).size(); i++) {cout << (V).at(i) << endl;}

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c=1,x=0,y,z;
double d,e,f;
string s,t;
bool flg = false;
//

signed main() {
  RAPID;
  IN(n);
  Vs vs(n);
  VIN(vs)
  REP(i,n){
    SORT((vs[i]));
  }
  SORT(vs);
  REP(i,n-1){
    if(vs[i] == vs[i+1]){
      c++;
      flg=true;
    } else {
      if(flg){
        if(c == 1){
          x++;
        } else {
          x += c*(c-1)/2; 
        }
        c = 1;
        flg = false;
      }
    }
  }
  if(flg){
    if(c == 1){
      x++;
    } else {
      x += c*(c-1)/2; 
    }
  }
  OUT(x);
}

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

int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  vector<int> count(N,0);
  for(int i=0;i<N;i++){
    if(a.at(i)%2==0){
      count.at(i)=1;
    }
    if(a.at(i)%4==0){
      count.at(i)=2;
    }
  }
  int zero=0,one=0,two=0;
  for(int i=0;i<N;i++){
    if(count.at(i)==0){
      zero++;
    }else if(count.at(i)==1){
      one++;
    }else{
      two++;
    }
  }
  if(zero>two+1){
    cout<<"No"<<endl;
  }else if(zero==two+1&&one>0){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#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 INF 2e9
#define IPSILON 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  string str;
  cin >> str;
  for(int i = 1;i < 4;i++){
    if(str[i-1] == str[i]){
      cout << "Bad";
      return 0;
    }
  }
  cout << "Good";
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N, X, T := sc.NextInt(), sc.NextInt(), sc.NextInt()

	fmt.Println((N + (X - 1)) / X * T)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1772
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=5005;
int n,A,B,p[N];long long dp[N][N];
int main(){
	scanf("%d%d%d",&n,&A,&B);
	for(int i=1;i<=n;++i)scanf("%d",&p[i]);
	memset(dp,63,sizeof(dp));
	for(int i=1;i<=n;++i){
		dp[i][i]=min(dp[i][i],1ll*(i-1)*A);
		for(int j=1;j<i;++j)
			if(p[j]<p[i]){
				dp[i][i]=min(dp[i][i],dp[i-1][j]);
				dp[i][j]=min(dp[i][j],dp[i-1][j]+A);
			}else{
				dp[i][j]=min(dp[i][j],dp[i-1][j]+B);
			}
	}
	long long ans=dp[0][0];
	for(int i=1;i<=n;++i)ans=min(ans,dp[n][i]);
	printf("%lld\n",ans);
	return 0;
}


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

typedef pair<double, double> P;
constexpr double EPS = 1e-9;

vector<P> points;

// 2つの円の交点
void circle_intersection(double x1, double y1, double r1, double x2, double y2, double r2){
    x2 -= x1; y2 -= y1;
    if(x2*x2+y2*y2>(r1+r2)*(r1+r2)) return;
    double a = x2*x2+y2*y2, b = (a+r1*r1-r2*r2)/2;
    points.push_back(P((b*x2+y2*pow(a*r1*r1-b*b,0.5))/a+x1, (b*y2-x2*pow(a*r1*r1-b*b,0.5))/a+y1));
    points.push_back(P((b*x2-y2*pow(a*r1*r1-b*b,0.5))/a+x1, (b*y2+x2*pow(a*r1*r1-b*b,0.5))/a+y1));
}

// 点(px,py)と円(cx,xy,r)の内包判定
bool is_inside_circle(double px, double py, double cx, double cy, double r){
    return pow(px-cx,2)+pow(py-cy,2) < r*r + EPS;
}

int main() {
    int n;
    double x[100], y[100];
    while(cin >> n, n){
        points.clear();
        for(int i=0;i<n;i++){
            scanf("%lf,%lf",&x[i],&y[i]);
        }
        // 2つの円の交点を列挙
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                circle_intersection(x[i],y[i],1,x[j],y[j],1);
            }
        }
        int ans = 1;
        // 各点を内包する円の個数を数える
        for(auto &p : points){
            int cnt = 0;
            for(int i=0;i<n;i++){
                if(is_inside_circle(p.first,p.second,x[i],y[i],1)) cnt++;
            }
            ans = max(ans, cnt);
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3360
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    double x1, x2, y1, y2;
    double distance;

    cin >> x1 >> y1 >> x2 >> y2;

    distance = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
    
    printf("% lf\n",sqrt(distance));

    return 0;
}


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

const int cost[]={0,2,5,5,4,5,6,3,7,6};
vector<int> A;
int N,M;
string dp[11000];

bool check(const string& a, const string& b)
{
	if(a=="-") return true;
	if(a.length()<b.length()) return true;
	if(a.length()==b.length()&&a<b) return true;
	return false;
}	

void solve()
{
	fill(dp, dp+N+10, "-");
	dp[0]="";
	for(int i=0;i<=N;++i){
		if(dp[i]=="-") continue;
		for(auto x : A){
			string b=dp[i]+(char)('0'+x);
			if(check(dp[i+cost[x]], b)){
				dp[i+cost[x]]=b;
			}
		}
	}
	cout << dp[N] << endl;
}

int main()
{
	cin >> N >> M;
	int x;
	for(int i=0;i<M;++i){
		cin >> x;
		A.push_back(x);
	}
	solve();
	return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n;
ll a[maxn], b[maxn];

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

    cin>>n;
    ll tota=0;
    ll totb=0;
    for (int i=0; i<n; i++) {
	cin>>a[i];
	tota+=a[i];
    }
    for (int i=0; i<n; i++) {
	cin>>b[i];
	totb+=b[i];
    }

    if (tota<totb) out(-1);

    priority_queue<ll> pq;
    vector<ll> todo;
    for (int i=0; i<n; i++) {
	if (a[i]-b[i]>0) {
	    pq.push(a[i]-b[i]);
	}
	if (b[i]-a[i]>0) {
	    todo.push_back(b[i]-a[i]);
	}
    }

    int used = todo.size();
    ll cur = 0;
    
    while (todo.size()) {
	if (cur==0) {
	    assert(pq.size());
	    cur = pq.top();
	    pq.pop();
	    used++;
	}
	ll tmp = min(todo.back(), cur);
	todo.back() -= tmp;
	cur -= tmp;
	if (todo.back()==0) {
	    todo.pop_back();
	}
    }

    cout<<used<<endl;    
    return 0;
}


Measured memory_bytes: 5848
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout<<(x)<<endl
typedef long long ll;
template<class T> inline void chmax(T& a, T b) {
  if (a < b) a = b;
}

template<class T> inline void chmin(T& a, T b) {
  if (a > b) a = b;
}

const long long INF = 1LL << 60;
int main() {
  ll x;
  cin >> x;
  ll sum = 100;
  int ans = 0;
  for (int i = 1; i <= 3760; ++i) {
    sum *= 1.01;
    if ( sum >= x) {
        ans = i;
        break;
    }
  }
  COUT(ans);
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int x, y;
  cin>>x>>y;
  REP(i, x+1){
    int j=x-i;
    if(j>=0 && i*2+j*4==y){
      cout<<"Yes"<<'\n';
      return 0;
    }
  }
  cout<<"No"<<'\n';
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int x,t;
    cin>>x;
    cout<<"ABC"<<x<<endl;
}

Measured memory_bytes: 256
import sys
from math import gcd
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    vec1 = list(accumulate(A, func=gcd))
    vec2 = list(accumulate(reversed(A), func=gcd))

    ans = 0
    for i in range(N):
        if i == 0:
            res = vec2[-2]
        elif i == N - 1:
            res = vec1[-2]
        else:
            res = gcd(vec1[i - 1], vec2[N - i - 2])

        if ans < res:
            ans = res

    print(ans)
    return


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
#define Sart(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])));
#define SartR(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])), std::greater<__typeof(a[0])>())

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

	ll n, m;

	cin >> n >> m;

	pair<ll, ll> p[n];
	ll cost = 0;

	ll i;

	rep(i, n) cin >> p[i].X >> p[i].Y;

	Sart(p);

	rep(i, n) {
        if (m <= p[i].Y) {
          cost += p[i].X * m;

          break;
        } else {
          cost += p[i].X * p[i].Y;
          m -= p[i].Y;
        }
	}

	Out(cost);
	
	return 0;
}


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

int N;
string s;

bool solve(bool a0, bool a1) {
  vector<bool> a(N);
  a[0] = a0;
  a[1] = a1;
  for (int i = 1; i < N - 1; i++) {
    a[i+1] = a[i-1] ^ (s[i] == 'x') ^ a[i];
  }
  for (int i = 0; i < N; i++) {
    if ((s[i] == 'o') ^ (a[(i-1+N) % N] == a[(i+1) % N]) ^ a[i]) {
      return false;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << (a[i] ? "W" : "S");
  }
  cout << endl;
  return true;
}

int main() {
  cin >> N >> s;
  if (solve(false, false)) {
    return 0;
  }
  if (solve(false, true)) {
    return 0;
  }
  if (solve(true, false)) {
    return 0;
  }
  if (solve(true, true)) {
    return 0;
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 512
class Box:
  def __init__(self, line):
    self.__b = {}
    for i in map(int, line.split(' ')):
      if i not in self.__b:
        self.__b[i] = 1
      else:
        self.__b[i] += 1

    self.__sum = 0
    for k, v in self.__b.items():
      self.__sum += k * v    

  def convert(self, b, c):
    if b in self.__b:
      if c in self.__b:
        self.__b[c] += self.__b[b]
      else:
        self.__b[c] = self.__b[b]

      self.__sum += (c - b) * self.__b[b]

      self.__b[b] = 0

  def sum(self):
    return self.__sum

if __name__ == "__main__":
  n = int(input())
  b = Box(input())
  q = int(input())
  for i in range(q):
    b.convert(*list(map(int, input().split(' '))))
    print(b.sum())

Measured memory_bytes: 22336
#include <stdio.h>
 
int main() {
  int n;
  scanf("%d",&n);
  int a[n],i,j;
  for(i=0; i<n; i++) scanf("%d",&a[i]);
 
  for(i=0; i<n; i++) {
    for(j=i-1; j>=0; j--) {
      if(a[j]>a[j+1]) {
    int tmp=a[j];
    a[j]=a[j+1];
    a[j+1]=tmp;
      } else break;
    }
    for(j=0; j<n; j++) {
      if(j) printf(" ");
      printf("%d",a[j]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2148
#include <algorithm>
#include <iostream>
#include <vector>

#include <string.h>

using namespace std;

typedef long long ll;

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

const int MAX_S = 100000;
char S[MAX_S + 1];

void solve(const int N) {
    vector<vector<int> > dp(N, vector<int>(33));
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') {
            dp[i][0] = i + 1;
        } else {
            dp[i][0] = i - 1;
        }
    }

    // cout << "1: " << endl;
    // for (int i = 0; i < N; i++) {
    //     cout << dp[i][1] << " ";
    // }
    // cout << endl;

    for (int i = 1; i <= 32; i++) {
        // cout << i << ": " << endl;
        for (int j = 0; j < N; j++) {
            dp[j][i] = dp[dp[j][i - 1]][i - 1];
            // cout << dp[j][i] << " ";
        }
        // cout << endl;
    }

    vector<int> last_positions(N, 0);
    for (int i = 0; i < N; i++) {
        last_positions[i] = i;
    }

    vector<int> as = {5, 7, 9, 10, 15, 16};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < (int) as.size(); j++) {
            last_positions[i] = dp[last_positions[i]][as[j]];
        }
    }

    vector<int> answer(N);
    for (int i = 0; i < N; i++) {
        answer[last_positions[i]]++;
    }

    cout << answer[0];
    for (int i = 1; i < N; i++) {
        cout << " " << answer[i];
    }
    cout << endl;
}

int main(void) {
    cin >> S;
    int N = strlen(S);

    solve(N);

    return 0;
}


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

int main(){
  int n; cin >> n;
  int a[n];
  
  int mul = 1, del = 1;
  for(int i=0; i<n; i++){
    cin >> a[i];
    mul *= 3;
    del *= (a[i] % 2)? 1: 2;
  }

  cout << mul - del << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
A = [list(map(int, input().split())) for i in range(n)]


dp = [['' for i in range(3)] for j in range(n)]
for i in range(n):
    if(i == 0):
        dp[i] = A[i]
        continue
    for j in range(3):
        if(j ==0):
            dp[i][j] = max(dp[i-1][1], dp[i-1][2])+A[i][j]
        elif(j ==1):
            dp[i][j] = max(dp[i-1][0], dp[i-1][2])+A[i][j]
        elif(j ==2):
            dp[i][j] = max(dp[i-1][0], dp[i-1][1])+A[i][j]

print(max(dp[n-1]))


Measured memory_bytes: 47280
#include <iostream>
#include <string>
using namespace std;
int N, A[3][3], b[10];
bool appear[3][3];
int main() {
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) cin >> A[i][j];
}
cin >> N;
for(int i = 0; i < N; i++) cin >> b[i];
for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
        appear[i][j] = false;
        for(int k = 0; k < N; k++) {
            if(A[i][j] == b[k]) appear[i][j] = true;
        }
    }
}
string ANS = "No";
for(int i = 0; i < 3; i++) {
    if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
}
for(int i = 0; i < 3; i++) {
    if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
}
if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
cout << ANS << endl;
    return 0;
}

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

int gcd(int a, int b){
	if(b==0) return a;
	else return gcd(b, a%b);
}

int main(){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int g=gcd(a, b);
	printf("%d\n", a/g*b/g*c);
}

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

int main() {
  int n, h;
  cin >> n >> h;
  vector<int> A(n);
  vector<int> B(n);
  for(int i = 0; i < n; i++) {
    cin >> A[i];
    cin >> B[i];
  }

  int maxA = *max_element(A.begin(), A.end());

  sort(B.begin(), B.end());

  int total = 0;

  int ans = 0;

  for(int i=0;i<n;i++) {
    if(B[n-1-i] >= maxA) {
      total += B[n-1-i];
    } else {
      ans += i;
      break;
    }

    if(total >= h) {
      ans += i + 1;
      break;
    }

    if(i == n-1) ans += i + 1;
  }

  if(total >= h) cout << ans << endl;
  else {
    if((h - total) % maxA == 0) cout << ans + (h - total) / maxA << endl;
    else cout << ans +(h - total) / maxA + 1 << endl;
  }
}

Measured memory_bytes: 1024
round = Array.new
round[0] = Hash::new
round[1] = Hash::new
round[2] = Hash::new
final = Hash::new

#get input
for j in 0...3
  for i in 0...8
    input = gets.split(" ")
    round[j][input[0]] = input[1]
  end
end

#ソートのために配列化
r1 = round[0].to_a
r2 = round[1].to_a
r3 = round[2].to_a

#タイムでソート
r1.sort!{|rec1, rec2|  rec1[1]<=>rec2[1]}
r2.sort!{|rec1, rec2|  rec1[1]<=>rec2[1]} 
r3.sort!{|rec1, rec2|  rec1[1]<=>rec2[1]}
  
#各ラウンド上位2位を決勝候補に追加
print(r1[0][0], " ", r1[0][1], "\n")
print(r1[1][0], " ", r1[1][1], "\n")
r1.delete_at(0)
r1.delete_at(0)

print(r2[0][0], " ", r2[0][1], "\n")
print(r2[1][0], " ", r2[1][1], "\n")
r2.delete_at(0)
r2.delete_at(0)

print(r3[0][0], " ", r3[0][1], "\n")
print(r3[1][0], " ", r3[1][1], "\n")
r3.delete_at(0)
r3.delete_at(0)

#残りの配列を結合してソートして上位2位取得
rest = r1.concat(r2).concat(r3)
rest.sort!{|rec1, rec2|  rec1[1]<=>rec2[1]}
print(rest[0][0], " ", rest[0][1], "\n")
print(rest[1][0], " ", rest[1][1], "\n")

Measured memory_bytes: 6132
n, k = map(int, input().split())
list_score = [ list(map(int,input().split(" "))) for i in range(n)]
list_score.sort(key=lambda x:x[0])
cnt = 0
ans = -1
for i in range(n):
    cnt += list_score[i][1]
    if cnt >= k:
        ans = list_score[i][0]
        break

print(ans)



Measured memory_bytes: 29040
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
char a[Max];
int n,k,ans[Max];
int main()
{
    scanf("%d%d",&n,&k);
    scanf("%s",a);
    int i=0,len=0,c0=0,mn=9999999;
    while(i<n)
    {
        if(a[i]=='0')
        {
            int t=0;
            while(a[i]=='0')
            {
                t+=-1;
                i++;
                c0++;
            }
            mn=min(t,mn);
            ans[len++]=t;
        }
        else if(a[i]=='1')
        {
            int t=0;
            while(a[i]=='1')
            {
                t+=1;
                i++;

            }
            ans[len++]=t;
        }
    }
    if(k>=c0){
        printf("%d\n",n);
        return 0;
    }
    int t=0;
    int Ans=0,sum=0,flag=0;
    for(int i=0; i<n; i++)
    {
        sum+=abs(ans[i]);
        if(ans[i]<0)
        {
            t++;
            if(!flag)
                flag=i+1;
        }
        if(t==k)
        {
            Ans=max(Ans,sum+ans[i+1]);
            sum=0;
            t=0;
            i=flag-1;
            flag=0;
        }
    }
    Ans=max(Ans,sum);
    printf("%d\n",Ans);
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
int n,s[100],ans[100],ok,k;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<n;i++){
        //cout<<"WWWWWWWWWWWWWWW"<<endl;
        ok=0;
        k=0;
        for(int j=n;j>0;j--){
            if(s[j-1]==-1)k++;
            //cout<<s[j-1]<<endl;
            if(s[j-1]==j-i+k){
                ans[i]=j-i+k;
                s[j-1]=-1;
                ok=1;
                break;
            }
        }
        if(ok==0){
            cout<<-1<<endl;
            return 0;
        }
    }
    for(int i=n-1;i>=0;i--){
        cout<<ans[i]<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
long long a[15],M=0;

long long search(int s,int e,int k){
	long long min,m,d,t;
	m=M;
	if(k>0){
		if(M<a[s]){
			M=a[s];
			t=search(s+1,e,k-1);
			M=m;
			return t;
		}
		d=M+1-a[s];
		a[s]+=d;
		M++;
		min=d+search(s+1,e,k-1);
		M--;
		a[s]-=d;
		if(e-s>k){
			t=search(s+1,e,k);
			min=(t<min)?t:min;
		}
		return min;
	}else return 0;
}

int main(int argc, char const *argv[]){
	int n,k,c=0,i;
	long long ans=0,max=0,min=-1;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	for(i=0;i<n;i++){
		if(max<a[i]){
			c++;
			max=a[i];
		}
	}
	if(c<k) ans=search(0,n,k);
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  vector<int> x(5);
  rep(i, 5) {
    cin >> x[i];
  }

  rep(i, 5) {
    if(x[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<string> aaa[11][12][2] = {};
    aaa[1][1][0] = {"a"};
    aaa[1][1][1] = {"a"};
    aaa[1][11][1] = {"a"};
    string xx[10] = {"a", "ab", "abc", "abcd", "abcde", "abcdef", "abcdefg", "abcdefgh", "abcdefghi", "abcdefghij"};
    char xxx[10] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};
    for (int i = 1; i < N; i++)
    {
        for (int j = 1; j <= i; j++)
        {
            for(auto x : aaa[i][j][0]){        
                for(auto y : xx[j]){
                    if(y == xxx[j]){
                        aaa[i+1][j+1][0].push_back(x+y);
                        aaa[i+1][11][1].push_back(x+y);
                    }else{
                        aaa[i+1][j][0].push_back(x+y);
                        aaa[i+1][11][1].push_back(x+y);
                    }
                }
            }
        }
    }
    sort(aaa[N][11][1].begin(), aaa[N][11][1].end());
    for(auto x : aaa[N][11][1]){
        cout << x << endl;
    }

}

Measured memory_bytes: 17776
#include<stdio.h>
#include <iostream>
using namespace std;
int main(void){

	int n,i,j,d1,d2,p,a,d=-1,c=-1,max=-1;
	scanf("%d",&n);
	while ( n > 0){
		
		for (i = 0; i < n; i++){
			scanf("%d %d %d", &p, &d1, &d2);
			a = d1 + d2;
			if (a > max){
				c = p;
				d = a;
				max = a;
			}
		}
		max = -1;

			printf("%d %d\n", c , d);
			scanf("%d", &n);
	}
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

//---------------------------

int main(){
    ll n;
    cin >> n;
    VVL test(n, VL(n,-1));

    rep(i,n){
        ll a;
        cin >> a;
        rep(j,a){
            ll x,y;
            cin >> x >> y;
            test[i][x-1] = y;
        }
    }

    ll ans = 0;
    rep(bit,1<<n){
        ll num = 0;
        bool flag = true;
        set<ll> honest;
        rep(i,n){
            if(bit & (1<<i)) honest.insert(i);
        }
        for(auto h : honest){
            rep(x,n){
                if(test[h][x]==1 && !honest.count(x)) flag = false;
                if(test[h][x]==0 && honest.count(x)) flag = false;
            }
        }
        if(flag){
            chmax(ans,honest.size());
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define is_set(num, bin) ((1 << bin) & num) >> bin
using namespace std;
int main(){
  string S;
  cin >> S;
  int bit, tmp;
  for(bit = 0; bit < 8; bit++){
    tmp = int(S[0]) - 48;
    for(int i = 0; i < 3; i++){
      if(is_set(bit, i)) tmp += int(S[i + 1]) - 48;
      else tmp -= int(S[i + 1]) - 48;
    }
    if(tmp == 7){
      char op[2] = {'-', '+'};
      cout << S[0] << op[is_set(bit, 0)] << S[1] << op[is_set(bit, 1)] << S[2] << op[is_set(bit, 2)] << S[3] << "=7" << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
S=input()
n=len(S)
hantei1,hantei2=1,1
for i in range(0,n,2):
    if S[i]=='R' or S[i]=='U' or S[i]=='D':
        continue
    else:
        hantei1=0
        break

for j in range(1,n,2):
    if S[j]=='L' or S[j]=='U' or S[j]=='D':
        continue
    else:
        hantei2=0
        break

if hantei1 == 1 and hantei2 == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
import numpy as np

N = int(input().rstrip())
A = [int(i) for i in input().rstrip().split()]
B = A.copy()

for i in range(N-1):
  if B[i+1] < B[i]:
    B[i+1] = B[i]
    
A = np.array(A)
B = np.array(B)
C = B - A

print(np.sum(C))

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

int main(){
    long long x;
    cin >> x;
    if(x<=6){
        cout << 1 << endl;
    }else if(x%11==6||x%11==5||x%11==0){
        cout << 2*x/11 << endl;
    }else{
        cout << 2*x/11+1 << endl;
    }

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;
const LL MOD = 1000000007LL;
LL mod_pow(LL a, LL n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		LL t = mod_pow(a, n / 2);
		return (t*t) % MOD;
	}
	return (a*mod_pow(a, n - 1)) % MOD;
}
LL inv[1001];
LL dp[1001][1001];
LL comb[1001][1001];
int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	comb[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		comb[i][0] = comb[i][i] = 1;
		for (int j = 1; j < i; j++) {
			comb[i][j] = comb[i - 1][j];
			(comb[i][j] += comb[i - 1][j - 1]) %= MOD;
		}
	}
	inv[0] = 1;
	for (int i = 1; i <= N; i++) {
		inv[i] = inv[i - 1];
		(inv[i] *= mod_pow(i, MOD - 2)) %= MOD;
	}
	dp[A - 1][0] = 1;
	for (int k = A; k <= B; k++) {
		for (int n = 0; n <= N; n++) {
			LL t = 1;
			for (int x = 0; x <= n / k; x++) {
				if (x > 0) (t *= comb[n - k*(x - 1)][k]) %= MOD;
				if (x == 0 || (C <= x && x <= D)) {
					LL add = (dp[k - 1][n - k*x] * t) % MOD;
					(add *= inv[x]) %= MOD;
					(dp[k][n] += add) %= MOD;
				}
			}
		}
	}
	cout << dp[B][N] << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> a(2, vector<int>(N));
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < N; j++) {
            cin >> a[i][j];
        }
    }

    int max_candies = 0;

    for (int i = 0; i < N; i++) {
        int candies = 0;
        int line = 0;
        for (int j = 0; j < N; j++) {
            
            candies += a[line][j];
            //cout << "at " << line << ", " << j << ", candies " << candies << endl;
            if (i == j) {
                line++;
                candies += a[line][j];
                //cout << "at " << line << ", " << j << ", candies " << candies << endl;
            }
        }
        max_candies = max(candies, max_candies);
    }
    cout << max_candies << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <algorithm>
#include <queue>
#define N 100005
using namespace std;
typedef long long ll;
struct st{ll a, b, c;} d[N];
ll n, x, y, z, ans, sc, g[N], s[N];
priority_queue<ll, vector<ll>, greater<ll> > q1, q2;
bool cmp(st p, st q) {return p.a-p.b > q.a-q.b;}

int main() {
	ll i;
	scanf("%lld%lld%lld", &x, &y, &z);
	n = x+y+z;
	for(i=1; i<=n; i++) scanf("%lld%lld%lld", &d[i].a, &d[i].b, &d[i].c), sc += d[i].c;
	sort(d+1, d+n+1, cmp);
	for(i=1; i<=x+z; i++) {
		q1.push(d[i].a - d[i].c);
		g[i] = g[i-1] + d[i].a - d[i].c;
		if(i>x) g[i] -= q1.top(), q1.pop();
	}
	for(i=n; i>x; i--) {
		q2.push(d[i].b - d[i].c);
		s[i] = s[i+1] + d[i].b - d[i].c;
		if(i<=n-y) s[i] -= q2.top(), q2.pop();
	}
	ans = g[x] + s[x+1];
	for(i=x; i<=n-y; i++) ans = max(ans, g[i] + s[i+1]);
	printf("%lld", ans + sc);
	return 0;
}

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

int main() {
	int n; cin >> n;
	map<int, int> mp;
	for(int i = 0; i < n; ++i) {
		int a; cin >> a;
		++mp[a];
	}
	map<int, int> d;
	for(auto e : mp) {
		++d[e.second];
	}
	int l[n + 1] = {}, r[n + 1] = {};
	for(int k = 1; k <= n; ++k) {
		r[0] += d[k];
	}
	for(int x = 1; x <= n; ++x) {
		l[x] = l[x - 1] + x * d[x];
		r[x] = r[x - 1] - d[x];
	}
	int ans[n + 1] = {};
	for(int x = 1; x <= n; ++x) {
		int fx = (l[x] + x * r[x]) / x;
		ans[fx] = x;
	}
	for(int i = n - 1; i >= 1; --i) {
		ans[i] = max(ans[i], ans[i + 1]);
	}
	for(int k = 1; k <= n; ++k) {
		cout << ans[k] << '\n';
	}
	return 0;
}

Measured memory_bytes: 31360