akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){

	int	a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	if (a < b){
		if (b < c){
			printf("Yes\n");
			return 0;
		}
	}

	printf("No\n");

	return 0;
}

Measured memory_bytes: 1008
from math import atan, pi
a,b,x = [int(i) for i in input().split()]




ocupado = x/(a*a)



if ocupado == b:
    alfa = pi/2

elif ocupado*2 >= b:
    sobra = b - ocupado

    #alfa = atan(sobra/ocupado)
    alfa = atan(a / (2*(b-ocupado)))
else:
    alfa = atan((2*a*ocupado) / (b*b))
print("%.10f" %(90 - alfa*180/pi))

Measured memory_bytes: 38384
from itertools import combinations as Comb
N, M, X = map(int, input().split())
AC = [""] * N

for c in range(N):
    AC[c] = list(map(int, input().split()))

ans = 12 * 1000000
C = 0

def han(i): # 与えられた組み合わせがいいかどうか判定 i = ([C, A, ...], [C, A, ...], ...)
    global going, C
    A_wa = [0] * M
    for c in i:
        for co in range(1, M + 1, 1):
            A_wa[co - 1] += c[co]
        C += c[0]
    if min(A_wa) >= X:
        going = True
        

for c in range(1, N + 1, 1):
    lll = list(Comb(AC, c))
    for z in lll:
        going = False
        C = 0
        han(z)
        if going and C < ans:
            ans = C
if ans != 12 * 1000000:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 9308
n = int(input())
a = dict()
for i in range(n):
    x = input()
    if x not in a:
        a[x] = 1
    else:
        a[x] += 1

maxer = 0
for i in a:
    if a[i] > maxer:
        maxer = a[i]

out = []
for i in a:
    if a[i] == maxer:
        out.append(i)

print("\n".join(sorted(out)))

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

N,u,v=map(int,input().split())
E=[tuple(map(int,input().split())) for i in range(N-1)]

EDGE=[[] for i in range(N+1)]

for x,y in E:
    EDGE[x].append(y)
    EDGE[y].append(x)

from collections import deque
T=[-1]*(N+1)

Q=deque()
Q.append(u)
T[u]=0

while Q:
    x=Q.pop()
    for to in EDGE[x]:
        if T[to]==-1:
            T[to]=T[x]+1
            Q.append(to)

A=[-1]*(N+1)

Q=deque()
Q.append(v)
A[v]=0

while Q:
    x=Q.pop()
    for to in EDGE[x]:
        if A[to]==-1:
            A[to]=A[x]+1
            Q.append(to)


OK=[0]*(N+1)

for i in range(N+1):
    if T[i]<A[i]:
        OK[i]=1

ANS=0
for i in range(N+1):
    if OK[i]==1:
        ANS=max(ANS,A[i])

print(max(0,ANS-1))


Measured memory_bytes: 37356
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
void solve(){
    ll x;
    cin>>x;
    ll amt;ll p=100;
    for(int i=1;;i++){
        amt = (long long)p+(p*0.01);
        p=amt;
        if(amt>=x) {cout<<i;return;}
    }
}
int  main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
    //cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
ll a[1004];
ll b[1004];
ll dp[20004];
int main()
{
    
	
    	
        ll i,h,n,j,x=0;

        cin>>h>>n;

        for(i=0;i<n;i++) {cin>>a[i]>>b[i];x=max(x,a[i]);}

        	dp[0]=0;

        	for(i=1;i<=2*h;i++)
        		dp[i]=999999999999;

        	for(i=0;i<=h;i++)
        	{

        		for(j=0;j<n;j++)
        		{
        			dp[min(h,i+a[j])]=min(dp[i]+b[j],dp[min(h,i+a[j])]);
        		}
        	}
        	
        	cout<<dp[h];
        	return 0;
        }


Measured memory_bytes: 384
N, X = list(map(int,input().split()))
L = list(map(int,input().split()))

zahyou = 0
num = 1

for i in range(N):
    if zahyou + L[i] <= X:
        zahyou = zahyou + L[i]
        num += 1
    else:

        break

print(num)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string>
 
using namespace std ;
 
int main ( )
{
	string x , y;
	cin >> x >> y ;
    bool flag=0;
	if  (x.size() > y.size())
	{
		cout << "GREATER\n" ;
	}
	else if (x.size()==y.size() )
	{
		for (int i =0;i<x.size();i++)
		{
			if (x[i]>y[i])
			{
				cout << "GREATER\n" ;
				flag=1;
				break ;
 
			}
			else if (x[i] <y[i])
			{
				cout <<"LESS\n" ;
				flag=1;
				break ;
			}
		}
		if(flag==0)
            cout << "EQUAL\n" ;
 
	}
	else if (x.size()<y.size() )
	cout << "LESS\n" ;
	else
			cout << "EQUAL\n" ;
 
		return 0 ;
}

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

int main(){
  int n,m; cin >> n >> m;
  vl a(n); rep(i,n) cin >> a[i];
  vl s(n+1); rep(i,n) s[i+1] = (s[i] + a[i])%m;

  // mapを使って累積和の剰余類ごとの個数を管理
  map<ll,ll> C;
  ll ans = 0LL;
  rep(i,n+1) {
    ans += C[s[i]];
    C[s[i]]++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 5760
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete

signed main(){

    int N;
    cin>>N;
    int K;
    cin>>K;

    int A[SIZE]={};
    for(int i=0;i<K;i++){
        int D;
        cin>>D;
        for(int d=0;d<D;d++){
            int a;
            cin>>a;
            a--;
            A[a]++;
        }
    }
    int ans=0;
    for(int i=0;i<N;i++)
        ans+=(!A[i]);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4416
#include <iostream>

using namespace std;

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

    int a[m], b[m];
    for (int i = 0; i < m; i++) cin >> a[i] >> b[i];

    int road[60] = {0};
    for (int i = 0; i < m; i++) {
        road[a[i] - 1]++;
        road[b[i] - 1]++;
    }

    for (int i = 0; i < n; i++) {
        cout << road[i] << endl;
    }
}

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

using namespace std;

void check_num(array<int,8> a){
  int hit_num=0,blow_num=0;
  for(int i=0;i<4;i++){
    for(int j = 4;j<8;j++){
      if(a[i] == a[j]){
        if(j-4 == i){
          ++hit_num;
        }else{
          ++blow_num;
        }
      }
    }
  }

  cout<<hit_num<<" "<<blow_num<<endl;
}

int main(void){
  array<int,8> a; //プレイヤーa,bの値
  int input;

  while(cin >> input){
    a[0]=input;
    for(int i = 1;i<8;i++){
      cin >>a[i];
    }
    check_num(a);
  }

  return 0;
}



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

using namespace std;

int main(void){
    int K,N; cin >> K >> N;
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    int maxj = abs(K + A[0] - A[N-1]);
    for(int i = 1; i < N; i++){
        maxj = max(maxj, abs(A[i] - A[i-1]));
    }
    cout << K - maxj << endl;
    return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    int ans = 0;
    for(int i=0; i<n; ++i){
        int t;
        cin >> t;
        if(!(a <= t && t < b))
            ++ ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
if a>b:
    print(-1)
else:
    p=a/0.08
    q=(a+1)/0.08
    r=b/0.1
    s=(b+1)/0.1
    if q<=r or s<=p:
        print(-1)
    else:
        if r<=p and q<=s:
            if p%1==0:
                print(int(p))
            else:
                print(int(p//1+1))
        elif p<=r and s<=q:
            if r%1==0:
                print(int(r))
            else:
                print(int(r//1+1))
        elif p<=r and q<=s:
            if r%1==0:
                print(int(r))
            else:
                if r//1+1<=q:
                    print(int(r//1+1))
                else:
                    print(-1)
        elif r<=p and s<=q:
            if p%1==0:
                print(int(p))
            else:
                if p//1+1<=s:
                    print(int(p//1+1))
                else:
                    print(-1)
                    

Measured memory_bytes: 38400
-module('Main').
-export([main/1]).

solve() ->
    [N] = input("~d"),
    A = input(lists:flatten(["~d" || _ <- lists:seq(1, N)])),
    io:format("~B~n", [length(lists:usort(A))]),
    ok.

main(_) ->
    solve(),
    halt().

input(Pat) ->
    {ok, L} = io:fread("", Pat),
    L.


Measured memory_bytes: 21852
#include<stdio.h>
int main(){
int N,Y,SEN,GOSEN,MAN,BOOL=0,i,j,k;
  scanf("%d %d",&N,&Y);
  for(i=0;i<=N;i++)
  {
    for(j=0;j<=N;j++)
    {
      k=N-(i+j);
      if(k>=0&&i+j+k==N&&10000*k+5000*j+1000*i==Y)
      {
	   MAN=k;
	   GOSEN=j;
        SEN=i;
        BOOL=1;
     	break;
      }
    }    
   }
  
  if(BOOL==1){printf("%d %d %d",MAN,GOSEN,SEN);}
  else printf("-1 -1 -1");
return 0;
}

Measured memory_bytes: 2096
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;

int main(){
string str;
cin >> str;
if(str[0]==str[1]&&str[1]==str[2]&&str[2]==str[3]){
  cout<<"No"<<endl;
}
else if(str[0]==str[1]&&str[2]==str[3]){
    cout<<"Yes"<<endl;
}
else if(str[0]==str[3]&&str[1]==str[2]){
  cout<<"Yes"<<endl;
}
else if(str[0]==str[2]&&str[1]==str[3]){
  cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll h,w,n;
const ll MAXN = 3005;
pair<ll,ll> a[MAXN];
const ll MAX = 3e5 + 10;
ll fact[MAX],inv_fact[MAX];
const ll MOD = 1e9 + 7;
ll ans[MAXN];

ll power(ll x,ll y){
    ll res = 1;

    while(y){
        if(y&1) res = (res*x)%MOD;
        x = (x*x)%MOD;
        y >>= 1;
    }
    return res;
}

ll calculate(ll x1,ll y1,ll x2,ll y2){
    ll x = x2 - x1,y = y2 - y1;
    ll ret = fact[x+y];
    ret = (ret*inv_fact[x])%MOD;
    ret = (ret*inv_fact[y])%MOD;
    return ret;
}

void solve(){

    fact[0] = inv_fact[0] = 1;
    FOR(i,1,MAX-1) {
        fact[i] = (i*fact[i-1])%MOD;
        inv_fact[i] = power(fact[i],MOD-2);
    }    

    cin>>h>>w>>n;

    FOR(i,0,n-1){
        cin>>a[i].first>>a[i].second;
    }
    a[n].first = h,a[n].second = w;
    n++;

    sort(a,a+n);

    FOR(i,0,n-1) ans[i] = calculate(1,1,a[i].first,a[i].second);
    
    FOR(i,0,n-1){
        FOR(j,i+1,n-1){
            if(a[j].second < a[i].second) continue;
            ans[j] = (ans[j] - (ans[i]*calculate(a[i].first,a[i].second,a[j].first,a[j].second))%MOD)%MOD;
            ans[j] = (ans[j] + MOD)%MOD;
        }
    }

    cout<<ans[n-1]<<endl;
}

signed main(){
 
   FastRead;    
 

    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repri(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define repr(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define reprs(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;
typedef vector<int> VI;
typedef vector<ll> VL;

const int N = 1e7 + 5;
int d[N];
 
int ans[N];
 
vector<PII> g[N];

void dfs (int v = 1, int p = -1, int c = -1) {
	int cur = 1;
	for (auto to : g[v]) if (to.first != p) {
		if (cur == c) cur++;
		ans[to.second] = cur;
		cur++;
		dfs (to.first, v, ans[to.second]);
	}
}

void Main() {
	int n, mx = 0;
	cin >> n;
	for (int i = 1 ; i < n ; ++ i) {
		int a, b;
		cin >> a >> b;
		d[a]++;
		d[b]++;
		g[a].push_back({b, i});
		g[b].push_back({a, i});
		mx = max(mx, d[a]);
		mx = max(mx, d[b]);
	}
	dfs();
	cout << mx << LF;
	for (int i = 1;  i < n ; ++ i) cout << ans[i] << LF;
}

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

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

int M = 200000, N = 1;

int GetRandom(int min,int max){
	return min + (int)(rand()*(max-min+1.0)/(1.0+RAND_MAX));
}

int main(){
    // 入力
    int D;
    cin >> D;   // D = 365
    ll c[26];
    for(int i=0;i<26;i++)
        cin >> c[i];
    ll s[D][26];
    for(int i=0;i<D;i++)
        for(int j=0;j<26;j++)
            cin >> s[i][j];
    // 初期解t[D]
    int t[D];
    /*
    for(int i=0;i<D;i++)
        cin >> t[i];
    */
    for(int i=0;i<D;i++){
        //t[i] = GetRandom(1,26);   // 1<=, <=26
        t[i] = i%26 + 1;
        //cout << t[i] << endl; 
    }
    // クエリ
    // cin >> M;
    int d[M][N], q[M][N];
    /*
    for(int i=0;i<M;i++)
        cin >> d[i] >> q[i];
    */
    for(int i=0;i<M;i++){
        for(int j=0;j<N;j++){
            d[i][j] = GetRandom(1,D);   // 1<=, <=365
            q[i][j] = GetRandom(1,26);   // 1<=, <=26
            //cout << d[i][j] << ' ' << q[i][j] << endl; 
        }
    }

    // 処理部
    ll v_best = LLONG_MIN;
    for(int query=0;query<M;query++){
        int last[26] = {}, q_[N];
        // コンテスト種別の変更（N個）
        for(int i=0;i<N;i++){
            q_[i] = t[d[query][i]-1];
            t[d[query][i]-1] = q[query][i];
        }
        // D日分
        ll v = 0;
        for(int i=1;i<=D;i++){
            // 満足度の増加分
            v += s[i-1][t[i-1]-1];
            last[t[i-1]-1] = i;
            // 満足度の低下分（コンテスト26種分）
            for(int j=0;j<26;j++)
                v -= c[j]*(i - last[j]);
        }
        // cout << v << endl;
        if(v < v_best){
            for(int i=0;i<N;i++){
                t[d[query][i]-1] = q_[i];
            }
        }else{
            v_best = v;
        }
    }

    // 答え出力
    for(int i=0;i<D;i++)
        cout << t[i] << endl;
    //cout << v_best << endl;

}


Measured memory_bytes: 5272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int dist[100][100][2];

struct state{
	int d,x,y,flag;
};

bool operator>(const state& a,const state& b){
    return a.d>b.d;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	while(true){
		int h,w;
		cin>>w>>h;
		if(h==0 && w==0) return 0;
		vector<vector<char>> g(h,vector<char>(w));
		rep(i,h)rep(j,w) cin>>g[i][j];
		auto check=[&](int x,int y){
			return (0<=x && x<h && 0<=y && y<w && g[x][y]!='X');
		};
		int ans=INF;
		rep(st,w){
			if(g[h-1][st]!='S') continue;
			rep(ii,2){
				rep(i,100)rep(j,100)rep(k,2) dist[i][j][k]=INF;
				priority_queue<state,vector<state>,greater<state>> que;
				dist[h-1][st][ii]=0;
				que.push({0,h-1,st,ii});
				while(!que.empty()){
					auto now=que.top();
					que.pop();
					if(dist[now.x][now.y][now.flag]<now.d) continue;
					int x=now.x,y=now.y;
					FOR(j,1,4){
						for(int i=j-3;i<=3-j;i++){
							int nx,ny;
							if(now.flag){//次は右足を動かす
								nx=x+i,ny=y+j;
							}else{
								nx=x+i,ny=y-j;
							}
							if(!check(nx,ny)) continue;
							int nd;
							if(g[nx][ny]!='T') nd=g[nx][ny]-'0';
							else nd=0;
							if(chmin(dist[nx][ny][!now.flag],now.d+nd)){
								que.push({now.d+nd,nx,ny,!now.flag});
							}
						}
					}
				}
				rep(en,w){
					if(g[0][en]!='T') continue;
					rep(k,2){
						chmin(ans,dist[0][en][k]);
					}
				}
			}
		}
		if(ans!=INF) cout<<ans<<endl;
		else cout<<-1<<endl;
	}
}


Measured memory_bytes: 3240
#include <iostream>
#include <algorithm>

using namespace std;

int n , a[10005];
double sum , m , conditie;

int main()
{
    cin >> n >> m;
    for(int i = 1 ; i <= n ; i ++)
        {
            cin >> a[i];
            sum += a[i];
        }
    conditie = sum / (4 * m);
    sort(a + 1 , a + n + 1);
    for(int i = n ; i >= n - m + 1 ; i --)
        if(a[i] < conditie)
        {
            cout << "No" << '\n';
            return 0;
        }
    cout << "Yes" << '\n';
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        int n=s.length();
        if(s[n-1]=='s')
        s+="es";
        else
        s+="s";
 
    cout<<s;
}
}
// 🍪 🍪 🍪


Measured memory_bytes: 3652
module ABC082

	! <module>s to import
	use, intrinsic :: iso_fortran_env


	! require all variables to be explicitly declared
	implicit none


	! accessibility of <subroutine>s and <function>s in this <module>
	public  :: ABC082_A


	! contained <subroutine>s and <function>s are below
	contains


	subroutine ABC082_A

		! variables for this <subroutine>
		integer( kind= INT16 ) :: a, b

		! STEP.01
		! read out the target positive integers
		read *, a, b

		! STEP.02
		! output the result
		write( unit=OUTPUT_UNIT, fmt='(I0)', advance='yes' ) (a+b+1)/2

		! STEP.END
		return

	end subroutine ABC082_A

end module ABC082


program main

	! <module>s to import
	use, non_intrinsic :: ABC082

	! require all variables to be explicitly declared
	implicit none

	call ABC082_A


end program main


Measured memory_bytes: 256
S = input()
s = set()
table = "abcdefghijklmnopqrstuvwxyz"
for x in S:
  s.add(x)
v = 0
for x in table:
  if x not in s:
    print(x)
    v = 1
    break
  else:
    pass
if v == 0:
  print("None")

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int a,b;cin>>a>>b;
  for(int i=1;i<4;i++){
    if(i!=a&&i!=b){
      cout<<i;
    }
  }
}

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

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
// int maxa = max(A,max(B,C));
// int mina = min(A, min(B,C));

  vector<int> vec;
 vec.push_back(A);
 vec.push_back(B);
 vec.push_back(C);
 sort(vec.begin(), vec.end());
// for (auto c : vec) {
//   cout << c << endl;
// }
 int a;
 int b;
 a = vec[2] - vec[0];
 b = vec[2] - vec[1];
 
 int sum = 0;
 if ( (a % 2 == 0)  && (b % 2 == 0)) {
   sum += a/2;
   sum += b/2;
 } 
 else  if ( (a % 2 == 0)  && (b % 2 != 0)) {
   sum += a/2;
   sum += (b+1)/2;
   sum++; 
 }
 else  if ( (a % 2 != 0)  && (b % 2 == 0)) {
   sum += b/2;
   sum += (a+1)/2;
   sum++;
 }
 else  if ( (a % 2 != 0)  && (b % 2 != 0)) {
   sum++;
   sum+=(a-1)/2;
   sum+=(b-1)/2;
 }
 cout << sum << endl;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var N = ConsoleUtil.IntReadLine();
        var S = Console.ReadLine();

        int x = 0;

        int xmax = 0;

        foreach(var c in S)
        {
            if (c == 'I')
            {
                x++;
            }
            if (c == 'D')
            {
                x--;
            }

            xmax = Math.Max(x, xmax);
        }

        Console.WriteLine(xmax);
    }
}



static class ConsoleUtil
{
    public static string[] StrArrayReadLine(char sepalator)
    {
        string str = Console.ReadLine();
        return str.Split(sepalator).ToArray();
    }
    public static string[] StrArrayReadLine()
    {
        string str = Console.ReadLine();
        if (str.Contains(','))
        {
            return str.Split(',').ToArray();
        }
        {
            return str.Split(' ').ToArray();
        }
    }
    
    public static int[] IntArrayReadLine()
    {
        return StrArrayReadLine().Select(s => int.Parse(s)).ToArray();
    }
    public static int[] IntArrayReadLine(char sepalator)
    {
        return StrArrayReadLine(sepalator).Select(s => int.Parse(s)).ToArray();
    }

    public static int IntReadLine() => int.Parse(Console.ReadLine());
}



Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    string str;
    cin>>str;
    long long int count=0;
    long long int r=0,g=0,b=0;
   
    
   for(int i=0;i<n;i++)
   {
       if(str[i]=='R')
       {
        //   r1.push_back(i);
           r++;
       }
       if(str[i]=='G')
       {
           g++;
        //   g1.push_back(i);
       }
       if(str[i]=='B')
       {
           b++;
        //   b1.push_back(i);
       }
   }
   count+=r*g*b;
   if(count==0)
   {
       cout<<"0";
   return 0;
   }
  
   for(int i=0;i<n;i++)
   {
        int len=1;
       int left=i-len;
       int right=i+len;
       while(left>=0&&right<n)
       {
           if(str[left]!=str[right]&&str[right]!=str[i]&&str[i]!=str[left])
           count--;
           len++;
            left=i-len;
       right=i+len;
           
       }
   }
   cout<<count;
   
}

Measured memory_bytes: 3604
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include <string>
 using namespace std;
 int main(){
 	int n;
 	int k;
 	int br=0;
 	cin>>n>>k;
 	for (int i=0;i<n;++i){
 		int g;
 		cin>>g;
 		if (g>=k)
 			br=br+1;
		 
	 }
	 cout<<br;
 return 0;
 }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		long X = sc.nextInt();
		int[] A = new int[N];
		int[][] min = new int[N][N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; ++i) {
			min[i][i] = A[i];
		}
		for (int i = 0; i < N; ++i) {
			for (int j = i + 1; j < N; ++j) {
				min[i][j] = Math.min(min[i][j - 1], A[j]);
			}
		}
		long ans = Long.MAX_VALUE;
		for (int i = 0; i < N; ++i) {
			long cur = X * i;
			for (int j = 0; j < N; ++j) {
				if (j >= i) {
					cur += min[j - i][j];
				} else {
					cur += Math.min(min[0][j], min[N - (i - j)][N - 1]);
				}
			}
			ans = Math.min(ans, cur);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 34948
#include <bits/stdc++.h>
 
using namespace std;
 
map<int, int> ds;
map<int, int> ranks;
 
int find_root(int x) {
    return x==ds[x]?x:ds[x]=find_root(ds[x]);
}
 
void union_set(int x, int y) {
    int x_root=find_root(x);
    int y_root=find_root(y);
    if (x_root!=y_root) {
        if (ranks[x_root]>ranks[y_root]) {
            ds[y_root]=x_root; 
        } else if (ranks[x_root]<ranks[y_root]) {
            ds[x_root]=y_root;
        } else {
            ds[x_root]=y_root;
            ranks[y_root]++;
        }
    }
}
 
int main() {
    int n,m;
    cin>>n>>m;
 
    //初始化
    for (int i=1; i<=n; i++) {
        ds[i]=i;
        ranks[i]=0;
    }
 
    int cnt=0;
    for (int i=1; i<=m; i++) {
        int x,y;
        cin>>x>>y;
 
        x=find_root(x);
        y=find_root(y);
        if (x==y) {
            continue;
        }
 
        union_set(x, y);
        cnt++;
    }
 
    cnt=n-1-cnt;
    if (cnt<0) {
        cnt=0;
    }
    cout<<cnt<<"\n";
 
    return 0;
}

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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	auto n = load<int>();
	auto monster = loadMany<int>(n+1);
	auto hero = loadMany<int>(n);
	auto score = 0ll;
	for (auto i=0; i<n; ++i) {
		auto a1 = min(hero[i], monster[i]);
		hero[i] -= a1;
		monster[i] -= a1;
		score += a1;
		auto a2 = min(hero[i], monster[i+1]);
		hero[i] -= a2;
		monster[i+1] -= a2;
		score += a2;
	}
	cout << score << '\n';
}


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

int main(void) {
    int64_t N;
    cin >> N;

    vector<pair<int64_t,int64_t>> A(N);
    for(int i=0;i<N;i++) {
        cin >> A[i].first;
        A[i].second = i+1;
    }

    sort(A.begin(), A.end());
    for(auto a : A) {
        cout << a.second << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2432
function FuncSum(const x : Integer) : Integer;
	var
		ax : Integer;
	begin
	ax := x;
	Result := 0;
	while ax mod 2 = 0 do
		begin
		Result := Result + 1;
		ax := ax div 2;
		end;
	end;

procedure ProcMain;
	var
		n, i, sum : Integer;
		a : array of Integer;
	begin
		readln(n);
		setLength(a, n);
		sum := 0;
		for i := 0 to n - 1 do
			begin
			read(a[i]);
			sum := sum + FuncSum(a[i]);
			end;
		WriteLn(sum);
	end;
begin
ProcMain;
end.

Measured memory_bytes: 128
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let _n: usize = it.next().unwrap().parse().unwrap();
    let w: usize = it.next().unwrap().parse().unwrap();
    let mut dp = vec![0; w + 1];
    dp[0] = 1;
    const MOD: u32 = 1_000_000_007;
    for s in it {
        let a: usize = s.parse().unwrap();
        let mut next = vec![0; w + 1];
        next[0] = dp[0];
        for i in 1..(w + 1) {
            next[i] = next[i - 1] + dp[i];
            if i > a {
                next[i] += MOD - dp[i - 1 - a];
            }
            next[i] %= MOD;
        }
        dp = next;
    }
    println!("{}", dp[w]);
}

fn main() {
    run();
}


Measured memory_bytes: 6396
l, r = map(int, input().split())
mod = 2019

def check(left, right):
  ans = 2018
  # a mod p = b mod p なら a*c ≡ b*c (mod p)
  # r - l
  if right-left >= 2019:
    ans = 0
  # 2018**2個調べる(最小値が出たら打ち切り)
  else:
    for i in range(left, right):
      for j in range(l+1, right+1):
        ans = min((i*j)%mod, ans)
        if ans==0: return ans
  return ans
ans = check(l, r)
print(ans)

Measured memory_bytes: 3060
N, M = map(int, input().split())
pS = [tuple(input().split()) for i in range(M)]
pS.sort(key=lambda x: x[0])
problems = [0]*N
AC = 0
penalty = 0

for p, S in pS:
    p = int(p)
    if problems[p-1] < 0:
        continue
    else:
        if S == "AC":
            penalty += problems[p-1]
            problems[p-1] = -1
            AC += 1

        else:
            problems[p-1] += 1

print(AC, penalty)


Measured memory_bytes: 22860
#include <cstdio>
#include <string>
#include <vector>
#include <array>
using namespace std;

int main() {

	int N;
	array<int, 3> xs;
	vector<pair<int,int>> queries;
	vector<int> ans;
	scanf("%d%d%d%d", &N, &xs[0], &xs[1], &xs[2]);
	queries.resize(N);

	for(int i = 0; i < N; i++) {
		char buf[16];
		scanf("%s", buf);
		int i1 = buf[0] - 'A';
		int i2 = buf[1] - 'A';
		queries[i] = {i1, i2};
	}

	for(int step = 0; step < N; step++) {

		int i1 = queries[step].first;
		int i2 = queries[step].second;

		if(xs[i1] == 0 && xs[i2] == 0) {
			printf("No\n");
			return 0;
		}

		if(xs[i1] == 1 && xs[i2] == 1 && step < N - 1) {

			int j1 = queries[step + 1].first;
			int j2 = queries[step + 1].second;

			if(i1 == j1 || i1 == j2) {
				swap(i1, i2);
			}

		} else {
			if(xs[i1] < xs[i2]) {
				swap(i1, i2);
			}
		}

		xs[i1] -= 1;
		xs[i2] += 1;
		ans.push_back(i2);
	}

	printf("Yes\n");
	for(int i = 0; i < N; i++) {
		printf("%c\n", ans[i] + 'A');
	}

	return 0;
}


Measured memory_bytes: 4168
#include<bits/stdc++.h>
#define PB push_back
#define F first
#define S second
#define MP m ake_pair
#define LB lower_bound
#define UB upper_bound

using namespace std;
typedef long long ll;
typedef pair<int , int> pii;
typedef long double DB;

const int N = 200100;
ll a[N];

int main(){

	ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	
	int n;
	ll ans(0);
	cin >> n;

	for(int i = 0 ; i < n ; i++){
	   	cin >> a[i];
		a[i] -= (i+1);
	}
	sort(a , a+n);
	ll k = a[n/2];
	for(int i = 0 ; i < n ; i++){
		a[i] -= k;
		ans += abs(a[i]);
	}


	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 1792
N, K, Q = map(int, input().split())
A = [0 for i in range(Q)]
for i in range(Q):
    A[i] = int(input())
    
map_rights = {}
for i in range(Q):
    if A[i] not in map_rights:
        map_rights[A[i]] = 1
    else:
        map_rights[A[i]] += 1
        
for i in range(1, N + 1):
    rights = 0
    if i in map_rights:
        rights = map_rights[i]
    if K - Q + rights > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 11560
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
const int  MOD=1e9+7;
const int  INF=2000000000;
const int INF2=  10000000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INF2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}

int printintN(int array[],const int num){
    for(int i=0;i<num;i++){printf("%d ",array[i]);}
    br;
    return 0;
}


//#define int long long int

/*
 1.困った時こそ冷静に問題文を見直す！制約条件を見ろ！乱択アルゴリズムとかO(N^3)とか！
 2.一度に大量のことをやろうとしない。デバッグしやすいように細かく！
 3.プログラミングは半分数学だし、もう半分は数学ではない！
 4.できない問題はできない！！！！！
 */

int experiment(){
    int N;
    cin>>N;
    int partlymax=0;
    int H[N];
    int ans=0;
    FOR(i, 0, N){
        cin>>H[i];
        if(H[i]>=partlymax)ans++;
        partlymax=max(partlymax,H[i]);
    }
    OutputAndReturn0(ans);
    return 0;
}
signed main(){
    assert(1);
    experiment();
    return 0;
}


Measured memory_bytes: 256
// dp[i]=min cost occured to reach ith position


#include<bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    vector<vector<int>> dp(n, vector<int>(3));
    vector<int> points(3);
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>points[j];
        }
        for(int k=0;k<3;k++){
            // will make dp[i][k]
            dp[i][k]=0;
            for(int j=0;j<3;j++){
                if(j==k){
                    continue;
                }
                if((i-1)>=0){
                    dp[i][k]=max(dp[i-1][j], dp[i][k]);
                }
            }
            dp[i][k]+=points[k];
        }
    }

    int ans=0;
    for(int i=0;i<3;i++){
        ans=max(dp[n-1][i], ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8684
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static int n;

        static void Main(string[] args)
        {
            //[summary]B - Different Distribution
            n = int.Parse(Console.ReadLine());
            var players = new Player[n];

            for(int i = 0; i < n; i++)
            {
                var info = ReadLine();
                var player = new Player(info);
                players[i] = player;
            }

            var lowest = players.OrderBy(x => x.Score).First();

            Console.WriteLine(lowest.Rank + lowest.Score);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }

    struct Player
    {
        public int Rank { set; get; }
        public int Score { set; get; }

        public Player(List<int> info)
        {
            Rank = info[0];
            Score = info[1];
        }
    }
}

Measured memory_bytes: 19760
def main():
    h, w = map(int, input().split())
    d = h * w
    for i in range(1, h):
        sh = (h - i) // 2
        s = (i * w, sh * w, (h - i - sh) * w)
        d = min(max(s) - min(s), d)
        sv = w // 2
        s = (i * w, (h - i) * sv, (h - i) * (w - sv))
        d = min(max(s) - min(s), d)
    for i in range(1, w):
        sv = (w - i) // 2
        s = (h * i, h * sv, h * (w - i - sv))
        d = min(max(s) - min(s), d)
        sh = h // 2
        s = (h * i, sh * (w - i), (h - sh) * (w - i))
        d = min(max(s) - min(s), d)
    print(d)


if __name__ == '__main__':
    main()


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

#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

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

typedef long long ll;
typedef long double ld;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int k;
    cin>>k;

    ll S=2,L=2;
    vector<ll> a(k+1);
    a[0] = 1;

    rep(i,k)cin>>a[i+1];
    if(a[k] != 2){cout<<-1<<endl;return 0;}

    rep(i,k){
        int p = k-1-i;
        ll prS=S,prL=L;
        S = ( (S+a[p]-1)/a[p] ) * a[p];
        L = ( (L+a[p+1]-1)/a[p] ) * a[p];

        if(L < prS ){
            cout<<-1<<endl;return 0;
        }
    }


    cout<<S<<" "<<L<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 1152
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())-1
print((n*(n+1))//2)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int solve(int n,int k,int count){
  if(n==count)return 1;
  int a=solve(n,k,count+1)*2;
  int b=solve(n,k,count+1)+k;
  if(a < b){
    return a;
  }
  return b;
}
int main(void){
  int n,k;
  cin>>n>>k;
  cout<<solve(n,k,0)<<endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

def dfs(i, V, E, x):
    S = [i]
    while(len(S) > 0):
        vi = S.pop()
        p = x[vi]
        for j in E[vi]:
            if V[j] == 0:
                V[j] = 1
                x[j] += p
                S.append(j)
    return V, x

n, q = map(int, input().split())
V = [0 for _ in range(n + 1)]
E = defaultdict(list)
for i in range(n - 1):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)

x = [0 for _ in range(n + 1)]
for i in range(q):
    pi, xi = map(int, input().split())
    x[pi] += xi

V[1] = 1
V, x = dfs(1, V, E, x)
print(*x[1:])


Measured memory_bytes: 68284
#include <iostream>

using INT = long long;

int main() {
  INT K, A, B;

  std::cin >> K >> A >> B;

  INT ans = 0;

  if (A + 2 < B && K >= A + 1) {
    auto rest_K = K - A - 1;
    ans = B + (rest_K / 2 * (B - A));
    ans += rest_K % 2;
  } else {
    ans = 1 + K;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
vector<bool>seen;
void dfs(int v, int p, int roop) {
    //cout << v << endl;
    seen[v] = true;
    if(roop == 2) {
//cout << "stop" << endl;
        return;
    }
    roop++;
    for(int next_v : G[v]) {
        if(seen[next_v]) {
            continue;
        }
        if(next_v == p) {
            continue;
        }
        dfs(next_v, v, roop);
    }
}
int main() {
    int N, M;
    cin >> N >> M;
    G.resize(N);
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    seen.assign(N, false);
    dfs(0, -1, 0);
    string messages = "IMPOSSIBLE";
    if(seen[N-1] == true) {
        messages = "POSSIBLE";
    }
    cout << messages << endl;
    return 0;
}

Measured memory_bytes: 12016
import bisect
n, m, v, p = map(int, input().split())
ls = list(map(int, input().split()))

ls.sort()
total=m*v
for i in range(min(v-1,p-1)):
    ls[-i-1]+=m
    total-=m

ac = [0]*n
for i in range(n-1):
    ac[i+1] = ac[i]+(ls[i+1]-ls[i])*(i+1)

l=-1
r=n
while l+1<r:
    i=(l+r)//2
    idx=bisect.bisect_right(ls,ls[i]+m)
    if n-idx>=p:
        l=i
        continue
    totalnow=total-m*(i+1)
    if totalnow <= 0:
        r=i
        continue
    ok=ac[-p]-ac[i]-(ls[-p]-ls[i])*(i+1)+(ls[i]+m-ls[-p])*(n-p-i)
    if ok< totalnow:
        l=i
        continue
    r=i

print(n-r)



Measured memory_bytes: 62576
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <regex>
#include <initializer_list>
#define DBL_MIN 0.000000000000001

#define A_P(n,a,d) (n/2)*(2*a + (n-1)*d)
using namespace std;

//ちゃんとlong型でやってる？

int main(void){
    int N;
    cin >> N;
    int cnt = 0;
    for(int i = 1; i <= N; i++){
        int tmp;
        cin >> tmp;
        if(tmp % 2 > 0 && i % 2 > 0){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}



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

int main() {
int H,N;
cin >>H>>N;
int64_t sum=0;
for (int i = 0; i < N; i++)
{
  int x;
  cin >>x;
  sum+=x;
}
if(sum>=H) cout <<"Yes" << endl;
else cout <<"No" << endl;
  return 0;
}

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

      String n = sc.next();
      boolean ans =false;
      for(int i=0;i<2;i++){
        if(n.charAt(i)==n.charAt(i+1)){
          if(n.charAt(i+1)==n.charAt(i+2)){
            ans = true;
          }
        }
      }

      if(ans==true){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }

  }
}

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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;
    
    if(c < min(a, b) || c > max(a, b)) cout << "No";
    else cout << "Yes";
    
    return 0;
}

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


int main() {
    char a,b,c,d;
    cin>>a>>b>>c>>d;
    int A=a-'0';
    int B=b-'0';
    int C=c-'0';
    int D=d-'0';
    
    if(A+B+C+D==7)cout<<A<<"+"<<B<<"+"<<C<<"+"<<D<<"="<<7<<endl;
    else if(A+B+C-D==7)cout<<A<<"+"<<B<<"+"<<C<<"-"<<D<<"="<<7<<endl;
    else if(A-B+C+D==7)cout<<A<<"-"<<B<<"+"<<C<<"+"<<D<<"="<<7<<endl;
    else if(A-B+C-D==7)cout<<A<<"-"<<B<<"+"<<C<<"-"<<D<<"="<<7<<endl;
    else if(A+B-C+D==7)cout<<A<<"+"<<B<<"-"<<C<<"+"<<D<<"="<<7<<endl;
    else if(A+B-C-D==7)cout<<A<<"+"<<B<<"-"<<C<<"-"<<D<<"="<<7<<endl;
    else if(A-B-C-D==7)cout<<A<<"-"<<B<<"-"<<C<<"-"<<D<<"="<<7<<endl;
    else if(A-B-C+D==7)cout<<A<<"-"<<B<<"-"<<C<<"+"<<D<<"="<<7<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define s second
#define int long long
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1e6+5;


int32_t main() {
	int n, m;
	cin >> n >> m;
	ll sum = 0;
	while(m--) {
		int x;
		cin >> x;
		sum += x;
	}
	cout << (sum > n ? -1 : n-sum) << endl;
}


Measured memory_bytes: 3624
A, B = map(int, input().split())
ans = 0
for i in range(A, B+1):
    kaibun = str(i)
    for j in range(len(kaibun) // 2):

        if kaibun[j] != kaibun[-1-j]:
            break
        elif j == (len(kaibun) // 2) - 1:
            ans += 1
print(ans)


Measured memory_bytes: 2940