akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
 
    // exchange upper <=> lower

    string s;
    getline(cin,s);

    for(int i=0;i<s.size();i++){
        if(islower(s.at(i)))//lower
            cout<<(char)toupper(s.at(i));
        else if(isupper(s.at(i)))//upper
            cout<<(char)tolower(s.at(i));
        else
            cout<<s.at(i);
    }

    cout<<endl;

    return 0;
}


Measured memory_bytes: 3172
n,d = map(int,input().split())
c = [list(map(int, input().split())) for i in range(n)]

count = 0

for i in range(n-1):
    for j in range(i+1,n):
        sum = 0
        for k in range(d):
            sum += (c[i][k]-c[j][k])**2
        
        if sum ** 0.5 % 1 == 0:
            count += 1

print(count)

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
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; }

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


int main() {
    cout<<fixed<<setprecision(10);
    string s,t; cin>>s>>t;

    if(s== t.substr(0, s.size())) puts("Yes");
    else puts("No");

    return 0;

}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll n, m;
    cin >> n >> m;
    //cout << n << ' ' << m << endl;

    vector<vector<ll>> matrix(n, vector<ll>(m));
    vector<ll> vec(m);
    vector<ll> ans(n);

    for (ll j=0; j<n; j++)
    {
        for (ll i=0; i<m; i++)
        {
            cin >> matrix[j][i];
        }
    }

    for (ll j=0; j<m; j++)
    {
        cin >> vec[j];
        //cout << vec[j] << endl;
    }

    for (ll j=0; j<n ; j++)
    {
        for (ll i=0; i<m; i++)
        {
            ans[j] += matrix[j][i] * vec[i];
            //cout << matrix[j][i] << ' ' << vec[i] << endl;
            //cout << ans[j] << endl;
        }
    }

    for (ll j=0; j<n; j++)
    {
        cout << ans[j] << endl;
    }

    return 0;
}



Measured memory_bytes: 3180
#include<stdio.h>
int main(){
	int n;
	int sum=100000;
	scanf("%d",&n);
	while(n){
		sum*=1.05;
		if(sum%1000!=0)sum=(sum/1000+1)*1000;
		n--;}
	printf("%d\n",sum);
	return 0;}



Measured memory_bytes: 2636
//At coder k stones 
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;
#define display(v) f(v.size())cout << v[i] << " "
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;  cin>>n>>k;
    int arr[n];  f(n)cin>>arr[i];
    vl dp(k+1,0);
    dp[0] = 1;   // we have use i candies so far.
    for(int child = 0;child<n;child++)
    {
        int u_b = arr[child];   //upper bound on this position
        vl temp(k+1,0);
        for(int used = k ; used >=0 ; used--)
        {
            ll val = dp[used];
            int left = used +1 ;
            int right = used + min(u_b,k-used);   // scope of this postion if before this used candies have been distributed 
            if(right >= left)
            {
                temp[left]= add(temp[left],val);
                if(right + 1 <=k )
                {
                    temp[right+1]=sub(temp[right+1],val);
                }
            }
        }
        int pre_sum = 0;
        for(int i =0;i<=k;i++)
        {
            pre_sum = add(pre_sum,temp[i]);
            dp[i] = add(dp[i],pre_sum);
        } 
    }
    cout << dp[k] << "\n";
    
    
    return 0;
 }

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

int main(){
  double n, k;
  cin >> n >> k;
  int c=1; 
  while(n/k>=1){
    n /= k;
    c++;
  }
  cout << c << endl;
}


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

using namespace std;

int main()
{
    int r,c;
    cin >> r >> c;
    int a[r][c];
    int i,j,k,s;

    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            a[i][j] = 0;
        }
    }
    
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            cin >> a[i][j];
        }
    }

    for(i=0;i<r+1;i++){
        if(i!=r){
            for(j=0;j<c+1;j++){
                if(j==c){
                    int result = 0;
                    for(k=0;k<c;k++){
                       result += a[i][k];
                    }
                    cout <<  result << endl;
                }
                else{
                    cout << a[i][j] << " ";
                }
            }
        }
        else{
            for(j=0;j<c+1;j++){
                if(j!=c){
                    int result = 0;
                    for(k=0;k<r;k++){
                        result += a[k][j];
                    }
                    cout << result << " ";
                }
                else{
                    int result = 0;
                    for(k=0;k<r;k++){
                        for(s=0;s<c;s++){
                            result += a[k][s];
                        }
                    }
                    cout << result << endl;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3152
#include "bits/stdc++.h"
using namespace std;

//諸機能
#pragma region MACRO 
#define putans(x)  std::cerr << "[ answer ]: " ; cout << (x) << endl
#define dputans(x) std::cerr << "[ answer ]: "; cout << setprecision(27) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //ファイルからテストデータを読み込む
std::ifstream ifs("data.txt");
#define put ifs >>
#else //ジャッジシステムでいい感じにやる
#define put cin >>
#endif
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#ifdef _DEBUG
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#else
#define dbg(var0) {}
#define dbg2(var0, var1) {}
#define dbg3(var0, var1, var2) {}
#define dbgArray(a,n) {}
#endif 
#pragma endregion 
//typedef（書き換える、書き足す可能性ある）
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-10)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(2*1e9)
#pragma endregion

int main() {
	string s; put s;
	int gu = 0;
	int pa = 0;
	rep(i, s.size()) {
		if (s[i] == 'g') gu++;
		else pa++;
	}
END:
	putans((s.size()/2 - pa));
	return 0;
}

//int x, y, e; put x >> y >> e;
//int s = x + y;
//int t = s + 1;
//rep(i, x) {
//	addEdge(s, i, 1);
//}
//rep(i, y) {
//	addEdge(x + i, t, 2);
//}
//rep(i, e) {
//	int xi, yi;
//	put xi >> yi;
//	addEdge(xi, x + yi, 5);
//}
//cout << maxFlowDinic(s, t) << endl;

Measured memory_bytes: 512
N=input()
K=int(input())
l=len(N)
dp=[[0]+[1]*l]+[[0]*(l+1) for i in range(K)]
dp2=[[1]+[0]*l]+[[0]*(l+1) for i in range(K)]
for i,n in enumerate(N):
    n=int(n)
    for j in range(K):
        dp[j+1][i+1]=dp[j][i]*9+dp[j+1][i]+(dp2[j][i]*(n-1)+dp2[j+1][i] if n>0 else 0)
        dp2[j+1][i+1]=dp2[j][i] if n>0 else dp2[j+1][i]
print(dp[-1][-1]+dp2[-1][-1])

Measured memory_bytes: 3064
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << #x << " = " << (x) << " | "

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)
#define rrep(i, n)        for (int i = (n) - 1; i > -1; --i)

#define no                puts("No")
#define yes               puts("Yes")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair<ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

void solve() {
    std::string s; in(s);
    rep(i, 26) {
        int c = std::count(s.begin(), s.end(), 'A'+i);
        if (c != 0 && c!= 2) { no; return; }
    }
    yes; return;
}

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

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

N = int(input())
a_li = list(map(int, input().split()))
# y = X - x
# |x - y| = |x - (X - x)|
#         = |-X + 2x|
total = sum(a_li)
acc = list(accumulate(a_li))
ans = 10 ** 18
for i in range(N - 1):
    ans = min(ans, abs(acc[i] * 2 - total))
print(ans)


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

using namespace std;

const int MAXN = 1000000 + 10;
int n;
int a[MAXN];

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    sort(a, a+n);
    cout << a[n-1] - a[0] << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;

class Main{
    static int N;
    static ArrayList<Integer> C = new ArrayList<>();
    static ArrayList<Integer> S = new ArrayList<>();
    static ArrayList<Integer> F = new ArrayList<>();
    static ArrayList<Integer> time = new ArrayList<>();

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        N = Integer.parseInt(str);
        String[] s = new String[3];
        for (int i=0;i<N-1;i++){
            str = br.readLine();
            s = str.split(" ");
            C.add(Integer.parseInt(s[0]));
            S.add(Integer.parseInt(s[1]));
            F.add(Integer.parseInt(s[2]));
        }
        C.add(0);
        S.add(0);
        F.add(0);
        for (int i=0;i<N;i++){
            time.add(move(i,0));
        }
        for (int i=0;i<N;i++){
            System.out.println(time.get(i));
        }
    }

    static int move(int i,int now){
        if (i == N-1){
            return now;
        }
        if (now >= S.get(i) && now % F.get(i)!=0){
            now += F.get(i) - now % F.get(i);
        } else if (now < S.get(i)){
            now = S.get(i);
        }
        return move(i+1,now+C.get(i));
    }
}

Measured memory_bytes: 22808
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 28 18:39:26 2020

@author: Kanaru Sato
"""

n = int(input())
a = list(map(int, input().split()))
ans = [0]*n

for i in range(0,n):
    givenindex = n-1-i
    given = givenindex+1
    givenl = []
    
    for j in range(1,n+1):
        if given*j <= n:
            givenl.append(given*j)
        else:
            break
        
    sum = 0
    for j in givenl:
        sum += ans[j-1]
        
    if sum%2 == a[givenindex]:
        ans[givenindex] = 0
    else:
        ans[givenindex] = 1

sum = 0
for i in range(n):
    sum = sum + ans[i]
print(sum)

filledbox = []
for i in range(n):
    if ans[i] == 1:
        filledbox.append(i+1)
tmp = " ".join(map(str,filledbox))
print(tmp)

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

void solve() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  int h;
  rep(i, n) {
    cin >> h;
  	if (h < k) continue;
    ans++;
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}


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

using namespace std;
const int maxn = 1e5 + 7;
int N;
int stones[maxn];

void solve() {
    int dp1, dp2, dp;
    dp2 = 0;
    dp1 = abs(stones[N-1] - stones[N-2]);
    dp = dp1;
    for (int i = N - 3; i >= 0; --i) {
        dp = min(dp1 + abs(stones[i+1] - stones[i]), dp2 + abs(stones[i+2] - stones[i]));
        dp2 = dp1;
        dp1 = dp;
    }
    cout << dp << endl;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> stones[i];
    solve();
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    long long n,m;
	cin>>n>>m;
	if(n==1 || m==1)
	{
		cout<<1;
		return 0;
	}
	cout<<(n*m+1)/2;
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    vector<int> n(3);
    for(int i = 0; i < 3; i++){
        cin >> n[i];
    }
    sort(all(n));
    int x1 = n[2] - n[0];
    int x2 = n[2] - n[1];
    // 両方偶数
    if(x1 % 2 == 0 && x2 % 2 == 0){
        cout << x1 / 2 + x2 / 2 << endl;
    // 偶奇
    }else if((x1 % 2 == 0 && x2 % 2 != 0) || (x1 % 2 != 0 && x2 % 2 == 0)){
        cout << x1 / 2 + 1 + x2 / 2 + 1 << endl;
    // 両方奇数
    }else{
        cout << x1 / 2 + x2 / 2 + 1 << endl;
    }
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===


int ans[510][510];

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

	int N, M, Q;
	cin >> N >> M >> Q;

	memset(ans, 0, sizeof(ans));
	for (int i = 0; i < M; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		++ans[0][R];
		--ans[L + 1][R];
		--ans[0][N];
		++ans[L + 1][N];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = i; j < N; ++j) {
			ans[i + 1][j] += ans[i][j];
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = i; j < N; ++j) {
			ans[i][j + 1] += ans[i][j];
		}
	}

	for (int i = 0; i < Q; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		cout << ans[L][R] << "\n";
	}

	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

int main()
{
    int H,W;
    cin>>H>>W;
    string s[H];
    for(int i=0;i<H;i++)
        cin>>s[i];
    long long int a[H][W];
    a[0][0]=1;
    int flag=0;
    for(int i=0;i<W;i++){
        if(flag==0 && s[0][i]=='.')
            a[0][i]=1;
        else{
            a[0][i]=0;
            flag=1;
        }
    }
    flag=0;
    for(int i=0;i<H;i++){
        if(flag==0 && s[i][0]=='.')
            a[i][0]=1;
        else{
            a[i][0]=0;
            flag=1;
        }
    }
    for(int i=1;i<H;i++){
        for(int j=1;j<W;j++){
            if(s[i][j]=='.'){
                a[i][j] = (a[i-1][j]+a[i][j-1])%mod;
            }
            else a[i][j]=0;
        }
    }
    cout<<a[H-1][W-1]<<endl;
   
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
#define ll long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define rep(i,l,r) for(i=l;i<r;i++)
#define ld long double
#define ff first
#define ss second
#define pli pair<ll,int>
#define pi 3.1415926535897932384626433832
int main()
{
    io;
    int i,n;
    ll x;
    cin>>n>>x;
    vector<ll>b(n);
    vector<ll>l(n);
    vector<ll>u(n);
    vector<pli>p(n);
    vector<ll>pre(n);
    ll d=0;
    rep(i,0,n)
    {
    cin>>b[i]>>l[i]>>u[i];
    d-=l[i]*b[i];
    p[i]=mp(l[i]*b[i]+u[i]*(x-b[i]),i);
    }
    ll beg=0;
    ll r=n*x;
    //cout<<r;
    sort(p.begin(),p.end(),greater<pli>());
    pre[0]=p[0].ff;
    rep(i,1,n)
    pre[i]=pre[i-1]+p[i].ff;
    while(beg<=r)
    {
        //cout<<1;
        ll mid=(beg+r)/2;
        ll q=mid/x;
        ll rem=mid%x;
        ll ans;
        ll maxi=d;
        if(q==n)
            maxi=0;
        else
        rep(i,0,n)
        {
            ans=d;
            if(q!=0)
            {
            if(i<q)
                ans+=pre[q]-p[i].ff;
            else
                ans+=pre[q-1];
            }
            ans+=min(b[p[i].ss],rem)*l[p[i].ss]+max(rem-b[p[i].ss],0ll)*u[p[i].ss];
            maxi=max(ans,maxi);
        }
        if(maxi>=0)
        r=mid-1;
        else
        beg=mid+1;
    }
    cout<<beg;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int N;
vector<int> A;

int bubbleSort(){
	int cnt = 0;
	bool has_swap = true;
	while(has_swap){
		has_swap = false;
		for (int i = N-1;i >= 1;i--){
			if(A[i] < A[i-1]){
				swap(A[i],A[i-1]);
				cnt++;
				has_swap = true;
			}
		}
	}
	return cnt;
}

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

	cin >> N;

	A = vector<int>(N);
	for (int i = 0;i < N;i++){
		cin >> A[i];
	}

	int num_swap = bubbleSort();

	for (int i = 0;i < N;i++){
		cout << A[i] << (i == N-1?"\n":" ");
	}

	cout << num_swap << endl;

	return 0;

}



Measured memory_bytes: 3164
import java.util.*;
public class Main {
static Scanner inp=new Scanner(System.in);
static int a[]=new int[100000];
static int ans[][]=new int[1000][1000];
	static int max(int x,int y){
		if (x>y)return(x);
		return(y);
	}
	public static void main(String[] args) {
		int n=inp.nextInt();
		while (n>0){
			for(int i=1;i<=n;i++)a[i]=inp.nextInt();
			for(int i=1;i<=n;i++)
				for (int j=i;j<=n;j++)
					ans[i][j]=-10000000;
			for (int j=1;j<n;j++)
			    for(int i=1;i+j<=n;i++){
					for (int h=i+1;h<i+j;h++)
						ans[i][j+i]=max(ans[i][h]+ans[h+1][i+j],ans[i][i+j]);
					if (Math.abs(a[i]-a[i+j])<2) ans[i][i+j]=max(ans[i+1][i+j-1]+2,ans[i][j+i]);
				}
			for (int j=1;j<n;j++)
			    for(int i=1;i+j<=n;i++)
					for (int h=i+1;h<i+j;h++){
						ans[i][i+j]=max(max(ans[i][i+j],0),max(ans[i+1][i+j],max(ans[i][i+j-1],ans[i][h]+ans[h+1][i+j])));
				}
			System.out.println(ans[1][n]);
			n=inp.nextInt();
		}
			
	}

}

Measured memory_bytes: 46092
n=int(input())
arr = [[False for i in range(13)] for j in range(4)]
for count in range(n):
    code = input().split()
    if (code[0]=="S"):
        arr[0][int(code[1])-1]=True
    elif (code[0]=="H"):
        arr[1][int(code[1])-1]=True
    elif(code[0]=="C"):
        arr[2][int(code[1])-1]=True
    else:
        arr[3][int(code[1])-1]=True

for i in range(4):
    if(i==0):
        img="S"
    elif(i==1):
        img="H"
    elif(i==2):
        img="C"
    else:
        img="D"
    for j in range(13):
        if(arr[i][j]==False):
            print(img+" "+str(j+1))

Measured memory_bytes: 7776
T = [int(input()) for _ in range(5)]

ans = 1000
for i in range(5):
    tmp = 0
    for j in range(5):
        if i==j:
            tmp += T[j]
        else:
            tmp += T[j] + (-T[j])%10
    ans = min(tmp,ans)
print(ans)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> ans(4, 0);
    rep(i, n){
        string s;
        cin >> s;
        if(s=="P")ans[0]=1;
        if(s=="W")ans[1]=1;
        if(s=="G")ans[2]=1;
        if(s=="Y")ans[3]=1;
    }
  	int acu = accumulate(all(ans), 0);
    if(acu == 3)cout << "Three";
  	else cout << "Four";
}
    


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
struct ar{
	int x, l;
	int a, b;
}arr[100000];
bool cmp(ar a, ar b)
{
	return a.b < b.b;
}
int main()
{
	int n, count = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &arr[i].x, &arr[i].l);
		arr[i].a = arr[i].x - arr[i].l;
		arr[i].b = arr[i].x + arr[i].l;
	}
	std::sort(arr, arr + n, cmp);
	for (int i = 0, j = 1; j < n; j++)
	{
		if (arr[j].a >= arr[i].b)
		{
			count++;
			i = j;
		}
	}
	printf("%d\n", count + 1);
	return 0;
}

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

using namespace std;

typedef long long ll;

map<ll, ll> prime_factor(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) res[n]++;
    return res;
}

int main()
{
    ll L;
    while (cin >> L, L) {
        map<ll, ll> p = prime_factor(L);
        ll res = 1;
        for (auto &x: p) {
            ll n = x.second + 1;
            res *= (n * n - (n - 1) * (n - 1));
        }
        cout << (res + 1) / 2 << endl;
    }
    return 0;
}

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

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1;
    for (size_t i = 0; i < size; ++i) {
        vec1.push_back(cin2var<T>());
    }
    return vec1;
}

void sub()
{
    constexpr size_t N = 3;
    const auto lunchs(cin2vec<size_t>(N));
    const auto iteMax(max_element(lunchs.cbegin(), lunchs.cend()));
    const char no = iteMax - lunchs.cbegin();
    cout << static_cast<char>('A' + no) << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    sub();
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin >> N;
  int K;
  cin >> K;
  int L = N.size();
  vector<int> n(L);
  for (int i = 0; i < L; i++){
    n[i] = N[i] - '0';
  }
  vector<vector<vector<long long>>> dp(L + 1, vector<vector<long long>>(2, vector<long long>(K + 2, 0)));
  dp[0][0][0] = 1;
  for (int i = 0; i < L; i++){
    for (int j = 0; j < 2; j++){
      for (int k = 0; k <= K; k++){
        for (int d = 0; d <= (j ? 9 : n[i]); d++){
          dp[i + 1][j | d < n[i]][d == 0 ? k : k + 1] += dp[i][j][k];
        }
      }
    }
  }
  cout << dp[L][0][K] + dp[L][1][K] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    int n, l, p = -1, m = 0;
    cin >> n >> l;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        m += a[i];
        if (i > 0 && a[i] + a[i - 1] >= l) p = i;
    }
    if (p < 0) return cout << "Impossible", 0;
    cout << "Possible" << endl;
    for (int i = 0; i < p - 1; ++i) cout << i + 1 << endl;
    for (int i = n - 2; i >= p; --i) cout << i + 1 << endl;
    cout << p << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
using namespace std;
int n, mx[2], mi[2], my[2], ans, a[2][100005];
int main() {
	int i, j, t;
	cin>>n;
	for(i=0; i<n; i++) scanf("%d", &t), a[i%2][t]++;
	for(i=0; i<2; i++) for(j=1; j<=100000; j++) {
		if(a[i][j] > mx[i]) mx[i] = a[i][j], mi[i] = j;
	}
	if(mi[0] != mi[1]) ans = n - mx[0] - mx[1];
	else {
		for(i=0; i<2; i++) for(j=1; j<=100000; j++) {
			if(j == mi[0]) continue;
			if(a[i][j] > my[i]) my[i] = a[i][j];
		}
		ans = n - max(mx[0] + my[1], mx[1] + my[0]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N, A;

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

    if((N % 500) <= A) printf("Yes\n");
    else printf("No\n");
    
    return 0;
}


Measured memory_bytes: 256
input_num = int(input())

combinations = [(pow1, pow2, pow3, pow4, pow5, pow6)
                for pow1 in range(0, 6)
                for pow2 in range(0, 6)
                for pow3 in range(0, 6)
                for pow4 in range(0, 6)
                for pow5 in range(0, 6)
                for pow6 in range(0, 6)]

num_withdraw_list = []
for combination in combinations:
    pow1, pow2, pow3, pow4, pow5, pow6 = combination
    withdraw6 = 6 ** 1 * pow1 + 6 ** 2 * pow2 + \
                6 ** 3 * pow3 + 6 ** 4 * pow4 + \
                6 ** 5 * pow5 + 6 ** 6 * pow6

    if withdraw6 > input_num:
        continue
    else:
        rest = input_num - withdraw6
        num_withdraw = sum(combination)
        for i in reversed(range(1, 6)):
            withdraw_i = rest // 9 ** i
            rest -= 9 ** i * withdraw_i
            num_withdraw += withdraw_i
        num_withdraw += rest
        num_withdraw_list.append(num_withdraw)

print(str(min(num_withdraw_list)))


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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  a = (-1)*a;
  if(a+b <= 0) cout << "delicious" << endl;
  if(0 < a+b && a+b <= x) cout << "safe" << endl;
  if(x < a+b) cout << "dangerous" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	while(cin>>a>>b>>c){
		if((a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)||(a==5&&b==5&&c==7)){
			cout<<"YES"<<endl;
			//cout<<"Using three phrases of length "<<a<<", "<<b<<" and "<<c<<", it is possible to construct a Haiku."<<endl;
		}else {
			cout<<"NO"<<endl;
		}
    }
	
	
	
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
int main(){
	long H,W;cin>>H>>W;
    if(H==1||W==1) cout<<1<<endl;
	else cout<<(H*W+1)/2<<endl;
}

Measured memory_bytes: 256
'''
問題文
 黒橋君は，AtCoder Beginner Contest (ABC) にまだ参加したことがありません．
 次に行われる ABC は第 N 回です． 黒橋君は，初めて参加する ABC を第 x 回としたときに，
	x の十進法表記でのすべての桁の数字が同じであるようにしたいです．
	黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第何回でしょうか？

制約
	100 ≤ N ≤ 999
	N  は整数

入力
	入力は以下の形式で標準入力から与えられる．
	N

出力
	黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第何回かを出力せよ．

入力例 1 
	111
出力例 1 
	111
	次に行われる ABC は第 111 回です． これは黒橋君が初めて参加する ABC としてふさわしいです．

入力例 2 
	112
出力例 2 
	222
	次に行われる ABC は第 112 回です．そのため，第 111 回の ABC にはもう参加することはできません． 
	黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第 222 回です．

入力例 3 
	750
出力例 3 
	777

'''

def main():
	'''
	メイン関数
	'''
	
	# 次の回次を取得
	next = input()
	h = next[0] # 百の位
	d = next[1] # 十の位
	o = next[2] # 一の位
	
	# 百の位のぞろ目数
	zoro = int(h)*100 + int(h)*10 + int(h)

	# 次がぞろ目か判定
	if (h==d) and (d==o) :
		print(next)
	# ぞろ目でない場合　hdo < hhh ならば、hhh が次のぞろ目
	elif int(next) < zoro :
		print(zoro)
	else :
	# それ以外は、(h+1)(h+1)(h+1)
		print(zoro+111)


if __name__ == '__main__':
	main()


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(6); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,i;
    cin>>n;
    string a; long double x,b=0;
    while(n--){
        cin>>x>>a;
        if(a=="JPY") b+=x;
        else b+= (x*380000.0);
    }
    cout<<b el;
}

main()
{
//    fastio();
    fraction()
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> a(n), dp(n, 1e9+5);
    for (int i = 0; i < n; ++i) cin >> a[i];
    dp[0] = 0;
    for (int i = 0; i < n; ++i)
        for (int j = 1; j <= k; ++j)
            if (i+j < n)
                dp[i+j] = min(dp[i+j], dp[i]+abs(a[i]-a[i+j]));
    cout << dp[n-1] << '\n';
}

Measured memory_bytes: 1024
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var s = cin.ReadLine;
            var result = s.Where(t => t == '1').Count();
            WriteLine(result);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 11348
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String in[];
        int H, W, h, w;
        in = scanner.nextLine().split(" ");
        H = Integer.parseInt(in[0]);
        W = Integer.parseInt(in[1]);

        in = scanner.nextLine().split(" ");
        h = Integer.parseInt(in[0]);
        w = Integer.parseInt(in[1]);

        int ret = 0;
        for (int i = 0; i < H-h; i++) {
            for (int j = 0; j < W-w; j++) {
                ret++;
            }
        }
        System.out.println(ret);
    }
}

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

int main(){
  int n; cin >> n;
  vector<int> l(n);
  vector<int> r(n);
  for(int i=0; i<n; i++){
    cin >> l.at(i) >> r.at(i);
  }
  
  bool is_prime[100001];
  memset(is_prime, true, sizeof(is_prime));
  is_prime[0] = is_prime[1] = false;
  for(int i=2; i<=100000; i++){
    if(is_prime[i]){
      //cout << i << endl;
      for(int j=2*i; j<=100000; j+=i) is_prime[j] = false;
    }
  }
  int cum[100001];
  cum[0] = 0;
  cum[1] = 0;
  for(int i=2; i<100001; i++){
    if(is_prime[i]){
      if((i+1)%2==0&&is_prime[(i+1)/2]){
        //cout << cum[i-1] << " 1" << endl;
        cum[i] = cum[i-1] + 1;
        continue;
      }
    }
      //cout << ' ' << cum[i-1] << endl;
      cum[i] = cum[i-1];
    //cout << cum[i] << endl;
  }
  for(int i=0; i<n; i++){
    //cout << r.at(i) << ' ' << l.at(i) << endl;
    cout << cum[r.at(i)] - cum[l.at(i)-1] << endl;
  }
}

Measured memory_bytes: 1920
#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, c;
    cin >> a >> b >> c;
    string ans = "NO";
    if ((b*10+c) % 4 == 0) ans = "YES";
    cout << ans << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int ans = n*a < b ? n*a : b;
    cout << ans << endl;
    
    return 0;
}

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

int main(void)
{
    int N, K;
    cin >> N >> K;

    int ans = 0;
    while (N) {
        N /= K;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int n,b=0;
    long long k,a[100000],x=0,f=0,g=0,z=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(k==0){
        for(int i=0;i<n;i++){
            f+=a[i];
        }
        cout<<f<<endl;
        return 0;
    }


    for(long long i=40;i>=0;i--){
        int c=0;
        for(int j=0;j<n;j++){
            if(((a[j]>>i)&1)==1){
                c++;
            }
        }
        if(n-c>c){
            long long l=1,y=x;
            y+=(l<<i);
            if(b<0)z+=(l<<i);
            if(y<=k){
                x=y;
                if(b>=0)b=i;
            }else if(b>0){
                z=x-(l<<b);
                z+=(l<<i);
                b=-1;
            }
        }
    }

    for(int i=0;i<n;i++){
        f+=(x^a[i]);
        g+=(z^a[i]);
    }
    cout<<max(f, g)<<endl;
}


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

dp = [0] * (1 << n)
dp[0] = 1

bitcount = [0]
for _ in range(n):
    bitcount += [i + 1 for i in bitcount]

# 配るDP
for bit in range((1 << n) - 1):
    i = bitcount[bit]
    for j in range(n):
        if (a[i][j] == 1) and ((bit >> j) & 1 == 0):
            newbit = bit | (1 << j)
            dp[newbit] += dp[bit]
            dp[newbit] %= mod
print(dp[-1])


Measured memory_bytes: 130048
//g++ -std=c++14 test.cpp -o test.out

 //全部開催すると仮定した後、1つずつ減らして調べていく

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,M;
LL A[300][300];

LL ans = INF;

void solve(){
	//i番目の人が何番目のスポーツを選んでいるかをselected_index[i]とおく
	vector<int> selected_index(N,0);
	vector<int> hold(M,1);//M番目のスポーツを開催するのかどうか
	auto max_count = [&](){
		//スポーツiを選んでいる人間の数をcounter[i]とおく
		vector<int> counter(M,0);
		for(int i=0;i<N;i++){
			if(selected_index[i]<M) counter[A[i][selected_index[i]]]++;
		}

		int max_counter = 0;//選んでる人が一番多いスポーツの人数
		int max_sports = 0;//選んでる人が一番多いスポーツの番号
		for(int i=0;i<M;i++){
			if(max_counter<counter[i]){
				max_counter = counter[i];
				max_sports = i;
			}
		}
		return pair<LL,LL>(max_counter,max_sports);
	};
	ans = max_count().first;
	for(int _=0;_<M-1;_++){
		pair<LL,LL> maxs = max_count();
		LL max_counter = maxs.first;
		LL max_sports = maxs.second;

		hold[max_sports] = 0;//選んでる人が一番多いスポーツを中止
		for(int i=0;i<N;i++){
			while(1){
				if(!hold[A[i][selected_index[i]]]) selected_index[i]++;
				else break;
			}
		}

		// cout << endl;
		// for(int i=0;i<N;i++){
		// 	for(int j=0;j<M;j++){
		// 		if(hold[A[i][j]]==1) cout << A[i][j] << " ";
		// 		else cout << "  ";
		// 	}
		// 	cout << endl;
		// }

		maxs = max_count();
		ans = min(ans,maxs.first);
	}
}

int main(){
    cin >> N >> M;
    for(int i=0;i<N;i++){
    	for(int j=0;j<M;j++){
    		cin >> A[i][j];
    		A[i][j]--;
    	}
    }

    solve();

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

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

#define x first
#define y second
#define all(a) (a).begin(), (a).end()

#define sz(a) (int) (a).size()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (sz(s)<26) {
        set<char> st;
        for (int i=0; i<26; i++) {
            st.insert('a'+i);
        }
        for (auto c: s) {
            st.erase(c);
        }
        s.push_back(*st.begin());
        cout << s << '\n';
    } else {
        int i = 24;
        while (i>-1 && s[i]>s[i+1]) {
            i--;
        }
        if (i==-1) {
            cout << "-1\n";
        } else {
            char nxt = 'z';
            for (int j=i+1; j<26; j++) {
                if (s[j]>s[i] && s[j]<nxt) {
                    nxt = s[j];
                }
            }
            while (sz(s)>i) {
                s.pop_back();
            }
            s.push_back(nxt);
            cout << s << '\n';
        }
    }
    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)
const int mod=1000000007;
const int mod1=998244353;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	cout << (n-2)*180 << endl;
}

Measured memory_bytes: 256
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    
    X,Y,Z = LMIIS()
    print(Z,X,Y)
if __name__ == '__main__':
    main()

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vector<pll> pos(n);
  REP(i,n){
    ll a, b;
    cin >> a >> b;
    pos[i] = make_pair(a,b);
  }
  map<pll,ll> cost;
  REP(i,n){
    REP(j,n){
      if(i!=j){
        pll diff = make_pair(pos[i].first - pos[j].first,pos[i].second - pos[j].second);
        if(cost.find(diff)==cost.end()){
          cost.insert(make_pair(diff,1));
        }else{
          cost[diff]++;
        }
//        diff = make_pair(pos[j].first - pos[i].first,pos[j].second - pos[i].second);
//        if(cost.find(diff)==cost.end()){
//          cost.insert(make_pair(diff,0));
//        }else{
//          cost[diff]++;
//        }
      }
    }
  }
  ll ans = 0;
  for(auto itr=cost.begin();itr!=cost.end();itr++){
    CHMAX(ans,(ll)(*itr).second);
    //cout << (*itr).first.first << "," << (*itr).first.second << ":" << (*itr).second << endl;
  }
  ans = n - ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
int i,n,m,cnt=0;
ll sum=0;
double mx;
cin>>n>>m;
int a[n];
for(i=0;i<n;i++)
  {cin>>a[i];sum+=a[i];}
mx=sum;
mx/=(4*m);

for(i=0;i<n;i++)
  if(a[i]>=mx)
  cnt++;
if(cnt>=m)
cout<<"Yes\n";
else
cout<<"No\n";

return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace Contest
{

    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N, K;
        private void Scan()
        {
            Scanner sc = new Scanner();
            N = sc.NextInt();
            K = sc.NextInt();
        }

        public void Solve()
        {
            Scan();
            if (N % K == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(1);
            }
        }

        static void Main() => new Program().Solve();
    }
}

Measured memory_bytes: 11220
#include<stdio.h>
int main()
{
    int i,j=0;
    char s[4];
    scanf("%s",s);
    for(i=0;i<4;i++){
        if(s[i]==s[i+1])
        j=1;
    }
    if(j==1)
        printf("Bad");
    else
        printf("Good");
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger n = sc.nextBigInteger();
        BigInteger r = n.mod(BigInteger.valueOf(9));
        if(r.equals(BigInteger.valueOf(0))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 42312
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1],b[n];
	cin>>a[1];
	a[2]=a[1];
	b[2]=a[1];
	for(int i=3;i<=n;i++) 
	{
		cin>>b[i];
		if(b[i]>b[i-1])
		{
			a[i]=b[i];
		}
		else
		{
			a[i]=b[i];
			a[i-1]=b[i];	
		}
	} 
	long long ans=0;
	for(int i=1;i<=n;i++) 
	{
		ans+=a[i];
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


# inputs
N = 0


def set_inputs():
    global N
    N = get_int()
    return


DIVISOR = 1000000007


def main():
    setrecursionlimit(100000)
    set_inputs()

    # ACG, AGC, GAC, AGGC, AGTC, ATGC
    safe = [0] * (N+1)
    a = [0] * (N+1)
    g = [0] * (N+1)
    ac = [0] * (N+1)
    ag = [0] * (N+1)
    at = [0] * (N+1)
    ga = [0] * (N+1)
    agg = [0] * (N+1)
    agt = [0] * (N+1)
    atg = [0] * (N+1)

    safe[0] = 1
    for i in range(1, N+1):
        s = safe[i-1] * 2
        s += g[i-1] * 2
        s += ac[i-1] * 2
        s += at[i-1] * 2
        s += agg[i-1]
        s += agt[i-1]
        s += atg[i-1]
        safe[i] = s % DIVISOR

        a_ = safe[i-1]
        a_ += a[i-1]
        a_ += ac[i-1]
        a_ += at[i-1]
        a_ += ga[i-1]
        a_ += agt[i-1]
        a[i] = a_ % DIVISOR

        g_ = safe[i-1]
        g_ += g[i-1]
        g_ += agg[i-1]
        g_ += agt[i-1]
        g_ += atg[i-1]
        g[i] = g_ % DIVISOR

        ac[i] = a[i-1]
        ag[i] = ( a[i-1] + ga[i-1]) % DIVISOR
        at[i] = ( a[i-1] + ga[i-1]) % DIVISOR
        ga[i] = ( g[i-1] + ag[i-1] + agg[i-1] + atg[i-1]) % DIVISOR
        agg[i] = ag[i-1]
        agt[i] = ag[i-1]
        atg[i] = at[i-1]

        # dead = ( ac[i-1] + ag[i-1] + ga[i-1] + agg[i-1] + agt[i-1] + atg[i-1]) % DIVISOR
    print((safe[N] + a[N] + g[N] + ac[N] + ag[N] + at[N] + ga[N] + agg[N] + agt[N] + atg[N]) % DIVISOR)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384