akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if (u == NIL || k == u->key){
    return u;
  }
  if (k < u->key){
    return treeSearch(u->left, k);
  } else {
    return treeSearch(u->right, k);
  }
}

Node treeSuccessor(Node x){
  Node y;
  if (x->right != NIL){
    return treeMinimum(x->right);
  }
  y = x->parent;
  while (y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x!=NIL){
    y = x;
    if (z->key < x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if (y == NIL){
    root = z;
  } else if (z->key < y->key){
    y->left = z;
  } else {
    y->right = z;
  }

}

void inorder(Node u){
  if (u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if (u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

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

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll; 
typedef long double ld; 
typedef pair<int,int> p32;   
typedef pair<ll,ll> p64;  
typedef pair<double,double> pd; 
typedef pair<ld,ld> pld; 
typedef vector<int> v32;  
typedef vector<ll> v64;  
typedef vector<pd> vpd;   
typedef vector<p32> vp32;  
typedef vector<p64> vp64;  
typedef vector<v32> vv32;  
typedef vector<v64> vv64;  

#define pb push_back
#define mp make_pair
#define prarr(a,n) cerr<<#a<<" : ";for(ll i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define prmat(mat,row,col) cerr<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cerr<<mat[i][j]<<"\t";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }

#include <bits/extc++.h> /** keep-include */
using namespace __gnu_pbds;
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag,
        tree_order_statistics_node_update>;

const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
int mod=1000*1000*1000+7;  
// ----------------------------------------------------------------------------	-------------- 

void pre(){
}
bool cmp(p32 a, p32 b){
  return a.second < b.second; 
}
void solve(){
  int n; cin>>n; 
  vp32 rob(n);  
  for(int i=0;i<n;i++){
    int a,b; cin>>a>>b; 
    rob[i].first=a-b; 
    rob[i].second=a+b; 
  }
  sort(all(rob),cmp); 
  v32 dp(n,inf); 
  dp[0]=1; 
  for(int i=1;i<n;i++){
    dp[i]=dp[i-1]; 
    if(rob[0].second<=rob[i].first){
      int lo=0, hi=i;   
      while((hi-lo)>1){
        int mid=(lo+hi)>>1;  
        if(rob[mid].second <= rob[i].first){
          lo=mid;  
        }
        else{
          hi=mid; 
        }
      }
      dp[i]=max(dp[i],dp[lo]+1); 
    }
  }
  cout<<dp[n-1]<<endl; 
}



int main(){
	// clock_t beg=clock(); 
  fast_io; 
  int testcases=1; 
  pre(); 
  // cin>>testcases; 
  cout << fixed << setprecision(13); 
  while(testcases--){
    solve(); 	
  }
	// clock_t end=clock(); 
	// fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}


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

ll mod = 998244353;

ll modpower(ll a, ll r){ //a^r
    ll x = 1;
    a %= mod;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a){
    return modpower(a, mod-2);
}
vector<ll> fact;
vector<ll> invfact;

void set_fact(int n){
    fact.resize(n+1, 1);
    invfact.resize(n+1, 1);
    for (int i = 2; i <= n; i++) {
        fact[i] = fact[i-1] * i % mod;
    }
    invfact[n] = modinv(fact[n]);
    for (int i = n-1; i >= 2; i--) {
        invfact[i] = invfact[i+1] * (i+1) % mod;
    }
    return;
}


int main() {
    int N;
    cin >> N;
    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    vector<ll> A(N);
    for (int i = 0; i < N; i++) scanf("%lld", &A[i]);
    
    int M = 1000000;
    vector<int> table(M+1, 1);
    for (int i = 2; i <= M; i++) {
        if (table[i] != 1) continue;
        for (int j = i; j <= M; j += i) {
            table[j] = i;
        }
    }
    set_fact(M+1);
    
    vector<ll> msum(M+1, 0);
    for (int i = 0; i < N; i++) {
        ll t = A[i];
        vector<ll> divisor = {1};
        while (t > 1) {
            ll p = table[t];
            ll pcnt = 0;
            while (t%p == 0) {
                t /= p;
                pcnt++;
            }
            for (int j = (int)divisor.size()-1; j >= 0; j--) {
                ll u = divisor[j];
                for (int k = 0; k < pcnt; k++) {
                    u *= p;
                    divisor.push_back(u);
                }
            }
        }
        for (ll r : divisor) {
            msum[r] += A[i];
            msum[r] %= mod;
        }
    }
    
    vector<ll> B(M+1, 1);
    for (int i = 2; i <= M; i++) {
        B[i] = (invfact[i] * fact[i-1] + mod -B[i]) % mod;
        for (int j = i*2; j <= M; j+=i) B[j] += B[i];
    }
    
    ll ans = 0;
    for (int i = 1; i <= M; i++) {
        ans += msum[i] * msum[i] % mod * B[i] % mod;
        ans %= mod;
    }
    
    for (int i = 0; i < N; i++) ans += mod - A[i] % mod;
    ans %= mod;
    cout << ans * invfact[2] % mod << endl;
    return 0;
}

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

int main() {
    int N,K;
    cin>>N>>K;
    vector<int> p(N);
    for (int i = 0; i < N; i++){
        cin>>p[i];
    }
    sort(p.begin(),p.end());
    int ans=0;
    for (int i = 0; i < K; i++){
        ans+=p[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3656
n,a,b,*h=map(int,open(0).read().split());i,j=0,-(-max(h)*n//a)
while j-i>1:
 k=c=(j+i)//2
 for t in h:c+=min(0,(b*k-t)//(a-b))
 if c>=0:j=k
 else:i=k
print(j)

Measured memory_bytes: 71228
#include<stdio.h>
 
int main(void)
{
  int N,M,A[100],a,j=0;
  double c,sum=0;

  scanf("%d",&N);
  scanf("%d",&M);
  for(a=0;a<N;a++){
	scanf("%d",&A[a]);
	sum+=A[a];
}

  c=sum/(4*M);

  for(a=0;a<N;a++)
	if(c<=A[a])
		j++;

  if(M<=j)
    printf("Yes");
  else
    printf("No");
  
  return 0;
}

Measured memory_bytes: 1736
#include <stdio.h>

int M=1000000000+7;

int main(){
  int N;
  scanf("%d", &N);
  long long int S=1LL,T=2LL,U=1LL;
  for(int i=1;i<=N;i++){
    S*=8LL;
    T*=9LL;
    U*=10LL;
    S%=M;
    T%=M;
    U%=M;
  }
  S+=U;
  S%=M;
  S-=T;
  S%=M;
  if(S<0LL) S+=M;
  printf("%lld\n",S);
}

Measured memory_bytes: 1736
local mmi, mma = math.min, math.max
local n = io.read("*n", "*l")
local s = io.read()
local t = {}
for i = 1, n do
  t[i] = s:sub(i, i) == "W"
end
local left, right = {}, {}
do
  local c = 0
  for i = 1, n do
    if t[i] then c = c + 1 end
    left[i] = c
    right[i] = 0
  end
  c = 0
  for i = n, 1, -1 do
    if t[i] then c = c + 1 end
    right[i] = c
  end
end
local ret = mmi(n - right[1], left[n])
for i = 1, n - 1 do
  local need_red = left[i]
  local need_white = n - i - right[i + 1]
  ret = mmi(ret, mma(need_red, need_white))
end
print(ret)


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

using namespace std;

int main(void) {
    long n;
    cin >> n;

    vector<long> a(n), b(n);
    for(auto &x: a) cin >> x;
    for(auto &x: b) cin >> x;

    long sa = 0, sb = 0;
    for(auto &x: a) sa += x;
    for(auto &x: b) sb += x;

    long k = sb - sa;
    if(k < 0) {
        cout << "No" << endl;
        return 0;
    }

    long ka = k, kb = k;
    for(int i=0; i<n; i++) {
        if(a[i] < b[i]) {
            ka -= (b[i]-a[i] +1)/2;
            a[i] += (b[i]-a[i] + 1)/2*2;
        }
        if(a[i] > b[i]) {
            kb -= a[i] - b[i];
            b[i] += a[i] - b[i];
        }
    }
    if(ka < 0 || kb < 0) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

}


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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	int ans = 0;
	for (int i = 1; i <= 5; ++i) {
		int x;
		cin >> x;

		if (x == 0) {
			ans = i;
			break;
		}
	}

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


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>

std::string str,be,af;

long long res=1;

int main(){

    std::cin>>str;

    be=str[0];

    for(int i=1;i<str.size();i++){
        af+=str[i];
        if(be!=af){
            be=af;
            af="";
            res++;
        }
    }

    std::cout<<res<<std::endl;

    return 0;

}

Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
      cin >> A[i];
  }

  int count = 0;
  int break_flag = 0;
  while(true){
    for(int i = 0; i < N; ++i){
      if(A[i] % 2 != 0){
        ++break_flag;
      }else{
        A[i] = A[i] >> 1;
      }
    }
    if(break_flag >= 1){
      break;
    }else{
      ++count;
    }
  }

  cout << count << endl;
  return 0;
}


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

int main()
{
  int N;
  cin >> N;

  int A[N];

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

  vector<int> v;

  for (int i = 0; i < N; i++)
  {
    if (A[i] % 2 == 0)
    {
      v.push_back(A[i]);
    }
  }
  int cntDiv = 0;
  for (int i = 0; i < v.size(); i++)
  {
    while (true)
    {
      if (v[i] % 2 == 0)
      {
        cntDiv++;
      }
      else
      {
        break;
      }
      v[i] /= 2;
    }
  }
  cout << cntDiv;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int M = cin.nextInt();

        List<Tuple<long, long>> C = new List<Tuple<long, long>>();

        for (int i = 0; i < N; i++)
        {
            long a = cin.nextLong();
            C.Add(Tuple.Create(a, (long)1));
        }

        for (int i = 0; i < M; i++)
        {
            long b = cin.nextInt();
            long c = cin.nextLong();
            C.Add(Tuple.Create(c, b));
        }

        C.Sort((a, b) => (int)b.Item1 - (int)a.Item1);

        long ret = 0;
        long count = 0;
        for (int i = 0; i < C.Count(); i++)
        {
            count += C[i].Item2;
            ret += C[i].Item1 * C[i].Item2;
            if (count >= N)
            {
                ret -= C[i].Item1 * (count - N);
                break;
            }
        }

        Console.WriteLine(ret);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

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

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

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

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

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 33880
#include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;

const double EPS = 1e-9;

typedef complex<double> P;
struct L {
    P x, y;
    L() {};
    L(P a, P b) {x=a, y=b;};
};

namespace std {
    bool operator < (P a, P b) {
        return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
    }
}

double cross(P a, P b) { return imag(conj(a)*b); }
double dot(P a, P b) { return real(conj(a)*b); }

int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > 0) return 1;
    if (cross(b, c) < 0) return -1;
    if (dot(b, c) < 0) return 2;
    if (norm(b) < norm(c)) return -2;
    return 0;
}

bool insLL(L &l, L &m) {
    if (abs(cross(l.y-l.x, m.y-m.x)) > EPS) return true;
    if (abs(cross(l.y-l.x, m.y-l.x)) < EPS) return true;
    return false;
}

bool insLS(L &l, L &s) {
    double a = cross(l.y-l.x, s.x-l.x);
    double b = cross(l.y-l.x, s.y-l.x);
    if (a*b < EPS) return true;
    return false;
}

bool insSP(L &s, P &p) {
    return abs(s.x-p)+abs(s.y-p)+abs(s.y-s.x) < EPS;
}

bool insSS(L &s, L &t) {
    int a = ccw(s.x,s.y,t.x), b = ccw(s.x,s.y,t.y);
    int c = ccw(t.x,t.y,s.x), d = ccw(t.x,t.y,s.y);
    if (a*b <= 0 && c*d <= 0) return true;
    return false;
}

P crossp(L &l, L &m) {
    double A = cross(l.y-l.x, m.y-m.x);
    double B = cross(l.y-l.x, l.y-m.x);
    if (abs(A) < EPS && abs(B) < EPS) return m.x;
    return m.x+B/A*(m.y-m.x);
}

int main() {
    while (true) {
        L l1, l2, l3;
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if (!x1 && !y1 && !x2 && !y2) break;
        l1.x = P(x1, y1); l1.y = P(x2, y2);
        cin >> x1 >> y1 >> x2 >> y2;
        l2.x = P(x1, y1); l2.y = P(x2, y2);
        cin >> x1 >> y1 >> x2 >> y2;
        l3.x = P(x1, y1); l3.y = P(x2, y2);
        P p1 = crossp(l1, l2);
        P p2 = crossp(l2, l3);
        P p3 = crossp(l3, l1);
        double s = abs(cross(p2-p1, p3-p1))/2;
        if (!insSS(l1, l2) || !insSS(l2, l3) || !insSS(l3, l1)) s = 0;
        if (1900000 <= s) cout << "dai-kichi" << endl;
        else if (1000000 <= s) cout << "chu-kichi" << endl;
        else if (100000 <= s) cout << "kichi" << endl;
        else if (EPS <= s) cout << "syo-kichi" << endl;
        else cout << "kyo" << endl;
    }
}

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

int main(void) {
  string S;
  cin >> S;
  string ans = S.substr(0, 3);
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 3624
import sys
N, M, X, Y = map(int, input().split())
xlist = input().split() # string
ylist = input().split() # string

#intXlist = intYlist = []
intXlist = []
intYlist = []
for i in xlist:
    intXlist.append(int(i))
#intXlist.append(X)
for i in ylist:
    intYlist.append(int(i))
#intYlist.append(Y)

# print(max(intXlist))
# print(min(intYlist))

# mx = max(intXlist)
# my = min(intYlist)

# for z in range(X+1, Y+1):
#     return my <= mx:
#         print('No War')
#         sys.exit()
#     else:
#         continue
# print('War')


def judge(z):
    try:
        for i in xlist:
            i = int(i)
            if not i < z:
                return 0
            else:
                continue
        for j in ylist:
            j = int(j)
            if j < z:
                return 0
            else:
                if str(j) == ylist[-1]:
                    #print(z)
                    print('No War')
                    sys.exit()
    except Exception as e:
        print(e)
for z in range(X+1, Y+1):
    judge(z)
    if z == Y:
        print('War')

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int i,x,y,tmp;
    for (i =1; ;){
        scanf("%d %d", &x, &y);
        if ((x == 0) && (y == 0)){
            break;
        }
        if (x > y){
            tmp = x;
            x = y;
            y = tmp;
        }
        printf("%d %d\n", x, y);
    }
    return(0);
}

Measured memory_bytes: 600
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int q, h, s, d, min = 0;
	long long N, Q, H, S, D;
	scanf("%lld%lld%lld%lld%lld", &Q, &H, &S, &D, &N);
	min = Q * 4;
	if (H * 2 <= min) {
		min = H * 2;
	} 
	if (S <= min) {
		min = S;
	}
	if (min * 2 <= D) {
		printf("%lld", min * N);
		return 0;
	}
	else {
		if (N % 2 == 0) {
			printf("%lld", D * (N / 2));
			return 0;
		}
		else {
			printf("%lld",D * (N / 2) + min);
			return 0;
		}
	}
	return 0;
}

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

int main(void){
  int A, B, T, _A, ans = 0;
  cin >> A >> B >> T;
  int cnt = 1;
  while(1){
    _A = A * cnt;
    if(_A > T + 0.5)
      break;
    ans += B;
    cnt++;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3564
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    int n, k, q;
    cin >> n >> k >> q;
   vector<int> v(n, k - q);
   for (int i = 0; i < q; i++){
	    int x;
	    cin >> x;
	    x--;
	    v[x]++;
	  }
	for (int i = 0; i < n; i++){
	  if (v[i] <= 0) cout << "No" << endl;
	  else cout << "Yes" << endl;	
	}
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int a, b;
    cin >> a >> b;
    int h = 0;
    REP(i,b-a) h += i;
    cout << h - a << endl;
}

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

const int INF=1001001001;

int W,H,F,M,O;
int fld[15][15];

struct data{
    int y,x,s,o,f;
    data(int y,int x,int s,int o,int f)
        :y(y),x(x),s(s),o(o),f(f){}

    bool operator<(const data &d)const{
        return f>d.f;
    }
};

int dist[15][15][1<<10][50];

void solve(){
    fill_n(***dist,15*15*(1<<10)*50,INF);
    priority_queue<data>que;
    for(int i=0;i<W;i++){
        dist[0][i][1<<i][O]=0;
        que.push(data(0,i,1<<i,O,0));
    }

    while(que.size()){
        data d=que.top();que.pop();
        if(dist[d.y][d.x][d.s][d.o]<d.f)continue;
        if(d.o==0)continue;
        for(int i=-1;i<=1;i+=2){
            int ny=d.y,nx=d.x+i;
            if(nx<0||nx>=W)continue;
            int ns,no,nf;
            if(d.s>>nx&1){
                ns=d.s;no=d.o-1;nf=d.f;
            }
            else{
                ns=d.s|(1<<nx);
                no=min(M,d.o-1+(fld[ny][nx]>=0?fld[ny][nx]:0));
                nf=d.f+(fld[ny][nx]>=0?0:-fld[ny][nx]);
            }
            if(no<0)continue;
            if(dist[ny][nx][ns][no]<=nf)continue;
            dist[ny][nx][ns][no]=nf;
            que.push(data(ny,nx,ns,no,nf));
        }

        int ny=d.y+1,nx=d.x;
        if(ny>H)continue;
        int ns,no,nf;
        ns=1<<nx;
        no=min(M,d.o-1+(fld[ny][nx]>=0?fld[ny][nx]:0));
        nf=d.f+(fld[ny][nx]>=0?0:-fld[ny][nx]);
        if(no<0)continue;
        if(dist[ny][nx][ns][no]<=nf)continue;
        dist[ny][nx][ns][no]=nf;
        que.push(data(ny,nx,ns,no,nf));
    }

    int mi=INF;
    for(int j=0;j<W;j++){
        for(int o=0;o<=M;o++){
            mi=min(mi,dist[H][j][1<<j][o]);
        }
    }

    if(mi>F)cout<<"NA"<<endl;
    else cout<<mi<<endl;
}

int main(){
    while(cin>>W>>H,W||H){
        cin>>F>>M>>O;M--;O--;
        for(int i=1;i<=H;i++){
            for(int j=0;j<W;j++){
                cin>>fld[i][j];
            }
        }
        solve();
    }
    return 0;
}

Measured memory_bytes: 46328
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    
    if (a < b) 
    {
        if (a < c && c < b)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    else
    {
        if (b < c && c < a)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

#define mod 1000000007;

using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pr;

string s;

int main()
{
	cin >> s;

	if (s.size() % 2 == 0) 
		s = s.substr(0,s.size()-2);
	else 
		s = s.substr(0, s.size() - 1);
	

	while(1){
		string str1 = s.substr(0,s.size()-s.size()/2);
		string str2 = s.substr(s.size()/2,s.size()/2);
		if (str1 == str2) {
			break;
		}
		else {
			s = s.substr(0,s.size()-2);
		}
	}
	cout <<s.size()<< endl;
	return 0;
}

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


#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 10000007
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long 
#define mod  1000000007


int main()
{
	FAST;
	int n;
	cin >> n;
	ll a1 = 1, a2 = 2,  a3 = 1;
	for(int i = 1; i <= n; i ++){
		a1 *= 10;
		a2 *= 9;
		a3 *= 8;
		a1 %= mod;
		a2 %= mod;
		a3 %= mod;
		
	}
	cout << ((a1 - (a2 - a3)) + mod )  % mod;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
ll a;
void MAIN() {
	cin>>a;
	cout<<a+a*a+a*a*a;
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s, t = "CODEFESTIVAL2016";
  cin >> s;
  
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) != t.at(i)) ans++;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cctype>
#include <stack>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long lolo;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef unsigned long long ulolo;

const int maxn = (int)2e5 + 5;
const int INF = 0x3f3f3f3f;
const lolo inf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const int MOD = 1000000007;

template<class T>
inline void read(T &x) {
    x = 0; T flag = 1;char c;
    do { c = (char) getchar(); if (c == '-') break; } while (c < '0' || c > '9');
    if (c == '-') { c = '0', flag = -1;}
    do { x = x * 10 + c - '0';c = (char) getchar();} while (c >= '0' && c <= '9');
    x *= flag;
}
template<class T>
inline void out(T x) {
    if (x > 9) out(x / 10);
    x = x % 10;
    putchar('0' + x);
}

bool check(char *s, int b, int e) {
    for (int i = b, j = e; i < j; ++i, --j) {
        if (s[i] != s[j]) {
            return false;
        }
    }
    return true;
}
int main() {
//    freopen("../in.txt", "r", stdin);
    char str[100];
    scanf("%s", str);
    int len = strlen(str);
    bool flag = check(str, 0, len-1) && check(str, 0, (len-1)/2-1);
    printf("%s\n", flag?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
  int i,j,w,minj,tmp
    ;
  int *A;
  int n,count=0;


  scanf("%d",&n);

  A=(int *)malloc(n*sizeof(int));

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

  
  for(i=0; i<n; i++){
    minj = i;
    for(j=i+1; j<n; j++){
      if(A[j] < A[minj]){
	minj =j;
      }
    }

    if(A[i]>A[minj]){
	tmp=A[i];
	A[i]=A[minj];
	A[minj]=tmp;
	count++;
    }
      }
  
   for(w=0; w<n ; w++){

    if(w==n-1){
      printf("%d\n",A[w]);
      break;
    }
    
      printf("%d ",A[w]);
  
}


  printf("%d\n",count);
  
  return 0;
}



Measured memory_bytes: 2144
import sys
import bisect
input=sys.stdin.readline
n,q=map(int,input().split())
s=input()
ac=[]
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    ac.append(i+1)
for i in range(q):
  a,b=map(int,input().split())
  print(bisect.bisect_right(ac,b-1)-bisect.bisect_left(ac,a))

Measured memory_bytes: 6032
#include <cstdio>
#include <utility>
#include <bitset>
#include <iostream>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	bitset<64> f = 0;
	for (int q = in(); q; q--) {
		switch (in()) {
		case 0:
			outl((int) f.test(in()));
			break;
		case 1:
			f.set(in());
			break;
		case 2:
			f.reset(in());
			break;
		case 3:
			f.flip(in());
			break;
		case 4:
			outl((int) f.all());
			break;
		case 5:
			outl((int) f.any());
			break;
		case 6:
			outl((int) f.none());
			break;
		case 7:
			outl(f.count());
			break;
		case 8:
			outl(f.to_ulong());
			break;
		default:
			outl("error");
		}
	}
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int H,W;
cin >> H >> W;
vector<vector<char>> vec(H,vector<char>(W));

for (int i = 0;i < H;i++) {
    for (int j = 0;j < W;j++) {
        cin >> vec.at(i).at(j);
    }
}
for (int i = 0;i < W+2;i++) cout << '#';
cout << endl;
for (int i = 0;i < H;i++) {
    cout << '#';
    for (int j = 0;j < W;j++) cout << vec.at(i).at(j);
    cout << '#' << endl;
}
for (int i = 0;i < W+2;i++) cout << '#';
cout << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);
 
int main() {
  int a,b;
  cin >> a >> b;
  if(a > 8 | b > 8)
    cout << ":(" << endl;
  else 
    cout << "Yay!" << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int x, n;
    cin >> x >> n;

    if (n == 0) {
        cout << x << endl;
    } else {
        vector<int> p(n);
        for (int i = 0; i < n; i++) {
            cin >> p[i];
        }

        int closest, minAbs;
        minAbs = 1000;
        for (int i = 0; i <= 101; i++) {
            if (find(p.begin(), p.end(), i) == p.end()) {
                if (abs(x - i) < minAbs) {
                    closest = i;
                    minAbs = abs(x - i);
                }
            }
        }

        cout << closest << endl;
    }

    return 0;
}

Measured memory_bytes: 3568
def check(day):
	tmp = meet[day]
	for i in range(day,0,-1):
		if tmp & meet[i] != 0:
			tmp |= meet[i]
	return tmp == all_maps

while 1:
	n = int(raw_input())
	if n == 0:
		break
	all_maps = 2**n-1
	meet = [0 for i in range(31)]
	for i in range(n):
		freeday = map(int,raw_input().split(" "))
		for j in freeday[1:]:
			meet[j] += 1 << i
	for i in range(1,31):
		if check(i):
			print i
			break
	else:
		print -1
		

Measured memory_bytes: 4236
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] numbers = new int[n];
    for (int i = 0; i < n; i++) {
      numbers[i] = Integer.parseInt(sc.next());
    }
    if (n == 1) {
      pw.println(numbers[0]);
      return;
    }
    int secondMin = getSecondMin(numbers);
    for (int i = secondMin; i >= 1; i--) {
      int numOfIndivisible = 0;
      for (int number : numbers) {
        if (number % i != 0) {
          numOfIndivisible++;
        }
        if (numOfIndivisible > 1) {
          break;
        }
      }
      if (numOfIndivisible <= 1) {
        pw.println(i);
        return;
      }
    }
    throw new RuntimeException();
  }

  static int getSecondMin(int[] numbers) {
    int min = Integer.MAX_VALUE;
    int secondMin = Integer.MAX_VALUE;
    for (int i = 0; i < numbers.length; i++) {
      if (min > numbers[i]) {
        secondMin = min;
        min = numbers[i];
      } else if (secondMin > numbers[i]) {
        secondMin = numbers[i];
      }
    }
    return secondMin;
  }
}


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

int main() {
	int n, r;
	while( cin >> n >> r, n&&r ) {
		vector<int>N( n ), M, L;
		iota( N.begin(), N.end(), 1 );
		for( size_t i = 0; i < r; i++ ) {
			int a, b;
			cin >> a >> b;
			a--;
			for( size_t j = 0; j < a; j++ ) {
				M.push_back( *N.rbegin() );
				N.pop_back();
			}
			for( size_t j = 0; j < b; j++ ) {
				L.push_back( *N.rbegin() );
				N.pop_back();
			}
			for( size_t j = 0; j < a; j++ ) {
				N.push_back( *M.rbegin() );
				M.pop_back();
			}
			for( size_t j = 0; j < b; j++ ) {
				N.push_back( *L.rbegin() );
				L.pop_back();
			}
		}
		cout << *N.rbegin() << endl;
	}
}

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

int main(){
  int h, w;
  while(true){
    cin >> h >> w;
    if(h == 0 && w == 0) break;
    rep(i,h){
      rep(j,w){
        if((i+j) % 2 == 0) cout << '#';
        else cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if (A == C){
        cout << B << endl;
    }
    else if (A == B){
        cout << C << endl;
    }
    else {
        cout << A << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
a = 26
keta = 1
nn = 0
while n > 0:
    if n > a:
        keta += 1
        n -= a
        a *= 26
    else:
        nn = n - 1
        n -= a
#nnを桁数をketaとして26進法で表す
l = []
for i in range(keta):
    amari = nn % 26
    nn = nn // 26
    l.append(amari)
revl = []
for i in range(len(l)-1,-1,-1):
    revl.append(l[i]+97)
ansl = []
for i in revl:
    ansl.append(chr(i))
print("".join(ansl))


Measured memory_bytes: 9220
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
#define sz(x)       int(x.size())
//#define int         int64_t

using namespace std;

typedef pair<int, int> pii;
const int N = int(3e3) + 3;
const int mod = int(1e9) + 7;

int n, a[N];

ll dp(int l, int r, int addl, int addr) {
    if(l == r - 1) return 0;
    ll res = 1e18; int sum = addl + addr;
    for(int i = l + 1; i < r; ++i) {
        res = min(res, dp(l, i, addl, sum) + dp(i, r, sum, addr) + 1ll * a[i] * sum);
    }
    return res;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    cout << dp(1, n, 1, 1) + a[1] + a[n];
}


Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    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;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
// template<class T>
map<ll,int> prime(ll x){
    map<ll,int> e;
    rep(i,sqrt(x)+1){
        if(i <= 1)continue;
        while(x % i == 0){
            e[i]++;
            x /= i;
        }
    }
    if(x != 1)e[x]++;
    return e;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    auto mp = prime(n);
    ll ans = 0;
    for(auto it : mp){
        ll ok = 0;
        ll ng = 1e5;
        while(abs(ok - ng) > 1){
            ll mid = (ok + ng)/ 2;
            if((mid + 1) * mid / 2 <= it.second)ok = mid;
            else ng = mid;
        }
        ans += ok;
    }

    cout << ans << endl;
}

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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


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

int n, m, c;
int b[20];
int a[20][20];
int main() {
  cin >> n >> m >> c;
  for (int j = 0; j < m; ++j) cin >> b[j];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }
  
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int sum = 0;
    for (int j = 0; j < m; ++j) {
      sum += a[i][j] * b[j];
    }
    cnt += sum > -c;
  }
  cout << cnt << 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>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

int main() {
  int n, x;
  cin >> n >> x;
  int m;
  cin >> m;
  int ans = abs(m-x);
  rep(i,n-1) {
    cin >> m;
    ans = gcd(ans,abs(m-x));
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
a,b,k=map(int,input().split())

for i in range(k):
    if i%2==0:
        if a%2!=0:
            a-=1
        a//=2
        b+=a
    else:
        if b%2!=0:
            b-=1
        b//=2
        a+=b
print(a,b)


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

int main() {
  int X,Y,Z;
  cin >> X >> Y >> Z;
  
  int N = 0;
  while(1){
    if((Y * N + Z * (N + 1)) > X){
    	break;
    }
    N++;
  }

  cout << N - 1 << endl; 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
void slove(int question_num)
{
    while(question_num--)
    {
        double a,b,x,ans=0;cin>>a>>b>>x;
        x/=a;
        if(x>=(a*b)/2)
        {
            x=a*b-x;
            ans=atan((2*x)/(a*a));
            printf("%.10lf\n",ans*180/3.1415926535897932384626);
        }
        else
        {
            ans=atan((b*b)/(2*x));
            printf("%.10lf\n",ans*180/3.1415926535897932384626);
        }
    }
}
int main()
{
//    int t;cin>>t;
    slove(1);
    return 0;
}


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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

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

    cout << dp[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
import heapq
#N = int(input())
N, M = list(map(int,input().split()))
jobs = [[] for _ in range(M)]
#AB = [list(map(int,input().split())) for _ in range(N)]

for i in range(N):
    d, r = list(map(int, input().split()))
    if d-1 < M:
        jobs[d-1].append(-r)

#print(jobs)
ans = 0
heap = []

for i in range(M) :
    #print(jobs[:i])

    for hou in jobs[i] :
        heapq.heappush(heap, hou)
    if len(heap) > 0 :
        thou = heapq.heappop(heap)
        ans += -thou

print(ans)

# print(AB)
# AB = sorted(AB, key = lambda x : x[1], reverse=True)
# AB = sorted(AB, key = lambda x : x[0])
# print(AB)
# hou = 0
# nokori = M
#
# for i in range(N)  :
#     ab = AB[i]
#     if ab[0] <= nokori :
#         hou += ab[1]
#         nokori -= 1
# print(hou)


Measured memory_bytes: 23752
def digit_sum(n, s):
    if s > n:
        return -1
    if s == n:
        return n + 1

    b = 2
    while b**2 < n:
        if f(b, n) == s:
            return b

        b += 1

    p = int(n ** 0.5)
    while p >= 1:
        b = (n - s) // p + 1
        if b > 1 and f(b, n) == s:
            return b
        
        p -= 1

    return -1


def f(b, n):
    if n < b:
        return n

    return f(b, n // b) + (n % b)

def solve():
    n = int(input())
    s = int(input())
    result = digit_sum(n, s)
    print(result)

solve()


Measured memory_bytes: 3188
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
   string s;
   cin>>s;
   for(int i=0;i<s.length();i++)
   {
       if(s[i]!=',')
       cout<<s[i];
       if(s[i]==',')
       cout<<" ";
   }}

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

int main()
{
  string s;
  cin >> s;
  map<char, int> mp;
  rep(i, s.size()) mp[s[i]]++;
  char c;

  for(int i = 0; i < 26; i++) {
    c = 'a' + i;
    if(mp[c] == 0) {
      cout << c << endl;
      return 0;
    }
  }
  

  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;

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

  int cnt=0;
  for(int i=0;i<s.size()/2;i++){
    if(s[i] != s[s.size()-i-1]) cnt++;
  }

  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>
#include <queue>

using namespace std;

void solution() {
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

/*-------------------*/

int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);

    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif

/*
　　     　 　          ∧_,,∧　　　
    　            ♪　  (・ω・)　♪
               ＿＿＿＿○＿＿つヾ＿＿＿＿＿
             /δ⊆・⊇ 。/†: :† /δ ⊆・⊇｡ /|
            |￣￣￣￣￣￣￣￣￣￣￣￣￣ | |
            |　　　*/solution();/* 　　| |
            |　　　　　　　　　　　　　 |
*/

#ifdef Time
    double P2HxQ = clock();
    printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

Measured memory_bytes: 256