akhauriyash/Code-Regression huggingface dataset:
/*input
4
4 3 2 1
*/
#include <bits/stdc++.h>

using namespace std;

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

  vector<int> v;
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    int x; cin >> x; 
    v.emplace_back(x);
    v.emplace_back(x);
  }

  sort(v.begin(), v.end(), greater<int>());

  int64_t ans = accumulate(v.begin() + 1, v.begin() + n, 0LL);
  cout << ans << endl;

  return 0;
}

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

int main() {
  //int N; cin >> N;
  string S; cin >> S;
  
  int n=0, w=0, s=0, e=0;
  
  rep(i, S.size()) {
    if(S[i] == 'N') n=1;
    if(S[i] == 'W') w=1;
    if(S[i] == 'S') s=1;
    if(S[i] == 'E') e=1;
  }
  if((n*s==1||n+s==0) && (w*e==1||w+e==0)) cout << "Yes" << endl;
  else cout << "No" << endl;
    
}

Measured memory_bytes: 256
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

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

const int N = (1<<19);

int n, q, t = 1, in[N], out[N], drz[2*N];
VI child[N];

void dfs(int v, int p) {
  in[v] = t++;
  for (int x: child[v])
    if (x != p)
      dfs(x, v);
  out[v] = t++;
}

void add(int p, int q, int val) {
  p += N;
  q += N;
  drz[p] += val;
  if (p != q)
    drz[q] += val;
  while (p/2 != q/2) {
    if (p%2 == 0)
      drz[p+1] += val;
    if (q%2 == 1)
      drz[q-1] += val;
    p /= 2;
    q /= 2;
  }
}

int get(int p) {
  p += N;
  int res = drz[p];
  while (p > 1) {
    p /= 2;
    res += drz[p];
  }
  return res;
}

int main() {
  init_ios();
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    child[x].PB(y);
    child[y].PB(x);
  }
  dfs(1, 0);
  while (q--) {
    int x, y;
    cin >> y >> x;
    add(in[y], out[y], x);
  }
  for (int i = 1; i <= n; ++i)
    cout<<get(in[i])<<" ";
  cout<<"\n";
}

Measured memory_bytes: 38528
a, b = list(map(int, input().split()))

def f0n(n):
    if n % 2 == 0:
        return (n // 2) % 2 ^ n
    else:
        return 0 if ((n + 1) / 2) % 2 == 0 else 1

print(int(f0n(a-1)) ^ int(f0n(b)))


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

int main()
{
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;
  if(std::abs(a - c) <= d || (std::abs(a - b) <= d && std::abs(b - c) <= d)){
    std::cout << "Yes";
  }else{
    std::cout << "No";
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

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

	int ans=0;

	for(int i=1;i<=m;i++)
		for(int j=1;j<=d;j++)
		{
			int d1=j%10;
			int d2=j/10;


			if(d1>=2 and d2>=2 and d1*d2==i)
				ans++;
		}

	cout << ans << endl;




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long ans=1;
  string s;
  cin >> s;
  map<char, int> mp;
  for(int i=s.size()-1;i>=0;i--){
    mp[s[i]]++;
    ans+=s.size()-i-mp[s[i]];
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n, k;
  std::cin >> n >> k;

  if (2 * k - 1 <= n) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}


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

int main() {

	//数字
	int X;
	cin >> X;
  	int ss=X/100;
  	int tt=ss/5;
  	//cout << X << " " << ss << " " << tt << endl;
  	if(X>=ss*100 && X<=ss*105)
    {
    cout << 1 << endl;
    }else{
    cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
int main(){
//	judge();
	int a,b;read(a);read(b);
	if(a<=0&&b>=0){
		return puts("Zero"),0;
	}
	if(a>0){
		return puts("Positive"),0;
	}
	int tot=min(0,b)-a+1;
	if(tot&1)
		return puts("Negative"),0;
	else
		return puts("Positive"),0;
	return 0;
}


Measured memory_bytes: 256
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;
    ll n, m, k, i, j, x, y, p=0, s=0, h, f=0;
    cin>>n>>m;
    priority_queue<ll> pq;
    for(i=0; i<n; i++){
        cin>>x;
        pq.push(x);
    }
    while(m>0  && !pq.empty()){
        x=pq.top();
        pq.pop();
        x/=2;
        if(x>0)pq.push(x);
        m--;
    }
    while(!pq.empty()){
        s+=pq.top();
        pq.pop();
    }
    cout<<s<<endl;
    return 0;
}



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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if ((a*100+b*10+c)%4==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val T = readLine()!!.split(" ").map(String::toInt)

    val PX = Array(readLine()!!.toInt()) { readLine()!!.split(" ").map(String::toInt) }.map {
        Pair(it[0], it[1])
    }

    PX.forEach {
        println(T.sum() - T[it.first - 1] + it.second)
    }

}



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

int main()
{
    int n, m;
    cin >> n >> m;
    int s[m], c[m];
    rep(i, m) cin >> s[i] >> c[i];

    int answer = -1;
    int first = 0;
    int end = 10;
    if (n == 2)
    {
        first = 10;
        end = 100;
    }
    if (n == 3)
    {
        first = 100;
        end = 1000;
    }

    for (int i = first; i < end; i++)
    {
        bool ok[m];
        int hikaku[n];
        int buf = i;
        rep(i, m)
        {
            ok[i] = false;
        }
        rep(i, n)
        {
            hikaku[n - i - 1] = buf % 10;
            if (buf > 1)
                buf /= 10;
        }

        rep(j, m)
        {

            if (hikaku[s[j] - 1] == c[j])
            {
                ok[j] = true;
            }
        }

        bool ans = true;
        rep(i, m) if (!ok[i]) ans = false;
        if (ans)
        {
            answer = i;
            break;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[20][5][2][10];

void print_debug(int a, int b, int c, int x, int y, int z, int val) {
    /*
    if(dp[x][y][z]) {
        printf("move: %lld, %lld, %lld <- %lld, %lld, %lld (value = %lld, digit = %lld)\n", a, b, c, x, y, z, dp[x][y][z], val);
    }
    */
}
 
signed main() {
    int init_val; cin >> init_val;
    string s = to_string(init_val);
    int N = s.length();

    dp[0][0][0][0] = 1;
    string pat = "51?3";
    for(int i=0; i<N; i++) {
        for(int k=0; k<4; k++) {
            for(int f=0; f<2; f++) {
                for(int y=0; y<10; y++) {
                    int lim = f ? 9 : s[i] - '0';
                    for(int x=0; x<lim+1; x++) {
                        bool is_match = (pat[k] == '?' || pat[k] - '0' == x);
                        if(is_match) {
                            if(k+1 != 4) {
                                dp[i+1][k+1][f || x<lim][x] += dp[i][k][f][y];
                                // print_debug(i+1, k+1, f||x<lim, i, k, f, x);
                            }
                        }
                        else {
                            int nidx;
                            if(k == 3 && y == 5 && x == 1) nidx = 2;
                            else nidx = (x == 5);
                            dp[i+1][nidx][f || x < lim][x] += dp[i][k][f][y];
                            // print_debug(i+1, 0, f||x<lim, i, k, f, x);
                        }
                    }
                }
            }
        }
    }

    int sum = -1;
    for(int i=0; i<4; i++) {
        for(int j=0; j<2; j++) {
            for(int k=0; k<10; k++) {
                sum += dp[N][i][j][k];
            }
            // printf("dp[%lld][%lld][%lld] = %lld\n", N, i, j, dp[N][i][j]);
        }
    }
    cout << init_val - sum << endl;
    return 0;
}


Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			int[] n = new int[5];
			for (int i = 0 ; i < 5 ; i++) n[i] = sc.nextInt();
			Arrays.sort(n);
			for (int i = 4 ; i > 0 ; i--) System.out.print(n[i]+" ");
			System.out.print(n[0]+"\n");
		}

	}
}

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

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  COMinit();
  for (int i = 1; i <= k; i++){
    ans = (COM(n - k + 1, i) * COM(k - 1, i - 1)) % MOD;
    cout << ans << endl;
  }
}

Measured memory_bytes: 12160
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int N, M;
	cin >> N >> M;
	int num = pow(2, M);
	//cout << num << endl;
	int time = M * 1900 + 100 * (N - M);
	int ans = num * time;
	cout << ans << endl;

//"Hiroakimm0415"
//4 * (1900 * 2 + 800) = 4 * (3800 + 800) = 4 * 4600 = 18400
	return 0;
}

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

int main() 
{
    int n;
    long long ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) 
    {
        int t; cin >> t;
        ans += t-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

main(){
  int in;
  double q, x, temp;

  while(1){
    scanf("%d", &in);
    if(in==-1) break;
    q=in;
    x=q/2.0;
    while(1){
      temp=x*x*x-q;
      if(-0.00001*q<temp && temp<0.00001*q) break;

      x=x-(temp/(3*x*x));
    }
    printf("%.6f\n", x);
  }
  return 0;
}

Measured memory_bytes: 0
def q3():
    from itertools import permutations
    N = int(input())
    P = [int(i) for i in input().split()]
    Q = [int(i) for i in input().split()]

    n_list = list(range(1, N+1))
    n_perm = permutations(n_list, N)
    p_i, q_i = 0, 0
    for i, p in enumerate(n_perm):
        if P == list(p):
            p_i = i
        if Q == list(p):
            q_i = i
    print(abs(p_i - q_i))


if __name__ == '__main__':
    q3()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) REP(i,(vec).size()) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;
ll f(ll n, ll x) {
    if (n == -1) {
        return 0;
    }
    return n / x + 1;
}

int main() {
    STARTUP;

    int A, B, C;
    cin >> A >> B >> C;

    YESNO(A + B == C || B + C == A || C + A == B, "Yes", "No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int a[3001];
long long int dp[3001];
int main(){
	long long int n,i,j;
	cin>>n;
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<=n;i++)
	for(j=1;j+i-1<=n;j++)
	dp[j]=max(a[j]-dp[j+1],a[j+i-1]-dp[j]);
	cout<<dp[1];
}

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

int main()
{
	int n; cin>>n; double dp[n+1][n+1]; double p[n+1];
	memset(dp,0,sizeof(dp));
	for (int i=1; i<=n; i++)
		cin>>p[i];
	dp[1][0] = 1 - p[1]; dp[1][1]=p[1];
	for (int i=2; i<=n; i++)
		for (int j=0; j<=i; j++)
			if(j!=0)
				dp[i][j] = dp[i-1][j]*(1-p[i]) + (dp[i-1][j-1]*p[i]);
			else
				dp[i][j] = dp[i-1][j]*(1-p[i]);
	double ans =0;
	for (int i=(n/2)+1; i<=n; i++)
		ans+=dp[n][i];
	cout<<fixed<<setprecision(15)<<ans<<endl;

}

Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define endl "\n"
#define debug(x) cout<<"AA Baju Smit------> "<<#x<<" -> "<<x<<endl
#define all(x) x.begin(),x.end()
#define mint map<int,int>
#define mod 1000003
#define ciN cin
////////////////////////////////////////////////////////////////
//Ha Moj Ha///
////////////////////////////////////////////////////////////////

void jabru() {
	ll n, d; ciN >> n >> d;
	ll ans = 0;
	d *= d;
	For(i, 0, n) {
		ll x, y; cin >> x >> y;
		ll j = x * x + y * y;
		if (j <= d)
			ans++;
	}
	cout << ans << endl;
}




////////////////////////////////////////////////////////////////
//Bas aabaju nai javanu///
////////////////////////////////////////////////////////////////

int main() {
	//int t; cin >> t;
	//while (t--)
	jabru();

	return 0;
}





///////////////////////////////////////////////////////////////////////////////////////////
//Kai baju bhai???


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int x, y;
	cin >> x >> y;
	
	if (abs(x) == abs(y))
	{
		if (x > 0 && y < 0)
			printf("1\n");
		else if (x < 0 && y > 0)
			printf("1\n");
		else
			printf("0\n");
	}
	else if (abs(x) < abs(y))
	{
		int ans = 0;
		if (x < 0)
			ans++;
		ans += abs(y) - abs(x);
		if (y < 0)
			ans++;
		printf("%d\n", ans);
	}
	else
	{
		int ans = 0;
		if (x > 0)
			ans++;
		ans += abs(x) - abs(y);
		if (y > 0)
			ans++;
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

struct edge{int to, cost;};

class Graph
{
public:
    int V;
    vector<vector<edge>> G;

    Graph(int V): V(V){
        G = vector<vector<edge>>(V, vector<edge>(0));
    }

    void add_edge(int from, int to, int cost){
        G[from].push_back(edge({to, cost}));
    }

    void add_edge2(int v1, int v2, int cost){
        add_edge(v1, v2, cost);
        add_edge(v2, v1, cost);
    }

    void dfs(int v, vector<bool> &used, int &s, vec &D){
        used[v] = true;
        s = (s + D[v]) % 26;
        REP(k, G[v].size()){
            if(!used[G[v][k].to]) dfs(G[v][k].to, used, s, D);
        }
    }

};

signed main(){

    string S; cin >> S;
    int M = S.size();
    vec D(M + 1);
    D[0] = (int)(S[0] - 'a');
    D[M] = (26 - (int)(S[M - 1] - 'a')) % 26;
    REP(i, M - 1) D[i + 1] = ((int)(S[i + 1] - S[i]) + 26) % 26;
    Graph G(M + 1);
    REP(i, M + 1) if(i < M - i) G.add_edge2(i, M - i, 0);

    int N; cin >> N;
    int L, R;
    REP(i, N){
        cin >> L >> R;
        G.add_edge2(L - 1, R, 0);
    }

    vector<bool> used(M + 1, false);
    bool ans = true;
    REP(i, M + 1){
        if(!used[i]){
            int s = 0;
            G.dfs(i, used, s, D);
            if(s) ans = false;
        }
    }
    ANS(ans);
    
    return 0;
}

Measured memory_bytes: 13056
#include <cstdio>
#include <algorithm>
using namespace std;

int n,sum[3][101],a[3][101];

int main()
{
    int i,j;

    scanf("%d",&n);

    for(i=1;i<=2;i++)
        for(j=1;j<=n;j++)
            scanf("%d",&a[i][j]);
    for(j=0;j<=n;j++)
        sum[0][j]=0;
    for(i=0;i<=2;i++)
        sum[i][0]=0;
    sum[1][1]=a[1][1];
    for(j=1;j<=n;j++)
        for(i=1;i<=2;i++)
            sum[i][j]=max(sum[i][j-1],sum[i-1][j])+a[i][j];

    printf("%d\n",sum[2][n]);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	int n,count=0;
	long h[101]={0},c[100]={0};
	while(cin>>n){
		if(n==0)break;
		for(int i=0;i<=n;++i)
			cin>>h[i];
		for(int i=0;i<=n;++i){
			int count=0;
			for(int j=0;j<=n;++j){
				if(i!=j){
					c[count]=h[j];
					++count;
				}
			}
			bool flag=true;
			for(int j=1;j<n;++j){
				if(c[1]-c[0]!=c[j]-c[j-1])flag=false;
			}
			if(c[1]<=c[0])flag=false;
			if(flag){
				cout<<h[i]<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

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

   int n,k; cin>>n>>k;
   vll v(n);
   ll sum=0;
   for(int i=0;i<n;i++){
    cin>>v[i];
    sum+=v[i];
   }
   //cout<<"Sum= "<<sum<<endl;
   double les=(double)sum/(4*k);

   //cout<<les<<endl;
   ll total=0;
   for(int i=0;i<n;i++){
    if(v[i]>=les) total++;
   }
   if(total<k) cout<<"No"<<endl;
   else cout<<"Yes"<<endl;
   End;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{int p, l, r;};
struct Node T[MAX];
int n;

/* ??????????????? */
void preParse(int u){
	if(u == NIL) return;
	printf(" %d",u);
	preParse(T[u].l);
	preParse(T[u].r);
}

/* ??????????????? */
void inParse(int u){
	if(u == NIL) return;
	inParse(T[u].l);
	printf(" %d",u);
	inParse(T[u].r);
}

/* ??????????????? */
void postParse(int u){
	if(u == NIL) return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d",u);
}

int main(){
	int i, v, l, r, root;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		T[i].p = NIL;
	}

	for(i=0;i<n;i++){
		scanf("%d %d %d",&v,&l,&r);
		T[v].l = l;
		T[v].r = r;
		if(l != NIL) T[l].p = v;
		if(r != NIL) T[r].p = v;
	}

	for(i=0;i<n;i++) if(T[i].p == NIL) root = i;

	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");

	return 0;
}

Measured memory_bytes: 2760
#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 N, M; cin >> N >> M;
    vector<P> ab(M);

    // 終わりの島を昇順にソートしたいので、firstがb
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        ab[i].first = b-1;
        ab[i].second = a-1;
    }

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

    int loc_m = 0, broke = 0;

    while (loc_m < M) {
        // 必ず壊す橋
        int breaking_bridge = ab[loc_m].first;
        loc_m += 1;
        // 取り除ける要望分loc_mを進む
        // secondがbreaking_bridge未満なら効果あり
        while (loc_m < M && ab[loc_m].second < breaking_bridge) {
            loc_m += 1;
        }
        broke += 1;
    }
    
    cout << broke << endl;

    return 0;
}

Measured memory_bytes: 1024
#候補
a = 1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049

n = gets.to_i
a = a.select{|i|i <= n}

map = []

map[0] = [0]

i = 1
while true
    temp = []
    a.each do |j|
        map[i-1].each do |k|
            temp << j + k if j + k <= n
            if j + k == n
                puts i
                exit
            end
        end
    end
    map[i] = temp.uniq
    i += 1
end


Measured memory_bytes: 47136
#include <stdio.h>

int main(){
  int n,i,c;
  long int a[500];

  for(i=0;i<500;i++)a[i]='\0';

  scanf("%d",&n);

  for(i=1;i<=n;i++)
    scanf("%ld",&a[i]);

  for(i=1;i<=n;i++){
    printf("node %d: key = %ld, ",i ,a[i]);
    if(i!=1)
      printf("parent key = %ld, ",a[i/2]);
 
    if(a[i*2] != '\0')
      printf("left key = %ld, ",a[i*2]);

    //c = i * 2 + 1;
    if(a[i*2+1] != '\0')printf("right key = %ld, ",a[i*2+1]);
    printf("\n");
  }
  
  return 0;
}



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

#define    ll    long long int

int main( )
{
    int n, T, t, i, c, ans = 1111;
    cin >> n >> T;
    for (i = 0; i < n; i++) {
        cin >> c >> t;
        if (t <= T) {
            ans = min(ans, c);
        }
    }
    if (ans == 1111) {
        cout << "TLE\n";
    }
    else {
        cout << ans << '\n';
    }
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true) {
			int cnt = 0;
			String[] line = br.readLine().split(" ");

			int n = Integer.parseInt(line[0]);
			int x = Integer.parseInt(line[1]);
			int[] set = new int[n];

			if (n == 0 && x == 0) {
				break;
			}

			for(int i = 0; i < n; i++) {
				set[i] = i + 1;
			}

			for(int j = 0; j < n; j++) {
				for(int k = j + 1; k < n; k++) {
					for (int l = k + 1; l < n; l++) {
						if(x == (set[j] + set[k] + set[l])) {
							cnt++;
						}
					}
				}
			}
			sb.append(cnt + "\n");
		}
		System.out.print(sb);
	}
}

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

using namespace std;

int main()
{
    int n,k;
    string s;

    cin>>n>>k;
    cin>>s;

    int i,j,m,y;
    m = 0;
    y = 0;
    if(s[0]=='0')
        y++;

    for(i=1,j=0;i!=s.length();i++)
    {
        if(s[i]=='0' && s[i-1]!='0')
            y++;

        if(y>k)
        {
            m = max(m,i-j);
            y=max(0,y-1);

            j++;
            while(!(s[j]=='1' && s[j-1]=='0'))
                j++;
        }
    }

    m = max(m,i-j);

    cout<<m;

    return 0;
}


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

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

	if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}

	return 0;
}


Measured memory_bytes: 3088
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#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 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)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    for(int i=1; i<=9; i++){
        if(N/i<10 && (N%i)==0){
            cout<<"Yes"<<endl;return;
        }
    }cout<<"No"<<endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

using namespace std;

const int maxn = 100010;

int n, a[maxn];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(a, a + n, greater<int>());
	int x = 0, y = 0;
	while (y+1 < a[x+1]) ++ x, ++ y;
	int len_u = a[x] - y;
	int len_r = 0; while (a[x + len_r] > y) ++ len_r;
	if ((!(len_r & 1)) || (!(len_u & 1))) puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n, k;
  cin >> n >> k;
  vecint v(n, 0);
  for (auto& e : v) cin >> e;
  int m = min(n, k);
  int ans = 0;
  for (int i = 0; i <= m; i++) {
    for (int j = 0; j <= m; j++) {
      if (i + j > n||i + j > k) break;
      priority_queue<int, vector<int>, greater<int>> q;
      int tmp = 0;
      for (int i2 = 0; i2 < i; i2++) {
        q.push(v[i2]);
        tmp += v[i2];
      }
      for (int j2 = 0; j2 < j; j2++) {
        q.push(v[n - 1 - j2]);
        tmp += v[n - 1 - j2];
      }
      REP(l, k - i - j) {
        if (q.empty() || q.top() >= 0) break;
        tmp -= q.top();
        q.pop();
      }
      ans = max(tmp, ans);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define rn return
#define fi first
#define se second
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int mainE(){
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N);
    vector<int> F(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> F[i];
    
    
    rn 0;
}

const double pi  =3.141592653589793238463;

int main(){
    double ans;
    double a,b,x;
    
    cin >> a >> b >> x;
    x = x/a;

    if (abs(x-(a*b)/2) < 1e-12){
        ans = atan(b/a)/pi*180;
        if (a==b){
            printf("%.11f", 45.0);
            rn 0;
        }
        printf("%.11f",ans);
    }
    else if(x - (a*b)/2 < -1*1e-12){
        ans = 90.0 - 180.0*atan(2*x/pow(b,2))/pi;
        printf("%.11f",ans);
    }
    else{
        ans = 180.0*atan(((b*a-x)*2.0)/(pow(a,2)))/pi;
        printf("%.11f",(ans));
    }
    
    rn 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int 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 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;

ll f(ll n){
    ll sum = 0;
    while(n>0){
        sum += n%10;
        n /= 10;
    }
    return sum;
}

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

    // input
    ll N;
    cin >> N;

    if(N % f(N) == 0){
        p_yes();
    }else{
        p_no();
    }

    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#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 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)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(std::vector<long long> x, std::vector<long long> y){
    int dx = x[1]-x[0];
    int dy = y[1]-y[0];
    cout<<x[1]-dy<<" "<<y[1]+dx <<" "<<x[0]-dy<<" "<<y[0]+dx<<endl;
    return;

}

int main(){
    std::vector<long long> x(2);
    std::vector<long long> y(2);
    for(int i = 0 ; i < 2 ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 256
day = str(input())
if day == "SAT":
	print("1")
elif day == "FRI":
	print("2")
elif day == "THU":
	print("3")
elif day == "WED":
	print("4")
elif day == "TUE":
	print("5")
elif day == "MON":
	print("6")
else:
	print("7")

Measured memory_bytes: 2940
#include <stdio.h>
int main()
{
int n,S[100000]={-1},q,t,a=0;
scanf("%d",&n);
int i;
for(i=0;i<n;i++)
scanf("%d",&S[i]);
scanf("%d",&q);
 
for(int i=0;i<q;i++){
scanf("%d",&t);
int left=0,right=n-1;
while(left<=right){
int mid=(left+right)/2;
if(t==S[mid]){
right=-1;
break;
}
else if(t>S[mid])
left=mid+1;
else
right=mid-1;
}
if(right==-1)
a++;
    }
printf("%d\n",a);
    
return 0;
}

Measured memory_bytes: 2184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i=0; i<(int)c; i++)
int main() {
	int n,m;
	cin >>n>>m;
//	vector<int>h(n+1);
	int h[n+1][2];
	for(int i=1;i<=n;i++){
		cin >> h[i][0];
		h[i][1]=1;
	}
	int a,b;
	rep(i,m){
		cin >>a>>b;
		if (h[a][0]<=h[b][0]) h[a][1]=0;
		if (h[a][0]>=h[b][0]) h[b][1]=0;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if (h[i][1]==1)ans++;
	}
	cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 4428
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
void fp(bool flag, string s, string t){
    if(flag)cout << s << endl;
    else cout << t << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl min = 1e13;
    for(intl i = 1; i * i <= n; i++){
        if(!(n % i)){
            min = min(min, i + (n / i) - 2);
        }
    }
    cout << min << endl;
    return 0;
}

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

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

    int X;
    cin >> X;

    cout << 1000 * (X / 500) + 5 * (X % 500 / 5) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k,ans,v[55];
int main(){
	cin >> n >> k;
	for(int i=0;i<n;i++)cin >> v[i];
	for(int i=0;i<n;i++)
		for(int j=i;j<=n;j++){
			if(i+n-j>min(n,k) )continue;
			int sum=0,x=k-(i+n-j);
			multiset<int> s;
			for(int p=0;p<i;p++){
				sum+=v[p];
				if(v[p]<0)s.insert(v[p]);
			}
			for(int p=j;p<n;p++){
				sum+=v[p];
				if(v[p]<0)s.insert(v[p]);
			}
			for(multiset<int>::iterator it=s.begin();it!=s.end() and (x--)>0;it++)
				sum-=*it;
			ans=max(ans,sum);
		}
	cout << ans;
    return 0;
}


Measured memory_bytes: 256
i = list(map(int,input().split()))
n = i[0]
m = i[1]
h_list = list(map(int,input().split()))
ans_list = [1 for i in range(n)]
for num in range(m):
    ab = list(map(int, input().split()))
    a = ab[0]-1
    b = ab[1]-1
    if h_list[a]>h_list[b]:
        ans_list[b] = 0
    elif h_list[a]<h_list[b]:
        ans_list[a] = 0
    else:
        ans_list[a] = 0
        ans_list[b] = 0
print(sum(ans_list))

Measured memory_bytes: 20124
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



int main(int argc, char* argv[])
{
    int K,X;
    scanf("%d%d", &K, &X);

    if(K*500>=X) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

long f(long a,long b){
	return a!=b ? (2 * b + f(b,a-b)) : a;
}


int main(){
	
	long N,X;
	cin>>N>>X;
	
	long sum = N;	
	long a,b;
	a = max(N-X,X);
	b = min(N-X,X);

	while(b > 0){
		sum += 2 * b * static_cast<long>(a/b);
		//if(b <= a)cerr<<"Error"<<endl;
		
		long tmp = a % b;

		if(tmp > b){
			a = tmp;
		}
		else{
			a = b;
			b = tmp;
		}
	//	cout<<"s "<<sum<<endl;
	//	cout<<a<<","<<b<<endl;
	}
	sum -= a;
	cout<<sum<<endl;
	return 0;

}



Measured memory_bytes: 256
#include<iostream>

bool rc(int);
bool board[64]{}, row[8]{}, column[8]{}, right_down[15]{}, left_down[15]{};

int main()
{
	int k, r, c;

	std::cin >> k;
	for (int i = 0; i < k; ++i)
	{
		std::cin >> r >> c;
		board[r * 8 + c] = true;
		row[r] = column[c] = true;
		right_down[7 + c - r] = left_down[r + c] = true;
	}

	rc(k);
	for (int i = 0; i < 64; ++i)
	{
		if (board[i])
			std::cout << 'Q';
		else
			std::cout << '.';
		if (i % 8 == 7)
			std::cout << std::endl;
	}

	return 0;
}

bool rc(int k)
{
	if (k == 8)
		return true;

	for (int i = 0; i < 8; ++i)
	{
		if (row[i]) continue;
		row[i] = true;
		for (int j = 0; j < 8; ++j)
		{
			if (column[j] || right_down[7 + j - i] || left_down[i + j])
				continue;
			column[j] = right_down[7 + j - i] = left_down[i + j] = true;
			board[i * 8 + j] = true;

			if (rc(k + 1))
				return true;

			column[j] = right_down[7 + j - i] = left_down[i + j] = false;
			board[i * 8 + j] = false;
		}
		row[i] = false;
		return false;
	}
}


Measured memory_bytes: 3088
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    bool flag = false;

    while (cin >> a >> b, a || b) {
        int ans = 0;

        if (flag)
            cout << endl;
        for ( ; a <= b; a++) {
            if (a % 4 == 0 && (a % 100 != 0 || a % 400 == 0)) {
                cout << a << endl;
                ans++;
            }
        }
        if (ans == 0)
            cout << "NA" << endl;
        flag = true;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long int
#define INF 1000000000000
#define MOD 1000000007
#define DEBUG(x) cerr<<'>'<<#x<<':'<<x<< endl
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3648
/*
* @Author: Nazrul Islam
* @Date:   2020-09-20 20:15:13
* @Last Modified by:   Nazrul Islam
* @Last Modified time: 2020-09-20 21:06:57
*/

#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll; 
typedef double dd;
typedef vector<int> vi;
typedef vector<char> vc;
typedef list<int> li;
typedef set<int> si;
typedef map<int,int> mp;
#define pb push_back
#define pf push_front
#define mk make_pair
#define sc scanf
#define pr printf
#define pi acos(-1.0)
#define endl '\n'
// char s[200009];
// char st[200009];
// int a[600][600];
// int b[29][10];
// int a[200009];
// int c[200009];
ll m = 1e9+7;
ll func(ll n, ll k) {
	// cn++;
	if(k == 0) return 1;
	ll p = func(n, k/2);
	if(k % 2 == 0) return ((p * p) % m);
	else return (((p*p)%m*n) %m);
}
void solve()
{
	ll n;
	cin >> n;
	// if(n == 0) cout << ""
	ll o = func(10, n) - 2*func(9, n) + func(8, n);
	o = o%m;
	o = (o+m)%m;
	cout << o << endl; 
}
int main()
{
	IO;
	int t; 
	t = 1;
	// cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3620
n,K = map(int,input().split())

x,y = [],[]
xx,yy = [],[]

for _ in range(n):
    X,Y = map(int,input().split())

    x.append(X)
    xx.append(X)
    y.append(Y)
    yy.append(Y)

xx.sort()
yy.sort()

ans = 10**20
for i in range(n):
    for j in range(i):
        lx,rx = xx[j],xx[i]

        num = [0 for _ in range(n+1)]
        for k in range(n):
            if lx <= x[k] <= rx:
                num[yy.index(y[k])+1] += 1

        for k in range(n):
            num[k+1] += num[k]

        for k in range(n):
            for l in range(k):
                ly,ry = yy[l],yy[k]

                if num[k+1] - num[l] >= K:
                    ans = min(ans, (rx-lx)*(ry-ly))

print(ans)


Measured memory_bytes: 46684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
#define pb push_back

int main()
{
    int tst=1;
	//scanf("%d",&tst);
    while(tst--)	
	{
		int k,i,j;
		cin >> k;
		string s;
		cin >> s;
		int l=s.size();
		if(l<=k)
		{
			cout << s << endl;
		}
		else
		{
			for(i=0;i<k;i++)
			{
				cout << s[i];
			}
			cout << "..." << endl;
		}
	}
    return 0;
}


Measured memory_bytes: 3640