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;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  rep(i,n-1)if(s[i]==s[i+1]){
    cout << i+1 << ' ' << i+2 << endl;
    return 0;
  }
  rep(i,n-2)if(s[i]==s[i+2]){
    cout << i+1 << ' ' << i+3 << endl;
    return 0;
  }
  cout << -1 << ' ' << -1 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <iterator>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<29
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define _DEBUG(x) cout<<#x<<": "<<x<<endl
#define _DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T>
ostream& operator<< (ostream& out, const vector<T>& v) {
  if ( !v.empty() ) {
    out << '[';
    copy (v.begin(), v.end(), ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}


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

    int n;
    cin >> n;
    ll arr[n];
    vector<long long> v(n + 1);
    v[0] = 0;
    REP(i, n) {
        cin >> arr[i];
        v[i + 1] = v[i] + arr[i];
    }

    sort(v.begin(), v.end());
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        ans += distance(v.begin() + i, upper_bound(v.begin() + i, v.end(), v[i])) - 1;
#if DEBUG
        cout << "** DEBUG **" << endl; // debug
        cout << "# ans : " << ans << endl;
        cout << "# diff : " << distance(v.begin() + i, upper_bound(v.begin() + i, v.end(), v[i])) - 1 << endl;
        cout << v << endl;
#endif
   }

#if DEBUG
	cout << "** RESULT **" << endl; // debug
#endif
    cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3328
import java.io.*;
import java.math.BigDecimal;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        BigDecimal A = new BigDecimal(sc.next());
        BigDecimal B =  new BigDecimal(sc.next());
        long ans = (A.multiply(B)).longValue();
        out.println(ans);

        out.flush();

    }

    static 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());
        }

    }
}

Measured memory_bytes: 33308
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 10005
using namespace std;
int n,id,c[M],ans[M];
vector<int> e[M];
void dfs(int cur,int fa) {
    ans[cur] = c[++id];
    for (int i:e[cur]) if(i!=fa) dfs(i, cur);
}
int main()
{
    while (~scanf("%d", &n)) {
        REP(i,1,n) e[i].clear();
        REP(i,1,n-1) {
            int a,b;
            scanf("%d %d",&a,&b);
            e[a].push_back(b);
            e[b].push_back(a);
        }
        REP(i,1,n) scanf("%d", &c[i]);
        sort(c+1, c+n+1, greater<int>());

        id = 0;
        dfs(1, -1);
        printf("%lld\n", accumulate(c+2, c+n+1, 0LL));
        REP(i,1,n) {
            printf("%d%c",ans[i],i==n ? '\n':' ');
        }
    }
    return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 500005
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long

#define mod  1000000007



int main()
{
	FAST;
	int n; 
	string a, b;
	cin >> n >> a >> b;
	string ans = "";
	for(int i = 0; i < n; i ++){
		ans += a[i];
		ans += b[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll INF = 1e17;
const ll MOD = 1e9+7;

// https://math.nakaken88.com/textbook/cp-binary-exponentiation-and-recursive-function/
ll modPow(long long a, long long n) {
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  long long t = modPow(a, n / 2);
  return (t * t) % MOD;
}

ll comb(ll n, ll p) {
	if (p * 2 > n) p = n - p;
	if (p > n - p) p = n - p;
	ll a = 1, b = 1;
	for(int i=1; i< p+1; i++) {
		a = (a * (n - i + 1)) % MOD;
		b = (b * i) % MOD;
	}
	return a * (modPow(b, MOD - 2)) % MOD;
}

int main() {
    // input, ready
    ll n,a,b;
    cin >> n >> a >> b;
    ll comball = modPow(2, n);
    ll comba = comb(n,a);
    ll combb = 0;
    if (a != b) combb = comb(n,b);

    ll ans = (comball - comba - combb -1) % MOD;
    if (ans < 0 ) ans += MOD;

    // output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#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 int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  vstring mass(n);
  rep(i,n) cin >> mass[i];
  int ans = 0;
  rep(i,n){
    bool flag = true;
    rep(j,n){
      rep(s,n){
        if(mass[j][s] != mass[s][j]) flag = false;
      }
    }
    if(flag) ans += n;
    vstring newmass(n);
    newmass[0] = mass[n-1];
    rep1(j,n){
      newmass[j] = mass[j-1];
    }
    mass = newmass;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {
	
	string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	string S;
	cin >> S;

	size_t val = 0;
	bool jdg = true;
	for (int i = 0; i < ALP.size(); i++) {
		val = count(S.begin(), S.end(), ALP[i]);
		if (val == 1 || val == 3 || val == 4) {
			jdg = false;
			break;
		}
	}
	
	if (jdg == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    if(s=="SUN") cout << 7 <<endl;
    if(s=="MON") cout << 6 <<endl;
    if(s=="TUE") cout << 5 <<endl;
    if(s=="WED") cout << 4 <<endl;
    if(s=="THU") cout << 3 <<endl;
    if(s=="FRI") cout << 2 <<endl;
    if(s=="SAT") cout << 1 <<endl;
}


Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;

int N;

vector<string> ans;

void add_string(string now,int ns){
	if(now.size()==N){
		ans.push_back(now);
		return;
	}
	string ret = now;
	for(int i=0;i<=ns;i++){
		add_string(now+char(i+'a'),max(ns,i+1));
		//add_string(now+char(i+'a'),i+1);
		//これだと例えばN=4の時
		//abac　のような文字列が生成できない
		//1. add_string("ab",3) が呼び出される
		//2. この時for(int i=0;i<=ns(この時ns=3);i++)内でi=0の時
		//3. add_string("aba",1)が呼ばれるが、
		//4. add_string("aba",3)としないとcがくっつかなくなってしまう
	}
}

void solve(){
	add_string("a",1);
}
 
int main(){
	cin >> N;
 
	solve();

	for(int i=0;i<ans.size();i++) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 7796
function main()
  
  N = parse(Int,readline())
  
  ans = Int[]
  
  for i in 0:N
    
    if i == 0
      push!(ans,2)
    elseif i == 1
      push!(ans,1)
    else
      push!(ans,ans[i]+ans[i-1])
    end
    
  end
  
  println(ans[N+1])
  
end

main()

Measured memory_bytes: 108284
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main() {
	int s, w; cin >> s >> w;
	if (s <= w)
		cout << "unsafe" << endl;
	else
		cout << "safe" << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

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

int main(){
    int n, k;
    cin >> n >> k;
    int x[n];
    rep(i, n) cin >> x[i];
    int ans = 0;
    rep(i, n) ans += 2 * min(k - x[i], x[i]);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if(r <= x && x <= W-r && r <= y && y <= H-r){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26296
#include<cstdio>
#define maxn 105
int n,a[maxn],cnt[maxn],ans[maxn];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) cnt[a[i]]++;
	for(int i=1;i<=n;i++)
		if(cnt[i]>n-i+1) { printf("-1\n"); return 0; }
	for(int i=n;i;i--)
	{
		int pos=0;
		for(int j=1;j<=i;j++)
			if(a[j]==j&&a[j]>a[pos]) pos=j;
		ans[i]=pos;
		for(int j=pos;j<i;j++) a[j]=a[j+1];
		for(int j=1;j<i;j++)
			if(a[j]>=i) { printf("-1\n"); return 0; }
	}
	for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
}

Measured memory_bytes: 128
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,m,a,b;
map<int,int> mp;
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a;
        mp[a]=1;
    }
    if(mp[n]==0){cout<<n<<endl;return 0;}
    for(int i=1;i<=100;i++){
        if(n-i<0){cout<<n-i<<endl;return 0;}
        if(mp[n-i]==0){cout<<n-i<<endl;return 0;}
        if(mp[n+i]==0){cout<<n+i<<endl;return 0;}
    }
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
/**==Info==
*Program:1
*Problem:すぬけ君の地下鉄旅行 / Snuke's Subway Trip
*Date:2018-7-14
*Algorithm:BFS Tourist's
*Stats:AC*/

bool debug=false;



template<typename T> struct undispose_queue{
	vector<T> v;
	int s;
	
	undispose_queue(){
		s=0;
		v.clear();
	}
	
	void push(T value){
		v.push_back(value);
	}
	void pop(){
		s++;
	}
	
	T front(){
		return v[s];
	}
	
	void clear(){
		v.clear();
		s=0;
	}
	
	bool empty(){
		return s==v.size();
	}
	
	int size(){
		return v.size()-s;
	}
	
	vector<T> getData(){
		return v;
	}
};

const int A=2e6+1;
const int B=2e5+1;
int n,m;

map<int,vector<int>> nei[B];

int col[B];

set<int> cols;
vector<int> on[A];

vector<int> nnei[A];

int dis[A];

int main(int argc,char* argv[]){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		a--;b--;
		nei[a][c].push_back(b);
		nei[b][c].push_back(a);
		on[c].push_back(a);
		on[c].push_back(b);
		cols.insert(c);
	}
	
	if(debug)cout<<"ok"<<endl;
	
	memset(col,-1,sizeof(col));
	
	int stpos=n;
	
	for(set<int>::iterator it=cols.begin();it!=cols.end();it++){
		int thscol=*it;
		if(debug)cout<<thscol<<endl;
		
		for(int i=0;i<on[thscol].size();i++){
			int thspos=on[thscol][i];
			if(col[thspos]==thscol){
				continue; //In the same block
			}
			
			undispose_queue<int> uq;
			col[thspos]=thscol;
			uq.push(thspos);
			
			while(!uq.empty()){
				
				int last=uq.front();
				uq.pop();
				
				for(int j=0;j<nei[last][thscol].size();j++){
					int nxtpos=nei[last][thscol][j];
					if(col[nxtpos]!=thscol){
						col[nxtpos]=thscol;
						uq.push(nxtpos);
					}
				}
			}
			
			vector<int> v=uq.getData();
			
			for(int j=0;j<v.size();j++){
				nnei[v[j]].push_back(stpos);
				nnei[stpos].push_back(v[j]);
				
				if(debug)cout<<"connected "<<v[j]<<" and "<<stpos<<endl;
			}
			
			stpos++;
		}
		
	}
	
	
	if(debug)cout<<"bfs"<<endl;
	
	queue<int> q;
	
	fill(dis,dis+A,-2);
	dis[0]=0;
	q.push(0);
	while(!q.empty()){
		int last=q.front();
		q.pop();
		
		for(int i=0;i<nnei[last].size();i++){
			if(dis[nnei[last][i]]==-2){
				dis[nnei[last][i]]=dis[last]+1;
				q.push(nnei[last][i]);
			}
		}
	}
	
	cout<<dis[n-1]/2;
	return 0;
}



Measured memory_bytes: 180224
import java.text.SimpleDateFormat;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) throws Exception {
        System.out.println(new SimpleDateFormat("yyyy/MM/dd").parse(scanner.next()).getTime() <= 1556550000000L ? "Heisei" : "TBD");
    }
}

Measured memory_bytes: 21584
n = int(input())
arr = list(map(int, input().split()))

count = 0
for i in range(n):
    for j in range(n - 1, 0, -1):
        if arr[j] < arr[j-1]:
            arr[j], arr[j-1] = arr[j-1], arr[j]
            count += 1

print(*arr)
print(count)



Measured memory_bytes: 5612
#include<stdio.h>
int main()
{
	long int a,b,c,d,sum1,sum2;
	scanf("%lld %lld %lld %lld ",&a,&b,&c,&d);
	sum1 = a*b;
	sum2= c*d;
	if(sum1>sum2)
		printf("%lld",sum1);
	else
		printf("%lld",sum2);
}


Measured memory_bytes: 128
n = int(input())
M = [[float("inf") for i in range(n)] for i in range(n)]
for i in range(n):
 L = list(map(int, input().split()))
 for j,v in enumerate(L):
  if v != -1:
   M[i][j] = v

def prim():
 color = [0] * n
 d = [float("inf")] * n
 p = [-1] * n
 d[0] = 0

 while True:
  minv = float("inf")
  u = -1
  for i in range(n):
   if minv > d[i] and color[i] != 2:
    u = i
    minv = d[i]
  if u == -1: break
  color[u] = 2
  for v in range(n):
   if color[v] != 2 and M[u][v] != float("inf"):
    if d[v] > M[u][v]:
     d[v] = M[u][v]
     p[v] = u
 return sum(d)

print(prim())

Measured memory_bytes: 8136
$stdin.read.split.map(&:to_i).tap do |n, a, *xs|
  @n, @a, @xs = n, a, xs
  @dp = Array.new(n) { Array.new(n+1) { Array.new(n*50+1) } }
  def solve i, c, v
    return c != 0 && v%c == 0 && v/c == @a ? 1 : 0 if i == @n
    @dp[i][c][v] ||= (solve(i+1, c, v) + solve(i+1, c+1, v+@xs[i]))
  end
  puts solve(0, 0, 0)
end

Measured memory_bytes: 51708
local mma = math.max
local mfl, mce, mmi = math.floor, math.ceil, math.min

local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
if n == 1 then print("YES") os.exit() end

local sum = 0
local mod = mfl(n * (n + 1) / 2)
local cnt = 0
for i = 1, n do
  cnt = cnt + mfl((sum + a[i]) / mod)
  sum = (sum + a[i]) % mod
end
if sum ~= 0 then print("NO") os.exit() end

local b = {}
for i = 1, n - 1 do
  b[i] = a[i + 1] - a[i]
end
b[n] = a[1] - a[n]

for i = 1, n do
  b[i] = b[i] - cnt
end

for i = 1, n do
  if 0 < b[i] then cnt = -1 break end
  local v = -b[i]
  if v % n ~= 0 then cnt = -1 break end
  cnt = cnt - mfl(v / n)
end
print(cnt == 0 and "YES" or "NO")


Measured memory_bytes: 2304
import collections
import numpy as np
import sys
input = sys.stdin.readline

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
inf = float('inf')


def bfs(sx, sy):
    # sx,sy := スタートの座標
    # gx,gy := ゴールの座標
    d = [[-inf]*W for _ in range(H)]
    que = collections.deque()
    que.append([sx, sy])
    d[sx][sy] = 0
    while (len(que) > 0):
        p = que.popleft()
        # if p[0] == gx and p[1] == gy:
        #     break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if (0 <= nx and nx < H and 0 <= ny and ny < W and f[nx][ny] != "#" and d[nx][ny] == -inf):
                que.append([nx, ny])
                d[nx][ny] = d[p[0]][p[1]] + 1
        if len(p)==0:
            break
    return np.max(d)

# 入力
H, W = map(int, input().split())
f = [list(input()) for _ in range(H)]

res = 0
for h1 in range(H):
    for w1 in range(W):
        # 全"."を開始とする探索をする。
        # 最短経路で一番遠いポイントが理想的なゴール地点
        if f[h1][w1] == ".":
            # 理想的なゴール地点を更新
            res = max(res, bfs(h1,w1))
        else:
            continue
print(int(res))


Measured memory_bytes: 12952
#include<stdio.h>
int main()
{
    int N;
    scanf("%d",&N);
    if(N==1)
        printf("Hello World");
    else if(N==2)
    {
        int A,B;
        scanf("%d %d",&A,&B);
        printf("%d",A+B);
    }
    return 0;
}


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

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a;
  for (int i = 0; i < n; ++i) {
    int a_i;
    std::cin >> a_i;
    a.push_back(a_i);
  }
  std::vector<int> b;
  for (int i = n - 1; i >= 0; i -= 2) {
    b.push_back(a[i]);
  }
  for (int i = n % 2; i < n; i += 2) {
    b.push_back(a[i]);
  }
  for (int i : b) {
    std::cout << i << " ";
  }
  std::cout << std::endl;
}


Measured memory_bytes: 3828
N,M,*abs=$<.read.split.map(&:to_i)

arr = Array.new(N+1) { Array.new(N+1, 0)}
abs.each_slice(2) do |a,b|
    arr[a][b] = 1
    arr[b][a] = 1
end

ret = 0
(2..N).to_a.permutation do |ls|
    ls = [1] + ls
    count = 0
    ls.each_cons(2) do |a,b|
        count += 1 if arr[a][b] == 1
    end
    ret += 1 if count == N-1
end

puts ret

Measured memory_bytes: 14236
import java.util.*;
public class Main{
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	String s = sc.next();
    	if(a>=3200){
    		System.out.println(s);
    	}else{
    		System.out.println("red");
    	}
    }
}

Measured memory_bytes: 23508
class Restorant
  attr_accessor :id, :city, :score
  def initialize(id, city, score)
    @id = id
    @city = city.to_s
    @score = score.to_i
  end

  def to_s
    "#{@id} #{@city} #{@score}"
  end

  def compare_to(res)
    return res.score <=> @score if @city == res.city
    @city <=> res.city
  end
end

N = gets.chop.to_i
restorants = []
N.times do |n|
  line = gets.chop.split
  restorants.push(Restorant.new(n + 1, line[0], line[1]))
end

restorants.sort! { |a, b| a.compare_to(b) }

restorants.each do |r|
  puts r.id
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	char a = S[0];
	int b = 0;
	rep(i, S.size()) {
		if (S[i] != a) {
			b++;
			a = S[i];
		}
	}
	reverse(all(S));
	char d = S[0];
	int c = 0;
	rep(i, S.size()) {
		if (S[i] != d) {
			c++;
			d = S[i];
		}
	}

	dunk(min(b, c));

	return 0;
}

Measured memory_bytes: 512
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
    std.typecons, std.math, std.container, std.format, std.numeric;

class SegmentTree
{
private:
    long size;
    long[] xs;
public:
    this(long size)
    {
        long i = 1;
        while (i <= size)
        {
            i *= 2;
        }
        this.size = size;
        xs = new long[](i * 2);
    }

    this(long size, long initial_value)
    {
        this(size);
        this.xs.fill(initial_value);
    }

    void update(long i, long x)
    {
        i += this.size;
        xs[i] = x;
        while (i != 0)
        {
            i /= 2;
            xs[i] = min(xs[i * 2], xs[i * 2 + 1]);
        }
    }

    long find(long l, long r)
    {
        l += this.size;
        r += this.size;

        long ans = long.max / 2;
        while (l < r)
        {
            if (l % 2 == 1)
            {
                ans = min(ans, xs[l]);
                l++;
            }
            l /= 2;
            if (r % 2 == 1)
            {
                ans = min(ans, xs[r - 1]);
                r--;
            }
            r /= 2;
        }
        return ans;
    }
}

void main(string[] args)
{
    long n, q, com, x, y;
    readf("%d %d\n", &n, &q);

    const INIT = (1 << 31) - 1;
    auto seg = new SegmentTree(n, INIT);

    foreach (_; 0 .. q)
    {
        readf("%d %d %d\n", &com, &x, &y);
        if (com == 0)
        {
            seg.update(x, y);
        }
        if (com == 1)
        {
            writeln(seg.find(x, y + 1));
        }
    }
}



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

int main() {
  string s;
  int n,ans = 0;
  cin >> n >> s;
  for(int i = 0;i < n-2;i++){
    if(s.at(i) == 'A' &&(s.at(i+1) == 'B' && s.at(i+2) == 'C')){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# = map(int, input().split())
n = int(input())
# = input()
h = list(map(int, input().split()))

if n == 1:
	print(h[0])
else:
	cnt = 0
	while 1:
		while h[0] == 0:
			del h[0]
			if len(h) == 1:
				print(cnt+h[0])
				exit(0)
		while h[len(h)-1] == 0:
			del h[len(h)-1]
			if len(h) == 1:
				print(cnt+h[0])
				exit(0)
		num = 1
		i = 0
		while 1:
			while h[i] != 0:
				i += 1
				if i == len(h):
					break
			if i == len(h):
				break
			num += 1
			while h[i] == 0:
				i += 1
		cnt += num
		for i in range(len(h)):
			if h[i] != 0:
				h[i] -= 1



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    cout << (S == "abc" ? "Yes" : "No") << endl;
}


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

using namespace std;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()
#define INF (int)1e9
#define MOD 1000000007
#define PI 3.1415926535897932384626
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
int a[mxN];

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

    string s;
    cin >> s;
    sort(s.begin(), s.end());

    if (s[0] == s[2])
        cout << "No";
    else
        cout << "Yes";

    return 0;
}

Measured memory_bytes: 3568
#include<stdio.h>

int main()
{
  int i,num,j,k,u,n;
  int M[101][101];

  for(i=0;i<=100;i++)
    {
      for(j=0;j<=100;j++)
	{
	  M[i][j] = 0;
	}
    }
  
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d %d",&u,&k);
      for(j=1;j<=k;j++)
	{
	  scanf("%d",&num);
	  M[u][num] = 1;
	}
    }

  for(i=1;i<=n;i++)
    {
      for(j=1;j<=n;j++)
	{
	  printf("%d",M[i][j]);
	  if(j != n)
	    {
	      printf(" ");
	    }
	}
      printf("\n");
    }
  return 0;
}





Measured memory_bytes: 2052
// Created by martinezdiego on 19/5/19

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  double ans = 0.0;
  for (int i = 1; i <= n; i++) {
    double cnt = 1.0/(double)n;
    int t = i;
    while (t < k) {
      t *= 2;
      cnt /= 2.0;
    }
    ans += cnt;
  }
  cout << setprecision(12) << ans << '\n'; 
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

ll N, K;
vector<ll> a;
vector<ll> x;

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

    cin >> N >> K;
    a.pb(0);
    rep(i, N){
        ll inp;
        cin >> inp;
        inp += a[a.size() - 1];
        a.pb(inp);
    }
    
    for(ll i =0  ; i < a.size(); i++){
        for(ll j = i+1; j < a.size(); j++){
            x.pb(a[j] - a[i]);
        }
    }
    
    
    ll ans = 0 ;
    
    
    for(ll i = 40; i >= 0; i--){
        
        vector<ll> candi;
        rep(j, x.size()){
            // TO DO
            if((x[j] >> i) & 1) candi.pb(x[j]);
        }
        
        if(candi.size() >= K){
            ans += (ll)((ll)1 << i);
            x.clear();
            rep(j, candi.size()){
                x.pb(candi[j]);
            }
        }
    }
    
    cout << ans << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 6256
import java.util.*;
     
public class Main{
  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = a - b * 2;
      if(c >= 0){
        System.out.println(c);
      }else{
        System.out.println("0");
      }
  }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());

            var ans = long.MaxValue;

            for (int i = 1; (long)i * i <= N ; i++)
            {
                if(N % i == 0)
                {
                    ans = Math.Min(Math.Max(i.ToString().Length, (N / i).ToString().Length), ans);
                }
            }

            Console.WriteLine(ans);
        }
    }
}


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

int combination(int num) {
    int ret = 0;
    for(int n1 = 0; n1 <= 9; n1++) {
        for(int n2 = 0; n2 <= 9; n2++) {
            for(int n3 = 0; n3 <= 9; n3++) {
                for(int n4 = 0; n4 <= 9; n4++) {
                    if(n1 + n2 + n3 + n4 == num) ret++;
                }
            }
        }
    }
    return(ret);
}

int main(void) {
    int num;
    while(cin >> num) cout << combination(num) << endl;
    return(0);
}

Measured memory_bytes: 1160
#include<stdio.h>
#define MAX 10000
#define FALSE -1
 
typedef struct
{
  int parent;
  int left;
  int right;
}Tree;
 
Tree A[MAX];
int n;
 
void pPato(int k)
{
  if(k==FALSE)return;
  printf(" %d",k);
  pPato(A[k].left);
  pPato(A[k].right);
}
 
void mPato(int k)
{
  if(k==FALSE)return;
  mPato(A[k].left);
  printf(" %d",k);
  mPato(A[k].right);
}
 
void lPato(int k)
{
  if(k==FALSE)return;
  lPato(A[k].left);
  lPato(A[k].right);
  printf(" %d",k);
}
 
int main()
{
  int i,pnum,lnum,rnum,pass;
 
  scanf("%d",&n);
  for(i=0;i<n;i++)A[i].parent=FALSE;
  for(i=0;i<n;i++)
    {
      scanf("%d %d %d",&pnum,&lnum,&rnum);
      A[pnum].left=lnum;
      A[pnum].right=rnum;
      if(lnum!=FALSE)A[lnum].parent=pnum;
      if(rnum!=FALSE)A[rnum].parent=pnum;
    }
  for(i=0;i<n;i++)if(A[i].parent==FALSE)pass=i;
  printf("Preorder\n");
  pPato(pass);
  printf("\n");
  printf("Inorder\n");
  mPato(pass);
  printf("\n");
  printf("Postorder\n");
  lPato(pass);
  printf("\n");
 
  return 0;
}

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

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

	string ans;
	
	if (b < a) {
		cout << "GREATER" << endl;
	}
	else if (a < b) {
		cout << "LESS" << endl;
	}
	else {
		cout << "EQUAL" << endl;
	}
	
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define emp emplace
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN = 200100;
const ll INF = 1e9;
const ll MOD = 1e9+7;

ll N,Q,a,b,c,d,e,M;
ll A[MAXN];
ll B[MAXN];
vi V[MAXN];
ll out[MAXN];
ll T[MAXN];
stack<ll> PMAT;

struct node{
	int s,e,m,v;
	node *l,*r;
	node(int _s,int _e):s(_s),e(_e),v(0){
		m=(s+e)/2;
		if(s!=e){l=new node(s,m);r=new node(m+1,e);}
	}
	int query(int x,int y){
		if(s==x&&e==y)return v;
		if(y<=m)return l->query(x,y);
		else if(x>m)return r->query(x,y);
		else return max(l->query(x,m),r->query(m+1,y));
	}
	void up(int x, int val){
		if(s==e){v=val;return;}
		if(x>m)r->up(x,val);
		else l->up(x,val);
		v=max(l->v,r->v);
	}
}*root;

void dfs(int x, int p){
	int a = A[x];
	int v = root->query(0,a-1)+1;
	out[x]=v;
	if(SZ(PMAT))out[x]=max(out[x],PMAT.top());
	PMAT.push(out[x]);
	int original = T[a];
	// cout<<x<<' '<<original<<'\n';
	// cout<<"Node "<<x<<": ";
	// for(int i=1;i<=N;++i)cout<<root->query(i,i)<<' ';
	// cout<<'\n';
	root->up(a,v);
	T[a]=v;

	for (auto v:V[x])if(v!=p)dfs(v,x);

	root->up(a,original);
	T[a]=original;
	PMAT.pop();
	// cout<<"Node "<<x<<": ";
	// for(int i=1;i<=N;++i)cout<<root->query(i,i)<<' ';
	// cout<<'\n';
}
vi des;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>N;
	for(int i=1;i<=N;++i){cin>>A[i];des.pb(A[i]);}
	sort(ALL(des));des.resize(unique(ALL(des))-des.begin());
	for(int i=1;i<=N;++i)A[i]=lb(ALL(des), A[i])-des.begin()+1;
	for(int i=1;i<N;++i){
		cin>>a>>b;V[a].pb(b);V[b].pb(a);
	}
	root =new node(0,N);
	dfs(1,-1);
	// cout<<'\n';
	for(int i=1;i<=N;++i)cout<<out[i]<<'\n';
}

Measured memory_bytes: 73556
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// to_string(数値)
// %0桁数d とすると表示桁数が「桁数」に満たない場合に0埋めされる
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
// printf("%02d:%02d:%02d",hour,minute,second);
// 降順 sort(a.begin(),a.end(),greater<int>());
// bitset<ビット数> 変数名;  // すべてのビットが0の状態で初期化される
// bitset<ビット数> 変数名("ビット列");  // 指定したビット列で初期化される
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  cout << a.at(n-1) - a.at(0) << endl;
}


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

int main() {
  int n;
  cin >> n;
  int a = n / 100, b = n % 100;
  if((0 < a && a < 13) && (0 < b && b < 13))
    cout << "AMBIGUOUS" << endl;
  else if((0 < a && a < 13) && (b == 0 || 12 < b < 100))
    cout << "MMYY" << endl;
  else if((0 < b && b < 13) && (a == 0 || 12 < a < 100))
    cout << "YYMM" << endl;
  else
    cout << "NA" << endl;
}

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

int main() {
  int a,b ,c,k;
  cin >> a >> b >> c >> k;
  if (k <= a) {
    cout << k << endl;
  }
  else if (k > a && k <= a+b) {
    cout << a << endl;
  }
  else if (k > a+b && k < a+b+c) {
    cout << 2*a + b - k << endl;
  }
  else cout << a - c << endl;

}

Measured memory_bytes: 3636
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int ch[30];
bool used[30];
bool cal(string s,string t){
	memset(ch,-1,sizeof(ch));
	memset(used,false,sizeof(used));
	rep(i,s.size()){
		int x=(s[i]-'a'),y=(t[i]-'a');
		if(ch[x]!=-1 && ch[x]!=y) return false;
		ch[x]=y;used[y]=true;
	}
	/*rep(i,26){
		if(!used[i]) return true;
	}
	rep(i,26){
		if(ch[i]!=i) return false;
	}*/
	return true;
}
int main(){
	string s,t;cin>>s;cin>>t;
	if(cal(s,t) && cal(t,s)) cout<<"Yes"<<endl;else cout<<"No"<<endl;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cstdio>

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout);
#define CLOSEALL() fclose(stdin), fclose(stdout)

using namespace std;

typedef long long i64;

i64 answer;
i64 a, b;
int main()
{
	//REDIRECT("or");

	scanf("%lld%lld", &a, &b);

	if (a > b)
		swap(a, b);

	i64 loDiff = 60, j;
	while (loDiff >= 0)
	{
		if ((b >> loDiff & 1) ^ (a >> loDiff & 1))
			break;
		if (a >> loDiff & 1)
			a ^= 1LL << loDiff;
		if (b >> loDiff & 1)
			b ^= 1LL << loDiff;

		loDiff--;
	}

	for (j = loDiff - 1; j >= 0; --j)
		if (b >> j & 1)
		{
			answer += (1LL << (j + 1)) - 1;
			break;
		}

	//printf("%d %d\n", a, b);
	//printf("%d %d\n", loDiff, j);

	answer += ((1LL << loDiff) - a) * 2;
	if (j != -1 && a <= ((1LL << (j + 1)) - 1))
		answer -= ((1LL << (j + 1)) - a);

	answer += (loDiff != 0);
	printf("%lld\n", answer);

	CLOSEALL();
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
  int a,b,c;
  int i;
  int count = 0;

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

  for (i = a; i <= b; i++) {
    if (c % i == 0) count++;
  }
  printf("%d\n", count);

  return (0);
}



Measured memory_bytes: 2120
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int N; int M;
	while (~scanf("%d%d", &N, &M)) {
		vector<vi> A(N, vi(N, INF));
		rep(i, N)
			A[i][i] = 0;
		rep(i, M) {
			int a; int b; int c;
			scanf("%d%d%d", &a, &b, &c), --a, --b;
			A[a][b] = A[b][a] = c;
		}
		vector<vi> wf = A;
		rep(k, N) rep(i, N) rep(j, N)
			amin(wf[i][j], wf[i][k] + wf[k][j]);
		int ans = 0;
		rep(a, N) reu(b, a + 1, N) if(A[a][b] < INF) {
			ans += wf[a][b] < A[a][b];
		}
		printf("%d\n", ans);
	}
	return 0;
}


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

int main(){
	
	int n,m,c,i; cin >> n >> m >> c;
	int b[m],a[m],k=0,x;
	
	for (i=0 ; i<m ; i++) cin >> b[i];
	
	while (n){
		n--;
		x = 0;
		
		for (i=0 ; i<m ; i++){
			cin >> a[i];
			x += a[i]*b[i];
		}
		
		if (x+c > 0) k++;		
	}
	
	cout << k << endl;
	
	return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>

#include<queue>

using namespace std ;

#define N_MAX 100000

int N ,K ;
int time[ N_MAX ] ;

priority_queue< int > que ;

int main( void )
{
	scanf( "%d %d" ,&N ,&K ) ;

	int i ,j ;
	for( i = 0 ; i < N ; ++i )
	{ 
		scanf( "%d" ,time + i ) ;

		if( i > 0 )
		{
			que.push( -(time[ i ] - time[ i - 1 ] - 1) ) ;
		}
	}

	long long sum = N ;	N -= K ;
	for( i = 0 ; i < N ; ++i )
	{
		sum += -que.top() ;	que.pop() ;
	}

	printf( "%lld\n" ,sum ) ;

	return 0 ;
}


Measured memory_bytes: 3408
#include <iostream>
#include <queue>
#define int long long
using namespace std;
priority_queue<int> down;
priority_queue<int,vector<int>,greater<int>> up;
int seppen;
int Q;
signed main(void){
    // Your code here!
    int q, a, b, size=0;
    seppen = 0;
    cin >> Q;
    down.push(-1000000007);
    up.push(1000000007);
    for(int i=0; i<Q; i++){
        cin >> q;
        switch(q){
            case 1:
            cin >> a >> b;
            if(size%2==0){
                int x=down.top(), y=up.top();
                if(a<=x){
                    down.push(a);
                    seppen += b + x-a;
                }else{
                    up.push(a);
                    int t = up.top(); up.pop();
                    down.push(t);  //down=up+1
                    if(y<=a){
                        seppen += b + a-y;
                    }else{
                        seppen += b;
                    }
                }
            }else{
                int x=down.top();
                if(a<=x){
                    down.push(a);
                    int t = down.top(); down.pop();
                    up.push(t); //down= up
                    seppen += b + x - a;
                }else{
                    up.push(a);
                    seppen += b + a - x;
                }
            }
            size++;
            break;
            case 2:
            cout << down.top() << " " << seppen << "\n";
        }
    }
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e6+18
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=200001;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
vector<int>v[maxn];
int l;
int vis[maxn];
void dfs(int node)
{
	vis[node]=1;
	l++;
	for(int child: v[node])
	{
		if(!vis[child])
			dfs(child);
	}
}
int main()
{
	fastio;
	int t;
	int i,j,k,n,m;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>j>>k;
		v[j].pb(k);
		v[k].pb(j);
	}
	k=0;
	for(i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			l=0;
			dfs(i);
			k=max(k,l);
		}
	}
	cout<<k;
	

}

Measured memory_bytes: 21536
#include <bits/stdc++.h>
using namespace std;
struct body{
    char city[12];
    int p;
    int i;
};
bool cmp(const body &a, const body &b)
{
    if(strcmp(a.city,b.city) != 0){
        int ans = strcmp(a.city,b.city);
        return ans<0;
    }
    else{ 
        return a.p > b.p;
    }
}
int main(void){
    int N;
    cin>>N;
    vector<struct body> list(N);
    for(int i = 0; i<N; i++){
        char n[4];
        cin>>list[i].city>>list[i].p;
        list[i].i = i+1;
    }
    sort(list.begin(),list.end(),cmp);
    // for(int i = 0; i<N; i++){
    //     cout<<list[i].city<<" : "<<list[i].p<<endl;
    // }
    
    for(int i = 0; i<N; i++){
        cout<<list[i].i<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        City[] cities = new City[m];
        for (int i = 0; i < m; i++) {
            cities[i] = new City(in.nextInt(), in.nextInt());
        }

        City[] citiesClone = cities.clone();
        Arrays.sort(citiesClone, (x, y) -> Integer.compare(x.year, y.year));
        Arrays.sort(citiesClone, (x, y) -> Integer.compare(x.prefecture, y.prefecture));

        Map<Integer, Integer> yearToNum = new HashMap<>();
        int cityNum = 1;
        int prev = 0;
        for (int i = 0; i < m; i++) {
            int currPref = citiesClone[i].prefecture;
            if (currPref == prev) {
                cityNum++;
            }
            else {
                cityNum = 1;
            }
            yearToNum.put(citiesClone[i].year, cityNum);
            prev = currPref;
        }

        StringBuilder out = new StringBuilder();
        for (int i = 0; i < m; i++) {
            out.append(toID(Integer.toString(cities[i].prefecture)));
            out.append(toID(Integer.toString(yearToNum.get(cities[i].year))));
            out.append("\n");
        }

        System.out.println(out);
    }

    private static String toID(String s) {
        while (s.length() < 6) {
            s = "0" + s;
        }
        return s;
    }

    private static class City {
        private int prefecture;
        private int year;

        public City(int prefecture, int year) {
            this.prefecture = prefecture;
            this.year = year;
        }
    }

}


Measured memory_bytes: 109692
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;
using std::min;
using std::max;

using llint = long long int;

int main()
{
	llint N, A,B;
	cin >> N >> A >> B;
	llint d = std::abs(A-B);
	if(d % 2 == 0){
		cout << d / 2<< endl;
	}
	else{
		llint d = std::abs(A-B);

		llint s = std::min(A,B);
		llint t = std::max(A,B);
		if(N-t + 1 < s){
			llint u = s;
			s = N - t + 1;
			t = N - u + 1;
		}
	 	cout << s + (t - s - 1) / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N,K=gets.split.map &:to_i
W=$<.map &:to_i
l=0
r=$$**3
m=r/2
def a m
i=k=sum=0
while i<N
return if W[i]>m
sum+=W[i]
if m<sum
sum=W[i]
k+=1
end
i+=1
end
k<K
end
while l+1<r
a(m)?r=m :l=m
m=(l+r)/2
end
p r

Measured memory_bytes: 7032
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

//整数a,bの最大公約数を返す
//ユークリッドの互除法
long long gcd(long long a,long long b){
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}

int main(){
	int N,K;
	cin>>N>>K;
	int A[100001]={};
	int maxi=0;
	for(int i=0;i<N;i++){
		cin>>A[i];
		maxi=max(maxi,A[i]);
	}
	int G=gcd(A[0],A[1]);
	for(int i=2;i<N;i++){
		G=gcd(G,A[i]);
	}
	if(!(K%G) && maxi>=K)
		cout<<"POSSIBLE"<<endl;
	else
		cout<<"IMPOSSIBLE"<<endl;
	//cout<<G<<endl;
	return 0;
}

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

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

using namespace std;
using lint = long long;

int main(void)
{

    int A, B;
    cin >> A >> B;
    for(int i = 0; i <= 10000; i++){
        if((int)(i * 0.08) == A && (int)(i * 0.1) == B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,s,i,max,min,sum,ave;

  while(1){
    sum=0;
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d",&s);
      if(i==0){max=s;min=s;}
      if(s>=max)max=s;
      if(s<=min)min=s;
      sum+=s;
    }
    ave=(sum-max-min)/(n-2);
    printf("%d\n",ave);
  }

  return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  using ull = unsigned long long;
  ull x;
  cin >> x;

  ull ans = 0, n = 100;
  while (n < x) {
    ans++;
    n = n * 1.01;
  }

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

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

using namespace std;

#define MAXN 100100

typedef long long ll;

int v[MAXN];

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v[x]++;
  }
  int dif = 0;
  int even = 0;
  for (int i = 0; i < MAXN; i++) {
    if (v[i]) {
      dif++;
      if (v[i] % 2 == 0) even++;
    }
  }
  even %= 2;
  if (even) dif--;
  cout << dif << endl;
  return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int partition(int a[],int p,int r){
int x=a[r];
int i=p-1,j,no;
	for(j=p;j<r;j++){
		if(a[j]<=x){
		i++;
		no=a[i];
		a[i]=a[j];
		a[j]=no;
		}
	}
		no=a[i+1];
		a[i+1]=a[r];
		a[r]=no;
	return i+1;		
}

main(){
	int i,n,ind;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	ind=partition(a,0,n-1);
	for(i=0;i<n;i++){
		if(i==ind)
		printf("[%d] ",a[i]);
		else if(i==n-1)
		printf("%d\n",a[i]);
		else 
		printf("%d ",a[i]);
	}
	
	return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	cin>>n;
	vvi d(3,vi(n));
	vi s(n);
	rep(i,0,n){
		rep(j,0,3) cin>>d[j][i];
	}
	rep(i,0,3){
		int f[101]={};
		rep(j,0,n) f[d[i][j]]++;
		rep(j,0,n){
			if(f[d[i][j]]==1) s[j]+=d[i][j];
		}
	}
	rep(i,0,n) o(s[i]);
}

Measured memory_bytes: 1216
#include<iostream>
#include<vector>
using namespace std;
int main(){
  vector<int> vec(5);
  for(int i = 0; i < 5; i++){
    cin >> vec.at(i);
  }
  for(int i = 0; i < 5; i++) {
    if(vec.at(i) == 0){
      cout << i + 1 << endl;
    }
  }
}

Measured memory_bytes: 3624
iN = int(input())
iLim = int(iN**0.5) + 1

iMinMax = len(str(iN))
for i in range(iLim+1,0,-1):
    if iN % i == 0:
        iMax = len(str(max(i,iN//i)))
        if iMinMax < iMax :
            print(iMinMax)
            exit()
        else:
            iMinMax = iMax
print(iMinMax)


Measured memory_bytes: 3060