akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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 (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N;
    cin >> N;

    int a;
    deque<int> v;
    REP(_,N) {
        //cout << "v: " ; printv(v);
        cin >> a;
        int p = distance(v.begin(), lower_bound(ALL(v), a));   
        //cout << "p: " << p << endl;
        //cout << "a: " << a << endl;
        //cout << endl;
        if (p == 0) {
            v.emplace_front(a);
        } else {
            v[p-1] = a;
        }
    }
    
    cout << v.size() << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;


ll
gcd(ll a, ll b) {
  if (b < a)
    return gcd(b, a);

  if (a == 0)
    return b;

  return gcd(b % a, a);
}

void
solve() {
  int n, m;
  cin>>n>>m;

  vector<ll> a(n);
  ll value = 1;
  int last = -1;
  bool valid = true;
  for (int i=0; i<n; i++) {
    cin>>a[i];

    value /= gcd(value, a[i]/2);
    value *= a[i] / 2;

    int temp = a[i];
    int cnt = 0;
    while (temp % 2 == 0) {
      cnt++;
      temp /= 2;
    }
    if (last == -1) {
      last = cnt;
    }
    else if (last != cnt) {
      valid = false;
    }

    if (value > m) break;
  }

  if (!valid) {
    cout<<0<<endl;
  }
  else {
    int x = m / value;
    x = (x+1)/2;
    cout<<x<<endl;
  }
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(){
    int n, q;
    ll sum=0;
    cin>>n;
    vector<int>a(n,0);
    map<int, int>cnt;
    rep(i,n){cin>>a[i];sum+=a[i];cnt[a[i]]++;}
    cin>>q;
    vector<pair<int, int>>p(q);
    rep(i,q){
        int b,c;cin>>b>>c;
        p[i] = make_pair(b, c);
    }
    for(auto itr = p.begin();itr!=p.end();itr++){
        sum += cnt[itr->first]*(itr->second-itr->first);
        co(sum);
        cnt[itr->second]+= cnt[itr->first];
        cnt[itr->first]=0;
    }
}

Measured memory_bytes: 8720
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	int n;
	string s;
	int t=0;
	cin>>n>>s;
	string str=s;
	for(int i=0; i<n; i++) {
		if(s[i]=='(') {
			break;
		}else{
			str='('+str;
		}
	}
	s=str;
	for(int i=s.length()-1;i>=0;i--){
		if(s[i]==')'){
			break;
		}else{
			str+=')';
		}
	}
	s=str;
	for(int i=0;i<s.length();i++){
		if(s[i]=='('){
			t++;
		}else{
			t--;
		}
		if(t<0){
			t=0;
			str='('+str;
		}
	}
	s=str;
	for(int i=0;i<t;i++){
		s+=')';
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


char s[100100];
int len;
long K;

int main(void) {
  cin >> s >> K;
  len = strlen(s);

  REP(i, 0, len) {
    int d = ('z' - s[i] + 1) % 26;
    if(K >= d) {
      K -= d;
      s[i] = 'a';
    }
  }

  s[len - 1] = (s[len - 1] - 'a' + (K % 26)) % 26 + 'a';

  cout << s << endl;

  return 0;
}



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

int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int N,M,X;
  cin>>N>>M>>X;
  int left=0,right=0;
  for (int i=0; i<M; i++) {
    int A;
    cin>>A;
    if (A<X) {
      left++;
    } else {
      right++;
    }
  }
  cout<<min(left,right)<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))
for i in range(N):
    H[i] = T - H[i]*0.006
h = 100000
a = 0
for i in range(N):
    if abs(H[i]-A) < h:
        h = abs(H[i]-A)
        a = i+1
print(a)

Measured memory_bytes: 3060
"use strict";

const main = arg => {
    // 標準入力の不要な空白と改行を削除し、配列に格納する
    let input = arg.trim().split("\n").map(low => low.split(" ").map(str => Math.floor(str, 10)));

    if (input[0][1] >= input[0][0]) {
        console.log(0);
        return;
    }
    const returnSum = (a, n) => a + n;
    console.log(input[1].sort((a, b) => b - a).slice(input[0][1]).reduce(returnSum));
    
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

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

using namespace std;
using ll = long long;

int n;
vector<vector<pair<int,int>>> hen;
vector<int> col;

void dfs(int v, int prev, ll dist){

    col[v] = dist & 1;

    for(auto i : hen[v]) {
        if(i.first == prev)continue;
        dfs(i.first, v, dist + i.second);

    }

}

int main()
{
    cin >> n;
    hen.resize(n);
    col.resize(n);

    for(int i = 0; i < n - 1; i++){
        int a, b, c; cin >> a >> b >> c; a--, b--;
        hen[a].push_back({b,c});
        hen[b].push_back({a,c});
    }

    dfs(0,0,0);

    for(auto i : col){
        cout << i << endl;
    }

}

Measured memory_bytes: 8192
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def has_duplicates(seq):
    return len(seq) != len(set(seq))


N = INT()
A = LIST()

if has_duplicates(A):
    print('NO')
else:
    print('YES')


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}

template<typename T> T my_lcm(T a, T b){
	return a * b / my_gcd(a, b);	
}

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w, n;
    cin >> h >> w >> n;
    vector<int> A;
    A.resize(n);
    rep(i, n) {
        cin >> A[i];
    }

    vector<vector<int> > ans_grid;
    vector<int> row;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < A[i]; ++j) {
            row.push_back(i + 1);
            if (row.size() == w) {
                ans_grid.push_back(row);
                row.clear();
            }
        }
    }

    for (int i = 0; i < h; ++i) {
        if (i % 2 == 1) reverse(all(ans_grid[i]));
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (j) cout << " ";
            cout << ans_grid[i][j];
        }
        cout << endl;
    }

    return 0;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3)
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3)
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int main()
{
    int i,n;
    sf(n);
    double k;
    priority_queue<double,vector<double>,greater<double> >pq;
    rep0(i,n)
    {
        cin>>k;
        pq.push(k);
    }
    while(pq.size()>1)
    {
        double a=pq.top();
        pq.pop();
        double b=pq.top();
        pq.pop();
        pq.push((a+b)/2.0);
    }
    cout<<fixed<<setprecision(10)<<pq.top();
}


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

int main(){
    int r;
    cin >> r;
    double ans = 2*r*3.14;
    cout << ans << endl;
}

Measured memory_bytes: 3768
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif
            var line1 = Console.ReadLine();
            var line2 = Console.ReadLine();
            var line3 = Console.ReadLine();
            var solver = new Solver(line1, line2, line3);
            var answer = solver.Solve();
            Console.WriteLine(answer);
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public Solver(string line1, string line2, string line3)
        {
            var item = line1.Split().Select(elem => long.Parse(elem)).ToArray();
            this.N = (int)item[0];
            this.M = (int)item[1];
            this.K = item[2];
            this.A = line2.Split().Select(elem => long.Parse(elem)).ToList();
            this.B = line3.Split().Select(elem => long.Parse(elem)).ToList();
        }

        public int N { get; set; }
        public int M { get; set; }
        public long K { get; set; }
        public List<long> A { get; set; }
        public List<long> B { get; set; }

        public string Solve()
        {
            var ret = 0L;

            var a = new List<long> { 0 };
            for (int i = 0; i < this.N; i++)
            {
                a.Add(a[i] + this.A[i]);
            }

            var b = new List<long> { 0 };
            for (int i = 0; i < this.M; i++)
            {
                b.Add(b[i] + this.B[i]);
            }

            var j = this.M;
            for (int i = 0; i <= this.N; i++)
            {
                if (a[i] > this.K)
                {
                    break;
                }

                while (b[j] > this.K - a[i])
                {
                    j -= 1;
                }

                ret = Math.Max(ret, i + j);
            }

            return ret.ToString();
        }
    }
}


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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n;
    cin>>n;
    ll li[]={2,1};

    if(n<2){
        cout<<li[n]<<endl;
        return 0;
    }

    for(int i=2;i<=n;i++){
        ll tmp=li[1];
        li[1]=li[0]+li[1];
        li[0]=tmp;
    }
    cout<<li[1]<<endl;


    return 0;
}




Measured memory_bytes: 256
n, m  = map(int, input().split())
def prob_B(n, m):    
    ls_ans = [0] * n

    for _ in range(m):
        a, b = map(int, input().split())
        ls_ans[a-1] += 1
        ls_ans[b-1] += 1

    return ls_ans    
    
ls_ans = prob_B(n=n, m=m)
[print(ls_ans[i]) for i in range(len(ls_ans))]

Measured memory_bytes: 3060
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	Scanner scanner = new Scanner(System.in);
	String search = scanner.nextLine();	//検索文字
	boolean Judge = true;
  	int count = 0;
  	int count2 = 0;
  	int wordlengh,minlength;
  	String end = "END_OF_TEXT";
  	String work;
  	
  	
  	while( Judge ){
		String word = scanner.next();	//文章入力
  		//終わる処理と変換
  		int result = word.lastIndexOf(end);	//検索結果を入れる
  		if( result != -1 ){
  			Judge = false;
  		}else{
  			word = word.toLowerCase(); 		//小文字に
  		}
  		if( word.equals(search) ) {
  			count2++;
  		}
  		//文字列検索
  		wordlengh = word.length();			//元々の文字数
		work = word.replaceAll(search, ""); //検索する文字消す
		minlength = work.length();			//消した時の文字数
		count += ( wordlengh - minlength )/(search.length());	//含まれていた数を足す
  		
  	}
  	//結果出力
	//System.out.println(count);
	System.out.println(count2);
  	
	scanner.close();
  }
}


Measured memory_bytes: 26376
#include<iostream>
using namespace std;
void trace(int A[],int N){
    for (int i = 0;i < N;i++){
        if (i > 0) cout << " ";
        cout << A[i];
        }
    cout << endl;
}

int bubble_sort(int A[],int N){
    int count = 0;
    int flag = 1;
    while (flag){
        flag = 0;
        for (int j = N - 1;j >= 1;j--){
            if (A[j] < A[j-1]){
                swap(A[j],A[j-1]);
                count += 1;
                flag = 1;
            }
        }
    }
    return count;
}

int main(){
    int A[100],N,count;
    cin >> N;
    for (int i = 0;i < N;i++) cin >> A[i];
    count = bubble_sort(A,N);
    trace(A,N);
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define MOD 1000000007
template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N;
    cin >> N;
    vector<long long> dp(1<<N);
    vector<vector<int>> a(N, vector<int>(N));
    REP(i, N) REP(j, N)
        cin >> a[i][j];
    dp[0] = 1;
    REP(i, (1<<N)-1) REP(j, N){
        int cnt = __builtin_popcount(i);
        if(a[cnt][j] == 0) continue;
        int k = i | (1<<j);
        if(i == k) continue;
        dp[k] = (dp[k] + dp[i]) % MOD;
    }
    cout << dp[(1<<N)-1] << endl;
    return 0;
}

Measured memory_bytes: 16640
//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>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
 
LL N,K;
LL A[200000];
 
LL ans;
 
void solve(){
	sort(A,A+N);//とりあえず昇順にソート
	//二部探索開始
	LL left = -INF;//leftはギリギリOKなやつ
	LL right = INF;//rightはギリギリダメなやつ
	while(left+1<right){
		LL x = (left+right)/2;//xがOKなやつかどうかを判定する

		//ラムダ式(関数の簡易バージョンみたいなやつ)でxがOKなやつかどうかを判定
		//&で直前に出てきた、ラムダ式の外の変数を参照できるようになる
		bool ok = [&]{
			//このラムダ式は
			//あるA[i]に対し、
			//A[i]*A[0]、A[i]*A[1]、A[i]*A[2]、......、A[i]A[N-1]
			//のうちx未満の数がいくつあるかを二部探索で求める
			//これをi=0~N-1まで繰り返し
			//totalにその合計を格納
			//totalがkより小さければtrueを返す
			//という機能を持つ
			LL total = 0;//x未満の数がいくつあるかを格納
			for(int i=0;i<N;i++){//Aを順に一個ずつ見ていく
				if(A[i]>=0){//選んだA[i]が正なら
					int l = -1;//条件を満たす数が一個もなければ-1、全部条件を満たすならN-1になる
					int r = N;
					//二部探索
					while(l+1<r){
						int c = (l+r)/2;
						if(A[c]*A[i]<x) l = c;
						else r = c;
					}
					total += r;//結局、考えられるペアはr通り
				}else{//選んだA[i]が負なら
					int l = -1;//条件を満たす数が一個もなければ-1、全部条件を満たすならN-1になる
					int r = N;
					//二部探索
					while(l+1<r){
						int c = (l+r)/2;
						if(A[c]*A[i]<x) r = c;
						else l = c;
					}
					total += (N-r);//結局、考えられるペアはn-r通り
				}
				if(A[i]*A[i]<x) total--;
			}
			total/=2;
			return total<K;
		}();

		if(ok) left = x;
		else right = x;
	}
	ans = left;
}
 
int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++) cin >> A[i];
 
	solve();

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

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <fstream>
#include <bitset>
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 long long INF = 1LL << 60;
const long long MOD = 1000000007LL;
const long long MAX = 500000LL;
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;

int main()
{
	string s, t;
	cin >> s >> t;
	vector<vector<ll>> dp(s.size() + 1, vector<ll>(t.size() + 1, INF));

	for (ll i = 0; i <= s.size(); i++) {
		dp[i][0] = i;
	}

	for (ll j = 0; j <= t.size(); j++) {
		dp[0][j] = j;
	}

	for (ll i = 0; i < s.size(); i++) {
		for (ll j = 0; j < t.size(); j++) {
			if (s[i] == t[j]) {
				chmin(dp[i + 1][j + 1], dp[i][j]);
			}
			else {
				chmin(dp[i + 1][j + 1], dp[i][j] + 1);
				chmin(dp[i + 1][j + 1], dp[i + 1][j] + 1);
				chmin(dp[i + 1][j + 1], dp[i][j + 1] + 1);
			}
		}
	}

	cout << dp[s.size()][t.size()] << endl;
	return 0;
}



Measured memory_bytes: 10812
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18 -> 18回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i, m) cin >> p.at(i).first >> p.at(i).second;
    rep(x, 1000) {
        int keta = 1;
        int nx = x / 10;
        vector<int> d(1, x % 10);
        while(nx) {
            keta++;
            d.push_back(nx % 10);
            nx /= 10;
        }
        if (keta != n) continue;
        reverse(d.begin(), d.end());
        bool ok = true;
        rep(i, m) {
            if (d.at(p.at(i).first - 1) != p.at(i).second) ok = false;
        }
        if(ok) {
            cout << x << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node{
  int key;
  node *left,*right,*p;
  node(){}
  node(int key):key(key){left=right=p=NULL;};
};
node *root;
void insert(node z){
  node *y=NULL;
  node *x=root;
  while(x!=NULL){
    y=x;
    if(z.key<x->key) x=x->left;
    else x=x->right;
  }
  z.p=y;
  if(y==NULL) root=new node(z);
  else if(z.key<y->key) y->left=new node(z);
  else y->right=new node(z);
}
bool find(int z){
  node *x=root;
  while(x!=NULL){
    if(z==x->key) return true;
    if(z<x->key) x=x->left;
    else x=x->right;
  }
  return false;
}
node *nxt(node *x){
  if(x->left!=NULL) return nxt(x->left);
  return x;
}
void del(node *x){
  //cout<<x->key<<endl;
  node *y=x->p;
  if(x->left==NULL&&x->right==NULL){
    if(y!=NULL&&y->left==x) y->left=NULL;
    if(y!=NULL&&y->right==x) y->right=NULL;
    delete(x);
    return;
  }
  if(x->left==NULL&&x->right!=NULL){
    if(y!=NULL&&y->left==x) y->left=x->right;
    if(y!=NULL&&y->right==x) y->right=x->right;
    x->right->p=y;
    delete(x);
    return;
  }
  if(x->left!=NULL&&x->right==NULL){
    if(y!=NULL&&y->left==x) y->left=x->left;
    if(y!=NULL&&y->right==x) y->right=x->left;
    x->left->p=y;
    delete(x);
    return;
  }
  node *z=nxt(x->right);
  x->key=z->key;
  del(z);
}
void del(int k){
  node *x=root;
  while(x!=NULL){
    if(k==x->key) break;
    if(k<x->key) x=x->left;
    else x=x->right;
  }
  //cout<<k<<" "<<x->key<<endl;
  del(x);
}
void inorderTreeWalk(node *v){
  if(v==NULL) return;
  inorderTreeWalk(v->left);
  cout<<" "<<v->key;
  inorderTreeWalk(v->right);
}
void preorderTreeWalk(node *v){
  if(v==NULL) return;
  cout<<" "<<v->key;
  preorderTreeWalk(v->left);
  preorderTreeWalk(v->right);
}
signed main(){
  int n;
  cin>>n;
  root=NULL;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    //cout<<(root==NULL?-1:root->key)<<endl;
    if(s=="print"){
      inorderTreeWalk(root);
      cout<<endl;
      preorderTreeWalk(root);
      cout<<endl;
      continue;
    }
    int x;
    cin>>x;
    if(s=="insert"){
      insert(node(x));
    }
    if(s=="find"){
      cout<<(find(x)?"yes":"no")<<endl;
    }
    if(s=="delete"){
      del(x);
    }
  }
  return 0;
}

Measured memory_bytes: 21752
# 入出力から得点を計算する
import sys
input = lambda: sys.stdin.readline().rstrip()
D = int(input())
c = list(map(int, input().split()))
s = [[int(i) for i in input().split()] for _ in range(D)]
t = []
for i in range(D):
    tmp = int(input())
    t.append(tmp)

# 得点
result = 0

# 最後に開催された日を保存しておく
last_day = [0 for _ in range(26)]

for i in range(len(t)):
    # 選んだコンテスト
    choose = t[i] - 1

    # 最終開催日を更新
    last_day[choose] = i + 1

    # そのコンテストを選んだ時の本来のポイント
    result += s[i][choose]


    # そこから満足度低下分をマイナス
    for j in range(26):
        result -= c[j] * ((i+1) - last_day[j])
    # result += tmp_point
    print(result)
# print(c,s,t)


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

int main(){
    string s;
    cin >> s;
    
    vector<vector<long long>> dp(s.size() + 1,vector<long long>(13));
    
    dp.at(0).at(0) = 1;
    
    for(int i = 0; i < s.size(); i++){
        int c;
        if(s.at(i) == '?'){
            c = -1;
        }else{
            c = s.at(i) - '0';
        }
        
        for(int j = 0; j < 10; j++){
            if(c != -1 && c != j)continue;
            for(int ki = 0; ki < 13; ki++){
                dp[i + 1][(10 * ki + j) % 13] += dp[i][ki];
            }
        }
        
        for(int j = 0; j < 13; j++)dp[i + 1][j] %= (long long)1000000007;
    }
    
    int ans = dp[s.size()][5];
    
    cout << ans << endl;
    
}

Measured memory_bytes: 13696
n,m = map(int,input().split())
switch = [(i+1) for i in range(n)]
ks = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))

ans = 0

for i in range(2**n):
    on = []
    light = 0
    for j in range(n):
        if ((i >> j) & 1) == 1:
            on.append(switch[j])
    for k in range(m):
        count = 0
        for l in range(1,ks[k][0]+1):
            if ks[k][l] in on:
                count += 1
        if count % 2 == p[k]:
            light += 1
    if light == m:
        ans += 1
            
print(ans)

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = readInteger >>= putStrLn . reverse . solve

solve 0 = ""
solve n = chr ( ord 'a' + ( fromIntegral $ n' `mod` 26 ) ) : solve ( n' `div` 26 )
	where
		n' = pred n

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

int A[200005];
int B[200005];

typedef pair<int, int> pii;
typedef long long LL;
int main(){
	int N; cin >> N;
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	for (int i = 0; i < N; i++){
		cin >> B[i];
	}

	priority_queue<pii> pq;
	LL res = 0;
	for (int i = 0; i < N; i++){
		if (A[i] != B[i]){
			pq.push(make_pair(B[i], i));
		}
	}
	while (pq.size()){
		pii p = pq.top(); pq.pop();
		//cout << p.first << ' ' << p.second << endl;
		int idx = p.second;
		int rgt = (idx + 1) % N;
		int lft = (idx + N - 1) % N;
		int dec = (B[idx] - A[idx])  / (B[rgt] + B[lft]);
		if (dec == 0){
			cout << -1 << endl;
			return 0;
		}
		p.first -= dec * (B[rgt] + B[lft]);
		res += dec;
		B[p.second] = p.first;
		if (p.first == A[idx]) continue;
		if (p.first < A[idx]){
			cout << -1 << endl;
			return 0;
		}
		pq.push(p);
	}
	cout << res << endl;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

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

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

typedef   long long  int ll;
typedef  long double ld;
typedef std::vector<ll> vi;
typedef std::vector<std::vector<ll> > vv;

#define MOD 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,b) for(i=a;i<b;i++)
#define mp make_pair
#define pb(x) push_back(x)
#define fi first
#define se second
#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;
#define all(a) a.begin(),a.end()
#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];
#define ms(a,val) memset(a,val,sizeof(a))
using namespace std;

const int N = 1e5 + 5;


void solve(){
            ll i,j,n,m,k;
            cin>>n;
            ld p[n+1];
            input(p,0,n);
            ld ans[n+1][n+1] ;
            ms(ans,0);
            ans[0][0] = 1 - p[0];
            ans[0][1] = p[0];
            fo(i,1,n)
            {
				ans[i][0] = ans[i-1][0]*(1 - p[i]);
			}
			fo(i,1,n)
			{
				fo(j,1,n+1)
				{
					ans[i][j]+=(ans[i-1][j-1]*p[i]);
					ans[i][j]+=(ans[i-1][j]*(1 - p[i]));
				}
			}
			ld fans = 0;
			fo(i,n/2+1,n+1)
			fans+=ans[n-1][i];
			cout<<fixed<<setprecision(10)<<fans<<endl;
			
            
				    
            
        
    
            
						            









}

int main()
{
    IO;
      ll t=1;
      //cin>>t;


      while(t--)
      {

          solve();
      }
    return 0;
}


Measured memory_bytes: 144356
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
 
typedef long long ll;
typedef pair<ll, ll> Pa;
 
int main() {
    cin >> X;
    int low = (X%100)/5;
    if(X%5 != 0) low++;
    if(X/100 < low) cout << 0;
    else cout << 1;
}


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

#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define eb emplace_back

typedef long long ll;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const int INF = 0x3f3f3f3f;

const int T = 55;
double v[T];
int n;

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        v[i] = x;
    }

    sort(v,v+n);
    for(int i = 1; i < n; i++) v[i] = (v[i]+v[i-1])/2;
    cout << fixed << setprecision(5) << v[n-1] << endl;

    return 0;
}



Measured memory_bytes: 256
n = gets.to_i
a = gets.split().map(&:to_i)
hash = hash = a.group_by(&:itself).map{|key, value|[key, value.count]}.to_h


def cal(count)
  return count*(count-1)/2
end

all = 0

hash.each do |key, value|
  all += cal(value)
end

a.each do |k|
  puts all - (cal(hash[k]) - cal(hash[k]-1))
end

Measured memory_bytes: 57860
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef int64_t ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int find_k(int n) {
  for (int k = 0; k <= n; k++) {
    if (k * (k - 1) == 2 * n) {
      return k;
    }
  }
  return 0;
}

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

  int n;
  cin >> n;  

  if (n == 1) {
    cout << "Yes" << endl;
    cout << 2 << endl;
    cout << "1 1" << endl;
    cout << "1 1" << endl;
    return 0;
  }

  int k = find_k(n);
  if (k == 0) {
    puts("No");
    return 0;
  } else {
    cout << "Yes" << endl;
  }
  cout << k << endl;

  vector<vector<int>> ans(k, vector<int>(k-1));
  int c = 1;
  rep(i, k) {
    rep(j, k - 1 - i) {
      ans[i][i+j] = c;
      ans[i+j+1][i] = c;
      c++;
    }
  }

  rep(i, k) {
    cout << k-1 << " ";
    rep(j, k-1) {
      cout << ans[i][j];
      if (j != k - 2) cout << " ";
    }
    cout << endl;
  }
  
  return 0;
}


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


int main() {
  // 科目の数Nを受け取る
  string S;
  cin >> S;
  S.at(0) = '2';
  S.at(1) = '0';
  S.at(2) = '1';
  S.at(3) = '8';
  cout << S << endl;

  vector<int> d(10);
  for (int i = 0; i < 10; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vd(T) vector<vector<T>>
#define vi(T) vector<T>
#define mod (ll)(1e9+7)
#define pp(T) pair<T,T>
#define pb push_back
#define mp make_pair
#define NN 100005
#define IO ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG cout<<"***********DEBUGGING***********"<<endl
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 
ll power(ll a,ll b){ if(b==0) return 1; ll s=power(a,b/2); s*=s;if(b&1) return s*a; return s;}
ll powermod(ll a,ll b,ll m){ if(b==0) return 1; ll s=power(a,b/2);s*=s; s%=m; if(b&1) return (s*a)%m; return s;}
inline int add(ll a,ll b,ll m=0){
    if(m==0) return a+b;
    return (a%m+b%m)%m;
}

inline int sub(ll a,ll b ,ll m=0){
    if(m==0) return a-b;
    return ((a%m-b%m)%m+m)%m;
}

inline int mul(ll a,ll b,ll m=0){
    if(m==0)return (a*b);
    return ((a%m)*(b%m))%m;
}

inline int div(ll a,ll b,ll m=0){
    if(m==0) return a/b;
    return ((a%m)*(powermod(a,b,m-2)%m))%m;
}

bool isopen(char c){
    return ((c=='(')||(c=='{')||(c=='['));
}

ll longest_balanced_parenthesis(string a,ll n){
    stack<char> s;
    ll start=0;
    ll ans=0,m=0;
    for(ll i=0;i<n;i++){
        if(isopen(a[i])){
            s.push(a[i]);
        }
        else{
            if(isopen(a[i])|| s.empty()){
                m=max(m,ans);
                continue;
            }
            else{
                s.pop();
                ans+=2;
                m=max(ans,m);
            }
        }
    }

    return m;

}

ll setup_k(ll *a,ll k){
  ordered_set x;
  // Now , insert and then check number of integers less than k by just using x.order_of_key(k+1)
}

int main() {

    IO; 

    ll x,y;
    ll n;
    cin>>x>>y>>n;
    vector<vector<ll>> v(101);
    for(ll i=0;i<x;i++){
        v[i]=vector<ll>(y);
        for(ll j=0;j<y;j++){
            v[i][j]=0;
        }
    }

    for(ll i=0;i<n;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        if(c==1){
            for(ll j=0;j<=a;j++){
                for(ll k=0;k<y;k++){
                    v[j][k]=1;
                }
            }
        }
        else if(c==2){
            for(ll j=a+1;j<x;j++){
                for(ll k=0;k<y;k++){
                    v[j][k]=1;
                }
            }
        }
        else if(c==3){
            for(ll j=0;j<=b;j++){
                for(ll k=0;k<x;k++){
                    v[k][j]=1;
                }
            }
        }
        else{
            for(ll j=b+1;j<y;j++){
                for(ll k=0;k<x;k++){
                    v[k][j]=1;
                }
            }
        }
    }
    ll ans=0;
    for(ll i=0;i<x;i++){
        for(ll j=0;j<y;j++){
            ans+=(v[i][j]==0);
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int A;
  	string op;
  	int B;
  
  cin >> A >> op >>B;
  	if(op == "-"){
      int sum = A - B;
		cout << sum << endl;    
    }
	
  	if(op == "+"){
    	cout << A + B << endl;
    }
 
  }

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

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)

using namespace std;
using ll = long long;
using pos = pair<ll, ll>;

ll r,g,b;

void solve();

int main() {

   solve();
   return 0;

}

void solve() {

    cin >>r>>g>>b;
    cout << ((10*g+b)%4==0?"YES":"NO") << endl;

}

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


int main()
{
    long long K, A, B;
    cin >> K >> A >> B;


    if( A+2 >= B or K < A+1 ){  // 交換するコストの方が高い場合、そもそも交換できない場合
        cout << 1 + K << endl;
    }else{
        long long ans = 0;
        ans += B;
        K -= A + 1;
        ans += K/2 * (B - A) + K%2;
        cout << ans << endl;
    }    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int sum;
void solve(){
  int price[10]; 
  for (int i = 0; i < 9; i++){
    scanf("%d", &price[i]);
    sum -= price[i];
  }
  printf("%d\n", sum);
}

int main(){
  while (scanf("%d", &sum), sum) solve();
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int getNum(string a,int &i){
  int res=0;
  while(isdigit(a[i]))res=res*10+a[i++]-'0';
  return res;
}

double getx(double R,double r){
  if(R<r) swap(R,r);
  return sqrt((R+r)*(R+r)-(R-r)*(R-r));
}

int n;
vector<double> num;
double mem[11][11][1<<12];
int used[11][11][1<<12];
double dfs(int l,int r,int sta){
  if(sta==(1<<n)-1)return 0;
  if(used[l][r][sta]++)return mem[l][r][sta];

  double res=INF;
  for(int i=0;i<n;i++){
    if((sta&(1<<i)))continue;
    double lcost=num[i]+getx(l,num[i])-l;
    double rcost=num[i]+getx(num[i],r)-r;
    res=min(res,lcost+dfs(num[i],r,sta|(1<<i)));
    res=min(res,rcost+dfs(l,num[i],sta|(1<<i)));
  }
  return mem[l][r][sta]=res;
}

int main(){
  string str;
  while(getline(cin,str)){
    int w,idx=0;
    w = getNum(str,idx);
    num.clear();
    while(idx++<str.size())num.push_back(getNum(str,idx));
    n = num.size();
    memset(used,0,sizeof(used));
    double mn=INF;
    for(int i=0;i<n;i++)mn=min(mn,2*num[i]+dfs(num[i],num[i],1<<i));
    cout<<(mn<=w? "OK":"NA")<<endl;
  }
  return 0;
}

Measured memory_bytes: 7160
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    long[] a = new long[n];
    long sum = 0;
    for(int i = 0; i < n; i++) {
      a[i] = Long.parseLong(sc.next());
      sum += a[i];
    }
    long temp = 0;
    long answer = 0;
    int index = 0;
    if(sum % 2 == 1) {
      for(index = 0; index < n; index++) {
        temp += a[index];
        if(sum / 2 <= temp) {
          break;
        }
      }
      if(temp == sum / 2 && temp != index + 1) answer = 1;
      else answer = Math.min(temp * 2 - sum, sum - 2 * temp + 2 * a[index]);
    } else {
      for(index = 0; index < n; index++) {
        temp += a[index];
        if(sum / 2 <= temp) {
          break;
        }
      }
      answer = Math.min(temp * 2 - sum, sum - 2 * temp + 2 * a[index]);
    }
    System.out.println(answer);
  }
}


Measured memory_bytes: 50700
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  map<ll, ll> ya;
  rep(i, 2, n+1) {
    ll tmpi = i;
    ll j = 2;
    while (tmpi > 1) {
      if (tmpi % j == 0) {
        while (tmpi % j == 0) {
          ya[j]++;
          tmpi /= j;
        }
      }
      j++;
    }
  }

  ll ans = 1;
  for (auto y: ya) {
    ans *= (y.second + 1);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vll;
const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int x[5];
    REP(i,5){
        cin>>x[i];
    }
    REP(i,5){
        if(x[i] == 0){
            cout << i+1 << endl;
        }
    }
}

Measured memory_bytes: 3664
#include<stdio.h>

#define TOP_END	'#'
#define SONOTA  '.'
int main()
{
	int h,w;
	int loop_h,loop_w;
	int str='\0';

	while(1) {
		scanf("%d %d",&h,&w);
		if ((h==0)&&(w==0)) {
			return 0;
		}

		for (loop_h=0 ; loop_h<h ; loop_h++) {
			for (loop_w=0 ; loop_w<w ; loop_w++) {
				if ((loop_h == 0)||(loop_h == (h-1))) {
					str = TOP_END;
				}
				else {
					if ((loop_w == 0)||(loop_w == (w-1))) {
						str = TOP_END;
					}
					else {
						str = SONOTA;
					}
				}
				printf("%c",str);
			}
			printf("\n");
		}
		printf("\n");
	}
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    for(int p=0;p<testcase;p++){
	ll s=0,counter=0;
	cin>>s;
	while(s!=4 && s!=2 && s!=1)
	{ if(s%2==0)
	s=s/2;
else
s=3*s+1;
counter++;
		}
cout<<counter+4;
	
		
        
        
    }

    return 0;
}


Measured memory_bytes: 256
// @prefix atcoder
// @description atcoder template

#include <bits/stdc++.h>
using namespace std;
#define int long long

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int x;

signed main() {
    cin >> x;

    int cost = 100;
    REP(i, 100000) {
        if (cost >= x) {
            cout << i << endl;
            return 0;
        }
        cost *= 1.01;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
#define PI 3.14159265358979323846
int main(){
	int a; cin >> a;
	for (int i = 1; i * i <= a; i++){
		if (a % i == 0){
			if (i <= 9 && (a / i) <= 9){
				cout << "Yes";
				//getchar();
				//getchar();
				return 0;
			}
		}
	}
	cout << "No";
	//getchar();
	//getchar();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int r;
    cin >> r;
    double pi = 3.141592;
    double ans = 2.0*r*pi;
    printf("%.6f\n",ans);
}

Measured memory_bytes: 3752
// arock - 2019-08-18

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>

using f64 = double;

template <class T> std::vector<T> read(int n) {
	std::vector<T> res(n);
	for (auto& r : res) {
		std::cin >> r;
	}

	return res;
}

int main() {
	int N;
	std::cin >> N;
	auto v = read<f64>(N);
	std::sort(begin(v), end(v));

	f64 cur = (v[0] + v[1]) / 2;
	for (int i = 2; i < N; i++) {
		cur = (cur + v[i]) / 2;
	}

	std::cout << std::setprecision(20) << std::fixed << cur << std::endl;
}


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

int main(){
  string S;
  cin >> S;
  if (S[0] == '1'){
     S[0] = '9';
  }
  else {
     S[0] = '1';
  }
  if (S[1] == '1'){
     S[1] = '9';
  }
  else {
     S[1] = '1';
  }
  if (S[2] == '1'){
     S[2] = '9';
  }
  else {
     S[2] = '1';
  }
  cout << S << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/keyence2020/tasks/keyence2020_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  VPL rs(N);
  rep(i, N) { cin >> rs[i].fi >> rs[i].se; }

  sort(all(rs), [](PL a, PL b) { return a.fi + a.se < b.fi + b.se; });

  ll res = 0;
  ll cur_end = -INF;

  rep(i, N) {
    if (rs[i].fi - rs[i].se >= cur_end) {
      res++;
      cur_end = rs[i].fi + rs[i].se;
    }
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 1792
li=list(map(int,input().split()))
a=li[0]
b=li[1]
c=li[2]
d=li[3]
while True:
    c-=b
    if c>0:
        a-=d
        if a>0:
            continue
        else:
            print('No')
            break
    else:
        print('Yes')
        break

Measured memory_bytes: 61844
#include<iostream>
using namespace std;
int main()
{
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  if((x>=r&&x<=W-r)&&(y>=r&&y<=H-r))
    cout << "Yes"<<endl;
  else{
      cout << "No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3104
n, m  = map(int, input().split())
a = [int(i) for i in input().split()]
sum = 0
count = 0
for i in range(n):
    sum += a[i]
for i in range(n):
    if a[i] >= sum / (4 * m):
        count += 1
if count >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
H, W, M = map(int, input().split())
hws = [tuple(map(int, input().split())) for _ in range(M)]

hws_set = set(hws)
h_count = [0] * (H+1)
w_count = [0] * (W+1)
for h, w in hws:
    h_count[h] += 1
    w_count[w] += 1

max_h_count = max(h_count)
max_h_count_index = [i for i, c in enumerate(h_count) if c == max_h_count]
max_w_count = max(w_count)
max_w_count_index = [i for i, c in enumerate(w_count) if c == max_w_count]

if len(max_h_count_index) * len(max_w_count_index) > M:
    ans = max_h_count + max_w_count
else:
    ans = max_h_count + max_w_count - 1
    for i in max_h_count_index:
        for j in max_w_count_index:
            if (i, j) not in hws_set:
                ans += 1
                break
        else:
            continue
        break

print(ans)



Measured memory_bytes: 168772
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
using namespace std;

#define ll long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

int main() {
	ifstream fin("Text.txt");
	int i, j, q;
	ll a, b, c, e, f, n, t, m, r, d, k, x, y, ans;
	string st;
	cin >> st;
	
	if (st.size() > 3 && st[0] == 'Y' && st[1] == 'A' && st[2] == 'K' && st[3] == 'I') {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256