akhauriyash/Code-Regression huggingface dataset:
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;



int main()
{
	/*
	map<char, int> used;

	string s; cin >> s;
	

	for (int i = 0; i < s.size(); ++i)
	{

		auto itr = used.find(s[i]);

		if (itr != used.end())
		{
			used[s[i]]++;
		}
		else
		{
			used[s[i]] = 1;
		}

	}


	int atOnce = 0;

	for (auto itr = used.begin(); itr != used.end(); ++itr)
	{
		if (itr->first == 'x') { continue; }

		if (itr->second % 2 == 1)
		{
			atOnce++;
		}
	}


	if (atOnce > 1)
	{
		cout << -1 << endl;
		return 0;
	}
	*/


	string s; cin >> s;

	string srex = "";

	vector<int> numx(s.size() + 1, 0);
	int pos = 0;
	
	for (int i = 0; i < s.size(); ++i)
	{
		if (s[i] == 'x')
		{
			numx[pos]++;
		}
		else
		{
			srex += s[i];
			pos++;
		}
	}


	for (int i = 0; i < srex.size(); ++i)
	{
		if(srex[i]==srex[srex.size()-1-i])
		{

		}
		else
		{
			cout << -1 << endl;
			return 0;
		}
	}


	int ans = 0;

	for (int i = 0; i <= srex.size() / 2; ++i)
	{
		ans += abs(numx[i] - numx[srex.size() - i]);
	}

	cout << ans << endl;

	return 0;

}

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

int main() {
	int a, b;
	cin >> a >> b;
	string s_a, s_b;
	rep(i, b) s_a += '0' + a;
	rep(i, a) s_b += '0' + b; 
	string ans;
	if (s_a < s_b) ans = s_a;
	else ans = s_b;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
N,D = map(int,input().split())

def people(t):
    t = t + 2*D
    return t
if N<D:
    print(1)

else:
    t = 1
    c = 0
    while t <= N:
        #print(t)
        t = people(t+1)
        c+=1
    print(c)

Measured memory_bytes: 2940
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

#include <iostream>
 
int main(void)
{
  int X, A;
  std::cin >> X >> A;
  
  std::cout << ((X < A) ? 0 : 10) << std::endl;
  
  return 0;
}

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

using namespace std;

int main(int argc, char* argv[])
{
    int N; cin >> N;

    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());

    cout << d[N/2]-d[N/2-1] << endl;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i,N)cin >>S[i];
    SORT(S);
    vector<pair<int,string>> a;
    int j=0;
    a.push_back(pair<int,string>(0,S[0]));
    rep(i,N){
        if(a[j].second == S[i])a[j].first++;
        else {
            a.push_back(pair<int,string>(1,S[i]));
            j++;
        }
    }
    SORT(a);
    rep(i,a.size()){
        if(a[i].first== a[a.size()-1].first){
            cout << a[i].second << endl;
            }
    }
    return 0;
}

Measured memory_bytes: 18548
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair 
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) <<"\n"
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 1e5+10;
const ll inf = 1e18+7;

int main(){
	fastio;
	ll k;
	cin>>k;
	f(i,0,k){
		cout<<"ACL";
	}
	cout<<"\n";	
	return 0; 
}

Measured memory_bytes: 3612
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a, bool g){
	if(g){
		if(a[index]<key){
			return true;
		}
	}
	else{
		if(a[index]>key){
			return true;
		}
	}
	return false;
}

ll bin_search(ll key, vector<ll> &a, bool g){
	
	ll l=-1;
	ll r=a.size();

	if(g){
		l=a.size();
		r=-1;
	}

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a, g)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

int main(){

	ll a,b,c;
	cin>>a>>b>>c;

	cout<<(a*b)/2<<endl;
	
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

string bt[] = {
  " ",
  "\',.!?",
  "abcABC",
  "defDEF",
  "ghiGHI",
  "jklJKL",
  "mnoMNO",
  "pqrsPQRS",
  "tuvTUV",
  "wxyzWXYZ",
};

int main(){
  string s;

  while(cin>>s){
    int i = 0;

    while(i < s.length()){
      if(s[i] == '0'){
        cout<<" ";
        i++;
        continue;
      }

      char ch = s[i];
      int j = i;
      while(i<s.length() && ch == s[i]) i++;
      cout<<bt[ch-'0'][(i-j-1)%bt[ch-'0'].length()];

      if(i >= s.length()) break;
      if(s[i] == '0') i++;
    }

    cout<<endl;
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
typedef pair<int, int> P;

int kind[20];
bool info[20];
int x[20][20], y[20][20];
int A[20];	
int N;
vector<string> S;

void check(string W) {
	if (W.size() == N) {
		S.push_back(W);
	}
	else {
		for (int i = 0; i <= 1; i++) {
			string tmp = W;
			tmp.push_back(i + '0');
			check(tmp);
		}
	}
}

int main()
{

	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		for (int j = 0; j < A[i]; j++) {
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	string T;
	check(T);
	for (int i = 0; i < S.size(); i++) {
		//cout << S[i] << endl;
		queue<int> Q;
		int sum = 0;
		bool no = false;
		for (int j = 0; j < N; j++) {
			if (S[i][j] == '1') {
				kind[j] = 1;
				sum++;
				Q.push(j);
			}
			else {
				kind[j] = 0;
			}
		}
		while(!Q.empty()) {
			int tmp = Q.front();
			Q.pop();
			//cout << j << endl;
			for (int l = 0; l < A[tmp]; l++) {
				//cout << " "<<l<<" "<<kind[x[tmp][l]] << " " << y[tmp][l] << endl;
				if (kind[x[tmp][l]] != y[tmp][l]) {
					//cout << "break" << endl;
					no = true;
					break;
				}
			}
			if (no) break;
		}
		if (!no) {
			//cout <<"sum="<< sum << endl;
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2556
while True:
    m = int(input())
    if m == 0: break
    star = list({tuple(map(int, input().split())) for i in range(m)})
    sx, sy = star[0]
    
    n = int(input())
    starset = {tuple(map(int, input().split())) for i in range(n)}
    for x, y in starset:
        flag = True
        for j in range(len(star)-1):
            dx = x + star[j+1][0] - sx
            dy = y + star[j+1][1] - sy
            if (dx, dy) not in starset:
                flag = False
                break

        if flag == True:
            print(x - sx, y - sy)
            break
    



Measured memory_bytes: 6048
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()

const int N = 1e5 + 5;

int solve()
{
	string input;
	cin >> input;
	for(int j = 0; j < input.si; j++)
	{
		int i = j + 1;
		if(i & 1 and (input[i - 1] != 'R' and input[i - 1] != 'U' and input[i - 1] != 'D'))
		{
			cout << "No" << endl;
			return 0;
		}
		if(i % 2 == 0 and (input[i - 1] != 'L' and input[i - 1] != 'U' and input[i - 1] != 'D'))
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes" << endl;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
	solve();
	return 0;
}          

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

using namespace std;

int main(){
	long long n, k, m, ans = 0;
	cin >> n >> k;
	m = n / k;
	ans = pow(m, 3);
	if(k % 2 == 0){
		if(n % k < k / 2){
			ans += pow(m, 3);
		}else{
			ans += pow(m + 1, 3);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define next tipa_next
#define prev tipa_prev
#define ll long long

using namespace std;
const int mod = 998244353;
const int half = (mod + 1) / 2;
int n , m;
int cnt[26];
string s[100];
int main()
{
	cin >> n >> m;
	for(int i = 0; i < n; i++)
	{
		cin >> s[i];
		for(int j = 0; j < s[i].size(); j++)
			cnt[s[i][j] - 'a']++;
	}
	int x = 0;
	for(int i = 0; i < 26; i++)
		if(cnt[i] % 2)
			x++;
	if(x > 1)
	{
		cout << "No";
		return 0;
	}
	int e = 0;
	for(int i = 0; i < 26; i++)
	{
		if(cnt[i] % 2)
		{
			cnt[i] --;
		}
		e += cnt[i] / 4;
	}
	if(e >= (n / 2) * (m / 2))
		cout << "Yes";
	else
		cout << "No";
}



Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


a = int(input())
b = int(input())
s = set(range(1,4))
s.remove(a)
s.remove(b)
print(s.pop())

Measured memory_bytes: 61760
n = int(input())

s = [list(input())[0] for i in range(n)]

hj = []
hj.append(s.count('M'))
hj.append(s.count('A'))
hj.append(s.count('R'))
hj.append(s.count('C'))
hj.append(s.count('H'))

c = 0

for i in range(0,3):
    for j in range(i+1,4):
        for h in range(j+1,5):
            c += hj[i]*hj[j]*hj[h]
print(c)

Measured memory_bytes: 3864
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`



	`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */

	h, w := nextInt(), nextInt()

	var ans int

	if h == 1 || w == 1 {
		ans = 1
	} else {
		ans = int(math.Ceil(float64(h*w) * 0.5))
	}

	fmt.Fprintln(out, ans)
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 640
#include <stdio.h>

int main ()
{
	int A[100], N, flag, i, j, tmp, count;
	
	scanf ("%d", &N);
	for ( i = 0; i < N; i++ ) {
		scanf ("%d", &A[i]);
	}
	
	flag = 1;
	count = 0;
	
	while (flag) {
		flag = 0;
		for (j = N - 1; j >= 1; j--) {
			if ( A[j] < A[j-1] ) {
				tmp = A[j];
				A[j] = A[j-1];
				A[j-1] = tmp;
				count++;
				flag = 1;
			}
		}
	}
	
	for(i = 0; i < N; i++) {
		printf ("%d", A[i]);
		if(i != N - 1) {
			printf (" ");
		}
	}
	printf ("\n%d\n", count);
	
	return 0;
}


Measured memory_bytes: 1992
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        K, S = map(int, input().split())
        ans = 0
        for i in range(K + 1):
            for j in range(K + 1):
                Z = S - i - j
                if 0 <= Z <= K:
                    ans += 1
        print(ans)


if __name__ == '__main__':
    AtCoder().main()

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
  public static void main (String[]args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();


    if(S.matches("(dream|dreamer|erase|eraser)+")) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 34364
Scanf.scanf "%s" (fun s ->
    let n = String.length s in
    let rec loop i acc =
        if i = n then acc else loop (i + 1) (acc + int_of_char s.[i] - 48)
    in
    print_endline @@ if loop 0 0 mod 9 = 0 then "Yes" else "No"
)

Measured memory_bytes: 4408
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d  long double
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (int)1e18
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;
const int e=100001;
pair<int,int> arr[100001];
 
 
 
 
 
signed main()
{
    char c;
    cin>>c;
    cout<<char(c+1);
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S, T = [x for x in input().split()]
    A, B = [int(x) for x in input().split()]
    U = input().strip()

    if U == S:
        A -= 1
    if U == T:
        B -= 1
    print(A, B)

    






if __name__ == '__main__':
    main()



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

using namespace std;

typedef long long int ll;

struct beauty{
  ll x, y, z;
};

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

  ll n, m;
  cin >> n >> m;
  vector < beauty > v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i].x >> v[i].y >> v[i].z;
  }

  ll ans = 0;
  for(int p = -1; p <= 1; p++){
    for(int q = -1; q <= 1; q++){
      for(int r = -1; r <= 1; r++){
        if(p == 0 || q == 0 || r == 0) continue;
        vector < ll > pos_ans;
        for(int i = 0; i < n; i++){
          pos_ans.push_back(p * v[i].x + q * v[i].y + r * v[i].z);
        }
        sort(pos_ans.begin(), pos_ans.end(), greater < ll > ());
        ll sum = 0;
        for(int i = 0; i < m; i++){
          sum += pos_ans[i];
        }
        ans = max(ans, sum);
      }
    }
  }

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


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

int main()
{
        char X, Y; cin >> X >> Y;

        if (X < Y) {
                cout << "<" << endl;
        }
        else if (X > Y) {
                cout << ">" << endl;
        }
        else {
                cout << "=" << endl;
        }


}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 10e9+7;
ll mod2 = 998244353;

int main(){
    string s;cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,sum=0;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)cin>>a[i];
	do{
		for(int i=1;i<=n;i++)
		if(a[i]%2==1)
		{
			cout<<sum;
			return 0;
		}
		else
		   a[i]/=2;
		sum++;
	}while(1);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


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

int N;
string S;
int K;
cin >> N >> S >> K;
K--;
char C = S[K];
rep(i,S.size()) {
    if(S[i] != C) S[i] = '*';
}
cout << S << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target ("sse4.2")
#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize ("unroll-loops")
using namespace std;

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

#define MP make_pair
#define sp(x) fixed<<setprecision(x)
#define pb push_back
#define die(x) return cout << x << endl, 0
#define fastio ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define file ifstream cin("input.txt"); ofstream cout("output.txt")
#define F first
#define S second
#define int long long
#define lc ind << 1
#define rc ind << 1 | 1
//thissss
const int MAXN = 1000 * 1000 + 7, MOD = 1000 * 1000 * 1000 + 7;
int n, sz[MAXN], par[MAXN], dis[MAXN];
pair<int, int>d[MAXN];
map<int, int>pos;
vector<int>adj[MAXN];
void dfs(int v, int p){
	for(auto u : adj[v])if(u!=p){
		dis[u] = dis[v] + 1;
		dfs(u, v);
	}
	return;
}
int32_t main(){
    fastio;
	cin >> n;
	for(int i = 0; i < n; i ++){
		cin >> d[i].F;
		d[i].S = i;
	}
	sort(d, d + n, greater<pair<int, int> >());
	for(int i = 0; i < n; i ++)
		pos[d[i].F] = i + 1;
	fill(sz, sz + n, 1);
	for(int i = 0; i < n - 1; i ++){
		int dis = d[i].F, v = d[i].S;
		int dpar = dis - (n - 2*sz[v]);
		int par= pos[dpar];
		par --;
		if(par == -1 || par <= i)die(-1);
		::par[v] = d[par].S;
		adj[::par[v]].pb(v);
		adj[v].pb(::par[v]);
		
		sz[::par[v]] += sz[v];
	}
	int sum = 0;
	dfs(d[n -1].S, -1);
	for(int i = 0; i < n; i ++)sum += dis[i];
	if(sum != d[n - 1].F)die(-1);
	for(int i = 0; i < n - 1; i ++){
		int v = d[i].S;
		cout << v + 1 << ' ' << par[v] + 1 << endl;
	}
    return 0;

}


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

using namespace std;

const double pi=3.14159265358979323946;
int main()
{
//    freopen("int.txt","r",stdin);

    int a,b;
    char c;
    while(cin>>a>>c>>b)
    {
        if(c=='+')
            cout<<a+b<<endl;
        if(c=='-')
            cout<<a-b<<endl;
        if(c=='*')
            cout<<a*b<<endl;
        if(c=='/')
            cout<<a/b<<endl;
    }
}



Measured memory_bytes: 3112
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {
	
	string res = "";
	string S; cin >> S;
	long mylen = S.length();

	for (int i = 1; i <= mylen; i++) if (i % 2 == 1) res = res + S[i - 1];

	cout << res << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<cstdio>
#define sec second
using namespace std;
const int maxn=1e2+5;
map<int,int>map_1;
map<int,int>::iterator number;
int n,ans,g[maxn],cnt[maxn];
int read(){
    ios::sync_with_stdio(false);
    int a=0;char chars=getchar();bool g=0;
    while(chars>'9'||chars<'0')
    {
        if(chars=='-')g=1;
        chars=getchar();
    }
    while(chars>='0'&&chars<='9')
    {
        a=(a<<1)+(a<<3)+chars-'0';
        chars=getchar();
    }
    return g?-a:a;
}
void display(int a){
    ios::sync_with_stdio(false);
    if(a<0) a=-a,putchar('-');
    if(a>9) display(a/10);
    putchar(a%10+48);
}
int search(int a){
    ios::sync_with_stdio(false);
    return g[a]==a?a:g[a]=search(g[a]);
}
int main(void)
{
    ios::sync_with_stdio(false);
    int i;
    n=read();
    for(i=1;i<=n;i++){
        g[i]=i;
        cnt[i]=read();
    }
    for(i=2;i<=n;i++){
        if(cnt[i]==cnt[i-1]){
            int g_a=search(i-1),g_b=search(i);
            g[g_b]=g[g_a];
        }
    }
    for(i=1;i<=n;i++){
        int g_a=search(i);
        map_1[g_a]++;
    }
    for(number=map_1.begin();number!=map_1.end();number++){
        ans+=(number->sec>>1);
    }
    display(ans);
    return 0;
}

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

int n;
int x[51], y[51];

int main() {
	int caseId = 0;
	
	while (cin >> n) {
		if (n == 0) break;
		caseId++;
		int i;
		for (i = 0; i < n; i++) cin >> x[i] >> y[i];
		x[n] = x[0]; y[n] = y[0];
		
		int area = 0;
		for (i = 0; i < n; i++) {
			area += x[i] * y[i + 1] - y[i] * x[i + 1];
		}
		printf("%d %.1f\n", caseId, abs(area) * 0.5);
	}
	return 0;
}

Measured memory_bytes: 3116
n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

cnt = 0
for i in range(n):
    j = 1
    while i + 2*j <= n-1:
        # if s[i] != s[i+j] and s[i+j] != s[i+2*j] and s[i+2*j] != s[i]:
        if len({s[i], s[i+j], s[i+2*j]}) == 3:
            cnt += 1
        j += 1

print(r*g*b-cnt)

Measured memory_bytes: 8908
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        long n = Long.parseLong(scan.next());
        long k = Long.parseLong(scan.next());

        scan.close();

        long a = n % k;
        long b = k - a;

        if (a < b) {
            System.out.println(a);
        } else {
            System.out.println(b);
        }

    }

}


Measured memory_bytes: 21588
///apigs property
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
#define md (s + e) / 2
using namespace std;
typedef long long ll;
ll q, tree[1000005], a[555555], k, l, m, n, o, p;
map < ll , ll > mp;
vll adj[555555];
const ll mod = 1e9+7;
void update(ll s , ll e , ll node , ll idx , ll val){
    if(idx > e || idx < s)return;
    if(s == e){
        tree[node] = val;
        return;
    }
    update(s , md , node * 2 , idx , val);
    update(md + 1 , e , node * 2 + 1 , idx , val);
    tree[node] = max(tree[node * 2] , tree[node * 2 + 1]);
}
ll query(ll s , ll e , ll node , ll idx){
    if(s > idx)return 0;
    if(e <= idx)return tree[node];
    return max(query(s , md , node * 2 , idx) , query(md + 1 , e , node * 2 + 1 , idx));
}
int main() {
    fast , cin >> n;
    for(ll i = 1 ; i <= n; i++){
        cin >> a[i];
    }
    for(ll i = 1 ; i <= n ; i++){
        cin >> o;
        l = query(1 , n , 1 , a[i]) + o;
        p = max(l , p);
        update(1 , n , 1 , a[i] , l);
    }
    cout << p;
}


Measured memory_bytes: 22312
def prepare(n, MOD):
 
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs

MOD = 10**9+7
fact, fact_inv = prepare(2*10**5, MOD)

n, m = map(int,input().split())
if abs(n-m) > 1:
    print(0)
elif abs(n-m) == 1:
    print(fact[n] * fact[m] % MOD)
else:
    print(2 * fact[n] % MOD * fact[m] % MOD)

Measured memory_bytes: 24740
#include <algorithm>
#include <iostream>
#include <utility>

using namespace std;

typedef pair<int, int> P;

int n, m;
int a[110000];
P p[110000];

long long ans;

int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  sort(a, a+n);
  
  for (int i = 0; i < m; i++) {
    cin >> p[i].second >> p[i].first;
  }
  
  sort(p, p+m, greater<P>());
  
  int num = 0;
  for (int i = 0; i < m; i++) {
    int b = p[i].second, c = p[i].first;
    int st = num;
    num = min(st+b, n);
    for (int j = st; j < num; j++){
      a[j] = max(a[j], c);
    }
    if (num == n) break;
  }
  
  for (int i = 0; i < n; i++) {
    ans += a[i];
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let asc = readn::<String>(" ");
    let s = asc[1].chars().collect::<Vec<char>>()[0];
    println!("A{}C", s);
}

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

int main() {
  int N;
  cin >> N;
  
  vector<long long int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) A[i] -= i+1;
  
  sort(A.begin(), A.end());
    
  long long int mid1 = A[(N-1)/2];
  long long int mid2 = A[N/2];
  long long int sum1 = 0;
  long long int sum2 = 0;
  for (int i = 0; i < N; i++) {
    sum1 += (A[i] > mid1) ? A[i] - mid1 : mid1 - A[i];
    sum2 += (A[i] > mid2) ? A[i] - mid2 : mid2 - A[i];
  }
  
  cout << min(sum1, sum2) << endl;
}


Measured memory_bytes: 1792
from collections import deque
S=deque(input())
Q=int(input())
r=1
for i in range(Q):
    T=input().split()
    if T[0]=="1":
        r*=-1
        continue
    t=T[2]
    if T[1]=="1":
        if r==1:
            S.appendleft(t)
        else:
            S.append(t)
        continue
    if r==1:
        S.append(t)
    else:
        S.appendleft(t)
if r==1:
    print("".join(list(S)))
else:
    S.reverse()
    print("".join(list(S)))

Measured memory_bytes: 8564
n=int(input())  #数値入力 「N」だけの入力のとき
v=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
v.sort()
ans = (v[0]+v[1])/2
if n > 2:
    for i in range(2,len(v)):
        ans = (ans+v[i])/2
print(ans)



Measured memory_bytes: 2940
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int n; cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    map<ll, ll> cnt;
    for(int i=0; i<n; i++) cnt[a[i]]++;

    ll sum = 0;
    for(auto i : cnt){
        sum += i.second * (i.second - 1) / 2;
    }

    for(int i=0; i<n; i++){
        ll ans = sum;
        ans -= cnt[a[i]] * (cnt[a[i]] - 1) / 2;
        ans += (cnt[a[i]] - 2) * (cnt[a[i]] - 1) / 2;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

int main()
{
	int i,a,b,c;
	char O[1000];
	char E[1000];
	char P[1000];

	cin >> O >> E;

	a=strlen(O)+strlen(E);
	b=0;c=0;
	for(i=0;i<a;i++){
		if((i+1)%2!=0){
			P[i]=O[b];
			b++;
		}else{
			P[i]=E[c];
			c++;
		}
	}
	for(i=0;i<a;i++){
	cout << P[i];
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 55, MOD = (int)(1e9 + 7);
inline void Add(int &x,int y) {
  x = x + y >= MOD ? x + y - MOD : x + y;
}
inline void Sub(int& x,int y) {
  x = x - y < 0 ? x - y + MOD : x - y;
}
int power(int a,int b) {
  int ret = 1;
  while (b) {
    if (b&1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD;
    b >>= 1;
  }
  return ret;
}

int dp[2][2][N][N], jc[N], ijc[N];
int n, ans;
int main() {
  read(n);
  jc[0] = 1;
  rep (i, 1, n) jc[i] = 1ll * i * jc[i-1] % MOD;
  ijc[n] = power(jc[n], MOD - 2);
  rrp (i, n-1, 0) ijc[i] = 1ll * ijc[i+1] * (i+1) % MOD;
  dp[0][0][1][0] = 1;
  for (int i = 1, j = 1; i <= n; ++ i, j ^= 1) {
    memset(dp[j], 0, sizeof dp[j]);
    rep (tp, 0, 1) rep (a, 0, n) rep (b, 0, n) if (dp[j^1][tp][a][b]) {
      int n0 = 0, n1 = 0;
      if (tp == 0) n0 += a;
      else n1 += a;
      rep (c, 0, n) rep (d, 0, n - b - c) if (c + d > 0) {
	int tmp = c + d - n0 - n1;
	if (i == 1 && c + d > 1) continue;
	if ((tmp&1) || tmp < 0) continue;
	tmp >>= 1;
	int nn0 = n0 + tmp;
	int nn1 = n1 + tmp;
	if (d >= nn1)
	  Add(dp[j][0][d - nn1][b + c + d], 1ll * dp[j^1][tp][a][b] * ijc[c] % MOD * ijc[d] % MOD);
	else
	  Add(dp[j][1][c - nn0][b + c + d], 1ll * dp[j^1][tp][a][b] * ijc[c] % MOD * ijc[d] % MOD);
      }
    }
    Add(ans, dp[j][0][0][n]);
  }
  ans = 1ll * ans * jc[n] % MOD;
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    cout << (a + b + c >= 22 ? "bust" : "win") << '\n';
    return 0;
}


Measured memory_bytes: 3616
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toLong() }
    val len = aa.sum()
    var ll = LongArray(n){0}
    val half = len/2L

    ll[0] = aa[0]
    for (i in 1 until aa.size) {
        ll[i] = ll[i-1] + aa[i]
    }

    var min = len
    for (i in 0 until n-1) {
        val left = ll[i]
        val right = len - left

        val leftDiff = Math.abs(half-left)
        val rightDiff = Math.abs(half-right)
        val diff = leftDiff + rightDiff
        if (diff < min) min = diff
    }

    println(min)
}

Measured memory_bytes: 80800
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(b==1){
			System.out.println(0);
			return;
		}
		int count=1;
		while(true){
			if(a*count-count+1>=b){
				break;
			}
			count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, K; string S;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K >> S;

	S[K - 1] += 'a' - 'A';

	cout << S << endl;
}

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

int n;

string solve(const vector<int>& P){
  int cnt = 0;
  string ans;
  stack< pair<char, int > > st;

  for(const auto& p: P){
    while(cnt <= p){
      int ni;
     //  if(st.empty()){
     //    ni = 0;
     //  }else{
     //    ni = st.top().second + 1;
     //  }
      st.push( make_pair('(', cnt));
      cnt++;
      ans += '(';
    }
    if(st.top().second == p){
      st.pop();
      ans += ')';
    }else{
      return ":(";
    }
  }
  return ans;
}

int main(void){
  cin >> n;
  vector<int> p(n);
  for(auto& _p: p){
    cin >> _p;
    _p--;
  }

  cout << solve(p) << endl;
}



Measured memory_bytes: 3788
import sys
input = sys.stdin.readline

n = int(input())

ans = set()

#約数の列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

a = make_divisors(n)

for i in a:
    if i == 1:
        continue
    n_ = n
    while n_ % i == 0:
        n_ //= i
    if (n_ - 1) % i == 0:
        ans.add(i)

d = make_divisors(n - 1)

for i in d:
    if i != 1:
        ans.add(i)

ans.add(n)

print(len(ans))





Measured memory_bytes: 39024
#include<iostream>

using namespace std;
bool p[10010010];

int main(){


    while(1){
        int m, n;
        cin>> m>> n;
        if(!(m||n)) break;

        for(int i=0; i<10010010; i++) p[i]=true;
        int c=0;
        for(int i=m; i<10010010; i++){
            if(p[i]){
                c++;
                if(c==n+1){
                    cout<< i<< endl;
                    break;
                }
                for(int j=2; i*j<10010010; j++){
                    p[i*j]=false;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 12844
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "SUN") {
		cout << 7;
	}
	else if (s == "MON") {
		cout << 6;
	}
	else if (s == "TUE") {
		cout << 5;
	}
	else if (s == "WED") {
		cout << 4;
	}
	else if (s == "THU") {
		cout << 3;
	}
	else if (s == "FRI") {
		cout << 2;
	}
	else if (s == "SAT") {
		cout << 1;
	}
}

Measured memory_bytes: 256
// 参考:http://kagamiz.hatenablog.com/entry/2013/10/05/005213

#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> G[1000000];
vector<int> articulation;
int ord[1000000], low[1000000];
bool vis[1000000];

void dfs(int v, int p, int &k)
{
	vis[v] = true;
	ord[v] = k++;
	low[v] = ord[v];
	
	bool isArticulation = false;
	int ct = 0;
	
	for (int i = 0; i < G[v].size(); i++){
		if (!vis[G[v][i]]){
			ct++;
			dfs(G[v][i], v, k);
			low[v] = min(low[v], low[G[v][i]]);
			if (~p && ord[v] <= low[G[v][i]]) isArticulation = true;
		}
		else if (G[v][i] != p){
			low[v] = min(low[v], ord[G[v][i]]);
		}
	}
	
	if (p == -1 && ct > 1) isArticulation = true;
	if (isArticulation) articulation.push_back(v);
}

int main()
{
	int n,m;
	scanf("%d %d", &n, &m);
	
	for (int i = 0;i < m;++i){
		int v, e;
		scanf("%d %d",&v,&e);
		G[v].push_back(e);
		G[e].push_back(v);
	}
	int k = 0;
	for (int i = 0; i < n; i++){
		if (!vis[i]) dfs(i, -1, k);
	}
	sort(articulation.begin(), articulation.end());
	for (int i = 0; i < articulation.size(); i++)
		printf("%d\n", articulation[i]);
}


Measured memory_bytes: 27592
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		String[] str = new String[n*2];

		int PRICE = 380000;

		for (int i = 0; i < n*2; i++) {
			str[i] = sc.next();
		}
		
		double sum = 0.0;
		for(int i=0;i<n;i++) {
			if("JPY".equals(str[i*2+1])) {
				sum += Integer.parseInt(str[i*2]);
			}else {
				sum += Double.parseDouble(str[i*2]) * PRICE;
			}
		}
		
		sc.close();

		System.out.println(sum);
	}
}


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

int main()
{
  int n, t;
  cin >> n >> t;
  int a[n][2];
  rep(i, n){
    rep(j, 2){
      cin >> a[i][j];
    }
  }
  int ans = 10000, m = 10000;
  rep(i, n){
    if(a[i][1] <= t){
      m = min(m, a[i][0]);
    }
  }
  rep(i, n){
    if(a[i][0] == m){
      ans = m;
    }
  }
  if(ans != 10000) cout << ans << endl;
  else cout << "TLE" << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
int main(void){
    int a, b, tasu, hiku, kakeru;
    scanf("%d%d", &a,&b);
    
    tasu = a + b;
    hiku = a - b;
    kakeru = a * b;
    
    if(tasu >= hiku && tasu >= kakeru){
        printf("%d\n", tasu);
    }
    else if(hiku >= tasu && hiku >= kakeru){
        printf("%d\n", hiku);
    }
    else if(kakeru >= tasu && kakeru >= hiku){
        printf("%d\n", kakeru);
    }
        
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Go_ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e3+100;


int main()
{
    Go_
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    
    mx=MAX;
    ll id;

    cin>>n;
    ll ara[n];
    for(i=0;i<n;i++) cin>>ara[i];

    for(i=1;i<=101;i++){

        ll p=i;
        ll sum=0;
        for(j=0;j<n;j++){
           sum+=((ara[j]-p)*(ara[j]-p));
        }

        if(sum<mx) mx=sum,id=p;
    }

    cout<<mx<<endl;
    
}

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

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

void order(string &S){
	if(S.size()!=6){
		string p="0";
		p+=S;
		S=p;
		if(S.size()!=6){
			order(S);
		}
	}
}


int main() {
	int N,M;
	cin>>N>>M;
	vector<vector<pair<int,int>>> G(N,vector<pair<int,int>>(0));
	int p,y;
	for(int i=0;i<M;i++){
		cin>>p>>y;
		G.at(p-1).push_back(make_pair(y,i));
	}
	vector<pair<int,string>> ans(0);
	for(int i=0;i<N;i++){
		if(G.at(i).size()==0)continue;
		else{
			sort(G.at(i).begin(),G.at(i).end());
			for(int j=0;j<G.at(i).size();j++){
				string ansp,ansx;
				ansp=to_string(i+1);
				order(ansp);
				ansx=to_string(j+1);
				order(ansx);
				ans.push_back(make_pair(G.at(i).at(j).second,ansp+ansx));
			}
		}
	}
	sort(ans.begin(),ans.end());
	for(int i=0;i<M;i++){
		cout<<ans.at(i).second<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 13168
// ABC168 A Therefore
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  // 初期値
  int N;
  cin >> N;
  vector<string>  hon = {"pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"};
  
  //Main loop
  cout << hon.at(N % 10) << endl;

  return 0;
}

Measured memory_bytes: 3572
n=int(input())
h=[int(i) for i in input().split()]
#連続しているところがどこかを考えればいい
#O(n^2)

def not_all_0(a):
    for i in a:
        if i!=0:
            return True
    else:
        return False

c=0
while(not_all_0(h)):
    d=0
    for i in range(n):
        if d==0:
            if h[i]!=0:
                h[i]-=1
                c+=1
                d=1
        else:
            if h[i]!=0:
                h[i]-=1
            else:
                d=0
print(c)


Measured memory_bytes: 3064
from collections import deque, defaultdict

N, Q = map(int, input().split(' '))

tree = defaultdict(set)
for _ in range(1, N):
    a, b = map(int, input().split(' '))
    tree[a].add(b)
    tree[b].add(a)

results = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split(' '))
    results[p] += x

stack = deque([1])
searched = set()

while len(stack) > 0:
    node = stack.popleft()
    searched.add(node)
    for child in tree[node]:
        if child not in searched:
            stack.append(child)
            results[child] += results[node]

print(' '.join([str(result) for result in results[1:]]))


Measured memory_bytes: 112452
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U> bool chmax(T &a, U b) { if (a <= b) {a = b; return 1;} return 0; }
template <class T, class U>  bool chmin(T &a, U b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T>  ostream &operator<<(ostream &os, vector<T> &v) { os << "{"; rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); } os << "}"; return os; }

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
    ll x=0,y=0,z=0,n,m,ans=0,sum=0,k,w,Max=-1,Min=1e9+1;
    bool ok = true;
    string s,t;
    cin >> x;
    for(ll i=-200; i<=200; i++){
        for(ll j=-200; j<=200; j++){
            if(i*i*i*i*i - j*j*j*j*j == x){
                cout << i  << " " << j << endl;
                return 0;
            }
        }   
    }
    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;


//mod演算ライブラリ
//mod=1000000007

LL add(LL a,LL b){
  return (a+b)%mod;
}

LL sub(LL a,LL b){
  return (a+mod-b)%mod;
}

LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法 単品利用可
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

LL dvs(LL a,LL b){
  return mul(a,power(b,mod-2));
}

const int SIZE_mod=200005;
int invfact[SIZE_mod];
int fact[SIZE_mod];

void factset(int a){//aまでの階乗%mod表を作成
  fact[0]=1;
  FORQ(i,1,a){
    fact[i]=mul(fact[i-1],i);
  }
}

void cmbset(int a){//1~aまでの階乗と階乗数の逆元のmod(mod)を用意 O(a)
  factset(a);
  invfact[a]=power(fact[a],mod-2);
  invfact[0]=1;
  FORD(i,a,1){
    invfact[i]=mul(invfact[i+1],i+1);
  }

}

LL cmb(int n,int r){//nCr%mod  (cmbset後に使用)
  if(n<r||r<0||n<0)return 0;
  return mul(fact[n],mul(invfact[r],invfact[n-r]));
}

LL prm(int n,int r){//nPr%mod
    return mul(cmb(n,r),fact[n]);
}

LL homo(int n,int r){//nHr%mod
  return cmb(n+r-1,r);
}


int main(){
	LL n;
    cin>>n;
    LL ans=sub(power(10,n),sub(mul(power(9,n),2),power(8,n)));
    cout<<ans<<endl;
}


Measured memory_bytes: 3596