akhauriyash/Code-Regression huggingface dataset:
l=input().split()

a=int(l[0])
b=int(l[1])
c=int(l[2])

if a<=b and b<=c:
    print(str(a)+" "+str(b)+" "+str(c))
elif a<=c and b>=c:
    print(str(a)+" "+str(c)+" "+str(b))
elif b<=a and a<=c:
    print(str(b)+" "+str(a)+" "+str(c))
elif b<=c and a>=c:
    print(str(b)+" "+str(c)+" "+str(a))
elif c<=a and a<=b:
    print(str(c)+" "+str(a)+" "+str(b))
else:
    print(str(c)+" "+str(b)+" "+str(a))


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

void Main() {
    // input
    u_int64_t N;
    cin >> N;

    u_int64_t nums[100000+1];
    for (int i = 0; i <= 100000; i++) {
        nums[i] = 0;
    }

    u_int64_t sum = 0;
    for (u_int64_t i = 0; i < N; i++) {
        u_int64_t num;
        cin >> num;
        sum += num;
        nums[num]++;
    }


    u_int64_t Q;
    cin >> Q;
    for (u_int64_t i = 0; i < Q; i++) {
        u_int64_t B, C;
        cin >> B >> C;
            
        sum += nums[B] * (C - B);
        cout << sum << endl;
        nums[C] += nums[B];
        nums[B] = 0;
    }
    // translate


    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4328
#include <bits/stdc++.h>
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define MOD 1000000007
#define PSET(x,y) fixed<<setprecision(y)<<x
#define ll long long
#define ld long double
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define lop(i,a,b) for(ll i=a;i<b;i++)
#define lopr(i,a,b) for(ll i=a;i>=b;i--)
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define ff first
#define ss second
#define pi pair<int,int>
#define pll pair<ll, ll>
#define si set<int>
#define sll set<ll>
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
#define state tuple<int,int,int>
#define graph map<ll,list<ll>>

const ld PI = asin(1) * 2;
inline int sbt(int x){return __builtin_popcount(x);} //returns number of set bits

using namespace std;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif

#define SIZE 100010
int n,k;
int h[SIZE];
int dp[SIZE];

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    fast_io()
    
    cin>>n>>k;

    lop(i,1,n+1)
    	cin>>h[i];

	fill_n(dp,sizeof(dp)/sizeof(int),INT_MAX);
	dp[1]=0;
    lop(i,2,n+1){
    	lop(j,1,k+1){
    		int tp = i-j;
    		// deb(i,tp,dp[i]);
    		if(tp<1)
    			break;
    		
    		dp[i] = min(
    			dp[i],
    			dp[tp] + abs(h[i]-h[tp])
    			);
    	}    	
    }

    // lop(i,1,n+1)
    // 	cout<<"dp["<<i<<"] = "<<dp[i]<<endl;

    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#define MAX 30
#define NIL -1

struct Node {
  int parent, left, right;
};

Node T[MAX];
int D[MAX], H[MAX], S[MAX];

void setSibling(int u) {
  if (T[u].parent == NIL) {
    S[u] = -1;
  } else {
    if (T[T[u].parent].left != u && T[T[u].parent].left != NIL) {
      S[u] = T[T[u].parent].left;
    } else if (T[T[u].parent].right != u && T[T[u].parent].right != NIL) {
      S[u] = T[T[u].parent].right;
    } else {
      S[u] = -1;
    }
  }
}

void setDepth(int u, int d) {
  // これでuにNILが来ても安全！
  if (u == NIL) {
    return;
  }
  D[u] = d;
  // leftとrightの子どもたちは自分の深さp+1が設定される
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

int getHeight(int u) {
  int h1 = 0, h2 = 0;
  // 左に子がいる時
  if (T[u].left != NIL) {
    h1 = getHeight(T[u].left) + 1;
  }
  // 右に子がいる時
  if (T[u].right != NIL) {
    h2 = getHeight(T[u].right) + 1;
  }
  if (h1 > h2) {
    return H[u] = h1;
  } else {
    return H[u] = h2;
  }
}

void printNode(int u) {
  // ここで次数を計算する
  int degree = 0;
  if (T[u].left != NIL) {
    degree++;
  }
  if (T[u].right != NIL) {
    degree++;
  }
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].parent << ", ";
  cout << "sibling = " << S[u] << ", ";
  cout << "degree = " << degree << ", ";
  cout << "depth = " << D[u] << ", ";
  cout << "height = " << H[u] << ", ";

  string type = "";
  if (T[u].parent == NIL) {
    type = "root";
  } else if (T[u].left != NIL || T[u].right != NIL) {
    type = "internal node";
  } else {
    type = "leaf";
  }
  cout << type << endl;
}

int main() {

  int n;
  cin >> n;
  // 初期化
  for (int i = 0; i < n; i++) {
    T[i].parent = T[i].left = T[i].right = NIL;
  }
  // 一行ずつ読み込む
  for (int i = 0; i < n; i++) {
    int v, left, right;
    cin >> v >> left >> right;
    // とりあえず左から右に受け流す〜
    // -1が入る可能性があるが、それはNIL扱い
    if (left != NIL) {
      T[v].left = left;
      T[left].parent = v;
    }
    if (right != NIL) {
      T[v].right = right;
      T[right].parent = v;
    }
  }

  int r;
  for (int i = 0; i < n; i++) {
    setSibling(i);
    if (T[i].parent == NIL) {
      r = i;
    }
  }

  setDepth(r, 0);
  getHeight(r);

  for (int i = 0; i < n; i++) {
    printNode(i);
  }

}



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

const int INF = (1<<29);

const int dy[2][6] = {{1,0,-1,-1,-1,0},{1,1,0,-1,0,1}};
const int dx[6] = {0,1,1,0,-1,-1};
int wmin,hmin,wmax,hmax;

class state{
public:
  int y,x,t,cost;
  state(int y=0, int x=0, int t=0, int c=0):y(y),x(x),t(t),cost(c){}
  bool operator < (const state &s) const {
    return cost > s.cost;
  }
};

bool check(int y, int x){
  if(y < hmin || y > hmax) return false;
  if(x < wmin || x > wmax) return false;
  return true;
}

int main(){
  int sx,sy,gx,gy;
  while(cin >> sx >> sy >> gx >> gy){
    sx += 100;
    sy += 100;
    gx += 100;
    gy += 100;
    int n, h, w, a[6][201][201], ans=INF;
    state u(sy,sx,0,0), v;
    queue<state> Q;
    for(int i=0;i<6;i++) for(int j=0;j<201;j++) for(int k=0;k<201;k++) a[i][j][k] = INF;
    a[0][sy][sx] = 0;

    cin >> n;
    for(int i=0;i<n;i++){
      int x,y;
      cin >> x >> y;
      x += 100;
      y += 100;
      for(int j=0;j<6;j++) a[j][y][x] = -1;
    }
    cin >> w >> h;
    wmin = 100 - w;
    wmax = 100 + w;
    hmin = 100 - h;
    hmax = 100 + h;

    for(Q.push(u); !Q.empty();){
      u = Q.front();
      Q.pop();
      if(u.y == gy && u.x == gx || ans <= u.cost){
	ans = min(ans,u.cost);
	continue;
      }
      
      int next = abs((u.x-100) * (u.y-100) * u.t) % 6;
      v = u;
      v.y += dy[u.x%2][next];
      v.x += dx[next];
      v.t++;
      if(check(v.y,v.x) && a[v.t%6][v.y][v.x] > v.cost){
	a[v.t%6][v.y][v.x] = v.cost;
	Q.push(v);
      }

      v = u;
      v.t++;
      v.cost++;
      if(check(v.y,v.x) && a[v.t%6][v.y][v.x] > v.cost){
	a[v.t%6][v.y][v.x] = v.cost;
	Q.push(v);
      }

      for(int i=0;i<6;i++){
	v = u;
	v.y += dy[u.x%2][i];
	v.x += dx[i];
	v.t++;
	v.cost++;
	if(check(v.y,v.x) && a[v.t%6][v.y][v.x] > v.cost){
	  a[v.t%6][v.y][v.x] = v.cost;
	  Q.push(v);
	}
      }
    }

    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
  }
}

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

const int mod = 1e9 + 7;

int main() {
    int n, m, res;
    cin >> n >> m;
    if (n > m) swap(n, m);
    if (n < m - 1) {
        cout << 0; return 0;
    }
    res = 1;
    for (int i = 1; i <= n; ++i) res = 1LL * i * res % mod;
    for (int i = 1; i <= m; ++i) res = 1LL * i * res % mod;
    if (n == m) res = 2 * res % mod;
    cout << res;
}


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

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]++;
  }
  int ans = 0;
  for (auto e : mp) {
    if (e.second % 2 == 1) ans++;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  using BS = bitset<64>;
  int n;
  cin>>n;
  vector<BS> ms(n);
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int x;
      cin>>x;
      ms[i].set(x);
    }
  }
  
  BS b(0);

  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int t,x;
    cin>>t>>x;
    if(t==0) cout<<b[x]<<endl;
    if(t==1) b|= ms[x];
    if(t==2) b&=~ms[x];
    if(t==3) b^= ms[x];
    if(t==4) cout<<((b&ms[x])==ms[x])<<endl;
    if(t==5) cout<<(b&ms[x]).any()<<endl;
    if(t==6) cout<<(b&ms[x]).none()<<endl;
    if(t==7) cout<<(b&ms[x]).count()<<endl;
    if(t==8) cout<<(b&ms[x]).to_ullong()<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3124
x = int(input())

v = [0] * 200
mv = [0] * 200
for i in range(200):
    v[i] = i*i*i*i*i
    mv[i] = i*i*i*i*i*(-1)

result_a = 0
result_b = 0
for i in range(200):
    for j in range(200):
        if(v[i] - v[j] == x):
            result_a = i
            result_b = j
        if(v[i] - mv[j] == x):
            result_a = i
            result_b = j*(-1)

print(result_a, result_b)

Measured memory_bytes: 9216
import sys

while(1):
    H, W = map(int, raw_input().split())
    if(H == 0 and W == 0):
        break
    else:
        for i in range(H):
            for j in range(W):
                if(i%2==0 and j%2==0):
                    sys.stdout.write("#")
                elif(i%2==0 and j%2==1):
                    sys.stdout.write(".")
                elif(i%2==1 and j%2==0):
                    sys.stdout.write(".")
                else:
                    sys.stdout.write("#")
            print
        print

Measured memory_bytes: 4224
from collections import defaultdict
import sys
input = sys.stdin.readline

H, W, N = map(int, input().split())
ans = [0] * 10
ans[0] = (H - 2) * (W - 2)
# print (ans)
tmplst = [-1, 0, 1]
dic = defaultdict(int)
for _ in range(N):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for i in tmplst:
        for j in tmplst:
            if 0 <= a + i <= H - 1 and 0 <= b + j <= W - 1: #範囲に入っている
                tmp = dic[(a + i, b + j)]
                dic[(a + i, b + j)] += 1
                if 1 <= a + i <= H - 2 and 1 <= b + j <= W - 2:
                    ans[tmp] -= 1
                    ans[tmp + 1] += 1


print (*ans, sep = '\n')

Measured memory_bytes: 166908
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll N;
    cin >> N;

    ll M = N % 10;

    switch(M){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
    }

    return 0;
}


Measured memory_bytes: 3632
<?php
fscanf(STDIN, "%d", $n);
$p = explode(" ", trim(fgets(STDIN)));
$cnt = 0;
for ($i = 0; $i < $n; $i++) if ($p[$i] != $i + 1) $cnt++;
echo ($cnt == 0 || $cnt == 2) ? "YES" : "NO";
?>

Measured memory_bytes: 4604
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		for(int t=1;t<=n;t++){	//n cases
			int outcnt=0,score=0,runner=0;
			while(in.hasNext()){
				//System.out.println(outcnt+" "+score+" "+runner);
				String s=in.next();
				if(s.charAt(1)=='I'){	//HIT
					runner++;
					if(runner>3){
						score++;
						runner--;
					}
				}
				else if(s.charAt(1)=='U'){	//OUT
					outcnt++;
					if(outcnt==3){
						System.out.println(score);
						break;
					}
				}
				else{	//HOMERUN
					score+=(runner+1);
					runner=0;
				}
			}
		}
		in.close();
	}
}

Measured memory_bytes: 25884
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(b >= a*c) cout << c << endl;
    else cout << b/a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int x, y;
    cin >> x >> y;
    int ans = 0;
    if(x < 4){
        ans += (4-x)*100000;
    }
    if(y < 4) ans += (4-y)*100000;
    if(x==1&&y==1) ans += 400000;
    cout << ans << endl;
}

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

const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;



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

  if (n < 10) {
    cout << n << endl;
    return 0;
  }

  if (n < 100) {
    cout << 9 << endl;
    return 0;
  }

  if (n < 1000) {
    cout << 9 + n - 99 << endl;
    return 0;
  }

  if (n < 10000) {
    cout << 9 + 999 - 99 << endl;
    return 0;
  }

  if (n < 100000) {
    cout << 9 + 999 - 99 + n - 9999 << endl;
    return 0;
  }

  cout << 9 + 999 - 99 + 99999 - 9999 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 5

int comp(const void *, const void *);

int main(void) {
    int i, ary[MAX];
    for(i = 0; i < MAX; scanf("%d", &ary[i++]));
    qsort((void *)ary, MAX, sizeof(int), comp);
    for(i = 0; i < MAX; printf("%d%s", ary[i++], -~i - MAX ? " " : "\n"));
    return 0;
}

int comp(const void *x, const void *y) {
    return *(int *)y - *(int *)x;
}

Measured memory_bytes: 600
def cul(x,y):
    if x%2 == 0:
        return cul(int(x/2),y+1)
    else:
        return y

N = int(input())
A = list(map(int,input().split(" ")))
count = 0
for i in range(len(A)):
    count += cul(A[i],0)
print(count)


Measured memory_bytes: 4148
import { readFileSync } from 'fs'

function main(input: string[]) {
  let a = Number(input[0])
  let ans = a + a * a +  a * a * a
  console.log(ans)
}

let lines: string[] = [];
const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', function (line: string) {
  lines.push(line);
});
reader.on('close', function () {
  main(lines)
});


Measured memory_bytes: 30120
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 50

int table[MAX];

void shuffle(int n, int c) {
    int mid = n / 2;
    int b[mid], a[n - mid];
    for (int i = 0; i < mid; i++) {
        b[i] = table[i];
    }
    for (int i = mid; i < n; i++) {
        a[i - mid] = table[i];
    }

    int count = 0;
    int p = 0;
    while (count * c <= n) {
        for (int i = count * c; i < min((count + 1) * c,  n - mid); i++) {
            table[p++] = a[i];
        }
        for (int i = count * c; i < min((count + 1) * c, mid); i++) {
            table[p++] = b[i];
        }
        count++;
    }
}

int main() {
    int n, r;
    while (cin >> n >> r) {
        for (int i = 0; i < n; i++) {
            table[i] = i;
        }
        for (int i = 0; i < r; i++) {
            int c;
            cin >> c;
            shuffle(n, c);
        }
        cout << table[n - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2956
N = gets.to_i
$a = gets.split.map(&:to_i)
$a.unshift(nil)

def max_heapify(i)
  l = 2 * i
  r = 2 * i + 1

  if l <= N && $a[l] > $a[i]
    largest = l
  else
    largest = i
  end

  if r <= N && $a[r] > $a[largest]
    largest = r
  end

  if largest != i
    $a[i], $a[largest] = $a[largest], $a[i]
    max_heapify(largest)
  end
end

(N / 2).downto(1) do |i|
  max_heapify(i)
end

puts " #{$a.compact.join(' ')}"


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

int main(){
  
  int N;
  cin >>N;
  double sum=0;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    int x;
    cin >> A[i];
    sum += double(1)/A[i];
  }
  cout << double(1)/sum << endl;
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (group, sort)
import Data.Bool (bool)

main :: IO ()
main = do
  (n : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    as' = group . sort $ as
  putStrLn . bool "NO" "YES" $ length as' == n

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 32124
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int A, B;
    string S;
    cin >> A >> B;
    cin >> S;
    bool flag = true;
    if(S[A] != '-') flag = false;
    REP(i, A) {
        if(S[i] == '-') flag = false;
    }
    FOR(i, A+1, A+B+1) {
        if(S[i] == '-') flag = false;
    }
    if(flag) puts("Yes");
    else puts("No");
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  vector<int> v(n);
  REP(i, n) {
    cin >> v[i];
  }

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

  LL ans = accumulate(v.begin(), v.end() - 1, 0);

  if (v[n - 1] < ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int		main(void)
{
	int		a;
	cin >> a;
	if (a == 1)
		cout << "Hello World" << endl;
	else
	{
		int		b, c;
		cin >> b >> c;
		cout << b + c << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, P;

  std::string S;

  std::vector<std::tuple<std::string, int, int>> a;

  std::cin >> N;

  for (int i = 0; i < N; i ++) {
    std::cin >> S >> P;

    a.emplace_back(S, P, i);
  }

  std::sort(ALL(a), [](const std::tuple<std::string, int, int>& a,
                       const std::tuple<std::string, int, int>& b) {
                      
                      const std::string& sa = std::get<0>(a);
                      const std::string& sb = std::get<0>(b);

                      int pa = std::get<1>(a);
                      int pb = std::get<1>(b);
                      
                      if (sa != sb)
                        return sa < sb;
                      
                      return pa > pb;
                    });

  for (int i = 0; i < N; i ++)
    std::cout << std::get<2>(a[i]) + 1 << std::endl;

  return 0;
}


Measured memory_bytes: 256
import           Data.Functor
import           Text.Printf

main :: IO ()
main = solve =<< fmap read . words <$> getLine

solve :: [Integer] -> IO ()
solve [a,b] = printf "a %s b\n" operator
  where
    operator = case a `compare` b of
      EQ -> "=="
      LT -> "<"
      GT -> ">"



Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int n;
P x[100010],y[100010];
int f[100010],s[100010];
bool C(int p)
{
    int mi=x[0].fi,mx=x[n-1].fi;
    memset(f,0,sizeof(f));
    memset(s,0,sizeof(s));
    f[x[0].sec]=2;
    for(int i=0;i<n;i++)
    {
        if(abs(mi-x[i].fi)>p&&abs(mx-x[i].fi)>p)return false;
        if(abs(mi-x[i].fi)>p)f[x[i].sec]=1;
        if(abs(mx-x[i].fi)>p)f[x[i].sec]=2;
    }
    mi=y[0].fi,mx=y[n-1].fi;
    s[y[0].sec]=2;
    for(int i=0;i<n;i++)
    {
        if(abs(mi-y[i].fi)>p&&abs(mx-y[i].fi)>p)return false;
        if(abs(mi-y[i].fi)>p)s[y[i].sec]=1;
        if(abs(mx-y[i].fi)>p)s[y[i].sec]=2;
    }
    int either=0,both=0;
    for(int i=0;i<n;i++)
    {
        if(f[i]==0||s[i]==0)both++;
        else if(f[i]!=s[i])either++;
    }
    return (either==0||both+either==n);
}
int main()
{
    cin >> n;
    for(int i=0;i<n;i++)
    {
        int tx,ty;
        cin >> tx >> ty;
        x[i]=mp(tx+ty,i);
        y[i]=mp(tx-ty,i);
    }
    sort(x,x+n);
    sort(y,y+n);
    int l=0,r=INF;
    while(r-l>1)
    {
        int mid=(l+r)/2;
        if(C(mid))r=mid;
        else l=mid;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N,result,amari;
  int output;
  
  cin>>N;
  
  result=N/2;
  amari=N%2;
  
  if(amari==1){
    output=result+1;
  }
  else{
    output=result;
  } 
  
  cout<<output;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<endl
#define AA(i) cout<<i<<endl
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
  int N; cin >> N;
  vector<ll> A(N);
  int i;
  ll ans=1,aans;
  rep(i,N) cin >> A[i];
  sort(A.begin(), A.end());
  rep(i,N-1){
    ans *= A[i];
    if(A[i] == 0){
      ans = 0;
      break;
    }
    if(1000000000000000000 / ans < A[i+1]){
      ans = -1;
      break;
    }
  }
  if(ans>0)ans *= A[N-1];
  AA(ans);
  return 0;
}


Measured memory_bytes: 3980
K = int(input())
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
ans = A[K-1]

print(ans)

Measured memory_bytes: 3060
#include <iostream>

int main()
{
    int n = 0;
    std::cin >> n;

    int m = 0;
    std::cin >> m;

    long long total = 0;
    for (auto count = 0; count < m; ++count)
    {
        int cost = 0;
        std::cin >> cost;
        total += cost;
    }

    if (n >= total)
    {
        std::cout << n - total;
    }
    else
    {
        std::cout << -1;
    }
    
}

Measured memory_bytes: 3632
N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))
from collections import Counter
D=Counter(D)
dic_D={}
for i in D.most_common():
  dic_D[i[0]]=i[1]
T=Counter(T)
ret = 'YES'
for i in T.most_common():
  if i[0] in dic_D:
    if dic_D[i[0]]<i[1]:
      ret = 'NO'
      break
  else:
    ret = 'NO'
    break
print(ret)

Measured memory_bytes: 79876
def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = 0
    for i in range(N):
        if A[i] % 2 == 1: count +=1
    if count % 2 == 0:
        return "YES"
    return "NO"

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 14104
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	x=0;char c=getchar();bool f=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
	if(x<0){putchar('-'),write(-x);}
	else{if(x>9)write(x/10);putchar('0'+x%10);}
}

const int N=5e5+5;
int n,a[N];
char s[N];
long long ans;

signed main(){
	scanf("%s",s);
	n=strlen(s);
	for(int i=0;i<n;i++) if(s[i]=='<')
		a[i+1]=a[i]+1;
	for(int i=n-1;i>=0;i--) if(s[i]=='>')
		a[i]=max(a[i],a[i+1]+1);
	for(int i=0;i<=n;i++) ans+=a[i];
	write(ans);
}


Measured memory_bytes: 2688
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int num = Integer.parseInt(br.readLine());
			System.out.println((int)Math.pow(num,3));
		}catch(IOException e){
			System.err.println(e);
		}
	}
}

Measured memory_bytes: 16880
#include <iostream>
#include <cmath>
#include <vector>
using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::pair;



int main(void)
{
    int32_t n, a, b;
    cin >> n >> a >> b;

    int32_t p[n];
    int32_t mondai1 = 0;
    int32_t mondai2 = 0;
    int32_t mondai3 = 0;
    for (uint32_t i = 0; i < n; i++) {
        cin >> p[i];

        if (p[i] <= a) {
            mondai1++;
        } else if (p[i] <= b) {
            mondai2++;
        } else {
            mondai3++;
        }
    }

    if (mondai1 <= mondai2 && mondai1 <= mondai3) {
        cout << mondai1 << endl;
    } else if (mondai2 <= mondai1 && mondai2 <= mondai3) {
        cout << mondai2 << endl;
    } else {
        cout << mondai3 << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;


int v[27];

int main(){
    INIT;
    string s; cin >> s;
    REP(i,s.size()) {
        v[(s[i]-'A')]++;
    }
    int cnt = 0;
    REP(i,27) {
        if(v[i] == 2) cnt++;
    }
    if(cnt == 2) cout << "Yes";
    else cout << "No";
}

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

#include <iostream> 
#include <string> 

int main()
{
	int n, a, b;
	string s;
	string::iterator it;
	cin >> n >> a >> b;
	getline(cin, s);
	getline(cin, s);

	int tot = a+b;
	int f = b;
	for(it=s.begin();it!=s.end();it++)
	{
		if(*it=='a' && tot){
			cout << "Yes" << endl;
			tot--;
		}
		else if(*it=='b' && f && tot){
			cout << "Yes" << endl;
			f--;
			tot--;
		}
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 896
#include <stdio.h>
int main()
{
	int n,b,f,r,v,a[3][10]={0},e[3][10]={0},c[3][10]={0},d[3][10]={0};
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		switch(b){
		case 1:
			a[f-1][r-1]=a[f-1][r-1]+v;
			break;
		case 2:
			e[f-1][r-1]=e[f-1][r-1]+v;
			break;
		case 3:
			c[f-1][r-1]=c[f-1][r-1]+v;
			break;
		case 4:
			d[f-1][r-1]=d[f-1][r-1]+v;
			break;
		}
	}
	for(int i=0;i<3;i++){
		for(int j=0;j<10;j++){
			printf(" %d",a[i][j]);
		}
		printf("\n");
	}
	printf("####################\n");
	for(int i=0;i<3;i++){
		for(int j=0;j<10;j++){
			printf(" %d",e[i][j]);
		}
		printf("\n");
	}
	printf("####################\n");
	for(int i=0;i<3;i++){
		for(int j=0;j<10;j++){
			printf(" %d",c[i][j]);
		}
		printf("\n");
	}
	printf("####################\n");
	for(int i=0;i<3;i++){
		for(int j=0;j<10;j++){
			printf(" %d",d[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1044
#include <iostream>
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

void findit(vector<vector<char>> &arr)
{
         int m=arr.size();
        int n=arr[0].size();
        int dp[n];
       
        dp[0]=1;
        
        for(int i=1;i<n;i++)
        {
           if(dp[i-1]==1 && arr[0][i]=='.')
           {
               dp[i]=1;
           }
            else
            {
                dp[i]=0;
            }
        }
        
        for(int i=1;i<m;i++)
        {
           for(int j=0;j<n;j++)
           { 
               if(arr[i][j]=='.')
               {
                   int right= j>0 ? dp[j-1] : 0;
                   int down=dp[j];
                   dp[j]= ( (right%mod)  + (down)%mod) %mod;
            
               }
               else
               {
                   dp[j]=0;
               }
               
           }
        }
        
        cout<<dp[n-1];
}

int main() 
{

   int m;
   cin>>m;
   int n;
   cin>>n;
   
   vector<vector<char>> v ( m, vector<char>(n) );
   
   for(int i=0;i<m;i++)
   {
       for(int j=0;j<n;j++)
       {
           cin>>v[i][j];
       }
   }
   findit(v);
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
    if you have any question about any part of my code,
    please don't shy to ask anytime :)
*/



void solve()
{
    string x;
    cin>>x;
    if(x=="ABC")
    {
        cout<<"ARC"<<endl;
    }
    else
    {
        cout<<"ABC"<<endl;
    }
    
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3664
import java.util.ArrayList;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();

		ArrayList<Integer>array = new ArrayList<Integer>();

		for(int i = 0 ; i < K ; i++) {
			int d = scanner.nextInt();
			for(int j = 0 ; j < d ; j++) {
				int A = scanner.nextInt();
				if(!array.contains(A)) {
					array.add(A);
				}
			}
		}

		System.out.println(N - array.size());

		scanner.close();

	}

}


Measured memory_bytes: 46156
#include <iostream>
#include<string>
#include<list>
#include<algorithm>
#include<cstdio>
using namespace std;


int main(){
    
    int n,t;
    cin>>n;
    list<int> V;
    string com;
    for(int i=0;i<n;i++){
        
        cin>>com;
        
        if(com[0]=='i'){
            cin>>t;
            V.push_front(t);
            
        }else if(com[6]=='F'){
                V.pop_front();
                //deleteLast
        }else if(com[6]=='L'){
                V.pop_back();
        }else if(com[0]=='d'){
                cin>>t;
                for(list<int>::iterator it = V.begin();it!=V.end();it++){
                    if(*it==t){
                        V.erase(it);
                        break;
                    }
                }
            }
    }
    int i=0;

    for(list<int>::iterator it = V.begin();it != V.end();it++){
       if(i++) cout<<' ';
       // printf("%d",*it);
    cout<<*it;
        }
        
    
    printf("\n");




return 0;
}



Measured memory_bytes: 34276
n , m = map(int, input().split())
lis = [int(input()) for _ in range(m)]
mod = 10**9+7

ans =[1] + [1] + [-1] * (n-1)

for i in lis:
    ans[i] = 0


for i in range(2, n+1):
    if ans[i] != 0:
        ans[i] = (ans[i-1] + ans[i-2]) % mod

print(ans[n])

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

int main(){
	//入力機構
	std::vector<int> A;
	size_t N;
	std::cin>>N;
	A.reserve(N);
	for(size_t i=0;i<N;i++){
		int num;
		std::cin>>num;
		A.push_back(num);
	}
	//処理機構
	//繰り上がりが1回でも起きると条件を満たさなくなるのを利用して、繰り上がりが起きない組み合わせを探す
	//更に、i~jまでが条件を満たすなら、i+1~jまでも条件を満たすのを利用して、探索回数を減らす
	//これらを用いて全探索
	size_t ans=0;
	size_t saveJ=0;//前回の探索でどの位置まで探索したかを保存する
	int saveXOR=0;//前回の探索でxorがどんな値になったか
	for(size_t i=0;i<N;i++){
		int xorNum=0;
		size_t j=0;//探索のindex位置。
		//前の計算結果を利用して、計算回数を減らす
		if(saveJ>1){
			j=saveJ-1;//前回のループの先頭と除く。前回のループの末尾に当たるから探索を始める
			xorNum=saveXOR-A[i-1];//前回のループの先頭の数値を引けばA[i+j]~A[i+j-1]の和が求まる
			ans+=(saveJ-1);//処理を飛ばした個数分、条件を満たす組み合わせの数を増やす
		}
		//探索
		for(;i+j<N;j++){
			if((xorNum&A[i+j])==0){
				//繰り上がりが起きるかはANDが0になるかどうか。0であった場合は、xorNumをAND計算して、探索を続ける。
				xorNum=xorNum+A[i+j];
				ans++;//組み合わせを1つ増やす
			} else{
				//繰り上がりがあった場合は終了
				break;
			}
		}
		//探索をラクにするための処理
		saveJ=j;
		saveXOR=xorNum;
	}

	//出力機構
	std::cout<<ans<<std::endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int f[5009];
int a[5009];
ll sum=0;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        sum+=min(a[i],k);
        a[i]=min(a[i],k);//这里可以自己验证一下，如果a[i]>k,令a[i]=k没有影响。否则如果a[i]>k不能传递。

    }
    sort(a+1,a+1+n);
    f[0]=1;
    for(int i=n;i>=0;i--)
    {
        int flag=1;
        for(int j=k-1;j>=k-sum&&j>=0;j--)
        {
            if(f[j])
            {
                flag=0;
            }
        }
        if(flag)
        {
            cout<<i<<endl;
            return 0;
        }
        for(int j=k-1;j>=a[i];j--)f[j]|=f[j-a[i]];//因为从i这个位置向前移动了一位，所以只要看j-a[i]是否出现了。
        sum-=a[i];
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
 

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


vector<int> b(n);

rep(i,n)  cin>>b[i]; 
   


int now =1;
   for(auto itr = b.begin(); itr != b.end(); ++itr)
    {
        if(*itr == now) now ++; 

    }

if(now ==1) cout<<-1<<endl;

else cout<<n-now+1<<endl;

}


Measured memory_bytes: 1024
N = int(input())
H_LIST = list(map(int, input().split()))

count = 0
for i in range(N):
    j = 0
    while (i - j) >= 0:
        if i == j:
            count += 1
            break
        if H_LIST[i] < H_LIST[j]:
            break
        j += 1
print(count)

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
	long long int A, B;
	scanf("%lld%lld",&A,&B);
	long long int a = A, b = B, q = 1, c;
	if (a < b) {
		c = a;
		a = b;
		b = c;
	}
	while(q != 0) {
			q = a % b;
			a = b, b = q;
	}
	printf("%lld", A * B / a);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, N, A[200001];
	long long K;
	scanf("%d %lld", &N, &K);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	A[0] = 0;
	
	list *L[200001] = {}, d[200002], *p;
	d[0].v = 0;
	d[0].next = L[0];
	L[0] = &(d[0]);
	d[N+1].v = 0;
	d[N+1].next = NULL;
	for (i = N; i >= 1; i--) {
		d[i].v = i;
		d[i].next = L[A[i]];
		L[A[i]] = &(d[i]);
	}

	int j, k, l, move[200001];
	for (i = 0; i <= 200000; i++) move[i] = -1;
	for (i = 0, k = 0; move[i] == -1; i = move[i], k++) {
		for (p = &(d[L[i]->v + 1]); p->next != NULL; p = &(d[p->next->v + 1]));
		move[i] = A[p->v];
	}
	for (j = 0, l = 0; j != i; j = move[j], l++, k--);
	
	int s[200001];
	if (K >= l) K = (int)((K - l) % k + l);
	for (i = 0, j = 1; j < K; i = move[i], j++);
	j = L[i]->v + 1;
	k = 0;
	while (j <= N) {
		if (d[j].next == NULL) s[k++] = A[j++];
		else j = d[j].next->v + 1;
	}
	for (i = 0; i < k - 1; i++) printf("%d ", s[i]);
	if (k > 0) printf("%d\n", s[k-1]);
	fflush(stdout);
	return 0;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if (a+b > c+d){
    cout << "Left" << endl;
  }
  else if(a+b == c+d){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
s = input()
A = [int(s[0]), int(s[1]), int(s[2]), int(s[3])]

for i in range(8):
    b = format(i, "03b")
    S = A[0]
    for j in range(3):
        if b[j] == "0":
            S += A[j + 1]
        else:
            S -= A[j + 1]
    if S == 7:
        break

op = ["+", "-"]
ans = s[0] + op[int(b[0])] + s[1] + op[int(b[1])] + s[2] + op[int(b[2])] + s[3] + "=7"
print(ans)

Measured memory_bytes: 9156
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 6005
#define F first
#define S second
using namespace std;

int n, t, mx, d[N];
pair<int, int> a[N];
int main()
{
	int i, j;
	cin >> n >> t;
	for (i = 0; i < n; i++) scanf("%d %d", &a[i].F, &a[i].S);
	sort(a, a + n);
	for (i = 0; i < n; i++) {
        for (j = t - 1; j >= 0; j--) {
			d[j + a[i].F] = max(d[j + a[i].F], d[j] + a[i].S);
        }
	}
	for (i = 0; i < N; i++) mx = max(mx, d[i]);
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		boolean b1 = false;
		boolean b2 = false;
		boolean b3 = false;
		boolean b4 = false;

		if(x-r < 0 || W < x+r) {
		//	System.out.println("No");
			b3 = true;
		}
		if(y-r < 0 || H < y+r) {
		//	System.out.println("No");
			b4 = true;
		}

		if(x-r >= 0 && W >= x+r){
		//	System.out.println("Yes");
			b1 = true;
		}
		if(y-r >= 0 && H >= y+r){
		//	System.out.println("Yes");
			b2 = true;
		}
		if(b1 && b2) {
			System.out.println("Yes");
		}
		if(b3 || b4) {
			System.out.println("No");
		}
	}
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<int64_t> a(n), b(n);
    for (auto&& aa : a) {
        cin >> aa;
    }
    for (auto&& bb : b) {
        cin >> bb;
    }

    for (auto i : irange(0L, n)) {
        if (b[i] != a[i] && 2 * b[i] >= a[i]) {
            cout << -1 << endl;
            return 0;
        }
    }

    vector<vector<vector<bool>>> table(
            51, vector<vector<bool>>(51, vector<bool>(51)));
    for (auto i : irange(0L, 51L)) {
        table[0][i][i] = true;
    }
    for (auto i : irange(1L, 51L)) {
        for (auto j : irange(0L, 51L)) {
            for (auto k : irange(0L, 51L)) {
                // i以下の数のみでj->kにできるか
                table[i][j][k] = (table[i - 1][j][k] || table[i - 1][j % i][k]);
            }
        }
    }

    vector<vector<bool>> c(n, vector<bool>(51));
    for (auto i : irange(0L, n)) {
        c[i][a[i]] = true;
    }
    int64_t ans = 0;
    for (auto i : irange(1L, 51L) | reversed) {
        bool required = false;
        for (auto j : irange(0L, n)) {
            bool j_required = true;
            for (auto k : irange(0L, 51L)) {
                if (!c[j][k]) {
                    continue;
                }

                if (!table[i][k][b[j]]) {
                    c[j][k] = false;
                    continue;
                }

                if (table[i - 1][k][b[j]]) {
                    j_required = false;
                }
            }
            required |= j_required;
        }

        if (!required) {
            continue;
        }

        ans += 1L << i;
        for (auto j : irange(0L, n)) {
            for (auto k : irange(0L, 51L)) {
                if (!c[j][k]) {
                    continue;
                }

                if (table[i - 1][k % i][b[j]]) {
                    c[j][k % i] = true;
                }
            }
        }
    }

    cout << ans << endl;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    int x, digit=0;
    cin >> n;
    for (int i=sqrt(n); i > 0; i--){
        if (n % i == 0){
            x = n / i;
            break;
        }
    }
    while (x > 0){
        x /= 10;
        digit++;
    }
    cout << digit << endl;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    bs <- B.getLine
    print $ solve n bs

solve :: Int -> B.ByteString -> Int
solve n bs = sum [M.findWithDefault 0 pair rightFreq| pair<-lefts]
  where
    (left, right) = B.splitAt n bs
    lefts = pairs n left
    rights = map swap . pairs n $ B.reverse right
    !rightFreq = foldl' (\m pair -> M.insertWith (+) pair 1 m) M.empty rights

pairs :: Int -> B.ByteString -> [(B.ByteString, B.ByteString)]
pairs n bs = [divide i bs|i<-[0..2^n-1]]
  where
    divide :: Int -> B.ByteString -> (B.ByteString, B.ByteString)
    divide i bs = (xs, ys)
      where
        (xis, yis) = partition (testBit i) [0..n-1]
        !xs = B.pack $ map (B.unsafeIndex bs) xis
        !ys = B.pack $ map (B.unsafeIndex bs) yis



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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n;
	cin >> n;

	string w[n];
	rep(i, n) cin >> w[i];

	rep(i, n){
		rep(j, i){
			if(w[j] == w[i]){
				cout << "No" << endl;
				return 0;
			}
		}
		if(i > 0 && w[i-1][w[i-1].size()-1] != w[i][0]){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let s: String = read();
 
    match &s[..] {
        "Sunny" => println!("Cloudy"),
        "Cloudy" => println!("Rainy"),
        "Rainy" => println!("Sunny"),
        _ => (),
    };
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main(){
  int A, B;
  cin >> A >> B;
  REP(i, 10) {
    int price = B * 10 + i;
    if(price * 2 / 25 == A) {
      cout << price << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

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

int main() {
  int N, X;
  cin >> N >> X;
	
  vector<int> L(N+1);
  L.at(0) = 0;
  for(int i = 0; i < N; i++){
    int x; cin >> x;
    L.at(i+1) = L.at(i) + x;
  }
  
  int count = 0;
  for(int i = 0; i <= N; i++){
    if(L.at(i) <= X){
        count ++;
      }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 998244353;

int main(){
  int n;
  
  cin >> n;
  vector<tuple<string ,int,int>> vec;
  rep(i,n) {
    string s;
    int p;
    cin >> s >> p;
    p*=(-1);
    vec.push_back(make_tuple(s,p,i+1));
  }
  sort(all(vec));
  for(auto res:vec){
    cout << get<2>(res) << endl;
  } 
}

Measured memory_bytes: 256
s = gets.chomp.reverse
t = gets.chomp.reverse

pattern = ""
t.size.times do |i|
  pattern << "[\?#{t[i]}]"
end

match = []
t.size.times do
  match << s.sub!(/#{pattern}/,t)
end


puts (match.compact.empty?) ? "UNRESTORABLE" : s.gsub(/\?/,"a").reverse


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

int main() {
    int h[5];
    int i;
    for(i=0;i<5;i++){
        cin >> h[i];
        if(h[i] == 0){
            cout << i+1 << '\n';
            break;
        }
    }
}

Measured memory_bytes: 3560
#include <stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if (-100<=a&&a<=100&&-100<=b&&b<=100&&-100<=c&&c<=100)
	{if (a<=c&&c<=b)
        printf("Yes\n");
    else
        printf("No\n");
	}
    return 0;

}


Measured memory_bytes: 128