akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

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

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	char c = 0;
	int ans = 0;
	REP(i, n) {
		if (c == s[i]) continue;
		c = s[i];
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main() {
    int K, X; cin >> K >> X;
    for(int i=X-K+1; i<X+K; i++){
        cout << i << endl;
    }
    
    return 0;
    
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>n;
    ll aa[n];
    for0(n)cin>>aa[i];
    sort(aa,aa+n);
    for0(n)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if(aa[i]!=aa[j]&&aa[j]!=aa[k]&&aa[i]!=aa[k])
                {
                    if(aa[i]+aa[j]>aa[k])
                    {
                        c++;
//                        cout<<i+1<<" "<<j+1<<" "<<k+1<<endl;
                    }
                }
            }
        }
    }
    cout<<c<<endl;
}



Measured memory_bytes: 3652
def main(str)
  lines = str.split("\n")
  _n = lines[0].to_i
  as = lines[1].split(" ").map(&:to_i)
  _q = lines[2].to_i
  bcs = lines[3..-1].map { |x| x.split(" ").map(&:to_i) }
  ahash = as.each_with_object({}) { |x, m| m[x] = m[x] ? m[x] + 1 : 1 }
  asum = ahash.map { |k, v| k * v }.sum
  ans = bcs.map do |b, c|
    val = ahash[b] || 0
    ahash[c] = (ahash[c] || 0) + val
    ahash[b] = 0
    asum += (c - b) * val
  end
  ans.map(&:to_s).join("\n")
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal("11
12
16", main("4
1 2 3 4
3
1 2
3 4
2 4"))
    assert_equal("8
4
4", main("4
1 1 1 1
3
1 2
2 1
3 5"))

    assert_equal("102
200
2000", main("2
1 2
3
1 100
2 100
100 1000"))
  end
end




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

using namespace std;

int main()
{
	int a, b, k;

	cin >> a >> b >> k;

	for(int i = max(a, b); i >= 1; --i)
	{
		if((a % i == 0) && (b % i == 0))
		{
			--k;
		}

		if(k == 0)
		{
			cout << i << endl;
			break;
		}
	}

	return 0;
}

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

int main() {
  string S, rS;
  cin >> S;
  rS=S;
  reverse(rS.begin(), rS.end());
  
  int A = S.find("A");
  int rZ = rS.find("Z");
  
  cout << S.size()-A-rZ << endl;
}

Measured memory_bytes: 3920
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define TYPE int
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}

int main(void){
	int n=in(),i;
	long long ans=1;
	for(i=1;i<=n;i++)ans=ans*i%mod;
	llprint(ans);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<sstream>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<climits>
#include<functional>

#include<memory.h>

#define ll long long

using namespace std;


int main()
{
	int N(0);
	while (cin >> N) {
		int num(0);
		int count0(0), count1(0), count2(0);
		for (int i = 0; i < N; ++i) {
			cin >> num;
			if (num % 4 == 0) {
				++count2;
			}
			else if (num % 2 == 0) {
				++count1;
			}
			else {
				++count0;
			}
		}

		if (count2 >= count0 || (count2 == count0 - 1 && count1 == 0)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 1000002
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
    ll t,n;
    cin>>t>>n;
    ll str[n+5];ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>str[i];
        sum=sum+str[i];
    }
    if(sum>=t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


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

#define sz(a) (int)a.size()
#define re return
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define gr greater <int>

#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")

using namespace std;

typedef long long ll;
typedef string str;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;

///!!!<3<3<3<3<3!!!
void ProdamGaraje () {
   int a, b;
   cin >> a >> b;
   if (a > b)
      cout << "safe";
   else
      cout << "unsafe";
}
///!!!<3<3<3<3<3!!!
int main () {
   //freopen ("input.txt", "r", stdin);
   //freopen ("output.txt", "w", stdout);
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   int tt = 1;
   //cin >> tt;
   while (tt--)
      ProdamGaraje ();
}
///GOOOOOOSE!!!!
/*
     ▄▀▀▀▄
▄███▀░0░░░▌
    ▌░░░░░▐
    ▌░░░░░▐
     ▌▌ ▌▌
     ▌▌ ▌▌
     ▌▌ ▌▌
     ▌▌ ▌▌
     ▌▌ ▌▌
   ▄▄▌▌▄▌▌        */


Measured memory_bytes: 3652
function Main(input) {

    var input = input.split("\n");

    const H = Number(input[0].split(" ")[0]);
    const A = input[1].split(" ").map(Number);

    const total = A.reduce(function (a, b) {
        return a + b;
    });

    const answer = H <= total ? "Yes" : "No";

    //出力
    console.log(answer);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 16716
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============fast_prime_factor============================
ll MAX_N = pow(10, 6) + 1;
bool init_called = false;
vector<ll> smallest_prime(MAX_N, -1);
void init() {
  for (ll i = 2; i < MAX_N; ++i) {
    if (smallest_prime.at(i) == -1) {
      smallest_prime.at(i) == i;
      ll cnt = 2;
      while (cnt * i < MAX_N) {
        smallest_prime.at(cnt * i) = i;
        cnt += 1;
      }
    }
  }
}

vector<pll> prime_factor(ll N)
{
  if (!init_called) {
    init_called = true;
    init();
  }
  vector<pll> res;
  while (true) {
    ll cnt = 0;
    ll now = smallest_prime.at(N);
    if (now == -1) {
      break;
    }
    while (N % now == 0) {
      N /= now;
      cnt += 1;
    }
    res.push_back({now, cnt});
  }
  if (N != 1) {
    res.push_back({N, 1});
  }
  return res;
}
//=================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  ll gcd = A.at(0);
  for (ll i = 0; i < N; ++i) {
    gcd = __gcd(A.at(i), gcd);
  }
  vector<ll> already(pow(10, 6) + 1, false);
  bool ok = true;
  for (ll i = 0; i < N; ++i) {
    vector<pll> temp = prime_factor(A.at(i));
    for (ll j = 0; j < temp.size(); ++j) {
      if (already.at(temp.at(j).first)) {
        ok = false;
        break;
      }
      already.at(temp.at(j).first) = true;
    }
    if (!ok) {
      break;
    }
  }
  if (ok) {
    cout << "pairwise coprime" << "\n";
  }
  else if (gcd == 1) {
    cout << "setwise coprime" << "\n";
  }
  else {
    cout << "not coprime" << "\n";
  }
}


Measured memory_bytes: 26696
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, M;
  cin >> N >> M;
  vi A(M);
  cin >> A;
  i64 ans = N - accumulate(rng(A), 0LL);
  if(ans < 0) cout << -1 << "\n";
  else cout << ans << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 3740
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
//const int INF = 100100100;
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

int n, c, k;
vector<int> t;
signed main() {
	ios::sync_with_stdio(false);
	cin >> n >> c >> k;
	rep(i, n) {
		int time;
		cin >> time;
		t.pb(time);
	}
	int ans = 0;
	sort(ALL(t));

	int cnt = 0;
	int limit = t[0] + k;
	//for (auto x : t) {
	//	cout << x << ' ';
	//}
	//cout << endl;
	int f = 0;
	for (int i = 0; i < t.size(); i++) {
		if (t[i] - t[f] > k or cnt == c) {
			//cout << "ans++" << endl;
			ans++;
			f = i;
			//debug(cnt);
			cnt = 0;
			//cout << "now limt is " << limit << endl;
			//limit = t[i] + k;
			//cout << "next kyaku is" << t[i] << "arrive\n";
			//cout << "next limit is " << limit << endl;
		}
		cnt++;
	}
	cout << ans+1 << endl;
	return 0;
}



Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int h[] = new int[N];
		int cnt = 0;
		for (int i = 0; i < h.length; i++) {
			h[i] = sc.nextInt();
			if (h[i] >= K) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


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

int main(void){
	int n, k, d;
	scanf("%d %d" , &n, &k);
	int gcd = 0;
	int maxi = INT_MIN;
	for(int i = 0 ; i < n ; i++){
		scanf("%d" , &d);
		gcd = __gcd(gcd, d);
		maxi = max(maxi, d);
	}
	if(k <= maxi && k%gcd == 0)
		printf("POSSIBLE");
	else
		printf("IMPOSSIBLE");	
	return 0;
}

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

#define MOD 1000000007

int N, C;
int A[400], B[400];
int T[401][401];
int dp[401][401];
int pow[401][401];

int pow_mod(int x, int k) {
  int a = 1;
  while (k > 0) {
    if (k & 1LL) a = (1LL*a*x) % MOD;
    x = (1LL*x*x) % MOD;
    k >>= 1;
  }
  return a;
}

int g(int n, int c) {
  return (0LL + MOD + T[B[n]][c] - T[A[n]-1][c]) % MOD;
}

int f(int n, int c) {
  if (dp[n][c] != -1) return dp[n][c];
  if (n == N-1) return g(n, c);
  int s = 0;
  for (int i=0; i<=c; i++) {
    s += (1LL * g(n, i) * f(n+1, c-i)) % MOD;
    s %= MOD;
  }
  return dp[n][c] = s;
}

signed main() {
  cin >> N >> C;
  for (int i=0; i<N; i++) cin >> A[i];
  for (int i=0; i<N; i++) cin >> B[i];
  for (int i=0; i<=400; i++) {
    for (int j=0; j<=400; j++) {
      pow[i][j] = pow_mod(i, j);
    }
  }
  for (int i=1; i<=400; i++) {
    for (int j=0; j<=400; j++) {
      T[i][j] = (T[i-1][j] + pow[i][j]) % MOD;
    }
  }
  for (int i=0; i<=N; i++) {
    for (int j=0; j<=C; j++) {
      dp[i][j] = -1;
    }
  }
  cout << f(0, C) << "\n";
  return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<map>
#include<cctype>
#include<sstream>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
		for (int i = 0;i <= 25;i++)
		{
			for (int j = 0;j <= 14;j++)
			{
				if (4 * i + 7 * j == n)
				{
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
		cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int c=0;
    for(int i=0;i<a.size()-1;i++)
    {

        if(i==2)
        {
            if(a[i]==a[i+1])
            {
                c++;
            }
        }
        else if(i==4)
        {
            if(a[i]==a[i+1])
            {
                c++;
            }
        }
    }
    if(c==2)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
from functools import reduce
while True:
    n = input()
    if n == '0000': break
    if len(n) < 4: n = n.zfill(4)
    if reduce(lambda x,y: x and y, [n[0] == s for s in n]):
        print('NA')
    else:
        cnt = 0
        while n != '6174':
            l = ''.join(sorted(n, reverse=True))
            s = l[::-1]
            n = str(int(l)-int(s))
            if len(n) < 4: n = n.zfill(4)
            cnt += 1
        print(cnt)

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

map<string,int>mp;


int main(){
  mp["RRR"] = 3;
mp["RRS"] = 2;
mp["RSR"] = 1;
mp["SRR"] = 2;
mp["SSR"] = 1;
mp["SRS"] = 1;
mp["RSS"] = 1;
mp["SSS"] = 0;

  string s;
  cin >> s;
  cout<<mp[s];
}


Measured memory_bytes: 3624
n = int(input())
s = []
a = []
for i in range(n):
    aa = int(input())
    a.append(aa)
    c = []
    for j in range(aa):
        xy = list(map(int,input().split()))
        c.append(xy)
    s.append(c)
#print(s[0])
sy = []
ans = 0
 
def syojiki(sy,count):
    if count == n:
     #   print(sy)
        check = [[] for i in range(n)]
        for i in range(n):
            if sy[i] == 1:
                check[i].append(1)
        for i in range(n):
            if sy[i] == 1:
                for j in range(a[i]):
                    if s[i][j][1] not in check[s[i][j][0]-1]:
                        check[s[i][j][0]-1].append(s[i][j][1])
    #    print(check)
        check2 = 0
        for i in range(n):
            if len(check[i]) == 0:
                check2 += 1
            elif len(check[i]) == 1 and check[i][0] == sy[i]:
                check2 += 1
   #     print(check2)
        if check2 == n:
            global ans
            ans = max(ans,check.count([1]))
   #         print(ans)
    else:
        syojiki(sy+[0],count+1)
        syojiki(sy+[1],count+1)
 
syojiki(sy,0)
print(ans)

Measured memory_bytes: 53468
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

double B;

ll LB,A,ans;

cin >> A >> B;

//LB = ll(B*100 + 0.1);

LB = lround(B*100 + 0.1);

ans = A*LB;

ans /= 100;

cout << ans << endl;

//printf("%0.8f\n",A);
//printf("%0.8f\n",B);
//printf("%0.8f\n",A*B);

//cout << A << endl;
//cout << B << endl;
//cout << A*B << endl;

//ans = 100 * B;

//printf("%0.8f\n",B*100.0);

//printf("%0.8f\n",A*B);

return 0;

}   


Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
using namespace std;

int N;
vector<long> A(100005);
vector<long> ans(100005);
vector<pair<long, int>> P(1000005);

int main() {
  cin >> N;
  rep(i, N) {
    cin >> A.at(i);
    P.at(i) = make_pair(A.at(i), i);
  }
  sort(P.rbegin(), P.rend());
  pair<long, int> pfirst = P.at(0);
  int num = 1;
  long dd = pfirst.first;
  int pos = pfirst.second;
  for (int i=1; i<N; i++) {
    pair<long, int> psecond = P.at(i);
    if (psecond.first < dd) {
      ans.at(pos) += (dd - psecond.first)*num;
      dd = psecond.first;
    }
    if (psecond.second < pos) {
      pos = psecond.second;
    }
    num++;
  }
  ans.at(0) += dd*num;
  rep(i, N) {
    cout << ans.at(i) << endl;
  }
}

// (1, 1), (5, 2), (4, 3)
// (5, 2), (4, 3), (1, 1)


Measured memory_bytes: 18304
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAX_N = 100005;

int n;
int h[MAX_N];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	bool res = true;
	for (int i = n - 1; i > 0; i--)
	{
		if (h[i - 1] > h[i])
		{
			h[i - 1]--;
			if (h[i - 1] > h[i])
			{
				res = false;
				break;
			}
		}
	}
	cout << (res ? "Yes" : "No") << endl;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	ll n = sz(s), res = 0;
	FOR(mask,0,1 << (n-1)) {
		ll cur = 0, x = 0;
		FOR(i,0,n) {
			x = 10*x + s[i] - '0';
			if (!(mask & (1 << i))) cur += x, x = 0;
		}
		res += cur;
	}
	cout << res << endl;

}



Measured memory_bytes: 256
from itertools import product
N = int(input())
cnt = [0 for _ in range(N+1)]
for x, y, z in product(range(1, 101), repeat=3):
    if x*x+y*y+z*z+x*y+y*z+z*x <= N:
  	  cnt[x*x+y*y+z*z+x*y+y*z+z*x] += 1

for n in range(1, N+1):
  print(cnt[n])



Measured memory_bytes: 9096
#9:28〜9:40
N,T=map(int,input().split())
ctlistlist=[]
for n in range(N):
  ctlist=list(map(int,input().split()))
  if ctlist[1] <= T:
    ctlistlist.append(ctlist)
ctlistlist.sort()
if ctlistlist == []:
  print("TLE")
else:
  print(ctlistlist[0][0])

Measured memory_bytes: 3060
def main():
    N, T = map(int, input().split())
    l = []
    for _ in range(N):
        c, t = map(int, input().split())
        l.append((c, t))
    l.sort()
    for e in l:
        if e[1] <= T:
            print(e[0])
            return
    print("TLE")
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 9188
#include <iostream>

using namespace std;

int64_t f(int64_t h)
{
    if (h == 1)
    {
        return 1;
    }
    else
    {
        return 1 + 2 * f(h / 2);
    }
}

int main()
{
    int64_t h;
    cin >> h;

    cout << f(h) << endl;
}

Measured memory_bytes: 256
import math
n, d = map(int,input().split())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int,input().split())

cnt = 0
for i in range(n):
    if math.sqrt(x[i] ** 2 + y[i] ** 2) <= d:
        cnt += 1
print(cnt)


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

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin>>n>>m;
    vector<vector<char>> a(n+1, vector<char> (m+1));
    
    long long int mod = 1000000007;
    
    for(int i = 1;i<=n;i++)
    {
        for(int j = 1;j<=m;j++)
        {
            cin>>a[i][j];
        }
    }
    
    vector<vector<int>> dp(n+1, vector<int> (m+1, 0));
    dp[1][1] = 1;
    
    for(int i = 1;i<=n;i++)
    {
        for(int j = 1;j<=m;j++)
        {
            if(i == 1 and j == 1)
            {
                continue;
            }
            if(a[i][j] != '#')
            {
                dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
            }
        }
    }
    cout<<dp[n][m]%mod<<"\n";
    
    return 0;
}

Measured memory_bytes: 8188
#include<bits/stdc++.h>
#pragma GCC optimize('O3')
using namespace std;
typedef long long ll;
#define rep(i,s,e) for(int i=s;i<e;i++)
#define endl '\n'
int main(){
    int N;cin>>N;
    vector<string> W(N);
    rep(i,0,N)cin>>W[i];
    rep(i,1,N){
        if(W[i].front()!=W[i-1].back()){
            cout<<"No"<<endl;
            return 0;
        }
        rep(j,0,N){
            if(i==j)continue;
            if(W[i]==W[j]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3632
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

point = {'s': R, 'p': S, 'r': P}

count = 0

for i in range(N):
  count += point[T[i]]

for i in range(K):
  S = [T[j] for j in range(i, N, K)]
  # print(S)
  same = 1
  for j in range(1, len(S)):
    # print((i, j, same))
    if S[j-1] == S[j]:
      same += 1
    else:
      t = point[S[j-1]] * (same // 2)
      # print(('!', same, t))
      count -= t
      same = 1
  if same >= 2:
    t = point[S[j-1]] * (same // 2)
    # print((same, t))
    count -= t
    same = 1

print(count)


Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int x, n;
  cin >> x >> n;
  vector<int> p;
  rep(i, 101) p.pb(i + 1);
  rep(i, 101) p.pb((i+1) * (-1));
  p.pb(0);
  sort(all(p));
  rep(i, n) {
    int r;cin >> r;
    p.erase(std::remove(p.begin(), p.end(), r), p.end());
  }
  int tmp = 999999,ans=99999;
  rep(i, sz(p)) {
    if(abs(p[i]-x)<tmp){
      tmp = abs(p[i] - x);
      ans = p[i];
    }
  }
  //show(p);
  cout << ans << endl;
  return 0;
}

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

int main(){
    string w;
    cin >> w;
    
    vector<int> alpha(26);
    for(int i=0; i<26; i++) alpha[i] = 0;

    for(int i=0; i<w.length(); i++){
        alpha[w.at(i) - 'a']++;
    }

    bool flg = true;
    for(int i=0; i<26; i++){
        if(alpha[i]%2 == 1){
            flg=false; break;
        }
    }

    if(flg) cout << "Yes"  << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3616
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define MAX_C 1000000001
#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  int len = s.size();
  vector<int> snum(len);
  for (int i = 0; i < len; i++) {
    snum[i] = (int)(s[i] - '0');
  }

  vector<int> memo(len); //memo[i]:下からi桁のあまり
  int tmp = 0, tmp_ten = 1;
  for (int i = 0; i < len; i++) {
    //tmp = (tmp * 10 + snum[len-1-i]) % MOD;
    tmp = (tmp_ten * snum[len-1-i] + tmp) % 2019;
    tmp_ten = (10 * tmp_ten) % 2019;
    memo[i] = tmp;
  }
  //cout << memo[0] << memo[1] << endl;

  sort(memo.begin(), memo.end());
  //cout << "sort" << endl;
  ll cnt = 0;

  ll c_tmp = 1;
  int c = 0;
  for (int i = 0; i < len; i++) {
    if (memo[i] == c) c_tmp++;
    else {
      cnt += (ll)(c_tmp * (c_tmp-1)) / 2;
      c_tmp = 1;
      c = memo[i];
    }
  }
  cnt += (ll)(c_tmp * (c_tmp-1)) / 2;

  cout << (ll)cnt << endl;
    
}


Measured memory_bytes: 5236
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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 main(){

    int N;
    cin >> N;
    vll L(N);
    REP(i, N) cin >> L[i];

    ll cnt = 0;
    REP(i, N){
        FOR(j, i + 1, N){
            FOR(k, j + 1, N){
                ll x = L[i];
                ll y = L[j];
                ll z = L[k];
                if (x == y || y == z || z == x) continue;
                if (x + y <= z || y + z <= x || z + x <= y) continue;
                cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3628
h,w,k = map(int,input().split())
x1,y1,x2,y2 = map(int,input().split())
c = []
for i in range(h):
  c.append(list(input()))

q = [(1,x1-1,y1-1)]
c[x1-1][y1-1] = 0
while(q):
  qq = []
  for a,x,y in q:
    for dx,dy in ((0,-1),(0,1),(-1,0),(1,0)):
      for kk in range(1,k+1):
        xx = x+dx*kk
        yy = y+dy*kk
        if not (0 <= xx < h) or not (0 <= yy < w) or c[xx][yy] == '@' or (c[xx][yy] != '.' and c[xx][yy] < a):
          break
        if c[xx][yy] == '.' or (c[xx][yy] != '.' and c[xx][yy] > a):
          c[xx][yy] = a
          qq.append((a+1,xx,yy))
  #print(qq)
  q = qq[:]

print(-1 if c[x2-1][y2-1] == '.' else c[x2-1][y2-1])
#print(c)


Measured memory_bytes: 232560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long Q,H,S,D,N;
    cin>>Q>>H>>S>>D>>N;
    Q*=8;
    H*=4;
    S*=2;
    long long num=N/2;
    long long minn=min(min(min(Q,H),S),D);
    long long ans=num*minn;
    num=N%2;
    if(num)
    {
        minn=min(min(Q,H),S);
        if(minn==Q)
        {
            ans+=Q/2;
        }
        else if(minn==H)
        {
            ans+=H/2;
        }
        else
        {
            ans+=S/2;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);   
    int k,a,b;
    cin>>k>>a>>b;
    if(b/k-(a-1)/k){
        cout<<"OK";
    } else{
        cout<<"NG";
    }
}

Measured memory_bytes: 3652
n,k = map(int, input().split())
a = [int(s) for s in input().split()]

if k > max(a):
  print('IMPOSSIBLE')
elif min(a) == 1 or k in a:
  print('POSSIBLE')
else:
  divmax = min(a)
  divval = 1
  for div in range(divmax):
    for x in a:
      if x % (div+1) != 0:
        break
    else:
      divval = div + 1
  if k % divval == 0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

Measured memory_bytes: 14224
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(void) {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  int sum = 0;
  rep(i, n) rep(j, i) {
    sum += d[i] * d[j];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
#n = int(input())
x, y = map(int, sys.stdin.readline().split())
#s = input()
#x = list(map(int, sys.stdin.readline().split()))
     

if 2 * x > y:
    print("No")
    sys.exit()

if 4 * x < y:
    print("No")
    sys.exit()

if y % 2 == 1:
    print("No")
else:
    print("Yes")





















Measured memory_bytes: 9988
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define all(c) begin(c), end(c)

int n;
int x,y;
int wx[10], wy[10];

inline bool in(int x,int y){
    return 0<=x && x<10 && 0<=y && y<10;
}

bool solve(){
    vector<pair<int,int>> cur{make_pair(x,y)};
    rep(l,n){
        vector<pair<int,int>> next;
        int dx1[]={-1,-1,-1,0,0,0,1,1,1};
        int dy1[]={0,1,-1,0,1,-1,0,1,-1};
        int dx2[]={-2,-2,-2,-1,-1,0,0,1,1,2,2,2};
        int dy2[]={-1,0,1,-2,2,-2,2,-2,2,-1,0,1};
        rep(i,cur.size()){
            int x=cur[i].first, y=cur[i].second;
            rep(j,9){
                int x1=wx[l]+dx1[j], y1=wy[l]+dy1[j];
                rep(k,12){
                    int x2=x+dx2[k], y2=y+dy2[k];
                    if(x1==x2 && y1==y2 && in(x1,y1)){
                        next.emplace_back(x1,y1);
                    }
                }
            }
        }
        sort(all(next));
        next.erase(unique(all(next)),next.end());
        cur=next;
        if(cur.size()==0) return false;
    }
    return true;
}

int main(){
    while(scanf("%d%d",&x,&y)!=EOF && x|y){
        scanf("%d",&n);
        rep(i,n)scanf("%d%d",&wx[i],&wy[i]);
        puts(solve()?"OK":"NA");
    }
}

Measured memory_bytes: 1004
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define f(i,x,z) for(int i=x;i<z;i++)
#define debug(x) cout<<"DEBUG------> "<<x<<endl
#define endl "\n"

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   long long co=0;
   string aa,bb;
   cin>>aa>>bb;
  	f(i,0,aa.length())
  	{
  		if(aa[i]!=bb[i])
  		{
  			co++;
  		}
  	}
  	cout<<co;

  	return 0;
		
}

Measured memory_bytes: 3836
// Dmitry _kun_ Sayutin (2019)

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;
using std::queue;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;
using std::swap;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

const int64_t mod = (1000 * 1000 * 1000 + 7) * int64_t(1000 * 1000 * 1000 + 9);
int p = 10000481;
vector<int64_t> pows;

int64_t mult(int64_t a, int64_t b) {
    return (__int128_t(a) * b) % mod;
}

struct node_t {
    int cnt;
    int64_t hash;
};

node_t operator+(node_t a, node_t b) {
    node_t res;

    res.cnt = a.cnt + b.cnt;
    res.hash = (mult(a.hash, pows[b.cnt]) + b.hash) % mod;
    return res;
}

const int max_n = 1 << 18;
vector<node_t> segtree(2 * max_n, node_t {0, 0});

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here
    int n, k;
    cin >> n >> k;

    vector<int> arr(n);
    for (int& elem: arr)
        elem = input<int>() + 1;

    pows.push_back(1);
    for (int i = 0; i < n + 3; ++i)
        pows.push_back(mult(pows.back(), p));

    vector<int64_t> prefhash(n + 1);
    for (int i = 0; i != n; ++i)
        prefhash[i + 1] = (mult(p, prefhash[i]) + arr[i]) % mod;

    auto update = [&](int i) {
        for (i /= 2; i != 0; i /= 2) {
            segtree[i] = segtree[2 * i] + segtree[2 * i + 1];
        }
    };

    for (int pos = n - 1; pos >= n - k; --pos) {
        segtree[max_n + arr[pos]] = node_t {1, arr[pos]};
        update(max_n + arr[pos]);
    }

    set<int64_t> st;
    node_t sufhash = node_t {0, 0};
    for (int end = n - 1; end >= k - 1; --end) {
        node_t n1 = node_t {end - k + 1, prefhash[end - k + 1]};
        node_t n2 = segtree[1];
        node_t n3 = sufhash;

        st.insert((n1 + n2 + n3).hash);
        
        if (end != k - 1) {
            segtree[max_n + arr[end]] = node_t {0, 0};
            update(max_n + arr[end]);

            segtree[max_n + arr[end - k]] = node_t {1, arr[end - k]};
            update(max_n + arr[end - k]);

            sufhash = node_t {1, arr[end]} + sufhash;
        }
    }
    

    cout << SZ(st) << "\n";

    return 0;
}


Measured memory_bytes: 21744
#include<iostream>//c[i]是原价，v[i]是现价 
using namespace std;
int main()
{
	int n,t=0;
	cin>>n;
	int c[n],v[n];
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
	 } 
	 for(int i=1;i<=n;i++)
	{
		cin>>v[i];
		if(v[i]<c[i])
		{
			t+=c[i]-v[i]; 
		}
	 } 
	 cout<<t<<endl;
	 return 0;
}

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 sc = new Scanner();
    	int n = sc.NextInt();
    	int m = sc.NextInt();
    	var g = new List<List<int>>();
    	for (int i = 0; i < n; i++) g.Add(new List<int>());
    	for (int i = 0; i < m; i++)
    	{
    		int a = sc.NextInt() - 1;
    		int b = sc.NextInt() - 1;
    		g[a].Add(b);
    		g[b].Add(a);
    	}
    	foreach (int first in g[0])
    	{
    		foreach (int second in g[first])
    		{
    			if (second == n - 1)
    			{
    				Console.WriteLine("POSSIBLE");
    				return;
    			}
    		}
    	}
    	Console.WriteLine("IMPOSSIBLE");
    }
    
    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }
        
    public long NextLong()
    {
    	CheckNext();
    	return long.Parse(buf[index++]);
    }
    
    public double NextDouble()
    {
    	CheckNext();
    	return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


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

int main() {
  int N,H,A=0,M=0;
  cin>>N>>H;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    p.at(i)=b;
    M=max(M,a);
  }
  sort(p.begin(), p.end());
reverse(p.begin(), p.end());
  int j=0;
  while(p.at(j)>M&&H>0){
    H-=p.at(j);
    A++;
    j++;
    if(j==N){
      break;
    }
  }
  if(H>0){
    A+=1+(H-1)/M;
  }
  cout<<A<<endl;     
}

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

#define int long long

int N;
int x[111], y[111], h[111];

// 中心座標の高さが求められたら高さを返す。求められなかったら-1を返す
int check(int cx, int cy) {
   set<int> cand;
   int Max = 1e10;
   for (int i = 0; i < N; i++) {
      int dist = abs(x[i] - cx) + abs(y[i] - cy); // 現在見ている座標から中心座標までの距離
      if (h[i] <= 0) {
         Max = min(Max, dist);
      } else {
         cand.insert(h[i]+dist);
      }
   }

   // 矛盾が無いなら中心座標の高さを返す
   if (cand.size() == 1 && *cand.begin() <= Max) {
      return *cand.begin();
   }

   return -1;
}

signed main() {
   // 入力
   cin >> N;
   for (int i = 0; i < N; i++) {
      cin >> x[i] >> y[i] >> h[i];
   }

   // 答えとなる(x, y, h)
   int ax = 0, ay = 0, ah = 0;

   // 多重ループを抜けやすくするためにラムダ式を使っている
   [&]() {
      // (cx, cy)を全列挙
      for (int cy = 0; cy <= 100; cy++) {
         for (int cx = 0; cx <= 100; cx++) {
            int t = check(cx, cy); // (cx, cy)が中心座標かどうかをcheck()で評価する
            if (t == -1) continue; // 返り値が-1なら処理を飛ばす

            // 答えが見つかった、変数に代入してループを抜ける
            ax = cx, ay = cy, ah = t;
            return;
         }
      }
   }();

   printf("%lld %lld %lld\n", ax, ay, ah); // 答えを出力

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=100005;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
	cin>>s;
	int n=s.length();
	if(n&1)
	{
		cout<<"No";
		return 0;
	}
	for(int i=0;i<n;i+=2)
	{
		if(s[i]=='h'&&s[i+1]=='i')
		{

		}
		else{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
}
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

Measured memory_bytes: 256
n, m = gets.rstrip.split.map(&:to_i)
as   = gets.rstrip.split.map(&:to_i).sort

bs = []
m.times do | i |
  bs[i] = gets.rstrip.split.map(&:to_i).reverse
end
bs.sort!.reverse!

i = 0
bs.each do | b |
  b[1].times do
    if i < n && as[i] < b[0]
      as[i] = b[0]
    else
      puts as.inject(:+)
      exit
    end
    i += 1
  end
end

puts as.inject(:+)

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

using namespace std;

using ll = long long;

int main(){

    ll n; cin >> n;
    ll arr[n];
    for(ll i = 0; i < n; ++i){
        cin >> arr[i];
    }
    ll ans = 1000, x;
    for(ll i = 1; i < n; ++i){
        if(arr[i] > arr[i - 1]){
            x = ans / arr[i - 1];
            ans -= (x * arr[i - 1]);
            ans += (x * arr[i]);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b) {return b ? gcd(b,a%b) : abs(a);}
const int N = 205, M = 998244353;
int p2[N];
pair<int,int> a[205];
int main()
{
    int n;
    cin >> n;
    p2[0] = 1;
    for (int i = 1; i <= n; ++i)
        p2[i] = p2[i-1] * 2 % M;
    long long ans = 1;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
        map<pair<int,int>,int> mp;
        for (int j = 0; j < i; ++j) {
            pair<int,int> v = {a[j].first - a[i].first, a[j].second - a[i].second};
            if (v.first < 0) {
                v.first *= -1;
                v.second *= -1;
            } else if (v.first == 0 && v.second < 0) {
                v.second *= -1;
            }
            int d = gcd(v.first, v.second);
            v.first /= d;
            v.second /= d;
            ++mp[v];
        }
        ++ans;
        for (auto it = begin(mp); it != end(mp); ++it)
            ans += p2[it->second] + M - 1;
    }
    cout << (p2[n] + M - ans%M) % M << endl; 
}


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

int main() {
  int N;cin>>N;
  string S;
  
  for(int i=0;i<N;i++){
    cin>>S;
  
  if(S=="Y"){
  cout<<"Four"<<endl;
  
  return 0;
  }
  }
   cout<<"Three"<<endl;
  }



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int h,w,n;
    cin >> h >> w >> n;
    int cnt = 0;
    int j = max(h,w);
    int tmp = 0;
    rep(i,n){
        if(tmp >= n) break;
        tmp += j;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1000000)




def main():
    n = int(input())

    if n == 1:
        print(1)
    else:
        _x2 = 2
        _x1 = 1
        _x = 0
        for i in range(n-1):
            _x = _x2 + _x1
            _x2 = _x1
            _x1 = _x

        print(_x)


main()


Measured memory_bytes: 2940
using System;
using System.Linq;

class B
{
	class LR { public int L, R; }

	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ts = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).Select(x => new LR { L = x[0], R = x[1] + 1 }).OrderBy(x => x.R).ThenBy(x => x.L).ToList();
		var t0 = ts.OrderBy(x => -x.L).ThenBy(x => -x.R).First();

		if (n == 2) { Console.WriteLine(ts.Sum(x => x.R - x.L)); return; }
		var M = Math.Max(0, ts[0].R - t0.L) + ts.Max(x => x.R - x.L);

		ts.Remove(t0);
		for (int l2 = 0, i = 0; i < n - 1; i++)
		{
			var v1 = Math.Max(0, Math.Min(t0.R, i == n - 2 ? int.MaxValue : ts[i + 1].R) - t0.L);
			var v2 = Math.Max(0, ts[0].R - (l2 = Math.Max(l2, ts[i].L)));
			M = Math.Max(M, v1 + v2);
		}
		Console.WriteLine(M);
	}
}


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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T1, class T2>
ostream &operator<<(ostream &s, pair<T1, T2> P)
{
    return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream &operator<<(ostream &s, vector<T> P)
{
    for (int i = 0; i < P.size(); ++i)
    {
        if (i > 0)
        {
            s << " ";
        }
        s << P[i];
    }
    return s;
}
template <class T>
ostream &operator<<(ostream &s, vector<vector<T>> P)
{
    for (int i = 0; i < P.size(); ++i)
    {
        s << endl
          << P[i];
    }
    return s << endl;
}
template <class T>
ostream &operator<<(ostream &s, set<T> P)
{
    EACH(it, P) { s << "<" << *it << "> "; }
    return s << endl;
}
template <class T1, class T2>
ostream &operator<<(ostream &s, map<T1, T2> P)
{
    EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; }
    return s << endl;
}
template <class T>
void show(vector<T> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cerr << v[i] << " ";
    }
    cerr << "\n";
}
typedef long long ll;

signed main()
{
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    while(n>0){
        n /= k;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string to_id(int num) {
    string s = to_string(num);
    reverse(s.begin(), s.end());
    while (s.size() < 6) s += '0';
    reverse(s.begin(), s.end());
    return s;
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> cities(n+10, vector<int>());
    vector<int> year(m), pre(m);
    for (int i = 0; i < m; i++) {
        int p, y;
        cin >> p >> y;
        cities[p].push_back(y);
        year[i] = y, pre[i] = p;
    }
    for (int i = 0; i < n+10; i++) sort(cities[i].begin(), cities[i].end());
    for (int i = 0; i < m; i++) {
        cout << to_id(pre[i]);
        cout << to_id(lower_bound(cities[pre[i]].begin(), cities[pre[i]].end(), year[i]) - cities[pre[i]].begin() + 1);
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 9372
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
  vector<int> n(3, 0);
  cin >> n[0] >> n[1] >> n[2];
  sort(n.begin(), n.end());
  cout << n[0] + n[1] + 10*n[2] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
typedef long long ll;
using namespace std;
  ll n,k,a;
  ll ans=0;
int main(void){
  cin >> n >> k;
  ll v[n+10]={0};
  for(ll i=0;i<n;++i){
    cin >>a;
   	v[a-1]++;
  }
  std::sort(v,v+n,greater<int>());
  for(ll i=0;i<k;++i){
     	ans += v[i];
  }
  cout << n-ans;
return 0;
}


Measured memory_bytes: 1792