akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MAX 101

std::pair<int, int >mins[MAX];
std::pair<int, int> maxs[MAX];
int N;


int main()
{
    int tmp;
    while(1) {

        std::cin >> N;
        if(N == 0) break;

        for (int i = 0; i < N; i++) {
            mins[i] = std::make_pair(-1, INT_MAX);
            maxs[i] = std::make_pair(-1, -1);
        }

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                std::cin >> tmp;
                if (tmp > maxs[j].second) {
                    maxs[j].second = tmp;
                    maxs[j].first = i;
                }
                if (tmp < mins[i].second) {
                    mins[i].second = tmp;
                    mins[i].first = j;
                }
            }
        }

        bool isFound = false;
        
        for (int i = 0; i < N; i++) {
            if (mins[i].second == maxs[mins[i].first].second) {
                isFound = true;
                std::cout << mins[i].second << std::endl;
                break;
            }
        }
        
        if (!isFound) { std::cout << 0 << std::endl; }
    }

    return 0;
}



Measured memory_bytes: 2988
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n;
    cin >> n;
    ll a = 26;

    string ans;

    while (n)
    {
        n--;
        ans.push_back(char('a' + n % a));

        n /= a;
    }

    reverse(ans.begin(), ans.end());

    cout << ans << endl;
}


Measured memory_bytes: 3616
count = 0
while True:
  a,b = map(int,input().split())
  if (a,b) == (0,0):
    break
  if count:
    print()
  flag = 0
  for i in range(a,b+1):
    if (not (i % 400)) or ((i % 100) and (not (i % 4))):
      print(i)
      flag = 1
  if not flag:
    print("NA")
  count += 1

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main() {
    int N, A[100000], l[100000], r[100000];
    cin >> N;
    REP(i, N) cin >> A[i];
    l[0] = A[0];
    r[N - 1] = A[N - 1];
    FOR(i, 1, N - 1) l[i] = gcd(l[i - 1], A[i]);
    RFOR(i, N - 2, 0) r[i] = gcd(r[i + 1], A[i]);

    int ans = 0;
    FOR(i, 1, N - 1) ans = max(ans, gcd(l[i - 1], r[i + 1]));
    ans = max(ans, max(l[N - 2], r[1]));
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n), c(n);
  rep(i, n) {
    cin >> p.at(i);
    p.at(i)--;
  }
  rep(i, n) cin >> c.at(i);

  ll ans = -1e18 - 1;
  rep(si, n) {
    // まず周期を求める
    int current = si;
    vector<int> s;
    ll tot = 0;
    while (1) {
      current = p.at(current);
      s.push_back(c.at(current));
      tot += c.at(current);
      if (current == si) break;
    }

    // 最大値を求める
    int l = s.size();
    ll t = 0;
    rep(i, l) {
      if (i + 1 > k) break;
      t += s.at(i);
      ll now = t;
      if (tot > 0) {
        ll loopNum = (k - i - 1) / l;
        now += tot * loopNum;
      }
      ans = max(ans, now);
    }
  }

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

Measured memory_bytes: 3676
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>


using ll =  long long;

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

using namespace std;

int main(){

    int x, y, z;
    cin >> x >> y >> z;

    cout << z <<" "<< x << " "<< y << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

int main() {
  size_t N, K;
  scanf("%zu %zu", &N, &K);

  std::vector<std::vector<int>> g(2*K+2, std::vector<int>(2*K+2));
  std::vector<std::vector<int>> h(2*K+2, std::vector<int>(2*K+2));
  int k=K;
  for (size_t i=0; i<N; ++i) {
    int x, y;
    char c;
    scanf("%d %d %c", &x, &y, &c);
    x %= 2*k;
    y %= 2*k;

    int score=(c=='B'? 1:-1);
    if (x >= k) {
      x -= k;
      score = -score;
    }
    if (y > k) {
      y -= k;
      score = -score;
    }

    int xl=x+1, xr=std::min(2*k, x+k)+1;
    int yl=y+1, yr=std::min(2*k, y+k)+1;
    g[yl][xl] += 2*score;
    g[yl][xr] -= 2*score;
    g[yr][xl] -= 2*score;
    g[yr][xr] += 2*score;

    if (score > 0)
      g[0][0] += score;

    g[yl][0] -= score;
    g[0][xl] -= score;

    g[0][xr] += score;
    g[yr][0] += score;
  }

  for (size_t i=0; i<=2*K; ++i)
    for (size_t j=1; j<=2*K; ++j)
      g[i][j] += g[i][j-1];

  for (size_t i=1; i<=2*K; ++i)
    for (size_t j=0; j<=2*K; ++j)
      g[i][j] += g[i-1][j];

  int res=0;
  for (size_t i=1; i<=2*K; ++i)
    for (size_t j=1; j<=2*K; ++j)
      res = std::max(res, g[i][j]);

  printf("%d\n", res);
}


Measured memory_bytes: 31744
h,w = map(int,input().split())

if h == 1:
    print(1)
elif w == 1:
    print(1)
elif h%2 == 0:
    print(w*(h//2))
else:
    if w%2 == 0:
        print((w*(h//2)) + (w//2))
    else:
        print((w*(h//2)) + ((w//2)+1))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    string S;
    cin >> N;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        
        printf("%c", 'A'+((S[i] + N)-'A')%26);
    }
}

Measured memory_bytes: 256
n = gets.to_i
l = gets.split.map(&:to_i).sort
ans = 0
n.times do |i|
  i.next.upto(n - 2) do |j|
    a = l[i] + l[j]
    b = l.bsearch_index{_1 >= a}
    b = n if b.nil?
    ans += b - j - 1
  end
end
puts ans

Measured memory_bytes: 14376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
/* #pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/
typedef long long ll;
const ll MAXN = 1e5 + 2;
const ll MAXK = 5e2 + 2;
const ll MOD = 1e9 + 7;
const ll MODH = 1e9 + 9;
const int MAXLG = 20;
const long double PI = acos(-1);
const ll p = 41;
const long double EPS = 1e-4;
#define x first
#define y second
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll rand(ll a, ll b) {ll c = rng(); return a+((ll)abs(c))%(b-a+1);}
ll binpow(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;}



int main() {
  
 
 ios::sync_with_stdio(0);
 cin.tie(0);
 cout.tie(0);
  int n;
  cin >> n;
  ll ans = 0;
  ll maxi;
  cin >> maxi;
  for(int i = 1 ; i < n ; i++)
  {
  	 ll x;
     cin >> x;
     if(x < maxi)
     	 ans+=maxi-x;
     maxi = max(x , maxi);
  }

  cout << ans ;
  

  }

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n, m, s, g;

struct S{
    int to;
    double cost;
    int speed;
    int prev;
    bool operator<(const S &s) const{
        return cost > s.cost;
    }
};
struct edge{
   int to, len, speed;
};

vector<edge> G[31];
double d[31][31][32];

void dijkstra(int s){
    rep(i, 0, n) rep(j, 0, 31) rep(k, 0, 32) d[i][j][k] = INF;
    d[s][0][31] = 0;
    priority_queue<S> q;
    q.push({s, 0, 0, 31});
    while(!q.empty()){
        S p = q.top(); q.pop();
        int from = p.to;
        double cost = p.cost;
        int speed = p.speed;
        int prv = p.prev;
        if(d[from][speed][prv] < cost) continue;
        rep(i, 0, G[from].size()){
            edge e = G[from][i];
            int next = e.to;
            if(prv == next) continue;
            for(int j = -1; j <= 1; j++){
                if(speed + j <= 0 || speed + j > 30) continue;
                if(speed + j > e.speed) continue;
                double newCost = (double)e.len / (double)(speed + j) + cost;
                if(d[next][speed + j][from] > newCost){
                    // cout << next << 
                    // ' ' << speed + j << ' ' << newCost << endl;
                    d[next][speed + j][from] = newCost;
                    q.push({next, newCost, speed + j, from});
                } 
            }
        }
    }
}

signed main(){
    while(1){
        cin >> n >> m;
        if(n + m == 0) break;
        cin >> s >> g;
        s--; g--;
        rep(i, 0, n) G[i].clear();
        rep(i, 0, m){
            int x, y, dd, c;
            cin >> x >> y >> dd >> c;
            x--; y--;
            G[x].push_back({y, dd, c});
            G[y].push_back({x, dd, c});
        }
        dijkstra(s);
        double ans = INF;
        rep(i, 0, n) chmin(ans, d[g][1][i]);
        if(ans > INF - 1) cout << "unreachable" << endl;
        else printf("%.10f\n", ans);
    }
}


Measured memory_bytes: 4048
function Main(input){
	x = 'Christmas'+' Eve'+' Eve'+' Eve';
  	y = x.split(' ');
   	if(input == 22){
    console.log(y[0]+' '+y[1]+' '+y[2]+' '+y[3]);
    }else if(input == 23){
    console.log(y[0]+' '+y[1]+' '+y[2]);
    }else if(input == 24){
    console.log(y[0]+' '+y[1]);
    }else if(input == 25){
    console.log(y[0]);
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

const int N = 5005;
const int mod = 1e9 + 7;
const int Base = N >> 1;

int f[N][N] , n , m , a[(int)2e5 + 5] , b[(int)2e5 + 5] , P[(int)2e5 + 5] , inv[(int)2e5 + 5];

int getinv(int x , int y) {
	if(y == 1) return x % mod;
	if(y == 0) return 1;
	int it = getinv(x , y >> 1);
	it = it * 1ll * it % mod;
	if(y & 1) {
		it = it * 1ll * x % mod;
	}
	return it;
}

int main(void) {
	scanf("%d" , &n);
	P[0] = 1;
	for(int i = 1;i <= 100000;i ++) P[i] = P[i - 1] * 1ll * i % mod;
	for(int i = 1;i <= 100000;i ++) inv[i] = getinv(P[i] , mod - 2) % mod;
	for(int i = 1;i <= n;i ++) {
		scanf("%d%d" , &a[i] , &b[i]);
		f[Base - a[i]][Base - b[i]] ++;
	}
	for(int i = 0;i <= N - 4;i ++) {
		for(int j = 0;j <= N - 4;j ++) {
			f[i + 1][j] = (f[i + 1][j] + f[i][j]) % mod;
			f[i][j + 1] = (f[i][j + 1] + f[i][j]) % mod;
		}
	}
	int ans = 0;
	for(int i = 1;i <= n;i ++) {
		ans = ans - P[2 * a[i] + 2 * b[i]] * 1ll * inv[2 * a[i]] % mod * 1ll *inv[2 * b[i]] % mod;
		ans %= mod;
	}
	if(ans < 0) ans += mod;
	for(int i = 1;i <= n;i ++) {
		ans += f[Base + a[i]][Base + b[i]];
		ans %= mod;
	}
	cout << ans * 1ll * getinv(2 , mod - 2) % mod<< endl;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

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

int n;
void dfs(string s, char mx) {
    if (int(s.size()) == n) {
        cout << s << endl;
        return;
    }
    for (char c='a'; c<=mx+1; c++) {
        string t = s;
        t += c;
        dfs(t, max(c, mx));
    }
}

int main(){
    cin >> n;
    dfs("", 'a'-1);
    return 0;
}



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

using namespace std;

int n,A[1010],O[1010];
bool used[1010]; 

bool cmp(int a,int b)
{
	return A[a]<A[b];
}

int main()
{
	scanf("%d",&n);
	int mi=INT_MAX;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
		O[i]=i;
		mi=min(mi,A[i]);
	}
	sort(O,O+n,cmp);
	//for(int i=0;i<n;i++) printf("%d\n",O[i]);
	memset(used,false,sizeof(used));
	int ans=0;
	for(int i=0;i<n;i++)
		if(!used[i])
		{
			int tot=0,tn=0,tmi=INT_MAX;
			for(int j=i;!used[j];used[j]=true,j=O[j])
			{
				tmi=min(tmi,A[j]);
				tot+=A[j];
				tn++;
			}
			ans+=min(tot+(tn-2)*tmi,tot+tmi+(tn+1)*mi);
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3260
def II():return int(input())
def MI():return map(int,input().split())
def LI():return list(MI())
def ok():print("Yes")
def ng():print("No");exit()

k,n=MI()
a=LI()

maxl=0
for i in range(n-1):
    maxl=max(maxl,a[i+1]-a[i])
maxl=max(maxl,a[0]+k-a[-1])
ans=k-maxl
print(ans)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> pii;
#define f(i, l, r) for (int i = l; i <= r; i++)
#define rf(i, r, l) for (int i = r; i >= l; i--)
#define all(x) (x).begin(), (x).end()
#define sf(a) scanf("%d",&a)
#define llsf(a) scanf("%lld", &a)
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))

const int inf = 2e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);

int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	int a = 2, b = 1,c=3,e;
	while (c--) {
		sf(e); if (e == 5)a--; else if (e == 7)b--;
	}
	if (!a && !b)cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    int x; cin >> x;
    int n = 0;
    int tmp = x;
    tmp %= 100;
    for (int i = 5; i > 0; --i) {
        n += tmp / i;
        tmp %= i;
    }
    if (n * 100 <= x) {
        out(1);
    }
    else {
        out(0);
    }




    
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define vi vector<int>
#define ll long long
#define vvi vector<vi>
#define vll vector<ll>
#define vvll vector<vll>
#define MOD 998244353
#define endL << '\n'
#define ii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define endL << '\n'
#define vii vector<ii>
#define pb push_back

/*
ll powmod(ll x, ll y, ll mod){
	ll res = 1;
	while (y > 0){
		if (y%2) res = (res*x) % mod;
		x = (x*x) % mod;
		y /= 2;
	}
	return res;
}
*/

/*const int N = 1000000;
int lp[N+1];
vector<ll> pr;

void sieve(){
	for (int i=2; i<=N; ++i) {
	    if (lp[i] == 0) {
	        lp[i] = i;
	        pr.push_back (i);
	    }
	    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
	        lp[i * pr[j]] = pr[j];
	}
}*/

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1; //cin >> t;
	while(t--){
		int n; cin >> n;
		vvll cost(n, vll(3));
		for (int i = 0; i < n; i++){
			for (int j = 0; j < 3; j++) cin >> cost[i][j];
		}

		vvll dp(n, vll(3, 0));
		for (int j = 0; j < 3; j++) dp[0][j] = cost[0][j];
		for (int i = 1; i < n; i++){
			for (int j = 0; j < 3; j++){
				for (int k = 0; k < 3; k++){
					if (k == j) continue;
					dp[i][j] = max(dp[i][j], dp[i-1][k] + cost[i][j]);
				}
			}
		}
		cout << *max_element(dp[n-1].begin(), dp[n-1].end());
	}
}

Measured memory_bytes: 11264
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin>>n;
    V vec(n);
    rep(i,n){
        cin>>vec[i];
        if(vec[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    ll sum=vec[0];
    rep3(i,1,n){
        ll max=1000000000000000000/sum;
        if(max<vec[i]){
            cout<<-1<<endl;
            return 0;
        }
        sum*=vec[i];
        if(sum-1000000000000000000>0){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3992
K=int(input())
S=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1,51]
print(S[K-1])

Measured memory_bytes: 3060
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for i in range(0, A+1):
        for j in range(0, B+1):
                for k in range(0, C+1):
                        if int(500*i + 100*j + 50*k) == X:
                            cnt += 1
                     
print(cnt)

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

void solve(long long N, std::vector<long long> X)
{
    std::vector<long long> min(101);
    for (int i = 1; i < 101; i++)
    {
        min[i] = 0;
        for (int j = 0; j < N; j++)
        {
            min[i] += (X[j] - i) * (X[j] - i);
        }
    }
    sort(min.begin(), min.end());
    cout << min[1] << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> X(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


Measured memory_bytes: 256
//=========================================\\   
  //          @Author : SajidZakaria           \\
 //     @File Created : 2020-05-02 19:30:24     \\
//===============================================\\

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define endl '\n'

int ans[200005];

int main(){
	ios_base::sync_with_stdio(false);
	int n, x;
	cin >> n;

	for(int i=1; i<=n; i++) {
		cin >> x;
		ans[x] = ans[x-1] + 1;
	}

	int mx = 0;
	for(int i=1; i<=n; i++) mx = max(mx, ans[i]);

	cout << n - mx << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
#define PI 2*acos(0)
typedef long double ld;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ld> vd;
typedef vector<vd> vvd;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;
const ll INF = 2*pow(10,9)+10;
const ll inf =  pow(10,18);
ll modulo = 163577857;
#define MAX 200100
 
 
 
void deal(){
	ll n;
	cin>>n;
	map<ll, ll> all;
	fori(n){
		ll ed;
		cin>>ed;
		all[ed]++;
	}
	if(all.size() == 1){
		if(all[0])
			cout<<"Yes";
		else
			cout<<"No";
		return;
	}
	if(n%3!=0){
		cout<<"No";
		return;
	}
	if(all.size() == 2){
		auto it = all.begin();
		auto it1 = it;
		++it1;
		if((*it).ff == 0 && (*it1).ss == (*it).ss * 2)
			cout<<"Yes";
		else
			cout<<"No";
		return;
	}
	if(all.size() == 3){
		auto it = all.begin();
		auto it1 = it; ++it1;
		auto it2 = it1; ++it2;
		if( ((*it).ff == ((*it1).ff ^ (*it2).ff) ) && (*it1).ss == (*it2).ss && (*it2).ss == (*it).ss)
			cout<<"Yes";
		else
			cout<<"No";
		return;
	}
	cout<<"No";
}
 
int main(){
//	cin.tie(0);
//	ios_base::sync_with_stdio(0);
	deal();
}
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 5120
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    if (a<=9 && a>=1 && b<=9 && b>=1){
        int ans=a*b;
        cout<<ans<<endl;
    }
    else {
        cout<<"-1"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;


int main(){
    string s,t;
    cin >> s >> t;
    cout << t << s << endl;
    
    return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF=1LL<<60;
int main(){
    ll n,a,b;cin >> n >> a >> b;
    ll c=a+b;
    if(n%c<a){
        cout << n/c*a+n%c << endl;
    }
    else{
        cout << n/c*a+a << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N = 0, K = 0;
	scanf("%d%d", &N, &K);
	if (N >= K)
	{
		if (N % K == 0)
		{
			printf("0\n");
		}
		else
		{
			printf("1\n");
		}
	}
	else
	{
		printf("1\n");
	}


	return 0;
}

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

int main()
{
	int k,x;
	cin >> k >> x;
	if (k * 500 >= x) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
 
signed main(){
    int n;
    cin>>n;
    map<string,int> mp;

    rep(i,n){
        string s;
        cin>>s;
        mp[s]++;
    }
    int tmp=-1;
    for(auto itr:mp){
        chmax(tmp,itr.second);
    }

   // dump(tmp);

    set<string> se;
    for(auto itr:mp){
        if(itr.second==tmp){
            se.insert(itr.first);
        }
    }
    for(auto itr:se){
        cout<<itr<<endl;
    }
 
}

Measured memory_bytes: 36480
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<queue>

struct work{
	long long a;
	long long b;

};


int main(){
	int n;

	std::cin>>n;

	std::vector<work> xList(n);

	for(int i=0; i<n; i++)
		std::cin>>xList[i].a>>xList[i].b;

	std::sort(xList.begin(), xList.end(), [](const work &x, const work &y){return x.b< y.b;});

	long long sum=0;

	bool isPossible = true;

	for(int i=0; i<n; i++){
		sum+= xList[i].a;
		if(sum> xList[i].b)
			isPossible= false;
	}


	if(isPossible)
		std::cout<<"Yes"<<std::endl;
	else
		std::cout<<"No"<<std::endl;



	return 0;
	
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
char str[101][101];
int main()
{
	int n,m,sum=0;
	int i,j,flag;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%s",str[i]);
	}
	for(i=0;i<n;i++)
	{
		flag=1;
		for(j=0;j<m;j++)
		{
			if(str[i][j]=='#')
			{
				flag=0;
				break;
			}
		}
		if(flag)
		{
			for(j=0;j<m;j++)
			{
				str[i][j]='G';
			}
		}
	}
	for(j=0;j<m;j++)
	{
		flag=1;
		for(i=0;i<n;i++)
		{
			if(str[i][j]=='#')
			{
				flag=0;
				break;
			}
		}
		if(flag)
		{
			for(i=0;i<n;i++)
			{
				str[i][j]='G';
			}
		}
	}
	for(i=0;i<n;i++)
	{
		sum=0;
		for(j=0;j<m;j++)
		{
			if(str[i][j]=='G')
			{
				continue;
			}
			printf("%c",str[i][j]);
			sum++;
		}
		if(sum)
		{
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
#define debug(a,b) cerr << #a<<" = "<<a<<"   |   "<<#b<<" = "<<b<<'\n'
#define endl '\n'
#define SZ(a) ((int)a.size())
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
typedef vector<pi32> vp32;
typedef vector<pi64> vp64;
const ll mod = 1e9 + 7;
const int MX = 1e5+7;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	ll n,k;cin>>n>>k;
	vi64 a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	
	for(int go=0;go<k;go++){
		ll endL=0,endR=0;
		vi64 b(n,0);
	for(int i=0;i<n;i++){
		ll l=max(0LL,i-a[i]);
		ll r=min(n-1LL,i+a[i]);
		b[l]++;
		if(r+1LL<n)b[r+1LL]--;
		if(l==0LL)endL++;
		if(r+1>=n)endR++;
	}
	for(int i=0;i<n;i++){
		if(!i)a[i]=b[i];
		else a[i]=a[i-1]+b[i];
	}
	if(endL==n and endR==n)break;
   }

	for(int i=0;i<n;i++)cout<<a[i]<<" ";
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 6356
#include<stdio.h>
#include<string.h>
char comm[100][2000],temp;
int main()
{
int q,i,j,jin,jen,start,p=0,v,w;
char str[1005];
scanf("%s",str);
scanf("%d",&q);
getchar();
for(i=0;i<q;i++)
{
p=0;
scanf("%[^\n]s",comm[i]);
getchar();
if(comm[i][2]=='i')
{
jin=0;
jen=0;
for(v=6;comm[i][v]!=' ';v++)
{
jin=(comm[i][v]-'0')+jin*10;
}
for(v=v+1;comm[i][v]!='\0';v++)
{
jen=(comm[i][v]-'0')+jen*10;
}
for(j=jin;j<=jen;j++)
{
printf("%c",str[j]);
}
printf("\n");
}
else if(comm[i][2]=='v')
{
jin=0;
jen=0;
for(v=8;comm[i][v]!=' ';v++)
{
jin=(comm[i][v]-'0')+jin*10;
}
for(v=v+1;comm[i][v]!='\0';v++)
{
jen=(comm[i][v]-'0')+jen*10;
}
for(j=jin;j<=(jin+jen)/2;j++)
{
temp=str[j];
str[j]=str[jen-p];
str[jen-p]=temp;
p++;
}
}
else
{
jin=0;
jen=0;
for(v=8;comm[i][v]!=' ';v++)
{
jin=(comm[i][v]-'0')+jin*10;
}
for(v=v+1;comm[i][v]!=' ';v++)
{
jen=(comm[i][v]-'0')+jen*10;
}
start=v+1;
for(j=jin;j<=jen;j++)
{
str[j]=comm[i][start];
start++;
}
}
}
return 0;
}


Measured memory_bytes: 2076
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define fish        push_front
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Deque       std::deque
#define PQueue      std::priority_queue
#define Set         std::set
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    inline boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        int a, b, c;
        read a >> b >> c;
        echo std::min ( c, b/a ) fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


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

int main() {
    constexpr int max_n = 1 << 22;
    vector<bool> is_prime(max_n, true);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i < max_n; ++i) {
        if(is_prime[i]) {
            for(int j = i + i; j < max_n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    int n;
    while(cin >> n, n) {
        cout << count(begin(is_prime) + n + 1, begin(is_prime) + 2 * n + 1, true) << endl;
    }
}



Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n;
    n = n % 10;
    switch(n){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
    }
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>

int cond(char *s){
  int n=strlen(s);
  if(n<6) return 0;
  int i;
  for(i=0;i<n;i++) if('0'<=s[i] && s[i]<='9') break;
  if(i==n) return 0;
  for(i=0;i<n;i++) if('A'<=s[i] && s[i]<='Z') break;
  if(i==n) return 0;
  for(i=0;i<n;i++) if('a'<=s[i] && s[i]<='z') break;
  if(i==n) return 0;
  return 1;
}

void run(void){
  char s[21];
  scanf("%s",s);
  printf("%s\n",cond(s)?"VALID":"INVALID");
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 2144
S=input()
T=input()
Slen=len(S)
Tlen=len(T)
ans=5000
for i in range(0,Slen-Tlen+1):
    tans=0
    for j in range(0,Tlen):
        if S[i+j]!=T[j]:
            tans+=1
    if tans<ans:
        ans=tans
print(ans)


Measured memory_bytes: 9084
#include "bits/stdc++.h"

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b == 0) return b;
  else gcd(b, a%b);
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b))*b;
}

struct UnionFind {
  vi par; //par[i] : iの親番号（例）par[3] = 2 : 3の親は2

  UnionFind(int N) : par(N) { //最初は全てが根として初期化
    rep(i,N) par[i] = i;
  }

  int root(int x){ //データxが属する木の根を再帰で得る : root(x) = {xの木の根}
    if(par[x] == x)return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){ //xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if(rx == ry)return; //xとyの根が同じ
    par[rx] = ry; //xとyの根が同じでない時、xの根rxをyの根にryにつける。
  }

  bool same(int x, int y){//2つのデータx，yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int main(){

  string S; cin >> S;
  
  int count1 = 0, count0 = 0;

  for(int i = 0; i < S.length(); i++)
  {
    if(S[i] == '0')
      count0 ++;
    else
      count1 ++;
  }
  
  pr(S.length() - abs(count0 - count1));

 return 0;

}


Measured memory_bytes: 512
N,A,B=map(int,input().split())
Aadd=A-B
H=[0]*N
for i in range(N):
  H[i]=int(input())
MAXV=max(H)//B+(max(H)%B>0)
ng=-1
ok=MAXV+1

def isOK(n):
  Anum=0
  Bdamage=n*B
  for i in range(len(H)):
    rest=H[i]-Bdamage
    if rest>0:
      Anum+=rest//Aadd+(rest%Aadd>0)
  if Anum<=n:
    return True
  return False
        
while abs(ok-ng)>1:
  mid=abs(ok+ng)//2
  if isOK(mid):
    ok=mid
  else:
    ng=mid
    
print(ok)

Measured memory_bytes: 6988
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T=ll>
using v =vector<T>;
template<typename T=ll>
using vv = vector<v<T>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
const ll INF = (ll)1e9;
template<typename T> T chmin(T &a,T b){a=min(a,b);}
template<typename T> T chmax(T &a,T b){a=max(a,b);}

void a(){
    ll n,r; cin >> n >> r;
    cout << (n>=10?r:100*(10-n)+r);
}

void b(){
    ll n,k; cin >> n >>k;
    ll ans=0;
    for(int i=0;n!=0;i++){
        ans=i;
        n/=k;
    }
    cout << ans+1 << endl;
}

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

Measured memory_bytes: 256
#include <stdio.h>
//#include <stdlib.h>
#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int p[m]; char s[m][5];
  for (int i=0; i<m; i++) scanf("%d %s", p+i, s[i]);
  int ac = 0, wa = 0, a[n];
  for (int i=0; i<n; i++) a[i] = 0;
  for (int i=0; i<m; i++) {
    if (a[p[i]-1] == -1) continue;
    if (s[i][0] == 'W') a[p[i]-1]++;
    else {
      ac++;
      wa += a[p[i]-1];
      a[p[i]-1] = -1;
    }
  }
  printf("%d %d\n", ac, wa);
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	long long n,count=0,max=1;
	cin >> n;

	vector<string> s(n),ans2;
	vector<pair<string, long long>> ans1;

	for (long long i = 0; i < s.size(); i++)
		cin >> s[i];

	sort(s.begin(), s.end());

	ans1.push_back({s[0], 1});

	for (long long i = 1; i < s.size(); i++)
	{
		if (s[i - 1] == s[i])
		{
			ans1[count].second++;
			if (max < ans1[count].second)
				max = ans1[count].second;
		}
		else
		{
			ans1.push_back({ s[i],1 });
			count++;
		}
	}

	for (long long i = 0; i < ans1.size(); i++)
		if (ans1[i].second == max)
			ans2.push_back(ans1[i].first);
	
	for(long long i = 0;i < ans2.size();i++)
		cout << ans2[i] << endl;
}

Measured memory_bytes: 21872
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        cout << (a + b - 1) / a << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

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

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

int main(){
    string s;
    cin>>s;
    bool life=true;
    for(int i=0;i<s.size();i++){
        if(s[i]!=s[s.size()-i-1]){
            life=false;
        }
    }
    for(int i=0;i<(s.size()-1)/2;i++){
        if(s[i]!=s[(s.size()-3)/2-i]){
            life=false;
        }
    }
    int k=s.size()-1;
    for(int i=(s.size()+1)/2;i<s.size();i++){
        if(s[i]!=s[k]){
            life=false;
        }
        k--;
    }
    if(life){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
import string

N = int(input())
char_list = string.ascii_lowercase
char_list = char_list[:-1]
char_list = 'z' + char_list

tmp = 0
count = 0
ans = ''
while 1:
    before = tmp
    count += 1
    tmp += 26**count
    if before < N <= tmp:
        tmp = N
        while 1:
             ans = char_list[tmp%26] + ans
             tmp = (tmp-1) // 26
             count -= 1
             if count == 0:
                 break
        break
    else:
        pass

print(ans)


Measured memory_bytes: 9916
a = gets.to_i
under = a%100
top = (a-under)/100
ans = "NA"
if (top <=12 && top >= 1) && (under <= 12 && under >= 1)
  ans = "AMBIGUOUS"
elsif under <= 12 && under >= 1
  ans = "YYMM"
elsif top <=12 && top >= 1
  ans = "MMYY"
end
puts(ans)

Measured memory_bytes: 1788
//https://cs.stackexchange.com/questions/84426/find-a-node-with-maximum-distance-from-given-node-in-a-tree
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
//#include <ext/rope> //header with rope
//using namespace __gnu_cxx;
//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order tells index pr kon hai..
// order_by_key  tells ki us element se kitne strictly smaller element hai...
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Senky_Bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
ll fact[1000007];
ll mdpower(ll a,ll b)
{
    ll res =1;
    while(b)
    {
        if(b&1) res = (res%mod*a%mod)%mod;
        b/=2;
        a = (a%mod*a%mod)%mod;
    }
    return res;
}
void factorial()
{
    fact[0]=1;
    for(int i=1;i<1000007;i++)
        fact[i] = (fact[i-1]%mod*i%mod)%mod;
}
ll inverse(ll a,ll b)
{
    return mdpower(a,b-2);
}
ll power(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1)
            res=(res*a);
        a=(a*a);
        b/=2;
    }
    return res;
}
int main()
{   
    Senky_Bansal
    IIIT_ALLAHABAD


      ll a,b,k;
      cin>>a>>b>>k;
      int count=0;
      for(int i=min(a,b);i>=1;i--)
      {
        if(a%i==0 && b%i==0)
          count++;
        if(count==k)
        {
          cout<<i<<endl;
          return 0;
        }
      }



}

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

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<ll,ll>> vii;
typedef vector<vii> vvii;
typedef pair<ll,ll> ii;

#define pb push_back
#define mp make_pair
#define sz(vs) (ll)(vs.size())
#define rep(i,a,b) for (ll i=a;i<b;i++)
#define rep_(i,a,b) for (ll i=a;i>b;--i)
#define iter(i,c) for (auto i:c)
#define ss second
#define ff first
#define D(x) cout << '>' << #x << ':' << x << endl;
#define D2(x,a) cout << '>' << #x << ':' << x << " >" << #a << ':' << a <<  endl;
#define D3(x,a,b) cout << '>' << #x << ':' << x << " >" << #a << ':' << a << " >" << #b << ':' << b << endl;
#define D4(x,a,b,c) cout << '>' << #x << ':' << x << " >" << #a << ':' << a << " >" << #b << ':' << b << " >" << #c << ':' << c << endl;
#define PS(a,st,e) if (1) {if (st<e) {cout<<a[st];rep(noname,st+1,e) cout<<""<<a[noname];}cout<<"\n";}
#define PA1(a,st,e) if (1) {if (st<e) {cout<<a[st];rep(noname,st+1,e) cout<<" "<<a[noname];}cout<<'\n';}
#define PA(a,st,e) if (1) {cout<<#a<<": [";if (st<e) {cout<<a[st];rep(noname,st+1,e) cout<<", "<<a[noname];}cout<<"]\n";}
#define PSET(c) if (1) {cout<<#c<<": {";for (auto noname:c) cout<<noname<<",";cout<<"}\n";}
#define PM(c) if (1) {cout<<#c<<": {";for (auto noname:c) cout<<noname.first<<":"<<noname.second<<", ";cout<<"}\n";}

#define MAXN 101
#define MAXK 10006
#define mod 1000000007

ll n, m, k, a[MAXN][MAXN][MAXN], ans[MAXK];
string s;
char c;

void solve() {
	cin>>n;
	memset(ans, 0, sizeof(ans));
	rep(x, 1, MAXN) rep(y, 1, MAXN) rep(z, 1, MAXN) {
		a[x][y][z] = x*x + y*y + z*z + z*x + x*y + y*z;
		if (a[x][y][z]<=n) ans[a[x][y][z]]++;
	}
	rep(i, 1, n+1) cout<<ans[i]<<endl;
}

void aux() {
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	aux();
	ll _ = 1;
	// cin>>_;
	while(_--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 11632
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	string s; cin >> s;

	if (s.length() == 2) {
		cout << s << endl;
	}
	else {
		for (int i = 2; i >= 0; i--) {
			cout << s[i];
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N,K;
	int ans = 1000000001;
	cin >> N >> K;
	
	vector<int> h(N);
	for (int i = 0; i < N+1; i++)
	{
		cin >> h[i];
	} 	
	sort(h.begin(), h.end());
	
	for (int i = 0; i < N-K+1; i++)
	{
		if (ans > h[i + K - 1] - h[i]) {
			ans = h[i + K - 1] - h[i];
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
int main(void)
{
  int a,b;
  map<int,int> m;
  cin >> a;
  REP(i,a) {
    int x;
    cin >> x;
    m[x]++;
  }
  bool flag=true;
  cin >> b;
  REP(i,b){
    int x;
    cin >> x;
    if(--m[x]<0) flag = false;
  }
  cout << (flag ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 9600
n = int(input())
al = [int(input())-1 for _ in range(n)]
used = [False] *n
s = 0
res = 0
used[s] = True
while s != 1:
    s = al[s]
    if used[s]:
        print(-1)
        exit()
    used[s] = True
    res += 1
print(res)

Measured memory_bytes: 7852
#include <iostream>

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

using namespace std;

int main(void){
  int N;
  cin >> N;
  string S;
  cin >> S;
  //入力終わり

  int size = S.size();

  //カッコの対応を数える配列
  // )より(がいくつ多いか
  int count[size+1];
  count[0] = 0;
  rep(i, size){
    count[i+1] = count[i];
    // ( があれば+1
    if(S[i] == '(')
      count[i+1]++;
    // )があれば-1
    else
      count[i+1]--;
  }

  //左側に挿入する( の数
  int l_ins = size;
  //count[] の最小値になる
  rep(i, size+1)
    if(count[i] < l_ins)
      l_ins = count[i];

  //count[]の仕様上，符号反転
  l_ins *= -1;

  //右側に挿入する)の数
  int r_ins;
  r_ins = count[size] + l_ins;

  //左側に挿入する文字列生成
  string l;
  rep(i, l_ins)
    l = l + '(';

  //右側に挿入する文字列生成
  string r;
  rep(i, r_ins)
    r = r + ')';

  //解答
  cout << l + S + r << endl;
  
  return 0;
}


Measured memory_bytes: 3616