akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9 + 7;
pair<ll, ll>s4[4] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}};
pair<ll, ll>s8[8] = {{ -1, -1}, { -1, 0}, { -1, 1}, {0, -1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}};

void judge() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve() {
    ll n;
    cin >> n;
    ll k = n;
    vector<int>v;
    int count = 0;
    while (n % 2 == 0) {
        n /= 2;
        count++;
    }
    v.pb(count);
    for (int i = 3; i <= sqrt(n); i += 2) {
        count = 0;
        while (n % i == 0) {
            count ++;
            n /= i;
        }
        v.pb(count);
    }
    if (n > 2)
        v.pb(1);

    ll ans = 0;
    for (int i = 0; i < v.size(); i++) {
        ans += (sqrt(1. + 8 * v[i]) - 1) / 2;
        //cout << ans << " ";
    }
    cout << ans << nl;

}

signed main() {
    judge();
    boost;
    solve();
}


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

bool s[3002];

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

  int R, G, B, N;
  cin >> R >> G >> B >> N;
  for (int i = 0; i * B <= N; ++i) {
    s[i * B] = true;
  }

  int res = 0;
  for (int i = 0; i * R <= N; ++i) {
    for (int j = 0; i * R + j * G <= N; ++j) {
      res += s[N - i * R - j * G];
    }
  }

  cout << res << '\n';
}


Measured memory_bytes: 256
#include <bitset>
#include <cstdio>
const int N = 2050;
std::bitset<N * N / 2> B;
int A[N];
int main() {
  int sum = 0;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &A[i]);
    sum += A[i];
  }
  int ans = sum;
  sum = (sum + 1) / 2;
  B.reset();
  B.set(0);
  for (int i = 0; i < n; ++i) {
    for (int j = sum - 1; j >= sum - A[i] && j >= 0; --j)
      if (B.test(j)) ans = std::min(ans, j + A[i]);
    B |= B << A[i];
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) { cout << x << " "; print(args...);}
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

template<typename T> 
struct SegmentTree {
  private:
    using F = function<T(T,T)>;
    const F f;
    const T DD; // e
    int n;
    vector<T> dat;
  public:
    SegmentTree(int n_, const F func, T dd):f(func),DD(dd){ init(n_);}
    void init(int n_) {
      n = 1; while(n < n_) n *= 2;
      dat.clear();
      dat.resize(2*n-1, DD);
    }
    void build(int n_, vector<T> v) {
      assert(n_ <= n);
      for(int i=0;i<n_;++i) dat[i+n-1] = v[i];
      for(int i=n-2;i>=0;--i) dat[i] = f(dat[2*i+1], dat[2*i+2]);
    }
    void set_val(int i, T x){
      assert(i < n);
      i += n-1;
      dat[i] = x;
      while (i > 0) {    
        i = (i-1)/2;  //child->parent
        dat[i] = f(dat[i*2+1], dat[i*2+2]);
      }   
    } 
    T query(int a, int b, int k, int l, int r) { 
      if (r<=a||b<=l) return DD;
      else if (a<=l&&r<=b) return dat[k];
      else {
        T vl = query(a,b,k*2+1,l,(l+r)/2);
        T vr = query(a,b,k*2+2,(l+r)/2,r);
        return f(vl, vr);
      }
    }
    T query(int a, int b) { //[a,b)
      assert(a < n);
      assert(b <= n);
      return query(a,b,0,0,n);
    }
};

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<int> h(n);
  vector<ll> a(n);
  rep(i,n) cin >> h[i];
  rep(i,n) cin >> a[i];
  auto f = [](ll a, ll b){ return max(a,b);}; 
  SegmentTree<ll> dp(n+1, f, 0);
  rep(i,n) {
    ll smax = dp.query(0, h[i]); //[0,h_i)のmax
    dp.set_val(h[i], smax + a[i]);
  }
  ll ans = dp.query(0, n+1); //[0,n+1)のmax
  cout << ans << endl;
  return 0;
}

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

int main(){
  char c;
  cin >> c;
  if (c=='a' || c=='i' || c=='u' || c=='e' || c=='o') {
    cout << "vowel" << endl;
  }else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define loop(i,L,R) for(int i=(L);i<=(R);i++)
const int maxn=1e5+5;
ll a[maxn],pre[maxn],pree[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    pre[0]=1;
    loop(i,1,n)
    {
        scanf("%lld",&a[i]);
        if(i==1) pre[0]=a[i];
        pre[i]=__gcd(pre[i-1],a[i]);
    }
    for(int i=n;i>=1;i--)
    {
        if(i==n) pree[n+1]=a[i];
        pree[i]=__gcd(pree[i+1],a[i]);
    }
    ll ans=1;
    loop(i,1,n)
    {
        if(i==1) ans=max(ans,pree[i+1]);
        else if(i==n) ans=max(ans,pre[i-1]);
        else
        {
            ans=max(ans,__gcd(pre[i-1],pree[i+1]));
        }
    }
    printf("%lld\n",ans);
}


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

int main(){
	int a, b, c, x;
	
	cin >> a >> b >> c;
	if(a > b){
		x = a;
		a = b;
		b = x;
	}
	if(a > c){
		x = a;
		a = c;
		c = x;
	}
	if(b > c){
		x = b;
		b = c;
		c = x;
	}
	
	printf("%d %d %d\n", a, b, c);
	
	return 0;
}

Measured memory_bytes: 1144
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Mon Jan  7 00:29:36 2019
//
package main

import "fmt"

func main() {
	var S, T string
	fmt.Scan(&S, &T)

	indexT := -1
	for i := len(S) - len(T); i >= 0; i-- {
		invalid := false
		for j := range T {
			if S[i+j] != T[j] && S[i+j] != '?' {
				invalid = true
			}
		}
		if invalid {
			continue
		}
		indexT = i
		break
	}

	if indexT == -1 {
		fmt.Println("UNRESTORABLE")
		return
	}

	for _, c := range S[:indexT] + T + S[indexT+len(T):] {
		if c == '?' {
			fmt.Print("a")
		} else {
			fmt.Print(string(c))
		}
	}
	fmt.Println()
}


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

int main() {
  int n, k; cin >> n >> k;
  vector<int> ar(n);

  for (auto &a : ar) {
    cin >> a;
  }

  sort(ar.begin(), ar.end());
  int res = 0;
  for (int i = 0; i < k; i++) {
    res = res + ar[i];
  }

  cout << res << endl;



}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	vector<string>name(2);
	string targ;
	map<string,int>mp;
	cin>>name[0]>>name[1];
	for(int i=0;i<2;i++){
		int x;cin>>x;
		mp[name[i]]=x;
	}
	cin>>targ;
	mp[targ]--;
	cout<<mp[name[0]]<<" "<<mp[name[1]]<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    long long sum = 0;
    for (long long i = 1; i <= n; i++) {
        if ((i % 3) != 0 && (i % 5) != 0) sum += i;
    }
    cout << sum << endl;
}



Measured memory_bytes: 3596
from heapq import heappush, heappop, heapify
import sys
input = sys.stdin.buffer.readline

N, M = map(int, input().split())
C = set()

edges = [[] for _ in range(N)]
for _ in range(M):
    fr, to, c = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append((to, c))
    edges[to].append((fr, c))
    C.add(c)

minDist = [10**18] * (N + 1)
minDistList = [set() for _ in range(N)]
minDistList[0] = C

que = [(1, 0, 0)]
while que:
    dist, f, now = heappop(que)

    for to, c in edges[now]:
        d = dist
        if not c in minDistList[now]:
            d += 1
        if minDist[to] > d:
            minDist[to] = d
            minDistList[to] = set()
            heappush(que, (d, f + 1, to))
        if minDist[to] == d:
            minDistList[to].add(c)

for _ in range(2):
    que = [(minDist[i], 0, i) for i in range(N)]
    heapify(que)
    while que:
        dist, f, now = heappop(que)

        for to, c in edges[now]:
            d = dist
            if not c in minDistList[now]:
                d += 1
            if minDist[to] > d:
                minDist[to] = d
                minDistList[to] = set()
                heappush(que, (d, f + 1, to))
            if minDist[to] == d:
                minDistList[to].add(c)

ans = minDist[N - 1]
print(ans if ans < 10**18 else -1)


Measured memory_bytes: 130736
#include <iostream>

using namespace std;

int max(int A,int B,int C){
    int ans=A;
    if (ans<B) ans=B;
    if (ans<C) ans=C;
    return ans;

}

int main(){
    int A,B;
    cin >> A >> B;
    cout << max(A+B,A-B,A*B) << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

def dfs(s, mx):
    if len(s) == N:
        print(s)
        return 0
    for c in range(ord("a"), mx + 2):
        t = s
        t += chr(c)
        dfs(t, max(mx, c))

N = int(input())
dfs("", ord("a") - 1)

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

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

//繰り返し自乗法による累乗計算
//a**n
int pow(int a, int n){
  if(n == 0) return 1;
  if(n%2 == 0){
    int res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
int modpow(int a, int n){
  if(n == 0) return 1;
  if(n%2 == 0){
    int res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
int com(int n, int a){
  int x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  int res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
int modcom(int n, int a){
  int x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  int ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
int ngcd(vector<int> a){
  int res;
  res = a[0];
  for(int i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
int nlcm(vector<int> a) {
  int res;
  res = a[0];
  for (int i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(int x){
  int i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
int digsum(int x){
  int res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


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






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	double t, x;
	cin >> t >> x;
	printf("%f\n", t/x);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
long long n=100009;
long long a[1000001];
int main()
{
    long long m;
    for(int i=1;i<=n;i++)
    {
        a[i]=pow(i,2);
    }
    while(~scanf("%lld",&m))
    {
        int sum=0;
        for(int j=0;j<=n;j++)
        {
            if(a[j]<=m&&a[j+1]>m)
                printf("%lld\n",a[j]);
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")

using namespace std;

const int N = 2777;
int n, m;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size() - 2; i++){
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,i;
  int coin = 0;
  
  scanf("%d %d",&a,&b);
  
  for(i = 0;i < 2;i++){
    if(a > b){
      coin += a;
      a--;
    }else{
      coin += b;
      b--;
    }
  }
      
  printf("%d",coin);
}

Measured memory_bytes: 128
//naru-hodo
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<time.h>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#define ff first
#define ss second
#define ll long long 
#define ull unsigned long long
#define loop(i,x,n) for(ll int i=x; i<=n; i++)
#define rloop(i,x,n) for(ll int i=x; i>=n; i--)
using namespace std;
int main(){
    ll int n,W;
    cin>>n>>W;
    ll int wt[n], v[n];
    loop(i,0,n-1) cin>>wt[i]>>v[i];
    ll int key[W+1][n+1];
    loop(i,0,W){
        loop(j,0,n){
            if(i==0 || j==0) key[i][j]=0;
            else if(wt[j-1]<=i) key[i][j]=max(v[j-1]+key[i-wt[j-1]][j-1], key[i][j-1]);
            else key[i][j]=key[i][j-1];
        }
    }
    cout<<key[W][n];
    return 0;
}

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

int main(){

	int n,ans;
	cin >> n;
	ans =0;
	for(int i=1;i<=n;i++){
		if(to_string(i).length() % 2 == 1)ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;

    private string[] S;
    private int Index;
    private const char Separator = ' ';

    public Scanner(Stream source)
    {
        Index = 0;
        S = new string[0];
        Sr = new StreamReader(source);
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public decimal NextDecimal()
    {
        return decimal.Parse(Next());
    }
    public string[] StringArray()
    {
        Next();
        Index = S.Length;
        return S.ToArray();
    }
    public int[] IntArray()
    {
        return StringArray().Select(int.Parse).ToArray();
    }
    public long[] LongArray()
    {
        return StringArray().Select(long.Parse).ToArray();
    }
    public bool EndOfStream
    {
        get { return Sr.EndOfStream; }
    }
}

class Magatro
{
   


    public void Solve()
    {
        string A = Console.ReadLine();
        string B = Console.ReadLine();
        if (A.Length > B.Length)
        {
            Console.WriteLine("GREATER");
            return;
        }
        else if (A.Length < B.Length)
        {
            Console.WriteLine("LESS");
            return;
        }
        else
        {
            for(int i = 0; i < A.Length; i++)
            {
                if (A[i] > B[i])
                {
                    Console.WriteLine("GREATER");
                    return;
                }
                else if (A[i] < B[i])
                {
                    Console.WriteLine("LESS");
                    return;
                }

            }
            Console.WriteLine("EQUAL");
        }
    }

}



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

int main() {
   string a, b;
   cin >> a >> b;
   string x = "", y="";

   for(int i=0; i<stoi(b); i++) {
      x += a;
   }
   for(int i=0; i<stoi(a); i++) {
      y += b;
   }


   if(x >= y) cout << y;
   else cout << x;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=998244353;
const int N=2e5+5;
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        int r;cin>>r;
        double c=2*(3.14159)*r;
        cout<<fixed<<setprecision(6);
        cout<<c;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 3804
N, x = map(int, input().split())

a = list(map(int, input().split()))

# 食べる数
tabeta = 0

# xを超えている数を出す
for n in range(N):
    if a[n] > x:
        # 超えている分は食べる
        tabeta += a[n] - x
        # 食べたので、残りはt個
        a[n] = x
        
# 隣り合っている数がXを超えているかチェック
for n in range(0, N-1):
    # 隣り合う数を足してもxを超える分は食べる
    if a[n] + a[n+1] >= x:
        ima_taberu = a[n] + a[n+1] -x
        # いっぱいある方を食べる
        if ima_taberu <= a[n+1]:
            a[n+1] = a[n+1] - ima_taberu
        elif ima_taberu >= a[n+1]:
            a[n] = a[n] - ima_taberu - a[n+1]
        elif ima_taberu == a[i+1]:
            a[n+1] = a[n+1] - ima_taberu
        tabeta += ima_taberu 

print(tabeta)

Measured memory_bytes: 63856
MOD = 10**9 + 7

N, K = map(int, input().split())

nums = [0] * (K+1)
for i in reversed(range(1, K+1)):
    num = pow(K//i, N, MOD)
    for j in range(2*i, K+1, i):
        num -= nums[j]
    nums[i] = num % MOD

ans = 0
for i in range(1, K+1):
    ans += i * nums[i] % MOD
    ans %= MOD

print(ans)


Measured memory_bytes: 11148
#include <iostream>
#include <math.h>

using namespace std;

void f(long int H, long int &ans, int level){
  
  if(H <= 1){
  	ans = ans + pow(2,level);
    return;
  }
  else{ 
  	ans  = ans + pow(2,level);
    f(H/2,ans,level+1);
  }
}

int main(){
	
  long int  H;
  cin>>H;
  
  long int ans = 0;
  
  f(H,ans,0);
  
  cout<< ans <<endl;
  
  return 0;
}

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 a,b,c;
  cin >> a >> b >> c;
  
  cout << ((a+b >= c) ? "Yes" : "No") << endl;
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(string s, string t, ll a, ll b, string u){
    if (u == s) a--;
    else b--;
    cout<<a<<' '<<b<<endl;
}

int main(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    ll a;
    scanf("%lld",&a);
    ll b;
    scanf("%lld",&b);
    string u;
    cin >> u;
    solve(s, t, a, b, u);
}


Measured memory_bytes: 256
use proconio::{fastout, input};

use std::collections::BTreeSet;
use std::iter::FromIterator;

#[fastout]
fn main() {
    input! {
        n: usize,
        ss: [String; n]
    }
    let s = BTreeSet::from_iter(ss.iter());
    println!("{}", s.len());
}


Measured memory_bytes: 18308
import java.util.*;

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

        int N = sc.nextInt();
        int R = sc.nextInt();

        if(N>=10){
            System.out.println(R);
        }
        else if(N<10){
            System.out.println(R + 100 * (10 - N));
        }
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define p2 pair<lo,lo>
#define p3 pair<pair<lo,lo>,lo>
#define p4 pair<pair<lo,lo>,pair<lo,lo> >
#define st first
#define nd second
using namespace std;
typedef long long int lo;
const int N=500005,mod=1000000007;
lo a,b,c,d,e,f,g,h[N],arr[N];
string s;
vector<lo>v;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);
 //    freopen("out.txt","w",stdout);
    cin >> a >> b >> c;
    if(a==b and b!=c){
    	cout << "Yes" << endl; 
    }
    else if(a==c and a!=b){
    	cout << "Yes" << endl;
    }
    else if(b==c and c!=a){
    	cout << "Yes" << endl;
    }
    else{
    	cout << "No" << endl;
    }
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

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

const int MOD = 1e9+7;

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

	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	cout << h2*60+m2-(h1*60+m1) - k << '\n';

 	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  int s[100];
  int ans=0;
  REP(i,n){
    cin>>s[i];
  }
  sort(s,s+n);
  REP(i,n){
    ans+=s[i];
  }
  if(ans%10!=0){
    P(ans);
    return 0;
  }
  REP(i,n){
    int tmp=ans-s[i];
    if(tmp%10!=0){
      P(tmp);
      return 0;
    }
  }
  P(0);
  return 0;
}


Measured memory_bytes: 256
def countMin(*vals):
  l = len(vals)
  li = []
  for i in range(l):
    li.append(vals[i])
  if l == 1:
    return li[0]
  else:
    m = min(li)
    li2 = list(map(lambda x:x - m, li))
    zlist = []
    for j in range(l):
      if li2[j] == 0:
        zlist.append(j)
    if zlist == [i for i in range(l)]:
      return m
    else:
      prev = 0
      re = 0
      re += m
      for k in range(len(zlist)):
        if prev == 0 and li2[0] != 0:
          re += countMin(*li2[:zlist[k]])
          prev = zlist[k]
        elif zlist[k] - prev <= 1:
          prev = zlist[k]
        else:
          re += countMin(*li2[prev + 1:zlist[k]])
          prev = zlist[k]
      if prev < l - 1:
        re += countMin(*li2[prev + 1:])
      return re

n = int(input())
h = list(map(int, input().split()))
print(countMin(*h))
        
          
      

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

int main(){
	long long a,b;
	while(cin >> a >> b){
		if (a < b){
			long long n = b;
			b = a;
			a = n;
		}
		long long times = a * b;
		vector<int> num;
		long long gcd,lcm;
		while(1){
			long long n;
			n = a % b;
			if(n == 0){
				break;
			}
			a = b;
			b = n;	//ユークリッドの互除法
		}
		gcd = b;
		lcm = times / gcd;
		cout << gcd << " " << lcm << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
a,b = [int(x) for x in input().split()]

big = max((a,b))
small = min((a,b))

# 互いに一切れずつ取った残り
last = 16 - small*2
if(last % 2 == 1):
    last += 1

if(last >= (big-small)*2):
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3060
#include <stdio.h>

int gcd(int n, int m){
    if (m == 0) return n;
    else return gcd(m, n % m);
}

int main(){
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", a > b ? gcd(a, b) : gcd(b, a));
    return 0;
}

Measured memory_bytes: 592
n = int(input())
s = input()
r_cnt = s.count("R")
g_cnt = s.count("G")
b_cnt = s.count("B")

sub = r_cnt * g_cnt * b_cnt

for i in range(n):
    for d in range(n):
        j = i+d
        k = j+d
        if k >= n:
            break

        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            sub-=1
print(sub)


Measured memory_bytes: 9196
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, x;
    cin >> n >> m >> x;
    vector <int> c(n);
    vector <vector <int> > a(n, vector <int>(m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = INF;
    for (int i = 0; i < (1 << n); i++) {
        int res = 0;
        vector <int> b(m);
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) {
                res += c[j];
                for (int k = 0; k < m; k++) {
                    b[k] += a[j][k];
                }
            }
        }
        if (res >= ans) continue;
        bool ok = true;
        for (int j = 0; j < m; j++) {
            if (b[j] < x) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans = res;
        }
    }
    if (ans == INF) ans = -1;
    cout << ans << '\n';
}


Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>

typedef struct node {
    int cnt, num;
    struct node *next;
} node;

int main()
{
    int cnt, num;
    node *head = NULL, *cur = NULL;

    for( cnt = 1; scanf("%d", &num), num; ++cnt ){
        node *new = (node *)malloc(sizeof(node));
        if( new == NULL ) exit(-1);
        new->cnt = cnt; new->num = num; new->next = NULL;
        if( head == NULL ){ head = new; }
        else { cur->next = new; }
        cur = new;
    }

    cur = head;
    while( cur ){
        printf("Case %d: %d\n", cur->cnt, cur->num);
        cur = cur->next;
    }

    return 0;
}

Measured memory_bytes: 912
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
using namespace std;

int main(){
    int N;
    cin>>N;
vector<int>H(N);
for(int i=0;i<N;i++)cin>>H[i];
int i=0;
int maxx=0;
int count=0;

while(i<N){
if(i==N-1){maxx=max(maxx,count);count=0;break;}
else{
if(H[i]>=H[i+1]){count++;i++;continue;}
if(H[i]<H[i+1]){maxx=max(maxx,count);count=0;i++;continue;}
}}
cout<<maxx;
return 0;


}

Measured memory_bytes: 640
def Gcd(a, b)
	tmp = 0
	while (a % b != 0)
		tmp = b
		b = a % b
		a = tmp
	end
	return b
end

def Lcm(a, b)
	return a * b / Gcd(a, b)
end

while nums = gets
	a, b = nums.split(' ').map(&:to_i)
	puts sprintf("%d %d", Gcd(a, b), Lcm(a, b))
end

Measured memory_bytes: 8616
#	#include<bits/stdc++.h>
#	using namespace std;
#	template<typename T>vector<T>&operator<<(vector<T>&v,const T t){v.push_back(t);return v;}
#	template<typename T>multiset<T>&operator<<(multiset<T>&m,const T t){m.insert(t);return m;}
#	template<typename T,typename U>istream&operator>>(istream&s,pair<T,U>&p){return s>>p.first>>p.second;}
#	template<typename T,typename U>ostream&operator<<(ostream&s,const pair<T,U>p){return s<<p.first<<" "<<p.second;}
#	template<typename T>ostream&operator<<(ostream&s,const vector<T>v){for(auto a:v){s<<a<<endl;}return s;}
#	#define all(x) x.begin(),x.end()
#	typedef pair<int,int>pii;
#
#	int p[2][200001];
#
#	int N,KL[2];
#	pair<pii,int>s[200001];
#	int ans[200001];
#
sub u1{my$i=pop;
	$p[$i]=$p[$i]&&$p[$i]!=$i?u1($p[$i]):$i+0
}
sub u2{my$i=pop;
	$q[$i]=$q[$i]&&$q[$i]!=$i?u2($q[$i]):$i+0
}
($N,$K,$L)=split$",<>;
for(1..$K){
	($a,$b)=split$",<>;
	$a=u1($a+0);
	$b=u1($b+0);
	if($a!=$b){
		$p[$a]=$b
	}
}
for(1..$L){
	($a,$b)=split$",<>;
	$a=u2($a+0);
	$b=u2($b+0);
	if($a!=$b){
		$q[$a]=$b
	}
}
@s=map u1($_)._.u2($_).$".$_,1..$N;
@s=sort@s;
for($i=0;$i<$N;){
	$j=$i+1,$t=1;
	($a,$b)=split$",$s[$i];
	for(;($c,$d)=split($",$s[$j]),$j<$N&&$a eq$c;++$j){
		++$t
	}
	for(;$i<$j;++$i){
		($a,$b)=split$",$s[$i];
		$ans[$b]=$t
	}
}
print$_,$"for@ans


Measured memory_bytes: 62456
#include <iostream>
#include <cstring>

using namespace std;

typedef long long ll;

int main() {
  int a,b;
  cin >> a >> b;
  for(int i = 1; i <= 100000; i++) {
    int ans = i * 0.08;
    int ans2 = i * 0.1;
    //cout << ans << "   "<<ans2<<endl;
    if(ans == a && ans2 == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  
}


Measured memory_bytes: 256
import numpy as np

N, = map(int, input().split())
titles = [None] * N
total_durations = np.zeros(N+1, dtype=np.int)

for i in range(N):
	title, duration = input().split()
	duration = int(duration)
	
	titles[i] = title
	total_durations[i+1] = total_durations[i] + duration

X, = map(str, input().split())
falling_asleep_index = titles.index(X)
print(
	total_durations[N]
	- total_durations[falling_asleep_index+1])


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int MOD = 1000000007;

inline void add(int &a, int b) {
    a += b;
    if (a >= MOD) {
       a -= MOD;
   }
}

inline void sub(int &a, int b) {
    a -= b;
    if (a < 0) {
       a += MOD;
   }
}

inline int mul(int a, int b) {
    return (long long) a * b % MOD;
}

inline int power(int a, int b) {
    int res = 1;

    while (b > 0) {
        if (b & 1) res = mul(res, a);
        b >>= 1;
        a = mul(a, a);
    }

    return res;
}

inline int inverse(int x) {
    return power(x, MOD - 2);
}

typedef vector<ll> vec;
typedef vector<vec> mat;

mat make_e(int n)
{
	mat A(n, vec(n));
	rep(i, n) {
		A[i][i] = 1;
	}
	return A;
}

mat mul(mat &A, mat &B)
{
	mat C(A.size(), vec(B[0].size()));
	rep(i, A.size()) {
		rep(k, B.size()) {
			rep(j, B[0].size()) {
				C[i][j] += A[i][k] * B[k][j];
				C[i][j] %= MOD;
			}
		}
	}
	return C;
}

mat pow(mat A, ll n)
{
	mat B(A.size(), vec(A.size()));

	rep(i, A.size()) {
		rep(j, A.size()) B[i][j] = 0;
		B[i][i] = 1;
	}

	while (n) {
		if (n & 1) B = mul(B, A);
		A = mul(A, A);
		n >>= 1;
	}

	return B;
}

int main() {
	int N; ll K;
	cin >> N >> K;
	mat a = make_e(N);

	rep(i, N) {
		rep(j, N) {
			cin >> a[i][j];
		}
	}

	mat b = pow(a, K);
	int ans = 0;
	rep(i, N) {
		rep(j, N) {
			add(ans, (int)b[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(void) {
    int N;cin>>N;
    vector<int>A(N+1);
    vector<int>B(N);
    long monsterSum = 0;

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

    for(int i = 0; i < N; i++){
        int m = min(A[i], B[i]);
        A[i] -= m;
        B[i] -= m;
        // cout<<A[i]<<" ";
        monsterSum += m;
        // cout<<m << " ";

        if(i + 1 < N +1){
            m = min(A[i+1], B[i]);
        // cout<<m<<endl;
            A[i+1] -= m;
            B[i] -= m;
            monsterSum += m;
            // cout<<A[i]<<" ";
        }
        // cout<<endl;
    }

    cout<<monsterSum<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[100][100],t[100][100];
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>m;
    rep(i,n)rep(j,n)cin>>s[i][j];
    rep(i,m)rep(j,m)cin>>t[i][j];
    rep(i,n){
        rep(j,n){
            int ok=1;
            rep(ii,m){
                rep(jj,m){
                    if(i+ii>=n||j+jj>=n){
                        ok=0;
                        break;
                    }
                    if(s[i+ii][j+jj]!=t[ii][jj]){
                        ok=0;
                        break;
                    }
                }
                if(!ok)break;
            }
            if(ok){
                Cout("Yes");
                return 0;
            }
        }
    }
    Cout("No");
    return 0;
}


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

int main(){
  int N, D;
  cin >> N >> D;
  if (N%(D*2+1) == 0){
    cout << N/(D*2+1) << endl;
  }
  else{
    cout << N/(D*2+1)+1 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
	int H, W, i, j, sum = 0;
	scanf("%d%d", &H, &W);
	char **A = (char **)malloc(sizeof(char *) * H);
	for(i = 0; i < H; i++){
		A[i] = (char *)malloc(sizeof(char) * (W + 1));
		scanf("%s", A[i]);
		for(j = 0; j < W; j++){
			if(A[i][j] == '#'){
				sum++;
			}
		}
	}
	if(sum == H + W - 1){
		printf("Possible\n");
	}
	else{
		printf("Impossible\n");
	}
	return 0;
}

Measured memory_bytes: 128
/*
题目要求每次删除P的相邻2个数加入到Q的开头。考虑其逆过程：即在得到Q的情况下，每次删除Q的开头2个数插入到P中相邻两个位置；问题转换成找到一个能够完成构造的Q，最小化其字典序
考虑当前求解P[l ~ r]的字典序最小的Q，贪心找到一个字典序最小的pair(P[x], P[y])，满足P[l ~ x - 1]有偶数个数、P[y + 1 ~ r]有偶数个数，显然P[x + 1 ~ y - 1]中也有偶数个数
这三个部分是独立的，可以分别求解最小的字典序。用堆维护即可
*/

#include <queue>
#include <cstdio>
#include <cstring>

using namespace std;
const int Max_N(200050);

int N, P[Max_N], ST[2][20][Max_N], Log[Max_N];

inline int cmin(int a, int b)
{
	return P[a] < P[b] ? a : b;
}

inline int rmq(int c, int l, int r)
{
	int k = Log[r - l + 1];
	return cmin(ST[c][k][l], ST[c][k][r - (1 << k) + 1]);
}

struct pil
{
	pil(const int &_x = 0, const int &_y = 0) : x(_x), y(_y) {}
	int x, y;
	inline bool operator<(const pil &b) const
	{
		return P[x] == P[b.x] ? P[y] < P[b.y] : P[x] < P[b.x];
	}
	inline bool operator>(const pil &b) const
	{
		return b < *this;
	}
};

struct node
{
	node(const int &_l, const int &_r)
	{
		l = _l, r = _r;
		int a = rmq(l & 1, l, r - 1);
		v = pil(a, rmq(r & 1, a + 1, r));
	}
	int l, r;
	pil v;
	inline bool operator<(const node &b) const
	{
		return v > b.v;
	}
};

int main()
{
	scanf("%d", &N);
	P[0] = 0X3F3F3F3F;
	for (int i = 1;i <= N;++i)
		scanf("%d", P + i);
	for (int i = 1;i <= N;++i)
		ST[i & 1][0][i] = i;
	for (int c = 0;c <= 1;++c)
		for (int j = 1;(1 << j) <= N;++j)
			for (int i = 1;i + (1 << j) - 1 <= N;++i)
				ST[c][j][i] = cmin(ST[c][j - 1][i], ST[c][j - 1][i + (1 << (j - 1))]);
	Log[0] = Log[1] = 0;
	for (int i = 2;i <= N;++i)
		Log[i] = Log[i >> 1] + 1;
	priority_queue<node> Q;
	Q.push(node(1, N));
	while (Q.empty() == false)
	{
		node t = Q.top();
		Q.pop();
		printf("%d %d ", P[t.v.x], P[t.v.y]);
		if (t.l <= t.v.x - 1)
			Q.push(node(t.l, t.v.x - 1));
		if (t.v.x + 1 <= t.v.y - 1)
			Q.push(node(t.v.x + 1, t.v.y - 1));
		if (t.v.y + 1 <= t.r)
			Q.push(node(t.v.y + 1, t.r));
	}
	return 0;
}

Measured memory_bytes: 35060
X, N = [int(x) for x in input().split()]

if N > 0:
    p = [int(x) for x in input().split()]

    for i in range(N + 1):
        if X - i not in p:
            print(X - i)
            break
        elif X + i not in p:
            print(X + i)
            break
else:
    print(X)


Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
typedef long long ll;


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

    vector<int> vi;
    for(int i = 0; i < n; ++i){
        int p;
        cin >> p;
        vi.push_back(p);
    }

    sort(vi.begin(), vi.end());
    int ans = vi[n/2] - vi[n/2-1];

    cout << ans << "\n";

}




Measured memory_bytes: 892
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n) {
        rep(j, n) {
            chmax(ans, abs(a[i] - a[j]));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
while 1:
    H,W = map(int,raw_input().split())
    if (H,W) == (0,0):
        break
    for k in range(H):
        if k%2==0 and W%2==0:
            print "#."*(W/2)
        elif k%2==0 and W%2==1:
            print "#."*(W/2)+"#"
        elif k%2==1 and W%2==0:
            print ".#"*(W/2)
        elif k%2==1 and W%2==1:
            print ".#"*(W/2)+"."
    print ''

Measured memory_bytes: 6332
#include <iostream>
#include<vector>
#include <cstdlib>
#include<cmath>
#include<string>
#include <iomanip>
#include <sstream>

using namespace std;





int main () {


   long long n,i,j;
    cin>>n;

    string s="";
    char t;

char a[26]={'a', 'b', 'c', 'd' , 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm' , 'n', 'o', 'p', 'q', 'r', 's', 't',
            'u', 'v', 'w', 'x', 'y', 'z'};





while (n>0){

    j=n%26;
    n=n/26;
    if( j==0 ){

        s=a[25]+s;
        n-=1;
    }

    else {

        s=a[j-1]+s;

    }




}

cout<<s;


}


















/*#include <iostream>
#include<vector>
#include <cstdlib>
#include<cmath>
#include<string>
#include <iomanip>
#include <sstream>

using namespace std;


int main (){


    unsigned long long n,i,j,m,cnt=0;

    cin>>n;

    vector<unsigned long long> a(n);

    stringstream s[n];

    string final[n];

    for(i=0;i<n;i++){

        cin>>a[i];
    }

    for(i=0;i<n;i++){

        s[i]<<a[i];
        s[i]>>final[i];

    }

    vector<long long>b(n,0);



    for(i=0;i<n;i++){

        m=final[i].size();

        for(j=0;j<m;j++){

            b[i]+=final[i][j]-'0';


        }



    }

    for(i=0;i<n;i++){


        cout<<b[i]<<endl;
    }



}
 */

Measured memory_bytes: 3636
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final long k = scanner.nextLong();

        final List<Pair> list = IntStream.range(0, n)
                .mapToObj(i -> new Pair(scanner.nextInt(), scanner.nextInt()))
                .sorted(Comparator.comparingInt(Pair::getA))
                .collect(Collectors.toList());

        long sum = 0;
        for (final Pair pair : list) {
            if (k <= sum + pair.b) {
                System.out.println(pair.a);
                return;
            }

            sum += pair.b;
        }
    }

    static class Pair {
        int a;
        int b;

        Pair(final int a, final int b) {
            this.a = a;
            this.b = b;
        }

        int getA() {
            return a;
        }
    }
}


Measured memory_bytes: 96052
n,k=map(int,input().split())
a=list(map(int,input().split()))
x=[]
for i in range(0,n-k+1):
    ans=a[i+k-1]-a[i]+min(abs(a[i+k-1]),abs(a[i]))
    x.append(ans)        
print(min(x))

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

int a, b, c;
int x;
int cnt;

int myrand() {
  cnt++;
  int nxt = (a*x+b)%c;
  return x = nxt;
}

int main() {
  while (1) {
    int n;
    scanf("%d%d%d%d%d", &n, &a, &b, &c, &x);
    if ((n|a|b|c|x) == 0) return 0;

    cnt = 0;
    for (int i=0; i<n; i++) {
      int y;
      scanf("%d", &y);
      if (i == 0 && y == x) continue;
      while (myrand() != y) {
        if (cnt > 10000) break;
      }
    }

    if (cnt > 10000) puts("-1");
    else printf("%d\n", cnt);
  }
}

Measured memory_bytes: 3156
#include <iostream>
#include <stdio.h>
//#include <string.h>
using namespace std;
int main(void){
    string S;
    int m,h;
while(1){
if(S=="-")break;
    cin >> S >> m;
    while(m>0){
         scanf("%d",&h);
         S=S+S.substr(0,h);
         S.erase(0,h);
        m=m-1;
   
   
   
    }
if(S!="-"){
cout << S << endl; 
}
    
}


}


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

int main(){
  int r,d,x;
  cin>>r>>d>>x;
  for(int i=1;i<=10;i++){
    x=r*x-d;
    cout<<x<<endl;
  }

  return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;


ull N, K;


const ull mod = ull(1E9) + 7;

ull my_plus(ull a, ull b) {
    return ((a % mod + b % mod) % mod);
}

ull my_minus(ull a, ull b) {
    ll ans;
    ans = (a % mod - b % mod);

    if (ans < 0) {
        ans += mod;
    }

    return ull(ans);
}

ull my_mult(ull a, ull b) {
    return ((a % mod * b % mod) % mod);
}

ull my_power(ull x, ull n) {
    ull p, ans;
    ull b;

    ans = 1;

    p = x;
    b = n;

    // cout << "--- x=" << x << " n=" << n << endl;

    while (b != 0) {
        if (b & 1) {
            ans = my_mult(ans, p);
        }
        b = b >> 1;
        p = my_mult(p, p);

        // cout << b << " p=" << p << " ans=" << ans<< endl;
    }


    return ans;

}

const int MAX = 1000001;

ull pwr10[MAX],pwr9[MAX],pwr8[MAX];
void PWRinit() {
    pwr10[0] = 1;
    pwr9[0] = 1;
    pwr8[0] = 1;

    for (ull i = 1; i < MAX; i++) {
        pwr10[i] = my_mult(pwr10[i - 1], 10);
        pwr9[i] = my_mult(pwr9[i - 1], 9);
        pwr8[i] = my_mult(pwr8[i - 1], 8);
    }
}


int main() {
    cin >> N;

    ull z, m;

    ull ans = 0;
    ull a,b;

    if (N == 1) {
        cout << 0 << endl;
        exit(0);
    }

    //cout << "--- " << N << endl;

    PWRinit();

    ans = my_plus(pwr10[N],pwr8[N]);
    ans = my_minus(ans, pwr9[N]);
    ans = my_minus(ans, pwr9[N]);

    cout << ans << endl;

}

Measured memory_bytes: 26488