akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void)
{
	int h;
	int w;
	int a;
	int b;

	

	for (;;)
	{
		scanf("%d %d", &h, &w);
		if (w==0 && h==0)
		{
			return 0;
		}
		for (b=0;b<h;b++)
		{
			for (a=0;a<w;a++)
			{
				if (b>=1 && b<(h-1))
				{
					
					if (a>=1 && a<(w-1))
					{
						printf(".");
					}
					else
					{
						printf("#");
					}
				}
				else
				{
					printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
		
	}

	return 0;
}

Measured memory_bytes: 572
def main():
    N = int(input())
    As = list(map(int, input().split()))
    ct = 1
    inc = False
    dec = False
    bef = As.pop(0)

    for Ai in As:
        if (not inc) and (not dec):
            if Ai < bef:
                dec = True
            elif Ai > bef:
                inc = True
        elif inc:
            if Ai < bef:
                ct += 1
                inc = False
        elif dec:
            if Ai > bef:
                ct += 1
                dec = False
        bef = Ai
    
    print(ct)

main()


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

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

    int n;
    cin >> n;
    vector<int> first;
    vector<int> second;
    for (int i=0;i<=n-1;i++)
    {
        int a;
        cin >> a;
        first.push_back(a);
    }
    for (int i=0;i<=n-1;i++)
    {
        int a;
        cin >> a;
        second.push_back(a);
    }

    int count=0;
    vector<int> alpha=min(first,second);
    vector<int> beta=max(first,second);
    while (alpha!=beta)
    {
        next_permutation(alpha.begin(),alpha.end());;
        count++;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
N, K = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
c = 0
d = 0
q = deque()
p = deque()
for i in range(K):
    if len(q) == 0:
        q.append(i)
    else:
        while len(q) > 0:
            if a[q[len(q)-1]] > a[i]:
                q.pop()
            else:
                q.append(i)
                break
        else:
            q.append(i)

    if len(p) == 0:
        p.append(i)
    else:
        while len(p) > 0:
            if a[p[len(p)-1]] < a[i]:
                p.pop()
            else:
                p.append(i)
                break
        else:
            p.append(i)
    if len(q) == K:
        c += 1

for i in range(K, N):
    if len(q) == 0:
        q.append(i)
    else:
        flag = 0
        while len(q) > 0:
            if a[q[len(q)-1]] > a[i]:
                q.pop()
                flag = 1
            else:
                q.append(i)
                break
        else:
            q.append(i)
        if q[0] == i-K:
            l = q.popleft()
        else:
            flag = 1

    if len(p) == 0:
        p.append(i)
    else:
        while len(p) > 0:
            if a[p[len(p)-1]] < a[i]:
                p.pop()
            else:
                p.append(i)
                break
        else:
            p.append(i)
        if a[p[0]] > a[i]:
            flag = 1

        if p[0] == i-K:
            l = p.popleft()



    if flag == 1:
        ans += 1
    if len(q) == K and flag == 1:
        c += 1

if c > 1:
    ans -= c-1
print(ans)


Measured memory_bytes: 88060
import java.util.*;
import java.util.stream.*;

class Main{
	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);

		int n=s.nextInt();
		int[] a=new int[n];
		int[] b=new int[n];
		Arrays.setAll(a,i->s.nextInt());

		//System.err.println(Arrays.toString(a));

		for(int t=0;t<100;++t){
			for(int i=0;i<n;++i){
				int h=(i+n-1)%n;
				int j=(i+1)%n;
				if(a[h]<a[i]&&a[i]>a[j]){
					int v=a[i]-Math.max(a[h],a[j]);
					a[h]-=v;
					a[i]-=v*2;
					a[j]-=v;
					b[i]+=v*2;
					b[j]+=v*2;
				}
				if(a[h]<a[i]&&a[i]==a[j]){
					int v=a[i]-a[h];
					a[i]-=v;
					a[j]-=v;
					b[j]+=v*2;
				}
			}
		}

		//System.err.println();
		System.err.println(Arrays.toString(a));
		//System.err.println(Arrays.toString(b));

		int t=a[0];
		System.out.println(Arrays.stream(b).mapToObj(i->String.valueOf(i+t)).collect(Collectors.joining(" ")));
	}
}


Measured memory_bytes: 64768
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n,a;
int len(ll k) {
	int res=0;
	while (k!=0) {
		res++;
		k/=10;
	}
	return res;
}
int main() {
	scanf("%lld",&n);
	a=sqrt(n);
	while (a>1&&n%a!=0) {
		a--;
	}
	printf("%d\n",max(len(a),len(n/a)));
	return 0;
}

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



signed main()
{
	int a;
	cin >> a;
	int iti = a%10;
	int zyu = (a/10)%10;
	int hyaku = (a/100)%10;
	int sen = (a/1000);

	if(iti == zyu || zyu == hyaku || hyaku == sen){
		cout << "Bad" << endl;
	}
	else
	{
		cout << "Good" << endl;
	}
	
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> B(N-1);
    for(int i=0; i<(N-1); ++i) cin >> B.at(i);

    vector<int> A(N);

    A.at(0) = B.at(0);

    for(int i=0; i<(N-2); ++i){
        A.at(i+1) = min(B.at(i), B.at(i+1));
    }

    A.at(N-1) = B.at(N-2);

    int sum = 0;
    for(int i=0; i<N; ++i) sum += A.at(i);
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
const int N = 100005;
using namespace std;
typedef long long ll;
int a[N];
int main()
{
    //freopen("e:\\in.txt","r",stdin);
	//freopen("output.txt", "w", stdout);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    ll imax=2,imin=2;

    for(int i=n;i>=1&&imax>=imin;i--){
        if(imin%a[i]!=0)
            imin=imin/a[i]*a[i]+a[i];//最小
        imax=(imax/a[i]+1)*a[i]-1;    //最大
    }
    if(imax>imin)
        printf("%lld %lld\n",imin,imax);
    else
        printf("-1\n");
    return 0;
}


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

int n, a, b;

vector <int> solve(int mask, int s, int e) {
	vector <int> ans;
	int x = __builtin_ctz(mask & (s ^ e));
//	cout << "81 " << mask << " " << s << " " << e << endl;
	if (__builtin_popcount(mask) == 1) {
		ans.push_back(s);
		ans.push_back(e);
		return ans;
	}
	int y = __builtin_ctz(mask ^ (1 << x));
	vector <int> vec1 = solve(mask ^ (1 << x), s, s ^ (1 << y));
	vector <int> vec2 = solve(mask ^ (1 << x), s ^ (1 << x) ^ (1 << y), e); 
	for (auto x : vec1) {
		ans.push_back(x);
	}
	for (auto x : vec2) {
		ans.push_back(x);
	}
	return ans;
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	if (__builtin_popcount(a) % 2 == __builtin_popcount(b) % 2) {
		cout << "NO";
	}
	else {
		cout << "YES" << endl;
		vector <int> ans = solve((1 << n) - 1, a, b);
		for (auto x : ans) {
			cout << x << " ";
		}
	}
	
	return 0;
}


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

int main() {
    int N, H[100100];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> H[i];

    reverse(H, H + N);
    bool ans = true;
    for (int i = 1; i < N; i++) {
        if (H[i] <= H[i - 1]) continue;
        if (H[i] - H[i - 1] == 1) H[i]--;
        else ans = false;
    }

    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 640
def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1

input()
A = list(map(int, input().split()))
index = partition(A, 0, len(A) - 1)
for i in range(len(A)):
    if i == index:
        A[i] = '[{}]'.format(A[i])
    else:
        A[i] = str(A[i])
print(' '.join(A))

Measured memory_bytes: 18528
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	fmt.Println(math.Pow(float64(n), 3))
}


Measured memory_bytes: 640
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

class song {
public:
  std::string s;
  i64 t;
  friend std::istream& operator>>(std::istream& is, song& self) {
    return is >> self.s >> self.t;
  }
};

int main() {
  i64 N;
  std::cin >> N;
  std::vector<song> songs;
  tools::read(songs, N);
  std::string X;
  std::cin >> X;
  std::cout << std::accumulate(
    std::next(std::find_if(songs.begin(), songs.end(), [&](const song& song) { return song.s == X; })),
    songs.end(),
    static_cast<i64>(0),
    [](const i64& sum, const song& song) { return sum + song.t; }
  ) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char s[3];
	char t[3];
	int count=0;
	for(int i=0;i<3;i++){
		scanf(" %c",&s[i]);
	}
	for(int i=0;i<3;i++){
		scanf(" %c",&t[i]);
	}
	for(int i=0;i<3;i++){
		if(s[i]==t[i]){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

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

int main(){
	int n, m; cin >> n >> m;
	int minv = 0, maxv = 1000000;
	for( int i = 0; i < m; ++i ){
		int left, right; cin >> left >> right;
		if(right > maxv && left < minv) continue;
		else if (left > maxv || right < minv) {
			cout << 0 << endl; 
			return 0;
		}
		else if (right <= maxv && left >= minv){
			maxv = right;
			minv = left;
		}
		else if (right > maxv && left <= maxv && left >= minv) minv = left;
		else maxv = right;
	}
	cout << maxv - minv + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k;
	cin>>n>>k;
	if(k == 1){cout<<0<<endl;return 0;}
	for(int i = 0; i < k; ++i)n--;
	if(n < 0)cout<<0<<endl;
	else cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std ;
bool is_war (const vector <int>&x,const vector <int>&y){
for (int Z=-100;Z<=100;Z++){
bool is_ok = true ;
for (int i=0;i<x.size();i++){
	if (x[i]>=Z) is_ok = false ;
}
for (int i=0;i<y.size ();i++){
	if (y[i]<Z) is_ok = false ;
}
if (is_ok) return false ;
}
return true ;
}

int main (){
	int N,M,i; cin >> N >> M ;
	vector<int> x(N+1),y(M +1);
	cin >> x[0] >> y[0];
	for (i=0; i<N ;i++) {
    	cin >> x[i+1];
	}
	for (i=0;i<M;i++) {
		cin >> y [i+1];
	}
	if(is_war(x,y)){
		cout << "War" << endl ;
	}
	else {
		cout << "No War" << endl ;
	}
}

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

#define PI 3.1415926535900
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 0; (int)(n) < i; i--)
#define Int long long
using namespace std;


int main() {

    int a[4];
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    int v = a[3];
    int sum = 0;

    if(v >= a[0]){
        //1
        sum += a[0];
        v = v - a[0];
        if(v >= a[1]){
            //0
            v = v - a[1];
            if(v >= a[2]){

                //-1
                sum -= a[2];
                v = v - a[2];
                cout << sum << endl;
            } else{

                sum -= v;
                cout << sum << endl;
            }
        } else{
            cout << sum << endl;
        }
    } else{
        cout << a[3] << endl;
    }
}

Measured memory_bytes: 3632
S = input()
mod = 10**9+7
dp = [[0]*13 for _ in range(len(S)+1)]
d = 1
dp[0][0] = 1

for i, s in enumerate(S[::-1]):
    if s == "?":
        for j in range(13):
            for k in range(10):
                dp[i+1][(j+(d*k)) % 13] += dp[i][j]
    else:
        for j in range(13):
            dp[i+1][(j+(d*int(s))) % 13] += dp[i][j]
    for j in range(13):
        dp[i+1][j] %= mod
    d = (d*10) % 13
print(dp[-1][5])


Measured memory_bytes: 62300
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>

int main(void){
    int i,j,k;
    int A,B;
    int answer = 0;
    
    scanf("%d %d",&A,&B);

    answer = (B-A) / (A-1) + 1;
    if((B-A) % (A-1) != 0){
        answer++;
    }
    
    if(B < A){
        if(B == 1){
            printf("%d\n",0);
        }else{
            printf("%d\n",1);
        }
    }else{
        printf("%d\n",answer);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int r, D;
    cin >> r >> D;
    vector<int> X(15);
    cin >> X[0];
    for(int i=1; i<11; i++){
        X[i]=r*X[i-1]-D;
        cout << X[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m; cin >> n >> m;
  auto bsearch =
    [&]() {
      auto test =
        [&](ll k) {
          if(m < k*2) return false;
          ll rem = m-k*2;
          if(n+rem/2 < k) return false;
          return true;
        };
      ll ok = 0, ng = longinf;
      while(ng-ok>1) {
        ll mid = (ok+ng)/2;
       (test(mid) ? ok : ng) = mid;
      }
      return ok;
    };
  cout << bsearch() << endk;
  return 0;
}


Measured memory_bytes: 3632
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i).sort!.reverse!
alice_point = a.select.with_index{|num, index| index%2 == 0}.inject(&:+)
bob_point = a.select.with_index{|num, index| index%2 != 0}.inject(&:+)
print("#{alice_point - bob_point}")


Measured memory_bytes: 1788
def main():
    x1, y1, x2, y2 = map(int, input().split())
    x3 = x2 - (y2 - y1)
    y3 = y2 + (x2 - x1)
    x4 = x3 - (y3 - y2)
    y4 = y3 + (x3 - x2)

    print(x3, y3, x4, y4)
main()  

Measured memory_bytes: 9024
// Problem : E - Sum of gcd of Tuples (Hard)
// Contest : AtCoder - AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

long long const m = pow(10, 9) + 7;

long long logPower(long long base, long exp) {
    long long power = base;
    long long ans = 1;
    while (exp > 0) {
        if (exp % 2 == 1) ans = (ans * power) % m;
        power = (power * power) % m;
        exp /= 2;
    }
    return ans;
}

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

    long n, k;
    cin >> n >> k;
    
    vector<long long> sequencesWithGcd(k + 1, 0);
    for (long i = k; i > 0; i--) {
        long long multiplesOfIBelowK = (long long) k / i;
        sequencesWithGcd[i] = logPower(multiplesOfIBelowK, n);   
        for (long j = 2 * i; j <= k; j += i) {
            sequencesWithGcd[i] = (sequencesWithGcd[i] + m - sequencesWithGcd[j]) % m;
        }
    }
    
    long long ans = 0;
    for (long i = 1; i <= k; i++) {
        ans = (ans + sequencesWithGcd[i] * i) % m;
    }
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
//---------------------------------------------------------------------------//

int main(){
        int l,n;
        string s[101];
        cin>>n>>l;
        rep(i,n) cin>>s[i];
        sort(s,n);
        rep(i,n){
                cout<<s[i];
        }
        cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    if(a>b){
        cout << 0 << endl;
        return 0;
    }
    if(n==1){
        if(a!=b){
            cout << 0 << endl;
        }else{
            cout << 1 << endl;
        }
        return 0;
    }
    ll hoge = a*(n-1)+b, fuga = b*(n-1)+a;
    cout << fuga - hoge + 1 << endl;
}

Measured memory_bytes: 256
//Fast IO + Debug Template
#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define pb push_back
#define gl(x) getline(cin,x)
#define gc(x) cin.get(x)
#define sz(x) (int)(x.size())
#define al(x) (x).begin(),(x).end()
#define ms(a, b) memset(a,b,sizeof(a))
#define sp ' '
#define nl '\n'
#define f first
#define s second
#define lsb(x) ((x)&(-x))
#define mp make_pair
#define m(x, y) (x + y) / 2
#define MOD 1000000007
#define gcd(x,y) __gcd(m,n);
#define perm(x) next_permutation(x.begin(), x.end());
#define bs(x,z) binary_search(x.begin(),x.end(),z);
#define lb(x,z) lower_bound(x.begin(),x.end(),z);
#define ub(x,z) upper_bound(x.begin(),x.end(),z);
#define nl '\n'


void sc(){}template<class T,class...A>void sc(T&t,A&...a){cin>>t,sc(a...);}
void pr(){}template<class T,class...A>void pr(T t,A...a){cout<<t,pr(a...);}
typedef long long ll;
typedef pair<int, int> pi;
//weighted (with adjList[])
typedef vector<pi> vii;
//unweighted (with adjList[])
typedef vector<int> vi;
typedef double db;
typedef long double ld;


const int INF = 0x3f3f3f3f;
const int NINF = -INF;
int TC, a, b;
char c;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	sc(c);
	a = (int) c;
	if (a >= 65 && a <= 90) cout << "A" << endl;
	else cout << "a" << endl;

return 0;
	}

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

int main(){
	ll n, m;
//	for(int i = 2; i <= 70; i++, i++)
//		cout << i << " "<< f(i) << endl;
	while(cin >> n){
		ll ans = 0;
		ll x = 10;
		while(x <= n){
			ans += n / x;
			x *= 5;
		}
		if(n % 2 == 1) cout << 0 << endl;
		else cout << ans << endl;	
	}
	return 0;	
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  int n;
  cin>>n;
  cout << n*n*n << endl;
}


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

int main(){
	int D, G;
	vector<int> p(11), c(11);
	cin >> D >> G;
	for(int i = 0; i < D; i++){
		cin >> p[i] >> c[i];
	}

	int ans = 1e9; //十分大きな数で初期化

	for(int bit = 0; bit < (1 << D); bit++){
		int s = 0, num = 0, rest_max = -1;
		for(int i = 0; i < D; i++){
			if (bit & (1 << i)) {
				s += 100 * (i+1) * p[i] + c[i]; 
				num += p[i];	//解く問題の合計
			}else{
				rest_max = i;	//使わなかったiの最大のi
			}
		}
		if (s < G) {
			int s1 = 100 * (rest_max + 1);
			int need = (G - s + s1 -1) / s1;	//(G -s)/s1では割り切れないときがある
			if(need >= p[rest_max]){
				continue;	//最適解の部分集合ではない
			}
			num += need;
		}
		ans = min(ans, num);
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
//関数
const long INF=1000000000000000;
bool check=false;

int main(void){
    string S,T;
    cin>>S>>T;
    long ans=0;
    for(int i=0;i<3;i++) ans+=(S.at(i)==T.at(i));
    cout<<ans<<endl;
}

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


int main(int argc, const char * argv[]) {

    int n;
    cin >> n;
    if(n%10 == 9 || n/10 == 9){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int N,i;
  int cnt = 0;
  cin>>N;
  
  int a[N];
  bool flg = true;
  for(i=0;i<N;i++){
    cin>>a[i];
  }

  while(true){
    for(i=0;i<N;i++){
      if(a[i]%2==1){
       flg = false; 
      }
    }
    if(flg == false){
      break;
    }
    for(i=0; i<N; i++){
      a[i]/=2;
    }
    cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 3576
#include<stdio.h>

#include <string.h>

int main()
{
    int N,K,Q;
  	scanf("%d", &N);
	scanf("%d", &K);
  	scanf("%d", &Q);
  int i=0;
  int j=0;
  int A[Q];
  int p[N];
 for(i=0;i<Q;i++){
	scanf("%d", &A[i]);
 	
 }
  for(i=0;i<N;i++){
	p[i] = K;
  }
  if(K > Q){
     for(i=0;i<N;i++){
	printf("Yes\n");
  }
    return 0;
  }
  
  
  
  /*
   for(j=0;j<Q;j++){
  for(i=0;i<N;i++){
	if(A[j] != i+1){
		p[i] = p[i] -1;
    }
 	 }
   }
   */
  
  for(j=0;j<Q;j++){
   p[A[j]-1] = p[A[j]-1] + 1;
 
  }
  
   for(i=0;i<N;i++){
     p[i] = p[i] - Q;
   }
	
  
   for(i=0;i<N;i++){
     if(p[i] <= 0){
       printf("No\n");
     }else{
       printf("Yes\n");
     }
   }
    return 0;
}


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

int main() {
	int a, b, c, go, nana;
	cin >> a >> b >> c;
	if (a == 5) go++;
	else if (a == 7) nana++;
	if (b == 5) go++;
	else if (b == 7) nana++;
	if (c == 5) go++;
	else if (c == 7) nana++;
	if (go == 2 && nana == 1) cout << "YES";
	else cout << "NO";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
int h,w,d;
int a[333][333];
int dp[100002];
map<P,int>A;
main(){
  map<int,P>M;
  cin>>h>>w>>d;
  r(i,h)r(j,w)cin>>a[i][j];
  r(i,h)r(j,w)M[a[i][j]]=P(i,j);
  for(int j=1;j<=d;j++)
  for(int i=j;i+1<=h*w;i+=d){
    P p1=M[i];
    P p2=M[i+d];
    dp[i+d]+=dp[i]+abs(p1.fi-p2.fi)+abs(p1.se-p2.se);

  }
  int q;
  cin>>q;
  r(e,q){
    int l,r,sum=0;
    cin>>l>>r;
    cout<<dp[r]-dp[l]<<endl;
    //cout<<sum<<endl;
  }
}

Measured memory_bytes: 12544
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize, k: usize,
        mut ab: [(usize, usize); n],
    }

    ab.sort();

    let mut sum = 0;
    for i in 0..n {
        sum += ab[i].1;
        if sum >= k {
            println!("{}", ab[i].0);
            return;
        }
    }
}


Measured memory_bytes: 6396
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = read.to!int;
	int m = read.to!int;
	
	S[] as;
	foreach(i; 0 .. m){
		as ~= S(i, read.to!int, read.to!long);
	}
	
	as.sort!"a.y<b.y"();
	
	int[][int] xm;
	foreach(a; as){
		if(a.p !in xm) xm[a.p] = [];
		xm[a.p] ~= a.id;
	}
	
	string[] ans = new string[](m);
	int[] ps = xm.keys;
	foreach(p; ps){
		int[] ids = xm[p];
		foreach(j, id; ids){
			ans[id] = "%06d".format(p) ~ "%06d".format(j + 1);
		}
	}
	
	foreach(an; ans) an.writeln;
}

struct S{
	int id;
	int p;
	long y;
}


Measured memory_bytes: 21500
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int N,M; cin >> N >> M;
    vector<set<int>> edge(N);
    REP(i,M){
        int a,b; cin >> a >> b;
        edge[a-1].insert(b-1); edge[b-1].insert(a-1);
    }

    bool flag=false;
    FOR(i,1,N-1){
        if(edge[0].find(i) != edge[0].end() && edge[N-1].find(i) != edge[N-1].end()){
            flag = true;
            break;
        }
    }
    cout << (flag ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}

Measured memory_bytes: 28416
S = input()

dif = 0
i = 1
last = S[0]
while i < len(S):
    if last!=S[i]:
        last = S[i]
        i += 1
    else:
        last = ''.join(S[i:i+2])
        i += 2
        dif += 1

print(len(S)-dif)


Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

typedef unsigned long long ull;
typedef pair<int,int> pii;

int t;

void solve(){
    ull k, x;
    cin>>k>>x;
    if(k*500>=x)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll a,b; cin >> a >> b;
  if(a+b<10) cout << a+b << endl;
  else cout << "error" << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#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++)


int main(){
    int n, answer = 0;
    cin >> n;
    vector<pair<int, int> > r(n), b(n);
    vector<bool> check(n);
    rep(i, n) cin >> r.at(i).first >> r.at(i).second;
    rep(i, n) cin >> b.at(i).first >> b.at(i).second;
    sort(b.begin(), b.end());
    fill(check.begin(), check.end(), false);
    rep(i, n){
        int y = -1;
        int index = -1;
        rep(j, n) {
            if(r.at(j).first < b.at(i).first && r.at(j).second < b.at(i).second && !check.at(j)){
                if(y < r.at(j).second){
                    y = r.at(j).second;
                    index = j;
                }
            }
        }
        if(y != -1){
            check.at(index) = true;
        }
    }

    rep(i, n) if(check.at(i)) answer++;
    cout << answer << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, a;
	cin >> n >> a;
	int b;
	b = n / 500;
	int c;
	c = n - 500 * b;
	if (c > a)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	if(n<1000) cout << "ABC" << endl;
	else cout << "ABD" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i = 0;i < N; ++i){
    cin >> A[i];
  }
  int ans = 0;
  for(int i = 0; i < N; ++i){
    if(A[A[i]-1] == i+1) ++ans;
  }
  cout << ans/2 << endl;
  return 0;
}


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

using namespace std;

int main()
{
        long long n,p=0,k=0;
        cin>>n;
        if(n>=500)
        {
                p=(n/500);
                n=n%500;
                k=p*1000;
               // cout<<k<<n<<p<<endl;

        }
       /* if(n>=100)
        {
                p=p+(n/100);
                n=n%100;
        }
        if(n>=50)
        {
                p=p+(n/50);
                n=n%50;
        }
        if(n>=10)
        {
                p+(n/10);
                n=n%10;
        }*/
        if(n>=5){
                        p=n/5;
                k=k+(p*5);
                //cout<<k<<p;
        }
        cout<<k<<endl;
}


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

#define all(A) (A).begin(), (A).end()
#define sz(A) int((A).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;


inline int max (const int& a, const int& b) { return a <= b ? b : a; }

inline pii merge (pii x, pii y) {
  int first_mx = max(x.first, y.first);
  int second_mx = max(x.second, y.second);
  if (first_mx == x.first) second_mx = max(second_mx, y.first);
  if (first_mx == y.first) second_mx = max(second_mx, x.first);
  return std::move(pii(first_mx, second_mx));
}

const int MAX_N = 1e5 + 10;

int n;
pii st[2 * MAX_N];

void build () {
  for (int i = n - 1; i > 0; i--) st[i] = merge(st[i << 1], st[i << 1 | 1]);
}

pii getMax (int l, int r) {
  r++;
  pii res(-1, -1);
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l&1) res = merge(res, st[l++]);
    if (r&1) res = merge(res, st[--r]);
  }
  return res;
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n;
  vector <int> arr(n + 1);
  vector <int> pos(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    pos[arr[i]] = i;
    st[n + i] = pii(arr[i], -1);
  }
  build();
  function <pii(int,int)> getRange = [&] (int num, int sec) -> pii {
    pii exp(num, sec);
    int l1 = 0, r1 = pos[num];
    while (l1 != r1) {
      int m = (l1 + r1) >> 1;
      pii cur = getMax(m, pos[sec]);
      if (exp == cur) r1 = m;
      else l1 = m + 1;
    }
    int l2 = pos[num], r2 = n - 1;
    while (l2 != r2) {
      int m = (l2 + r2 + 1) >> 1;
      pii cur = getMax(pos[sec], m);
      if (exp == cur) l2 = m;
      else r2 = m - 1;
    }
    return pii(l1, l2);
  };
  function <pii(int)> getRange2 = [&] (int num) -> pii {
    int l1 = 0, r1 = pos[num];
    while (l1 != r1) {
      int m = (l1 + r1) >> 1;
      pii cur = getMax(m, pos[num]);
      if (num == cur.first) r1 = m;
      else l1 = m + 1;
    }
    int l2 = pos[num], r2 = n - 1;
    while (l2 != r2) {
      int m = (l2 + r2 + 1) >> 1;
      pii cur = getMax(pos[num], m);
      if (num == cur.first) l2 = m;
      else r2 = m - 1;
    }
    return pii(l1, l2);
  };
  ll ans = 0;
  for (int sec = 1; sec < n; sec++) {
    pii ran = getRange2(sec);
    pii l = pii(-1, -1);
    pii r = pii(-1, -1);
    if (0 <= ran.first - 1) l = getRange(arr[ran.first - 1], sec);
    if (ran.second + 1 < n) r = getRange(arr[ran.second + 1], sec);
    if (l.first != -1) {
      l.second = ran.first - 1;
      ll x = l.second - l.first + 1;
      ll y = ran.second - pos[sec] + 1;
      ans += x * y * sec;
    }
    if (r.first != -1) {
      r.first = ran.second + 1;
      ll x = r.second - r.first + 1;
      ll y = pos[sec] - ran.first + 1;
      ans += x * y * sec;
    }
  }
  cout << ans << '\n';
  return (0);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int N = 20;
 
int s[N],per[N][N],is[N][N];
 
inline int cal(int x){
	int res = 0;
	while(x){
		x -= (x&(-x));
		res++;
	}
	return res;
}
 
int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n;++i){
		scanf("%d",&s[i]);
		for(int j = 1;j <= s[i];++j){
			scanf("%d%d",&per[i][j],&is[i][j]);
		}
	}
	
	int ans = 0;
	for(int i = 0;i < (1<<n);++i){
		bool f = 1;
		for(int j = 1;j <= n;++j){
			if(i & (1 << (j-1))){
				for(int k = 1;k <= s[j];++k){
					if(is[j][k] && !(i & (1 << per[j][k]-1))) f = 0;
					if(!is[j][k] && (i & (1 << per[j][k]-1))) f = 0;
					if(!f) break; 
				}
			}
			if(!f) break;
		}
		if(f) ans = max(ans,cal(i));
	}
	
	printf("%d\n",ans);
	return 0;
}//123213213213213

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
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; }

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  SPEED;
  int n; cin >> n;
  vector<int> a(n);
  int ma = -1;
  int p = -1;
  rep(i, n) {
    cin >> a[i];
    if (a[i] > ma) {
      p = i;
      ma = a[i];
    }
  }
  sort(a.rbegin(), a.rend());
  rep(i, n) {
    if (i != p) {
      cout << a[0] << '\n';
    } else {
      cout << a[1] << '\n';
    }
  }
}

Measured memory_bytes: 2432
N = str(input())

N = N[::-1]
if N[0] == '2' or N[0] =='4' or N[0] =='5' or N[0] =='7' or N[0] =='9' :
    print('hon')
elif N[0] == '0' or N[0] =='1' or N[0] =='6' or N[0] =='8' :
    print('pon')
else:
    print('bon')

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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    cin >> N;
    const auto &res = prime_factorize(N);
    // cout << N << ":";
    // for (auto p : res) {
    //     for (int i = 0; i < p.second; ++i) cout << " " << p.first;
    // }
    // cout << endl;

	ll ans = 0;
	for (auto p : res){
		ll cnt = 1;
		// while(true){
		// 	if(p.second <= 0) break;
		// }
		for(int i=0; i< p.second; ++i){
			ans++;
			p.second = p.second - (i+1);
		}

	}

	cout << ans << endl;


}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
using namespace std;
int main() {
  string s1,s2,s3;
  int s1_last,s2_last;
  cin >> s1 >> s2 >> s3;
  s1_last = s1.size();
  s2_last = s2.size();
  if(s1[s1_last-1] == s2[0] && s2[s2_last-1] == s3[0]) cout << "YES";
  else cout << "NO";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int x,a,b; cin >> x >> a >> b;
    if(abs(x-a)<abs(x-b)){
        cout << "A" << endl;
    }else{
        cout << "B" << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> x = new ArrayList<>();
        List<Integer> y = new ArrayList<>();
        List<Integer> h = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            x.add(sc.nextInt());
            y.add(sc.nextInt());
            h.add(sc.nextInt());
        }
        for (int X = 0; X <= 100; X++) {
            for (int Y = 0; Y <= 100; Y++) {
                boolean ok = true;
                int H = 0;
                int cnt = 0;
                for (int i = 0; i < n; i++) {
                    if (h.get(i) < 1) {
                        continue;
                    }
                    H = h.get(i) + Math.abs(x.get(i) - X) + Math.abs(y.get(i) - Y);
                    cnt++;
                }
                for (int i = 0; i < n; i++) {
                    if (h.get(i) < 1) {
                        continue;
                    }
                    if (H != h.get(i) + Math.abs(x.get(i) - X) + Math.abs(y.get(i) - Y)) {
                        ok = false;
                        break;
                    }
                    if (cnt == 1 && H != 1) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    System.out.printf("%d %d %d\n", X, Y, H);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 23712
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int A,B;
    int rev,cnt=0;
    
    cin>>A>>B;
    
    for(int i=A;i<=B;i++){
        int han=i;
        rev=0;
        while(han!=0){
            int x=han%10;
            rev = rev*10+x;
            han = han/10;
        }
        if(rev==i) cnt++;
    }
    
    cout<<cnt<<endl;
    return 0;
    
    
}


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

class Node:
    def __init__(self):
        self.parent = -1
        self.left = -1
        self.right = -1

def preParse(T, u):
    if u == -1:
        return
    print(' {}'.format(u), end='')
    preParse(T, T[u].left)
    preParse(T, T[u].right)

def inParse(T, u):
    if u == -1:
        return
    inParse(T, T[u].left)
    print(' {}'.format(u), end='')
    inParse(T, T[u].right)

def postParse(T, u):
    if u == -1:
        return
    postParse(T, T[u].left)
    postParse(T, T[u].right)
    print(' {}'.format(u), end='')

def main():
    N = int(input())
    T = [Node() for _ in range(N)]
    for _ in range(N):
        idx, l, r = map(int, input().split())
        T[idx].left = l
        T[idx].right = r
        if l != -1:
            T[l].parent = idx
        if r != -1:
            T[r].parent = idx
    root = [i for i, x in enumerate(T) if x.parent == -1][0]
    print('Preorder')
    preParse(T, root)
    print()
    print('Inorder')
    inParse(T, root)
    print()
    print('Postorder')
    postParse(T, root)
    print()

if __name__ == '__main__': main()


Measured memory_bytes: 5620
#include<stdio.h>
#include <iostream>
using namespace std;
int main(void)
{
	int i,n,a,j,b,c,d,A[101],B[101]; 
	cin>>n;
	for(i=1;i<=n;i++){
		A[i]=0;
		B[i]=1;
		}
	for(i=0;i<n*(n-1)/2;i++){
		cin>>a>>b>>c>>d;
		if(c>d){
			A[a]+=3;
		}
		else if(c<d){
			A[b]+=3;
		}
		else{
			A[a]++;
			A[b]++;
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(A[i]>A[j]){
				B[j]++;
			}
		}
	}
	for(i=1;i<=n;i++){
		cout<<B[i]<<endl;
	}
return 0;
}

Measured memory_bytes: 3088