akhauriyash/Code-Regression huggingface dataset:
n,m = map(int,input().split())
s,c = [0]*m,[0]*m
for i in range(m):
    s[i],c[i] = map(int,input().split())
a = [0]*n
 
flag = True
                    
for i in range(m):
    if s[i]==1 and c[i]==0:
        flag = False
        
if n==1:
    flag = True
 
if flag == True:        
    for i in range(m):
        for j in range(i,m):
            if s[i]==s[j]:
                if c[i]!=c[j]:
                    flag = False
                    
if flag == True:
    for i in range(m):
        a[s[i]-1] = c[i]
    if n!=1 and a[0]==0:
        a[0]=1
    print(*a,sep="")
else:
    print("-1")

Measured memory_bytes: 3444
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  ll n = 0, x = 0, t = 0;

  cin >> n >> x >> t;

  cout << (n + x - 1) / x * t;

  return 0;
}
/*

*/


Measured memory_bytes: 3640
n = int(input())
a = list(map(int,input().split()))

sums = 0
for i in range(n):
    sums += a[i]

sums *= sums;
ans = sums;

for i in range(n):
    ans -= a[i]*a[i]
ans //= 2
ans %= 1000000007
print(int(ans))


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

typedef long long ll;
const int nax = 5010;
const ll INF = 1e18L;
ll dp[nax][nax];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  for (int i = 0; i < nax; ++i) {
    for (int j = 0; j <= i; ++j) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;

  int n;
  cin >> n;
  vector<pair<int, int>> q(n);
  for (int i = 0; i < n; ++i) {
    cin >> q[i].first >> q[i].second;
    q[i].first += q[i].second;
  }
  sort(q.begin(), q.end());
  for (int i = 0; i < n; ++i) {
    q[i].first -= q[i].second;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= i; ++j) {
      if (dp[i][j] == INF) continue;
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      if (dp[i][j] <= q[i].first) {
        dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + q[i].second);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    if (dp[n][i] != INF) {
      ans = i;
    }
  }
  cout << ans << '\n';
}

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

namespace Application
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            foreach (var c in s)
            {
                var d = 'A' + (c + n - 'A') % 26;
                Console.Write((char)d);
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 11184
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)

int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	string S, T;
	cin >> S >> T;

	bool ans = false;
	int matched_idx = -1;
	for (size_t i = 0; i < S.size() - T.size() + 1; i++)
	{
		bool matched = true;
		for (size_t j = 0; j < T.size(); j++)
		{
			if (S[i + j] != '?' && S[i + j] != T[j])
			{
				matched = false;
				break;
			}
		}

		if (matched)
		{
			ans = true;
			matched_idx = i; // search max idx
		}
	}

	if (ans)
	{
		for (size_t i = 0; i < T.size(); i++)
		{
			S[matched_idx + i] = T[i];
		}

		for (size_t i = 0; i < S.size(); i++)
		{
			if (S[i] == '?')
			{
				cout << 'a';
			}
			else
			{
				cout << S[i];
			}
		}
		cout << endl;
	}
	else
	{
		cout << "UNRESTORABLE" << endl;
	}

	return 0;
}


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

int main(){
    int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a < b && c < d) {
    cout << a + c << endl;
  }
  else if (a > b && c < d) {
    cout << b + c << endl;
  }
  else if (a < b && c > d) {
    cout << a + d << endl;
  }
  else if (a > b && c > d) {
    cout << b + d << endl;
  }
  else if (a == b && c < d) {
    cout << a + c << endl;
  }
  else if (a == b && c > d) {
    cout << a + d << endl;
  }
  else if (a < b && c == d) {
    cout << a + c << endl;
  }
  else if (a > b && c == d) {
    cout << b + c << endl;
  }
  else {
    cout << a + c << endl;
  }
}


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

using namespace std;

signed main()
{
    int h, w;
    cin >> h >> w;
    int n = h, m = w;
    map<char, int> cnt;
    int cnt1 = 0, cnt2 = 0, cnt4 = 0;
    for(int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        for(auto c: s)
            cnt[c]++;
    }
    bool is_pal = 0;
    int max1 = (n % 2) * (m % 2);
    int max2 = (n / 2) * (m % 2) + (m / 2) * (n % 2);
    for(auto jt: cnt)
    {
        int it = jt.second;
        if(it % 4 == 1 || it % 4 == 3)
            max1--;
        if(it % 4 == 2)
            max2--;
    }
    cout << (max1 >= 0 && max2 >= 0 ? "Yes" : "No") << endl;
    return 0;
}


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

typedef long long ll;
int  main(){
	ll n,m,x;
	cin >> n>> m;
	ll c = 0;
	vector<ll> ve = {};
	ll su = 0;
	for(ll i = 0; i < n; i++){
		cin >> x;
		su += x;
		ve.push_back(x);
	}
	for(auto u : ve){
		if(su <= u*4*m) c++;
	}

	if(c >= m) cout << "Yes\n";
	else cout << "No\n";}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 32768
#define F for(i=1;i<N;i++)
long long M=0x3B9ACA07LL,a[N]={},b[N],c[N]={},n,k,i;
int main(){std::cin>>n>>k;F a[i]=i<n?i:n,b[i]=n/i;while(--k){F c[i]=(c[i-1]+b[i])%M;b[N-1]=c[n/(N-1)];for(i=N-2;i>0;i--)b[i]=(b[i+1]+a[i]*(n/i-n/(i+1)))%M;std::swap(a,c);}std::cout<<b[1];}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <string.h>
using namespace std;



int main(){

    int A, P, pie;
    cin >> A >> P;

    P += A*3;
    pie = P/2;

    cout << pie;

    return 0;
}

//g++ ファイル名 --input-charset=utf-8 --exec-charset=cp932
//日本語出力するときのやつ

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

void Solve()
{
	ll R, C, K;
	cin >> R >> C >> K;
	VL r(K), c(K), v(K);
	REP(i, K) {
		cin >> r[i] >> c[i] >> v[i];
		r[i]--;	c[i]--;
	}

	static ll vMase[3005][3005];
	REP(i, K) {
		vMase[r[i]][c[i]] = v[i];
	}

	static ll dp[3005][3005][4];
	memset(dp, -1, sizeof(dp));
	dp[0][0][0] = 0;
	REP(r, R) {
		REP(c, C) {
			REP(i, 4) {
				ll now = dp[r][c][i];
				if (0 <= now) {
					if (i != 3) {
						now += vMase[r][c];
					}
					chmax<ll>(dp[r + 1][c][0], now);
				}
			}

			REP(i, 4) {
				ll now = dp[r][c][i];
				if (0 <= now) {
					chmax<ll>(dp[r][c + 1][i], now);
				}
			}

			if (vMase[r][c]) {
				REP(i, 3) {
					ll now = dp[r][c][i];
					if (0 <= now) {
						now += vMase[r][c];
						chmax<ll>(dp[r][c + 1][i + 1], now);
					}
				}
			}
		}
	}

	ll ans = 0;
	REP(i, 4) {
		ll now = dp[R][C - 1][i];
		if (0 <= now) {
			chmax<ll>(ans, now);
		}
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 360564
import sys
import random

def rd():
        return sys.stdin.readline().rstrip()

def rdi():
        return [ int(x) for x in rd().split() ]

N, M = rdi()

if N == 1 and M == 1:
        print 1
elif min(N, M) == 1:
        print max(N, M) - 2
else:
        print (N-2) * (M-2)


Measured memory_bytes: 4588
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 100005
#define BLOCK 555
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
inline ll myceil(ll a, ll b) { if (a % b == 0)	return (a / b);	return (a / b + 1);}
inline ll binlen(ll n) {
	ll c = 0;
	while (n > 0)
		++c , n /= 2;
	return c;
}
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	fast
	string s;
	cin >> s;
	ll sum = 0;
	for (char c : s)
		sum += (c - '0');
	if (sum % 9 == 0)
		cout << "Yes";
	else
		cout << "No";


// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

// NTT / FTT / generating functions

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

mint c(int n , int k){
	mint a = 1 , b = 1;
	for(int i = 0 ; i < k ; i++){
		a*=n-i;
		b*=i+1;
	}
	return a/b;
}

void test_case(){
	int n; cin >> n;
	n -= 5;
	mint ans;
	for(int i = 0 ; i <=11 ; i++){
		int m = n - i;
		if(m < 0 || m%2 != 0) continue;
		ans += c(m/2+15,15)*c(11,i);
	}
	cout<<ans<<"\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T;
	cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3596
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
dp = Array.new(2).map{Array.new(45).map{Array.new(2,0)}}
43.downto(0) do |i|
    p = [0,0]
    a.each do |num|
        p[(num>>i)&1] += (1<<i)
    end
    if ((k>>i)&1) == 0
        dp[1][i][0] = dp[1][i+1].max+p[1]
        if dp[0][i+1].inject(:+) > 0
            dp[0][i][0] = dp[0][i][1] = dp[0][i+1].max
            dp[0][i][0] += p[1]
            dp[0][i][1] += p[0]
        end
    else
        dp[1][i][1] = dp[1][i+1].max+p[0]
        if dp[0][i+1].inject(:+) > 0
            dp[0][i][0] = dp[0][i][1] = dp[0][i+1].max
            dp[0][i][0] = [dp[0][i][0],dp[1][i+1].max].max+p[1]
            dp[0][i][1] += p[0]
        else
            dp[0][i][0] = p[1]
        end
    end
end
puts [dp[0][0].max,dp[1][0].max].max

Measured memory_bytes: 8860
#include <stdio.h>
//prototype
int main(void);

int main(void){

  int n, m, l;
  int ni = 0, mi = 0, li = 0;
  int matA_value;
  int matB_value;
  int count = 1;

  scanf("%d %d %d", &n, &m, &l);

  long Matrix_A[n][m];
  long Matrix_B[m][l];
  long Product_Arrays[n][l];

  //Initialize Product_Arrays
  for (ni = 0; ni < n ; ni++) {
    for (li = 0; li < l; li++) {
      Product_Arrays[ni][li] = 0;
    }
  }

  //Matrix_A processing
  ni = 0;
  while(1){
    scanf("%d", &matA_value);
    Matrix_A[ni][mi] = matA_value;

    mi++;

    if (mi >= m) {
      ni++;
      mi = 0;
    }

    count++;

    if(count > (n * m)){
      mi = 0;
      ni = 0;
      li = 0;
      count = 1;
      break;
    }
  }

  //Matrix_B processing
  while(1){
    scanf("%d", &matB_value);
    Matrix_B[mi][li] = matB_value;

    li++;

    if (li >= l) {
      mi++;
      li = 0;
    }

    count++;

    if(count > (m * l)){
      break;
    }
  }


  //product of arrays
  for (ni = 0; ni < n; ni++) {
    for (li = 0; li < l; li++) {
      for (mi = 0; mi < m; mi++) {
        Product_Arrays[ni][li] += Matrix_A[ni][mi] * Matrix_B[mi][li];
      }
    }
  }


  //disp Product_Arrays
  for (ni = 0; ni < n; ni++) {
    for (li = 0; li < l; li++) {
      printf("%ld", Product_Arrays[ni][li]);
      if (li < l - 1) {
        printf(" ");
      }
    }
    printf("\n");
  }
    
  return 0;
}



Measured memory_bytes: 2084
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;
const double PI = acos(-1);

int partition(vector<pair<int,string>>& a,int p,int r){
    int x = a[r].first;
    int i = p-1;
    rep(j,p,r){
        if(a[j].first <= x){
            i++;
            swap(a[i],a[j]);
        }
    }
    swap(a[i+1],a[r]);
    return i+1;
}

void quicksort(vector<pair<int,string>>& x,int p,int r){
    if (p<r){
        int q = partition(x,p,r);
        quicksort(x,p,q-1);
        quicksort(x,q+1,r);
    }
}

bool cmp(const pair<pair<int,string>,int> &a, const pair<pair<int,string>,int> &b){
    if(a.first.first == b.first.first){
        return a.second < b.second;
    }else{
        return a.first.first < b.first.first;
    }
}
int main(){

    int n; cin >>n;
    vector<pair<int,string>> a;
    vector<pair<pair<int,string>,int>> b;
    rep(i,n){
        string s;
        int x;
        cin >> s >> x;
        a.emplace_back(x,s);
        b.push_back(make_pair(make_pair(x,s),i));
    }

    

    quicksort(a,0,n-1);
    sort(b.begin(),b.end(),cmp);

    bool f = true;

    rep(i,n){
        if(a[i] != b[i].first) f = false;
    }

    if(!f) cout << "Not stable" << endl;
    else cout << "Stable" << endl;

    rep(i,n){
        cout << a[i].second << " " << a[i].first << endl;
        //cout << b[i].second << " " << b[i].first << endl;
    }
    

}


Measured memory_bytes: 11484
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n,num[3]={0};
    cin>>n;
    cin>>num[0]>>num[1];
    if(n==3)cin>>num[2];
    sort(num,num+2);
    for(int i=1;i<=num[0];i++){
        if(num[0]%i==0&&num[1]%i==0&&num[2]==0)cout<<i<<endl;
        else if(num[0]%i==0&&num[1]%i==0&&num[2]%i==0)cout<<i<<endl;
    }
    return 0;
}

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

int main(){
  int a,b;
  cin >> a >>b;
  int mx = max(a,b);
  int mn = min(a,b);
  int mx2 = max(mx-1,mn);
  cout << mx + mx2 << endl;
}

// cout << fixed << setprecision(15) <<  << endl;


Measured memory_bytes: 3580
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM =  1000000007;

map<long long,long long> decomposite(long long N, map<long long,long long> & primes,long long next_p = 2){
    if (N == 1){
        return primes;
    }


    while (next_p * next_p <= N ) {
        if (N % next_p == 0) {
            primes[next_p] += 1;
            return decomposite(N/next_p,primes,next_p);
        } else {
            next_p++;
        }
    }
    primes[N] += 1;
    return primes;
}

int main()
{
    // 整数の入力
    bool is_p = false;
    ll X;
    cin >> X;
    while(!is_p){
        map<ll,ll> deco;
        decomposite(X,deco);
        if (deco.size() == 1 && (*deco.begin()).second == 1){
            is_p = true;
        }else{
            X++;
        }
    }
    cout << X << endl;
    return 0;
}

Measured memory_bytes: 256
#def gcd(a, b):
#	while b:
#	a, b = b, a % b
#return a
#def lcm(a, b):
#	w = a //gcd(a,b)
#return w * b

#def insertionSortWithIndex(arr, m): 
#    for i in range(1, len(arr)): 
#        key = arr[i]
#        l = m[i]
#        j = i-1
#        while j >=0 and key < arr[j] : 
#                arr[j+1] = arr[j]
#                m[j+1] = m[j]
#                j -= 1  
#        m[j+1] = l
#        arr[j+1] = key 
#insertionSortWithIndex(arr, indexstore)

#def binary_search(array) -> int:
#    def condition(value) -> bool:
#        pass
#    left, right = min(search_space), max(
#        search_space)  # could be [0, n], [1, n] etc. Depends on problem
#    while left < right:
#        mid = left + (right - left) // 2
#        if condition(mid):
#            right = mid
#        else:
#            left = mid + 1
#    return left

#index = sorted(range(len(nums)), key = lambda x: nums[x])

def solver(N, X, W):
    return W*(N//X + (1 if N%X>0 else 0))


if __name__=='__main__':
    N, X, T= map(int, input().split())
    #arr = list(map(int,input().split()))
    print(solver(N,X,T))

Measured memory_bytes: 9048
#include <cstdio>

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

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    int a,b,c,ai,count = 0;
    
    cin >> a >> b >> c;
    
    for(ai = a; ai <= b; ai++){
        if(c % ai == 0){
            count++;
        } 
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	
	cout << std::min((n + a - 1) / a * b, (n + c - 1) / c * d) << endl;
	return 0;
}



Measured memory_bytes: 3048
import math
N = int(input())

res = [0 for i in range(10 ** 4)]
for x in range(1, math.ceil(math.sqrt(10 ** 4))):
    for y in range(1, math.ceil(math.sqrt(10 ** 4))):
        for z in range(1, math.ceil(math.sqrt(10 ** 4))):
            ans = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if ans <= 10 ** 4:
                res[ans - 1] += 1

for n in range(N):
    print(res[n])


Measured memory_bytes: 9064
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,k = LI()
    a = LI()
    index = a.index(1)
    left = index
    right = n-index-1
    ans = float("inf")

    for i in range(k):
        cl = left-i
        cr = right-(k-i-1)
        if cl < 0 or cr < 0:
            continue
        
        cntl = (cl+k-2)//(k-1) if cl!=0 else 0
        cntr = (cr+k-2)//(k-1) if cr!=0 else 0
        cnt = cntl+cntr+1
        ans = min(ans,cnt)

    print(ans)
    
main()            


Measured memory_bytes: 88516
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const int N=200005;
int n,q;
long long a[N],x;
long long p[N],s[N];
long long l,r;
int get(long long x,int k)
{
	if (!k)
		return n;
	int l=1;
	int r=n-k+1;
	while (l<r)
	{
		int mid=(l+r+1)>>1;
		if (x>=a[mid])
		{
			if (x-a[mid-1]<=a[mid+k-1]-x)
				r=mid-1;
			else
				l=mid;
		}
		else
			if (a[mid-1]<x&&abs(x-a[mid-1])>abs(a[mid+k-1]-x))
				l=mid;
			else
				r=mid-1;
	}
	return r+k-1;
}
int main()
{
	scanf("%d%d",&n,&q);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		s[i]=s[i-1]+a[i];
	}
	for (int i=1;i<=n;i++)
		if ((n^i)&1)
			p[i]=p[i-1]+a[i];
		else
			p[i]=p[i-1];
	while (q--)
	{
		scanf("%lld",&x);
		l=0;
		r=n/2;
		while (l<r)
		{
			int mid=(l+r+1)>>1;
			if (get(x,mid)<n-mid+1)
				l=mid;
			else
				r=mid-1;
		}
		int c=get(x,r);
		printf("%lld\n",s[n]-(s[c]-s[c-r]+p[c-r]));
	}
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <math.h>

int main(void)
{
	char s[10];
	char a='S';
	char b='C';
	char c='R';
	
	scanf("%s", s);
	
	if(s[0]==a){
		printf("Cloudy");
	}

	if(s[0]==b){
		printf("Rainy");
	}

	if(s[0]==c){
		printf("Sunny");
	}


	return 0;
}

Measured memory_bytes: 128
sx,sy,tx,ty = map(int, input().split())

# cms =  list("UDRL")
# mvs = [(0,1),(0,-1),(1,0),(-1,0)]

dx = (tx-sx)
dy = (ty-sy)
ans = ""
# 一回目 s -> t -> s
ans += ("U")*dy+("R")*dx+("D")*dy+("L")*dx
# 二回目 一旦左に行く s->t
ans += "L"
ans += "U"*(dy+1)
ans += "R"*(dx+1)
ans += "D"
# 二回目 t->s
ans += "R"
ans += "D"*(dy+1)
ans += "L"*(dx+1)
ans += "U"

print(ans)

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
	int total;
	while(scanf("%d", &total), total) {
		int re[9];
		int tmp = 0;
		rep(i, 9) {
			scanf("%d", &re[i]);
			tmp += re[i];
		}
		printf("%d\n", total - tmp);
	}
	return 0;
}

Measured memory_bytes: 3188
'use strict';
(function(stdin) {
    var inputs = stdin.toString();
    var params = inputs.split('\n')[0].split(' ').map(Number);
    (function(a, b) {
        if (a < b) {
            console.log('a < b');
        } else if (a > b) {
            console.log('a > b');
        } else {
            console.log('a == b');
        } //????????????????????????
    }(params[0], params[1]));
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7376
#include <iostream>
#include <string>

int main()
{
    // input
    int N;
    std::cin >> N;
    std::string s[N];
   


    int ac_count = 0;
    int wa_count = 0;
    int tle_count = 0;
    int re_count = 0;

    for(int i = 0; i < N; i++) {
        std::cin >> s[i];
    }

    for (std::string word : s) {
        if (word == "AC") {
            ac_count++;
            continue;
        }
        if (word == "WA") {
            wa_count++;
            continue;
        }
        if (word == "TLE") {
            tle_count++;
            continue;
        }
        if (word == "RE") {
            re_count++;
            continue;
        }
    }

    std::cout << "AC x " << ac_count << std::endl;
    std::cout << "WA x " << wa_count << std::endl;
    std::cout << "TLE x " << tle_count << std::endl;
    std::cout << "RE x " << re_count << std::endl;

}

Measured memory_bytes: 5536
/// @pSaurabh

#include <bits/stdc++.h>

using namespace std;

#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] << " ";

typedef long long ll;
const ll mod = 1e9 + 7;

void fast(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout .tie(0);
}

int main(){
	// fast();

	int n, k;
	cin >> n >> k;

	int h[n];
	read(h, n);

	int dp[n + 1];
	dp[0] = 0;

	for(int i = 1; i < n; i++){
		int c;

		dp[i] = INT_MAX;
		
		for(int j = i - 1; j >= max(i - k, 0); j--){
			c = dp[j] + abs(h[i] - h[j]);
			dp[i] = min(dp[i], c);
		}
	}

	cout << dp[n - 1];

	return 0;
}


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

int main() {
	vector<int> a(13, 0);
	a[1] = 1; 
	a[2] = 3; 
	a[3] = 1; 
	a[4] = 2; 
	a[5] = 1; 
	a[6] = 2; 
	a[7] = 1; 
	a[8] = 1; 
	a[9] = 2; 
	a[10] = 1; 
	a[11] = 2; 
	a[12] = 1; 

	int x, y; cin >> x >> y;
	if(a[x] == a[y]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
import java.util.BitSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main{
//	public static int[][][] cost;
	public static int[][] dx = {
		{1, 1, 2, 1, 2, 3, 1, 2, 1},
		{-1, -1, -2, -1, -2, -3, -1, -2, -1},
	};
	public static int[][] dy = {
		{-2, -1, -1, 0, 0, 0, 1, 1, 2},
		{-2, -1, -1, 0, 0, 0, 1, 1, 2}
	};
	
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		final int INF = (int)1e8;
		while(true){
			int w = in.nextInt();
			int h = in.nextInt();
			if(w == 0) break;
			char[][] map = new char[h][w];
			Queue<Pos> slist = new LinkedList<Pos>();
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					map[i][j] = in.next().charAt(0);
					if(map[i][j] == 'S'){
						slist.add(new Pos(i*w+j, j, i, 0, 0));
						slist.add(new Pos(i*w+j, j, i, 1, 0));
						// state: 0:left 1:right
					}
				}
			}
//			cost = new int[2][h][w];
			BitSet[] used = new BitSet[2];
			used[0] = new BitSet(h*w);
			used[1] = new BitSet(h*w);
			int res = INF;
			while(!slist.isEmpty()){
				Pos start = slist.poll();
				Queue<Pos> qu = new PriorityQueue<Pos>();
				qu.add(start);
				used[0].clear();
				used[1].clear();
				out: while(!qu.isEmpty()){
					Pos p = qu.poll();
					if(used[p.state].get(p.id)) continue;
					used[p.state].set(p.id);
					for(int i=0; i<9; i++){
						int nx = p.x + dx[p.state][i];
						int ny = p.y + dy[p.state][i];
						if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
						if(map[ny][nx] == 'S' || map[ny][nx] == 'X') continue;
						if(map[ny][nx] == 'T'){
							res = Math.min(res, p.dist);
							break out;
						}
						int d = map[ny][nx] - '0';
						qu.add(new Pos(ny*w+nx, nx, ny, p.state==0?1:0, p.dist+d));
					}
				}
			}
			System.out.println(res==INF?-1:res);
		}
		in.close();
	}
}

class Pos implements Comparable<Pos>{
	int id, x, y, state, dist;
	public Pos(int id, int x, int y, int state, int dist){
		this.x = x;
		this.y = y;
		this.id = id;
		this.dist = dist;
		this.state = state;
	}
	
	@Override
	public int compareTo(Pos o) {
		return dist - o.dist;
//		return Main.cost[state][y][x] - Main.cost[o.state][o.y][o.x];
	}
}

Measured memory_bytes: 75632
import java.util.*;

/*
問題文

*/

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();

        System.out.println(z + " " + x + " " + y);
    }
}

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

#define int long long

class s{
	public : 
	string str ; int score , ind ;
} ;

bool check(s a , s b){
	if(a.str == b.str ){
		return a.score > b.score ;
	}else{
		return a.str < b.str ;
	}
}

int32_t main() {
	int n ;
	cin >> n ;
	s a[n] ;
	for(int i = 0 ; i < n ; i++){
		cin >> a[i].str >> a[i].score ; a[i].ind = i+1 ;
	}
	sort(a,a+n,check) ;
	for(int i = 0 ; i < n ; i++) cout << a[i].ind << '\n' ;
	return 0;
}

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

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

ll partition(vector<ll>& A, ll p, ll r){
    ll x = A[r];
    ll i = p-1;
    FOR(j, p, r){
        if(A[j]<=x){
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i+1], A[r]);
    return i+1;
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    ll p = partition(A, 0, N-1);
    FOR(i, 0, N){
        if(i){
            cout << ' ';
        }
        if(i==p) cout << '[';
        cout << A[i];
        if(i==p) cout << ']';
    }
    cout << endl;
    
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int sum = 0;
  int length = s.size();
  for(int i = 0; i < length; i++){
    sum += s[i] - '0';
  }
  if(sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(){
 int N;
  cin>>N;
  vector<int>p(N);
  for(int i=0;i<N;i++)
    cin>>p.at(i);
  int sum=0;
  for(int i=0;i<N;i++)
    sum+=p.at(i);
  int max=p.at(0);
  for(int i=1;i<N;i++)
    if(max<=p.at(i))
       max=p.at(i);
  cout<<sum-max/2<<endl;
       
  
  
  return 0;
}

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

namespace Contest.cs
{
	class Program
	{
		private int rand;

		static void Main(string[] args)
		{
			int[] input = ReadInt();
			int a = input[0];
			int b = input[1];
			int ans;
			if(a <= b)
			{
				ans = a;
			}
			else
			{
				ans = a - 1;
			}
			Console.WriteLine(ans);
		}

		static string[] ReadStr()
		{
			return Console.ReadLine().Split(' ').ToArray();

		}

		static int[] ReadInt()
		{
			return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
		}
	}
}

Measured memory_bytes: 13268
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int count = 0;
	for (int x = a; x <= b; x++) {
		if (c % x == 0)count++;
	}
	cout << count << endl;
}


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

public class Program
{
	public static void Main()
	{
        string s = Console.ReadLine();
        if(s == "a" || s == "i" || s == "u" || s == "e" || s == "o")Console.WriteLine("vowel");
        else Console.WriteLine("consonant");
	}
}

Measured memory_bytes: 11092
import sys
from math import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

def eratosthenes_sieve(n):

    table = [0] * (n+1)
    table[1] = 1
    for i in range(2, n+1):
        if table[i] == 0:
            for j in range(i, n+1, i):
                table[j] = i
    return table

def factorize(table, num: int) -> dict:
    """ 素因数分解 """
    from math import sqrt
    from collections import Counter

    d = Counter()
    while num != table[num]:
        d[table[num]] += 1
        num //= table[num]
    if num != 1:
        d[num] += 1
    return d

N = INT()
A = LIST()

def check(se, fact):
    for k in fact:
        if k not in se:
            se.add(k)
        else:
            return False
    return True

# table[i] := iを割り切る最小の素数
table = eratosthenes_sieve(10**6)

is_pc = 1
se = set()
for a in A:
    fact = factorize(table, a)
    if not check(se, fact):
        is_pc = 0
        break

is_sc = 1
g = 0
for a in A:
    g = gcd(g, a)
if g != 1:
    is_sc = 0

if is_pc:
    print('pairwise coprime')
elif is_sc:
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 208984
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
n = gets.to_i
num = n.times.map{gets.to_i}

n.times do |x|
  if num[x] == a[0]
    a[0] = 0
  elsif num[x] == a[1]
    a[1] = 0
  elsif num[x] == a[2]
    a[2] = 0
  elsif num[x] == b[0]
    b[0] = 0
  elsif num[x] == b[1]
    b[1] = 0
  elsif num[x] == b[2]
    b[2] = 0
  elsif num[x] == c[0]
    c[0] = 0
  elsif num[x] == c[1]
    c[1] = 0
  elsif num[x] == c[2]
    c[2] = 0
  end
end
if a.all?{|e|e==0} || b.all?{|e|e==0} || c.all?{|e|e==0}
  puts "Yes"
elsif a[0]==0 && b[0]==0 && c[0]==0
  puts "Yes"
elsif a[1]==0 && b[1]==0 && c[1]==0
  puts "Yes"
elsif a[2]==0 && b[2]==0 && c[2]==0
  puts "Yes"
elsif a[0]==0 && b[1]==0 && c[2]==0
  puts "Yes"
elsif a[2]==0 && b[1]==0 && c[0]==0
  puts "Yes"
else
  puts "No"
end


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




int N, T[101010], X[101010], Y[101010];
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
string solve() {
    int pt = 0, px = 0, py = 0;
    rep(i, 0, N) {
        int d = abs(px - X[i]) + abs(py - Y[i]);
        int dt = T[i] - pt;
        if (dt < d) return no;
        if ((dt - d) % 2 == 1) return no;

        pt = T[i];
        px = X[i];
        py = Y[i];
    }
    return yes;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> T[i] >> X[i] >> Y[i];
    cout << solve() << endl;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void){
    int x,max=1,temp;
    cin >> x;
    for(int i=2; i<x; i++){
        temp=i;
        while(temp*i<=x){
            temp*=i;
            if(temp>max)max=temp;
        }
    }
    cout << max << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 

template <class T>
void printArray(vector<T> arr) {for (T a: arr) cout << a << '\n';}
void printVerdict(bool verdict) {cout << (verdict ? "APPROVED": "DENIED") << '\n';}
void printDecimal(double d) {printf("%.9f\n", d);}
bool inrange(int val, int start, int end) {return val >=start && val <= end;}
template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	vector<string> ret;
	map<string, int> count;
	int n; cin >> n;
	int cnt = 0;
	for (int i = 0; i<n; i++) {
		string temp; cin >> temp;
		if (!present(count, temp)) count[temp] = 1;
		else count[temp]++;
		cnt = max(cnt, count[temp]);
	}
	auto it = count.begin();
	while (it != count.end()) {
		if (it->second == cnt) ret.push_back(it->first);
		it++;
	}
	sort(ret.begin(), ret.end());
	printArray(ret);
} 




Measured memory_bytes: 31396
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class Type>struct is_vector : std::false_type {};
	template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
	template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
		if (v.empty())return out;
		constexpr bool is_vector_v = is_vector<T>::value;
		if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
		else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
		return out;
	}
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	inline void putn() {}
	template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

	vector<int> demical(ll n, int k, int l = -1) {
		vector<int> rtn;
		if (l < 0) {
			while (n > 0) {
				rtn.push_back(n % k);
				n /= k;
			}
		} else {
			rtn.resize(l);
			REP(i, l) {
				rtn[i] = n % k;
				n /= k;
			}
		}
		return rtn;
	}

	void solve() {
		IOS;
		int n, k;
		cin >> n >> k;
		vector<ll> a(n);
		REP(i, n) {
			cin >> a[i];
		}
		int t = 1 << n;
		ll res = LLONG_MAX;
		REP(i, t) {
			auto d = demical(i, 2, n);
			bool flag = true;
			ll tmp = 0;
			int cnt = 0;
			REP(j, n) {
				if (d[j]) {
					cnt++;
				}
			}
			if (cnt != k) {
				continue;
			}
			int h = 0;
			REP(j, n) {
				if (d[j]) {
					ll t1 = h + 1 - a[j];
					chmax(t1, 0);
					tmp += t1;
					h++;
				}
				chmax(h, a[j]);
			}
			chmin(res, tmp);
		}
		put(res);
	}
} // namespace idaten

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


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

int main(){
	int n,x,min=1000,sum=0,ans,m[100];
	cin>>n>>x;
	for(int i = 0; i < n; i++){
		cin>>m[i];
		sum+=m[i];
		if(min>m[i])min=m[i];
	}
	ans = (x-sum)/min+n;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    W, H, N = map(int, input().split())
    xl = 0
    xr = W
    yu = H
    yd = 0
    for _ in range(N):
        x, y, a = map(int, input().split())

        if a == 1:
            xl = max(xl, x)
        elif a == 2:
            xr = min(xr, x)
        elif a == 3:
            yd = max(yd, y)
        else:
            yu = min(yu, y)

    if xr <= xl or yu <= yd:
        return 0

    return (xr - xl) * (yu - yd)


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3064
def main():
    """
    1 <= N      <= 100
    0 <= xi, yi <= 100
    0 <= hi     <= 10^9
    """
    N = int(input())
    x, y, h = zip(*(
        map(int, input().split())
        for _ in range(N)
    ))

    # ans = no_sub(x, y, h)
    ans = editorial_movie(x, y, h)
    print(*ans)


def h_H(cx, cy, x, y):
    return - abs(x - cx) - abs(y - cy)


def no_sub(x, y, h):
    max_h = -1
    ans = None
    dict_h = {(_x, _y): _h for _x, _y, _h in zip(x, y, h)}
    for _x, _y, _h in zip(x, y, h):
        for cx in range(1, 100+1):
            for cy in range(1, 100+1):
                tmp = h_H(cx, cy, _x, _y)
                pos = (cx, cy)
                H = _h - tmp
                if pos in dict_h and H != dict_h[pos]:
                    continue

                if H > max_h:
                    max_h = H
                    ans = _x, _y, H

                # print((_x, _y), (cx, cy), _h, tmp, sep="\t")

    return ans


def editorial_movie(x, y, h):
    """
    H >= 1, これ重要
        コンテスト中にこれを意識していなかった
        入力の制約しか意識していなかった

    h(x, y) = max(H - |x - Cx| - |y - Cy|, 0)
    より
        h(x,y) > 0: H  = h(x, y) + |x - Cx| - |y - Cy|
        h(x,y) = 0:
            頂点なら制約を満たしていない
                    H <= h(x, y) + |x - Cx| - |y - Cy|
    """
    for cx in range(100 + 1):
        for cy in range(100 + 1):
            # 頂上がどれくらいの高さであってほしいか。
            # -1はまだ良く分からない時。0以上は確定してるとき
            # -2はダメだって分かった時
            need_h = -1

            # h=0 より大きい場合の検証
            for _x, _y, _h in zip(x, y, h):
                if not _h > 0:
                    continue

                # 頂点候補座標および調査座標の組合せにおいてHになるべき値
                tmp = _h + abs(_x - cx) + abs(_y - cy)
                if need_h == -1:
                    need_h = tmp
                elif need_h != tmp:
                    need_h = -2
                    break

            if need_h == -2:
                continue

            # h=0 の検証
            for _x, _y, _h in zip(x, y, h):
                if not _h == 0:
                    continue

                # _h == 0 より、計算式上では省略してマンハッタン距離のみ求めている
                dist = abs(_x - cx) + abs(_y - cy)
                if need_h > dist:
                    need_h = -2
                    break

            if need_h == -2:
                continue

            return cx, cy, need_h


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188