akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)


int main()
{
	int a,b;cin>>a>>b;
	if( a>=13) cout<<b<<endl;
	else if(a>=6) cout << b/2<<endl;
	else cout<<0<<endl;

	return 0;
}

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

ll num[sz];
ll cnt[sz];
set<ll>st;

set<ll>::iterator it;

int main()
{
    ll n,i,j,k,a,b,d,p,c,x,y;

    cin>>n;

    for(i=1; i<=n; i++)
    {
        cin>>num[i];
        cnt[num[i]]++;
        st.insert(num[i]);

    }
    ll s=0;


    for(it=st.begin(); it!=st.end(); it++)
    {
        a=*it;
        c=cnt[a];
        if(c>=2)
        {
            c--;
            x=(c*(c+1))/2;

            s+=x;


        }
    }


    for(i=1; i<=n; i++)
    {
        a=num[i];
        c=cnt[num[i]];
        if(c>=2)
        {
            c--;
            x=(c*(c+1))/2;
            ll cv=s-x;

            c--;
            ll tp=(c*(c+1))/2;

            cv+=tp;
            cout<<cv<<endl;

        }
        else
            cout<<s<<endl;
    }
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int>stone;
	for(int i = 0; i < n; i++){
		int ni; cin >> ni;
		stone.emplace_back(ni);
	}vector<int>d;
	d.resize(n);
	d[0] = 0;
	d[1] = abs(stone[1] - stone[0]);
	for(int i = 2; i < n; i++){
		d[i] = min(abs(stone[i] - stone[i - 1]) + d[i - 1],abs(stone[i] - stone[i - 2]) + d[i - 2]);
	}cout << d[n - 1] << "\n";
}

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

using namespace std;

#define endl "\n"
#define lln long long int
#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
    IOS;
    int a,b;
    cin >> a >> b;
    if(a >= 10 || b >= 10) cout <<  -1 << endl;
    else cout << a*b << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int c[3][3];
  REP(i, 3) {
    REP(j, 3) {
      cin >> c[i][j];
    }
  }

  bool ch = true;
  while(ch) {
    REP(i, 3) {
      REP(j, 3) {
        if(c[i][j] < 2) {
          ch = false;
        } 
      }
    }

    if(ch) {
      REP(i, 3) {
        REP(j, 3) {
          c[i][j] -= 2;
        }
      }
    }
  }

  vector<int> a(3);
  vector<int> b(3);
  a[0]=-1, a[1]=-1, a[2]=-1;
  b[0]=-1, b[1]=-1, b[2]=-1;

  bool br = false;
  
  REP(i, 3) {
    REP(j, 3) {
      if(c[i][j] == 0) {
        a[i] = 0;
        b[j] = 0;
        a[(i+1)%3] = c[(i+1)%3][j];
        a[(i+2)%3] = c[(i+2)%3][j];
        b[(j+1)%3] = c[i][(j+1)%3];
        b[(j+2)%3] = c[i][(j+2)%3];
        br = true;
        break;
      }
    }
    if(br) break;
  }

  //REP(i, 3) cout << a[i] << endl;
  //REP(i, 3) cout << b[i] << endl;

  if(a[0] != -1) {
    REP(i, 3) {
      REP(j, 3) {
        if(a[i] + b[j] != c[i][j]) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
    cout << "Yes" << endl;
    return 0;
  }
  
  vector<int> a2(3);
  vector<int> b2(3);
  a2[0]=-1, a2[1]=-1, a2[2]=-1;
  b2[0]=-1, b2[1]=-1, b2[2]=-1;

  REP(i, 3) {
    REP(j, 3) {
      if(c[i][j] == 1) {
        a[i] = 1;
        b[j] = 0;
        a[(i+1)%3] = c[(i+1)%3][j];
        a[(i+2)%3] = c[(i+2)%3][j];
        b[(j+1)%3] = c[i][(j+1)%3]-1;
        b[(j+2)%3] = c[i][(j+2)%3]-1;
        a2[i] = 0;
        b2[j] = 1;
        a2[(i+1)%3] = c[(i+1)%3][j]-1;
        a2[(i+2)%3] = c[(i+2)%3][j]-1;
        b2[(j+1)%3] = c[i][(j+1)%3];
        b2[(j+2)%3] = c[i][(j+2)%3];        
      }
    }
  }

  br = false;
  REP (i, 3) {
    REP(j, 3) {
      if(c[i][j] != a[i] + b[j]) {
        br = true;
        break;
      }
    }
    if(br) break;
  }

  if(!br) {
    cout << "Yes" << endl;
    return 0;
  }

  br = false;
  REP(i, 3) {
    REP(j, 3) {
      if(c[i][j] != a2[i] + b2[j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;

}


Measured memory_bytes: 256
#include <fstream>
//#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <unordered_map>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

const int SIZE = 1 << 17;

char buffer[SIZE];
int pointer = SIZE;

char Advance() {
    if (pointer == SIZE) {
        fread(buffer, 1, SIZE, stdin);
        pointer = 0;
    }
    return buffer[pointer++];
}

int Read() {
    int answer = 0;
    char ch = Advance();
    while (!isdigit(ch))
        ch = Advance();
    while (isdigit(ch)) {
        answer = answer * 10 + ch - '0';
        ch = Advance();
    }
    return answer;
}

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    int n, t;
    scanf("%d%d", &n, &t);
    int before = 0, answer = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        x++;
        if (x > before)
            answer += t;
        else
            answer += x + t - 1 - before;
        before = x + t - 1;
    }
    printf("%d\n", answer);
    return 0;
}


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

using namespace std;

int main() {
    string S;
    cin >> S;
    vector<int> A(26, 0);

    for (int i = 0; i < S.size(); ++i) {
        A[S[i] - 'a']++;
    }

    auto ans = "yes";
    for (int i = 0; i < A.size(); ++i) {
        if (A[i] > 1) ans = "no";
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;

/**
* 最大公約数をa,bから求める
* @param [in] a 正整数
* @param [in] b 正整数
* @return 最大公約数
*/
template<typename TypeInt>
TypeInt G_C_D(TypeInt a, TypeInt b)
{
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    while (b != 0) {
        a %= b;
        if (a == 0) return b;
        b %= a;
    }
    return a;
}
 
/**
* 最大公約数をa,b,...から求める
* @param [in] list 2つ以上の正整数
* @return 最大公約数
*/
template<typename TypeInt>
TypeInt G_C_D(const std::vector<TypeInt> &list)
{
    if (list.size() < 2)
        throw "内容が1以下\n";
 
    TypeInt a = list[0];
    for (size_t i = 1; i < list.size(); ++i) {
        a = G_C_D(a, list[i]);
    }
    return a;
}
/**
* 最小公約数をa,bから求める
* @param [in] a 正整数
* @param [in] b 正整数
* @return 最小公約数
*/
template<typename TypeInt>
TypeInt L_C_M(TypeInt a, TypeInt b) {
    if( a == 0 && b == 0)return 0;
    return a / G_C_D(a, b) * b;
}
 
/**
* 最小公約数をa,b,...から求める
* @param [in] list 2つ以上の正整数
* @return 最小公約数
*/
template<typename TypeInt>
TypeInt L_C_M(const std::vector<TypeInt> &list)
{
    if (list.size() < 2)
        throw "内容が1以下\n";
 
    TypeInt a = list[0];
    for (size_t i = 1; i < list.size(); ++i) {
        a = L_C_M(a, list[i]);
    }
    return a;
}

ll nd(ll a, ll b, long devider) {
	ll ret = 0;
	
	if (a == 0) {
		ret = b / devider;
	} else {
		ret = nd(0, b, devider) - nd(0, a, devider);
	}

	return ret;
}

int main(){
	ll a;
	ll b;
	long c;
	long d; 

	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;

	long lc = L_C_M(c, d);
	
	ll ret = (b - a + 1) - (nd(a-1, b, c) + nd(a-1, b, d) - nd(a-1, b, lc));

	cout << ret << endl;
	
	return 0;
}

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

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;

int a[100010] = {0};
int b[100010] = {0};

signed main(){
    
    int n;
    cin >> n;

    REP(i,n){
        int x;
        cin >> x;
        if(i%2){
            a[x]++;
        }else{
            b[x]++;
        }
    }

    int a1,a2,b1,b2;
    int A1,A2,B1,B2;
    a1 = a2 = b1 = b2 = 0;
    A1 = A2 = B1 = B2 = 0;
    REP(i,100009){
        if(a[i] >= a1){
            a2 = a1;
            a1 = a[i];
            A2 = A1;
            A1 = i;
        }else if(a[i] >= a2){
            a2 = a[i];
            A2 = i;
        }

        if(b[i] >= b1){
            b2 = b1;
            b1 = b[i];
            B2 = B1;
            B1 = i;
        }else if(b[i] >= b2){
            b2 = b[i];
            B2 = i;
        }

    } 

    if(A1 != B1){
        cout << n - a1 -b1 << endl;
    }else{
        cout << min(n - a1 -b2,n - a2 -b1) <<endl;
    }

    return 0;
}
//g++ -std=c++14 code1.cpp



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string> 
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	int ans[3] = {};
	rep(i, n)
	{
		int p;
		cin >> p;
		if (p <= a)ans[0]++;
		else if (p <= b)ans[1]++;
		else ans[2]++;
	}
	co(min(ans[0], min(ans[1], ans[2])));
	return 0;
}


Measured memory_bytes: 256
class GuideBook:
    def __init__(self):
        self.N = int(input())
        self.SP = []
        for i in range(self.N):
            s, p = input().split()
            self.SP.append([s, int(p), i])

    def main(self):
        tmp = sorted(self.SP, key=lambda x: x[1], reverse=True)
        result = sorted(tmp, key=lambda x: x[0])
        for x in result:
            print(x[2] + 1)


guideBook = GuideBook()
guideBook.main()


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    bool flg = 0;
	while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        if(flg == 1) cout << endl;
        char team[20][100] = {0};
        int ten[20] = {0};
        int score[20] = {0};
        for(int i = 0; i < n; i++){
            getchar();
            scanf("%s",team[i]);
            int a,b,c;
            cin >> a >> b >> c;
            ten[i] = 3 * a + c;
            score[i] = ten[i];
        }
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(ten[i] > ten[j]){
                    swap(ten[i],ten[j]);
                }
            }
        }
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(ten[i] == score[j]){
                    cout << team[j] << ',' <<  score[j] << endl;
                    score[j] = -1;
                }
            }
        }

        flg = 1;
	}
	return 0;
}

Measured memory_bytes: 1188
n,m = map(int,input().split())

ls = [0 for _ in range(n+1)]

ans = 0
pen = 0

for _ in range(m):
  p,s = input().split()
  p = int(p)
  
  if ls[p] == None:
    pass
  elif s == "WA":
    ls[p] += 1
  else:
    pen += ls[p]
    ls[p] = None
    ans +=1
print(ans,pen)

Measured memory_bytes: 3888
import sys

N = int(input())
W = [input() for _ in range(N)]

if len(W) != len(set(W)):
    print('No')
    sys.exit()

for i in range(1, N):
    if W[i-1][-1] != W[i][0]:
        print('No')
        sys.exit()

print('Yes')


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

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

  int x,y,a,b,c;

  std::cin >> x >> y >> a >> b >> c;

  int p[100000],q[100000],r[100000];
  for (int i = 0; i < a; ++i) {
    std::cin >> p[i];
  }
  for (int i = 0; i < b; ++i) {
    std::cin >> q[i];
  }
  for (int i = 0; i < c; ++i) {
    std::cin >> r[i];
  }

  std::sort(p, p + a, std::greater<int>());
  std::sort(q, q + b, std::greater<int>());

  int ret[300000];
  for (int j = 0; j < x; ++j) {
    ret[j] = p[j];
  }
  for (int j = 0; j < y; ++j) {
    ret[x + j] = q[j];
  }
  for (int j = 0; j < c; ++j) {
    ret[x + y + j] = r[j];
  }

  std::sort(ret, ret + x + y + c, std::greater<int>());

  std::cout << std::accumulate(ret, ret + x + y, 0ULL) << std::endl;

  return 0;
}


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

int main() {
  int N, K;
  int lengths[50];
  cin >> N >> K;
  for(int i=0; i<N; i++) {
    cin >> lengths[i];
  }
  
  sort(lengths, lengths+N, greater<int>());
  int sum = lengths[0];
  for(int i=1; i<K; i++) {
    sum += lengths[i];
  }
  
  cout << sum << endl;
}

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

int main() {
    int n;
    bool flag = false;
    cin >> n;
    rep(i, n / 7 + 1) {
        int temp = n - 7 * i;
        if(temp % 4 == 0) flag = true;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>

using namespace std;

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

struct edge {
    int to, cost;
    edge(int t, int c) : to(t), cost(c) { }
};

typedef pair<int, int> P;

int prim(int n, vector<vector<edge>> const& E ){
    vector<bool> used(n, false);

    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0, 0));

    int res = 0;
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (used[v]) { continue; }
        used[v] = true;
        res += max(0, p.first / 100 - 1);

        vector<edge> es = E[v];
        rep(i,es.size()){
            edge const& e = es[i];
            if (!used[e.to]){
                que.push(P(e.cost, e.to));
            }
        }
    }
    return res;
}

int main(){
    int n;
    while(cin >> n, n) {
        int m; cin >> m;
        vector<vector<edge> > E(n);
        rep(i,m){
            int a, b, c;
            scanf("%d,%d,%d", &a, &b, &c);
            E[a].push_back(edge(b, c));
            E[b].push_back(edge(a, c));
        }
        cout << prim(n,E) << endl;
    }
}

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

int main(){
  int n; scanf("%d", &n);
  deque<int> d;
  rep(i, n){
    int a; scanf("%d", &a);
    if(i & 1) d.push_front(a);
    else d.push_back(a);
  }
  if(n & 1){
    rep(i, n){
      printf("%d", d.back());
      d.pop_back();
      if(i < n-1) printf(" ");
    }
  }
  else{
    rep(i, n){
      printf("%d", d.front());
      d.pop_front();
      if(i < n-1) printf(" ");
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>

int main(void)
{
    int i,j,k,l;
    int count;
    int min,max;
	long sum=0;
    int a[10000];

    scanf("%d",&count);

    for(i=0;i<count;i++){
		if(i==0){
		    scanf("%d",&a[i]);
		}
		else{
		    scanf(" %d",&a[i]);
		}
    }

    /* 最小値を求める */
    min = a[0];

    for(j=1;j<count;j++){
        if(min > a[j]){
            min = a[j];
        }
    }

    /* 最大値を求める */
    max = a[0];

    for(k=1;k<count;k++){
        if(max < a[k]){
            max = a[k];
        }
    }

    /* 合計値 */
    for(l=0;l<count;l++){
        sum += a[l];
    }

    printf("%d %d %ld\n",min,max,sum);

    return 0;
}





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

const int _ = 5e5 + 7 , MOD = 998244353;
int jc[_] , inv[_] , N , M;

int poww(long long a , int b){
	int times = 1;
	while(b){if(b & 1) times = times * a % MOD; a = a * a % MOD; b >>= 1;}
	return times;
}

int C(int p , int q){return 1ll * jc[p] * inv[q] % MOD * inv[p - q] % MOD;}

int main(){
	cin >> N >> M; if(N < M) swap(N , M);
	jc[0] = 1; for(int i = 1 ; i <= N ; ++i) jc[i] = 1ll * jc[i - 1] * i % MOD;
	inv[N] = poww(jc[N] , MOD - 2);
	for(int i = N - 1 ; i >= 0 ; --i) inv[i] = inv[i + 1] * (i + 1ll) % MOD;
	int sum = 0;
	for(int i = 0 ; i <= M ; ++i)
		sum = (sum + (i & 1 ? -1ll : 1ll) * C(N , i) * C(M , i) % MOD * jc[i] % MOD * poww(M + 1 , N - i) % MOD * poww(N + 1 , M - i) % MOD + MOD) % MOD;
	cout << sum; return 0;
}

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

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main(){
    string S,T;
    cin >> S >> T;
    cout << T << S << endl;
}


Measured memory_bytes: 256
#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>;


// Nの約数を列挙する関数
vector<ll> enumDivisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i != 0) continue;
    res.push_back(i);
    if (i * i != n) res.push_back(n / i);
  }
  return res;
}

int main() {
  ll N;
  cin >> N;
  ll ans = 0;

  for (ll x: enumDivisor(N)) {
    if (x == 1) continue;
    ll tmp = N;
    while ( tmp % x == 0) tmp /= x;
    tmp %= x;
    if (tmp == 1) ans++;
  }
  
  ans += enumDivisor(N - 1).size() - 1;

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


Measured memory_bytes: 384
import Data.List

main = do
    s <- getLine
    print $ solve (next s)

next s = take n s
    where n = length s - 2

isss s = s1 == s2
    where (s1, s2) = splitAt (length s `div` 2) s

solve [] = -1
solve s | isss s = length s
        | otherwise = solve (next s)
    where n = length s

Measured memory_bytes: 892
#include <stdio.h>

int main(void){
  /*
  M: x + y = e
  N: x + y = e
  ------------
         x =ax
         y =ay
  */
  int   Mx,My,Me,Nx,Ny,Ne,y,e;
  double ax,ay;
  while(feof(stdin) == 0){
    scanf("%d %d %d %d %d %d\n",&Mx,&My,&Me,&Nx,&Ny,&Ne);
    y = My * Nx - Ny * Mx;
    e = Me * Nx - Ne * Mx;
    ay = (double)e / (double)y;
    ax = (Me - (My * ay)) / Mx;
    printf("%.3f %.3f\n",ax,ay);
  }
  return 0;
}

Measured memory_bytes: 644
import collections

num = int(input())
count = 0
ll = []
lr = []
for nn1 in range(1, num + 1):
  left = (str(nn1).lstrip('0')[0])
  right = (str(nn1)[-1])
  ll.append(left + '+' + right)
  lr.append(right + '+' + left)

c = collections.Counter(lr)

for i in range(num):
  count += int(c[ll[i]])

print(count)

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

string to_string(const string& s) { return '"' + s + '"'; }
string to_string(char c) { string s = "'"; s += c; return s + "'"; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) res += ", ";
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <typename A>
string to_string(A v) {
    bool first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
istream_iterator<string> eos;
void dbg_out(istream_iterator<string> it) { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(istream_iterator<string> it, Head H, Tail... T) {
    cerr << *it << " = " << to_string(H);
    if(++it != eos) cerr << ", ";
    dbg_out(it, T...);
}
#ifdef LOCAL
    #define dbg(...) { string _s = #__VA_ARGS__; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); dbg_out(_it, __VA_ARGS__); }
#else
    #define dbg(...)
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(v) ((int)(v).size())
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 1e9+7, nn = 2e5+5;

void solve(){
    int x, n;
    cin >> x >> n;
    set<int> s;

    fr(i, 0, n) {
        int y; cin >> y;
        s.insert(y);
    }
    int mn, ans, i = x;

    while(1){
        if(! s.count(i)) {
            mn = abs(x - i);
            ans = i;
            break;
        }
        i++;
    }
    i = x;
    while(1) {
        if(! s.count(i)) {
            if(abs(x - i) <= mn) {
                ans = i;
            }
            break;
        }
        i--;
    }
    cout << ans << nl;
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

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

int main()
{
    ll N;
    cin >> N;
    ll answer = 1e12 + 1;
    for (ll i = 1; i * i <= N; i++){
        if(N % i == 0){
            answer = min(answer, i - 1 + (N / i) - 1);
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
s = str(input())
l = len(s)

counter = 0
prev = None
pivot = 0

while pivot < l:
    n = 1
    if prev == s[pivot]:
        if pivot + 1 < l:
            if pivot + 2 < l:
                prev = s[pivot + 2]
                counter += 2
                pivot += 3
            else:
                counter += 1
                break
        else:
            break
    else:
        counter += 1
        prev = s[pivot]
        pivot += n

print(int(counter))

Measured memory_bytes: 3500
// header {{{
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    26
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
#define INF         1000000005

typedef long long ll;
typedef unsigned long long ull;
// }}}

int main() {
    ll N, A;cin >> N >> A;
    int size = 50*50*2;
    ll dp[N+1][size];
    for(int i=0;i<size;i++){
        dp[0][i] = 0;
    }
    for(int i=1;i<N+1;i++){
        ll x;cin >> x;
        x -= A;
        for(int j=0;j<size;j++){
            dp[i][j] = dp[i-1][j];
        }
        dp[i][50*50 + x]++;
        for(int j=0;j<size;j++){
            if(dp[i-1][j] > 0){
                dp[i][j+x] += dp[i-1][j];
            }
        }
    }
    printf("%lld\n", dp[N][50*50]);
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int l[n];
    for (int i=0;i<n;i++) {
        cin >> l[i];
    }
    sort(l,l+n);
    int cnt = 0;
    for (int i=0;i<n-2;i++) {
        for (int j=i+1;j<n-1;j++) {
            for (int k=j+1;k<n;k++) {
                if (l[k] < l[i] + l[j])
                    cnt++;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        string S = cin.next();

        int[] now = new int[2];
        int[] min = new int[2];

        int[] odd = new int[2];
        int[] even = new int[2];

        for (int i = 0; i < S.Length; i++)
        {
            for (int j = 0; j < 2; j++)
            {
                if (S[i] == (char)('0' + j)) now[j]++;
                else now[j]--;
                min[j] = Math.Min(now[j], min[j]);
                int max = now[j] - min[j];

                if(i % 2 == 1) odd[j] = Math.Max(odd[j], max);
                else even[j] = Math.Max(even[j], max);
            }
        }

        int[] ans = new int[2];

        for (int j = 0; j < 2; j++)
        {
            if (odd[j] == even[j]) ans[j] = odd[j] + 1;
            else ans[j] = Math.Max(odd[j], even[j]);
        }

        Console.WriteLine(Math.Max(ans[0], ans[1]));
    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 29808
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long K = sc.nextLong();
		if(A > K){
			A = A - K;
			K = 0;
		}else{
			K = K - A;
			A = 0;
		}
		if(B > K){
			B = B - K;
		}else{
			B = 0;
		}
		System.out.println(A+" "+B);
	}
}


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

struct edge{
    int node;
    edge *next;
}nodes[105];

int n,matrix[105][105];

int main()
{
    memset(matrix,0,sizeof(matrix));
    cin>>n;
    int i,j;
    for(i=1;i<=n;i++){
        int ii,n_i;
        cin>>ii>>n_i;
        for(j=0;j<n_i;j++){
            int jj;
            cin>>jj;
            matrix[ii][jj]=1;
        }
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            if(j!=1)cout<<" ";
            cout<<matrix[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    ll sum = 0;
    REP(i, N) {
        cin >> a[i];
        sum += a[i];
    }
    ll ans = INF, tmp = 0;
    REP(i, N-1){
        tmp += a[i];
        //cout << tmp << endl;
        ans = min(ans, abs(sum - 2 * tmp)); 
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 100055;
const int MX = 500055;

struct BIT {
	int d[MX];
	void init() { fill(d, d+MX, 0); }
	void upd(int x, int r) {
		for(x += MAXN; x < MX; x += rb(x))
			d[x] += r;
	}
	int get(int x) {
		int r = 0; for(x += MAXN; x; x -= rb(x))
			r += d[x];
		return r;
	}
} bit;

vector<int> XV;
int A[MAXN], B[MAXN];

int N;

ll f(int X) {
	for(int i = 1; i <= N; i++)
		B[i] = (A[i] <= X ? 1 : 0);
	for(int i = 1; i <= N; i++) B[i] += B[i-1];

	ll ret = 0;
	bit.init(); bit.upd(0, 1);
	for(int i = 1; i <= N; i++) {
		ret += bit.get(B[i]*2 - i - 1);
		bit.upd(B[i]*2 - i, 1);
	}
	return ret;
}

int getAns() {
	int s = 0, e = sz(XV)-1; for(int m; s < e;) {
		m = (s+e) >> 1;
		if(f(XV[m]) <= ll(N) * (N+1) / 4) s = m+1;
		else e = m;
	}
	return XV[s];
}

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 1; i <= N; i++) {
		cin >> A[i];
		XV.eb(A[i]);
	}
	sorv(XV); univ(XV);

	cout << getAns() << endl;

	return 0;
}

Measured memory_bytes: 3576
#include<algorithm>
#include<cassert>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T &a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

lint solve(void){
    string s, t;
    cin >> s >> t;

    vector< vector<int> > v(26);
    rep(i, s.size()){
        v[s[i] - 'a'].emplace_back(i);
    }

    lint res = 0;
    int pos = -1;
    lint n = s.size();
    rep(i, t.size()){
        if(v[t[i] - 'a'].empty()){
            return -1LL;
        }
        auto it = upper_bound(v[t[i] - 'a'].begin(), v[t[i] - 'a'].end(), pos);
        if(it == v[t[i] - 'a'].end()){
            it = v[t[i] - 'a'].begin();
        }
        if(pos < *it){
            res += (lint)(*it - pos);
        }else{
            res += (lint)(*it);
            res += (lint)(n - pos);
        }
        pos = *it;
    }

    return res;
}

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

    lint ans = solve();
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n)
using namespace std;
int main()
{
	MaRiaMa;
	set<int> p;
	int n;
	cin >> n;
	if (n == 1 || n == 2 || n == 3)
		cout << "1";
	else
	{
		for (int i = 2; i < n; i++)
		{
			int k = 2;
			while (1)
			{
				int u = pow(i, k);
				if (u > n)
				{
					break;
				}
				p.emplace(u);
				k++;
			}
		}
		auto it = p.rbegin();
		cout << *it;
	}
	/*   */	
}

Measured memory_bytes: 4072
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#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 SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;
#define PI 3.14159265359



int main(){
    int n,m;
    cin >> n >> m;
    map<int,int> added;
    vector<vector<int>> g(n,vector<int> ());
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    
    queue<int> q;
    q.push(0);
    while(q.size()){
        int sz = q.size();
        for(int i = 0; i < sz; i++){
            int cur = q.front();
            q.pop();
            for(auto ne: g[cur]){
                if (added.find(ne) == added.end() && ne != 0){
                    added[ne] = cur + 1;
                    q.push(ne);
                }
            }
        }
    }
    if (added.size() != n-1) cout << "No";
    else{
        cout << "Yes" << endl;
        for(int i = 1; i < n; i++){
            cout << added[i] << endl;
        }
    }
}
















Measured memory_bytes: 14288
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>

typedef long long ll;

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int ans=6;
    cout << ans - a - b;
}


Measured memory_bytes: 256
def main():

    N = int(input())
    d = dict()
    for v in ['AC', 'WA', 'TLE', 'RE']:
        d[v] = 0
    for _ in range(N):
        S = input()
        d[S] += 1

    for v in ['AC', 'WA', 'TLE', 'RE']:
        print(v + " x " + str(d[v]))

if __name__ == '__main__':
    main()


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

int main() {
  long long int a,b,x;
  cin>>a>>b>>x;
  if(a/x==b/x){
    if(a%x==0){
      cout<<1<<endl;
      return 0;
    }
    cout<<0<<endl;
    return 0;
  }
  if(a%x==0){
    cout<<b/x-a/x+1<<endl;
    return 0;
  }
  cout<<b/x-a/x<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	int N, X;
	cin >> N >> X;
	vector<int>a(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	a[N] = X;
	sort(a.begin(),a.end());
	int b[N + 10];
	for (int i = 0; i < N; i++) {
		b[i] = a[i + 1] - a[i];
	}
	int ans = b[0];
	for (int i = 0; i < N; i++) {
		ans = gcd(ans, b[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int S = sc.nextInt();
		int left = S/100 ;
		int right = S%100 ;

		boolean YYMM  = false ;
		boolean MMYY = false ;

		//YYMM
		{
			if(1 <= right && right <= 12) {
				YYMM = true ;
			}
		}

		//MMYY
		{
			if(1 <= left && left <= 12) {
				MMYY = true ;
			}
		}


		// 出力
		if(YYMM && MMYY) {
			System.out.println("AMBIGUOUS");
		}else 	if(YYMM && !MMYY) {
			System.out.println("YYMM");
		}else 	if(!YYMM && MMYY) {
			System.out.println("MMYY");
		}else {
			System.out.println("NA");
		}

	}

}


Measured memory_bytes: 22868
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		long A = Long.parseLong(Ws[0]);
		long B = Long.parseLong(Ws[1]);
		long C = Long.parseLong(Ws[2]);
		long X = Long.parseLong(Ws[3]);
		long Y = Long.parseLong(Ws[4]);

		//Cを利用しない場合の金額
		long ans = A*X+B*Y;

		//Cを利用する枚数を全探索
		int i=0;
		for(;i<=Math.max(X,Y);i++){
			ans=Math.min(ans, Math.max(0,X-i)*A+Math.max(0,Y-i)*B+C*i*2);
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 22484
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,p,odd=0,even=0,a,i,ans;
    cin >> n >> p;
    for(i=0;i<n;i++){
        cin >> a;
        if(a%2) odd++; else even++;
    }
    long long int ans1=1,ans2=1;
    for(i=0;i<odd-1;i++) ans1*=2;
    for(i=0;i<even;i++) ans2*=2;
    if(odd==0&&p==1) ans1=0;
    cout << ans1*ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

struct RSQ{
    int n;
    vector<int> dat;
    RSQ() {}
    RSQ(int n_) {
        n = 1;
        while(n < n_) n *= 2;
        dat.resize(2 * n - 1, 0);
        // rep(i, 0, 2 * n - 1) dat[i] = MAX;
    }
    void add(int k, int a){
        k += n - 1;
        dat[k] += a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = dat[2 * k + 1] + dat[2 * k + 2];
        }
    }
    //sum[a, b)
    int query(int a, int b){
        return query(a, b, 0, 0, n);
    }
    int query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return dat[k];
        int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return vl + vr;
    }
};

signed main(){
    int n, q;
    cin >> n >> q;
    RSQ r(n);
    rep(i, 0, q){
        int c, x, y;
        cin >> c >> x >> y;
        x--;
        if(c == 0){
            r.add(x, y);
        }else{
            cout << r.query(x, y) << endl;
        }
    }
}

Measured memory_bytes: 4896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  cout << N*N*N << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////
//Nチームで総当たり戦を行う。各チーム戦う相手の順番が決まっているものとする
//各チーム1日で１試合しか行えない。異なるチームは同日に並行して試合を行える
//総当たり戦を完了するまでに必要な最小日数は何日か
//試合が行えるものからどんどん行えばよい日数の効率的な数え方を考える
//愚直に全チーム見て試合できそうなところを貪欲に行うとすると間に合わない
//そこで２日目以降は前日に試合の実施状況に変化があった人のみ次の試合が可能か判定する
int N;
deque<int>A[1010];//両端キュー
int step[1010];//step[i]>numだったらその日iチームは試合を行えない
int M;
int main() {
	int i, j, k, l, r, x, y; string s;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N - 1; ++j) {
			cin >> x;
			A[i].push_back(x - 1);
		}
	}
	M = N * (N - 1) / 2;
	queue<int>Q;
	for (int i = 0; i < N; ++i)Q.push(i);
	int num = 0;
	while (Q.size()) {
		//このループ一回ごとに一日で行える試合を処理していく
		int ok = 0;
		queue<int>Q2;
		while (Q.size()) {
			i = Q.front();
			Q.pop();
			if (step[i] <= num && A[i].size() && A[A[i].front()].front() == i && step[A[i].front()] <= num) {
				step[i] = step[A[i].front()] = num + 1;
				Q2.push(i);
				Q2.push(A[i].front());
				A[A[i].front()].pop_front();
				A[i].pop_front();
				M--;
			}
		}
		num++;//日数カウント
		if (M == 0)break;//全試合終了
		swap(Q, Q2);
	}
	if (M)cout << -1 << endl;
	else cout << num << endl;
	return 0;
}

Measured memory_bytes: 4736
#include <random>    //ランダム
#include <algorithm> //アルゴリズム
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <iterator>
#include <cstdlib>
#include <fstream>
#include <cmath>
#include <cstring>
#include <string>
#include <sstream>
#include <cassert>
#include <cfloat>
#include <numeric>
#include <climits>
#include <stdint.h>
#include <ctime>
using namespace std;
// vector<int> temple(7,0);
    // for(int i=0; i<temple.size(); i++){
    
    // }
    // int maxtemp=*max_element(temple.begin(), temple.end());;
    // int mintemp=*min_element(temple.begin(), temple.end());;
    // int answer=0;
    // for(int i=0; i<temple.size(); i++){
    //     if(temple[i]==maxtemp||temple[i]==mintemp){
            
    //     }else{
    //         answer+=temple[i];
    //     }
    // }
    // answer/=5;
    // cout << answer << std::endl;
    // void ifmagic(int select, int depth, int kaisuu, int red, int green, int blue, int& answer){
    //     if(depth!=0){
    //         if(select==1){
    //             red*=2;
    //         }else if(select==2){
    //             green*=2;
    //         }else{
    //             blue*=2;
    //         }
    //     }
    //     if(depth>kaisuu){
    //         return;
    //     }else if(depth==kaisuu){
    //     if(green>red&blue>green){
    //         answer=1;
    //         return;
    //     }else{
    //         return;
    //     }        
    //     }
    //     // cout<<"depth="<<depth<<endl;
    //     // cout<<"red=="<<red<<endl;
    //     // cout<<"green=="<<green<<endl;
    //     // cout<<"blue=="<<blue<<endl;
    //     for(int i=1; i<4; i++){
    //         ifmagic(i,depth+1,kaisuu,red,green,blue,answer);
    //     }
    //     return;
    // }
int main()
{
    int kazu, D;
    cin >> kazu >> D ;
    vector<unsigned long> xz(kazu);
    vector<unsigned long> yz(kazu);
    for(unsigned int i=0; i<kazu; i++){
        cin >> xz[i] >> yz[i];
    }
    int answer=0;
    for(unsigned int i=0; i<kazu; i++){
        unsigned long xz2=xz[i]*xz[i];
        unsigned long yz2=yz[i]*yz[i];
        if(sqrt(xz2+yz2)<=D){
            answer++;
        }
    }
    cout<< answer <<endl;
    
}


Measured memory_bytes: 6488
#include <bits/stdc++.h>
#define ll int
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
 



int main()
{
    fastio
    ll i,j;
    
    ll x[5];
    cin>>x[0]>>x[1]>>x[2]>>x[3]>>x[4];
    
    sort(x,x+4);
    ll s=0;
    for(i=0;i<5;i++)
    s+=x[i];
    
    cout<<15-s;
}


Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
  for ( int i = g; i < n; i++ ) {
    int v = A[i];
    int j = i - g;
    while( j >= 0 && A[j] > v ) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n) {

  for ( int h = 1; ; ) {
    if ( h > n ) break;
    G.push_back(h);
    h = 3*h + 1;
  }

  for ( int i = G.size()-1; i >= 0; i-- ) {
    insertionSort(A, n, G[i]);
  }
}

int main() {
  cin >> n;

  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);

  cout << G.size() << endl;
  for ( int i = G.size() - 1; i  >= 0; i-- ) {
    printf("%d", G[i]);
    if ( i ) printf(" ");
  }
  printf("\n");
  printf("%d\n", cnt);
  for ( int i = 0; i < n; i++ ) printf("%d\n", A[i]);

  return 0;
}


Measured memory_bytes: 7140