akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
using namespace std;
int main() {
  int x, n;
  cin >> x >> n;
  set<int> p;
  for (int i = 0; i < n; ++i) {
    int pi;
    cin >> pi;
    p.insert(pi);
  }
  int i = 0;
  while (true) {
    int ans1 = x-i;
    int ans2 = x+i;
    auto f1 = p.find(ans1);
    auto f2 = p.find(ans2);

    if (f1 == p.end()) {
      cout << ans1 << endl;
      break;
    } else if (f2 == p.end()) {
      cout << ans2 << endl;
      break;
    }
    ++i;
  }
  return 0;
}


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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	int digit = 0;
	while (N != 0) {
		N /= K;
		digit++;
	}
	cout << digit << endl;
	return 0;
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,ans=0;
	string s;
	cin>>n>>s;
	for(int i=1;i<n;++i){
		if(s[i]!=s[i-1])
			++ans;
	}
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		int C = sc.nextInt();
		int D = sc.nextInt();
		long bdivic = B / C;
		long bdivid = B / D;
		long adivic = (A - 1) / C;
		long adivid = (A - 1) / D;
		long sum = B - (A - 1) - (bdivic - adivic) - (bdivid - adivid);
		sum += B / lcm(C, D) - (A - 1)  / lcm(C, D);
		System.out.println(sum);


	}

	//最小公約数を求める
	public static long lcm(long m, long n) {
	    return m * n / gcd(m, n);
	}

	//最大公約数を求める　ユークリッドの互除法
	public static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}


}


Measured memory_bytes: 22996
use std::io;


fn main() {
    let n = read_one::<usize>();
    let an = read::<usize>().iter()
        .map(|a| a - 1)
        .collect::<Vec<_>>();
    let mut cnt = 0;
    for (i, &a) in an.iter().enumerate() {
        if a != i - cnt { cnt += 1; }
    }
    if cnt == n { println!("-1"); }
    else { println!("{}", cnt); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍


int main(){
	ll n;cin>>n;
    ll p[n];rep(i,0,n)cin>>p[i];
    sort(p,p+n);
    ll sum=0;rep(i,0,n-1)sum+=p[i];
    cout<<sum+p[n-1]/2<<ednl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
typedef long long ll;
using namespace std;

ll num[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6}, n, k, a[10], m, cnt[10], minn = 0;
bool f = false;

void dfs(ll b) {
  ll i;
  if(!b) {
    if(!n || (num[a[b]] && !(n % num[a[b]]))) {
      ll tmp = 0;
      if(n) cnt[a[b]] = n / num[a[b]];
      for(i = 0; i < 10; ++i) tmp += cnt[i];
      if(tmp <= k) f = true;
    } 
    return;
  }
  if(!num[a[b]]) {
    dfs(b - 1);
    return;
  }
  for(i = n / num[a[b]]; i >= 0; --i) {
    n -= num[a[b]] * i;
    cnt[a[b]] = i;
    dfs(b - 1);
    if(f) {
      return;
    }
    n += num[a[b]] * i;
  }
  if(f) return;
}

int main(void) {
  ll i, j, min = 10, now, tn;
  scanf("%lld%lld", &n, &m);
  tn = n;
  for(i = 0; i < m; ++i) {
    scanf("%lld", &a[i]);
    if(num[a[i]] < min) min = num[a[i]];
  }
  for(i = 0; i < 10; ++i) cnt[i] = 0;
  k = n / min;
  n %= min;
  sort(a, a + m);
  for(i = 0; i < m; ++i) if(num[a[i]] == min) minn = a[i];
  for(i = 0; i < 10; ++i) num[i] -= min;
  while( 1 ) {
    ll dp[n + 1];
    for(i = 0; i <= n; ++i) dp[i] = 1e9;
    dp[0] = 0;
    for(i = 0; i < n; ++i) if(dp[i] != 1e9) {
      for(j = 0; j < m; ++j) if(i + num[a[j]] <= n && dp[i + num[a[j]]] > dp[i] + 1) dp[i + num[a[j]]] = dp[i] + 1;
    }
    if(dp[n] > k) --k, n += min;
    else break;
  }
  ll ans[k];
  for(i = 0; i < k; ++i) ans[i] = minn;
  ll tt;
  for(i = 0; i < m; ++i) if(minn < a[i]) {
    tt = i;
    break;
  }
  for(i = 0; i < tt; ++i) for(j = 0; j < tt - 1; ++j) if(num[a[j]] > num[a[j + 1]] || (num[a[j]] == num[a[j + 1]] && a[j] > a[j + 1])) {
    ll t;
    t = a[j], a[j] = a[j + 1], a[j + 1] = t;
  }
  if(n) {
    dfs(m - 1);
    now = k - 1;
    for(i = 0; i < minn; ++i) if(cnt[i]) {
      for(j = 0; j < cnt[i]; ++j) ans[now] = i, now--;
    }
    now = 0;
    for(i = 9; i > minn; --i) if(cnt[i]) {
      for(j = 0; j < cnt[i]; ++j) ans[now] = i, now++;
    }
  }
  for(i = 0; i < k; ++i) printf("%lld", ans[i]);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll n; cin >> n;
	vector<ll> a(n);
	rep(i,0,n) cin >> a[i];
	vector<ll> b(n,0);
	rep(i,1,n){
		b[i] = (b[i-1] + a[i-1]) % MOD;
	}
	ll ans = 0;
	for(ll i = n-1; i >= 0; i--){
		ans += ((a[i] % MOD) * (b[i] % MOD)) % MOD;
	}
	ans %= MOD;
	cout << ans << endl;
}


Measured memory_bytes: 6424
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

void solve();
int sum(vector<int>::iterator,vector<int>::iterator);

int main() {

   solve();
   return 0;

}

void solve() {

   vector<int> v={0,0,0};

   for (vector<int>::iterator itr=v.begin();itr<v.end();itr++) {

      cin >> *itr;

   }

   if (v[1] - v[0] == v[2] - v[1]) {

      cout << "YES" << endl;

   }
   else {

      cout << "NO" << endl;

   }

}

int sum(vector<int>::iterator b, vector<int>::iterator e) {

   int ans=0;

   for (; b < e; b++) {

      ans+=*b;

   }

   return ans;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
double v[3100];
double dp[3100][3100];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 0; i < n; i++)
	scanf("%lf",v+i);
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++)
    {
    	for(int j = 0; j <= i; j++)
    	{
    		if(j)
    		dp[i][j] += (dp[i-1][j-1]*v[i-1]);
    		dp[i][j] += (dp[i-1][j]*(1-v[i-1]));
		}
	}
	double ans = 0;
	for(int i = 0; i <= n; i++)
	{
		if(i > n-i)
		{
			ans += dp[n][i];
		}
	}
	printf("%.12f\n",ans);
	return 0;
}

Measured memory_bytes: 72320
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] v = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = Integer.parseInt(sc.next());
        }
        for (int i = 0; i < n; i++) {
            c[i] = Integer.parseInt(sc.next());
        }

        int result = 0;
        for (int i = 0; i < n; i++) {
            if (v[i] - c[i] > 0) {
                result += v[i] - c[i];
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 25300
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define CIN(a) cin >> a
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a << endl
#define COUT2(a, b) cout << a << " " << b << endl
#define COUT3(a, b, c) cout << a << " " << b << " " << c << endl
#define pb push_back
#define PB push_back
#define VINT(v, n) vector<int> v(n); REP(i, n) { v[i] = 0 }
#define VINT2(v, n, m) vector<vector<int> > v(n, vector<int>(m)); REP(i, n) { REP(j, m) { v[i][j] = 0 } }
#define VCHAR(v, n) vector<char>v(n)
#define KIRIAGE(a, b) a += (b - a % b) % b
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
	int sx, sy, tx, ty;
	CIN2(sx, sy);
	CIN2(tx, ty);
	REP(i, tx - sx) cout << 'R';
	REP(i, ty - sy) cout << 'U';
	REP(i, tx - sx) cout << 'L';
	REP(i, ty - sy) cout << 'D';
	cout << 'D';
	REP(i, tx - sx) cout << 'R';
	cout << 'R';
	cout << 'U';
	REP(i, ty - sy) cout << 'U';
	cout << 'L';
	cout << 'U';
	REP(i, tx - sx) cout << 'L';
	cout << 'L';
	cout << 'D';
	REP(i, ty - sy) cout << 'D';
	cout << 'R';
	cout << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
int n,m,k;
int cx[5] = {0,0,1,-1};
int cy[5] = {1,-1,0,0};
int len[805][805];
char s[805][805];
queue<pair<int,int> > q;
bool check(int x,int y)
{
    if(x<0 || y<0 || x>=n || y>=m || s[x][y]=='#') return 0;
    return 1;
}
int near(int x,int y)
{
    return min(min(x,n-1-x),min(y,m-1-y));
}
main()
{
    int i,j,x,y,sx,sy;
    int ans;
    scanf("%d%d%d",&n,&m,&k);
    for(i=0;i<n;i++) scanf(" %s",s[i]);
    for(i=0;i<n;i++) for(j=0;j<m;j++) if(s[i][j]=='S') {sx = i; sy = j;}

    for(i=0;i<n;i++) for(j=0;j<m;j++) len[i][j] = inf;
    ans = inf;
    len[sx][sy] = 0;
    q.push({sx,sy});
    while(!q.empty())
    {
        x = q.front().first; y = q.front().second; q.pop();
        ans = min(ans,(int)ceil((double)near(x,y)*1.0/k));
        if(len[x][y]==k) continue;
        for(i=0;i<4;i++)
        {
            if(check(x+cx[i],y+cy[i]) && len[x+cx[i]][y+cy[i]] > len[x][y] + 1)
            {
                len[x+cx[i]][y+cy[i]] = len[x][y] + 1;
                q.push({x+cx[i],y+cy[i]});
            }
        }
    }
    printf("%d",ans+1);
}


Measured memory_bytes: 3456
digit=list('abcdefghijklmnopqrstuvwxyz')
N=int(input())
ans=[]

for i in range(10):
    if N % 26 ==0:
        d=26
    else:
        d=N%26

    N = N-d
    N = N//26
    ans.append(d)

    if N<=26:
        ans.append(N)
        break

ans=ans[::-1]
ans2=''

for i in ans:
    if i !=0:
        ans2 += digit[i-1]

print(ans2)


Measured memory_bytes: 9112
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
cd = []
heapify(ab)
ans = 0
for i in range(M)[::-1]:
    while len(ab):
        a, b = heappop(ab)
        if M < a+i:
            heappush(ab, [a, b])
            break
        heappush(cd, -b)
    if len(cd):
        ans -= heappop(cd)
print(ans)


Measured memory_bytes: 122968
/*
 * Author: Utkal Sinha
 * Created on: 2020-09-19, Sat, 17:48
 * Problem:
 * Platfrom: General
 * */
#if USE_BOOST2
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_bin_float.hpp>
namespace bst = boost::multiprecision;
typedef bst::int1024_t vll; //int512_t or //int128_t
typedef bst::cpp_bin_float_100 vdouble;
#endif

#include <bits/stdc++.h>
using namespace std;
#define GETTIME std::chrono::system_clock::now()
#define DURATION std::chrono::duration<double>
#ifdef MY_DEV_ENV2
#define LOCALDEV
#endif
typedef long long ll;
typedef std::chrono::system_clock::time_point TPT;
static TPT starttime, endtime, timelimit;
static double problem_tle = 1.5;
static inline void calc_problem_end_time() {timelimit = starttime + std::chrono::milliseconds(int (problem_tle * 1000));}
// template end

void love() {
    ll n, x, m;
    cin >> n >> x >> m;
    ll ans = 0;
    if(x == 1) ans = n;
    if(x > 1) {
        unordered_map<ll, ll> mp;
        vector<ll> nums;
        nums.push_back(0);

        bool chk = true;
        ll ct = 1;
        while(ct <= n && chk) {
            if(mp.find(x) == mp.end()) {
                ans = ans + x;
                mp[x] = ct;
                nums.push_back(x);
            }
            else {
                ll ls = mp[x];
                ll prd = ct - ls;
                ll sm = 0;
                for(int i = ls; i<nums.size(); i++) {
                    sm = sm + nums[i];
                }

                ll rem = n - ct + 1;
                ll dv = rem / prd;
                ll extra = rem % prd;

                ans += dv * sm;
                for(int i = 0; i < extra; i++) {
                    ans += nums[ls + i];
                }
                break;
            }
            ct++;
            x = (x*x) % m;
        }
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    srand(time(0));
#ifdef LOCALDEV
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
#ifdef LOCALDEV
    starttime = GETTIME;
    calc_problem_end_time();
#endif
    while(t--) love();
#ifdef LOCALDEV
    endtime = GETTIME;
    DURATION elapsed_seconds = endtime - starttime;
    DURATION time_limit_seconds = timelimit - starttime;
    clog << "Elapsed time: " << elapsed_seconds.count() << "s\n";
    clog << "Time limit: " << time_limit_seconds.count() << "s\n";
#endif
    return 0;
}

Measured memory_bytes: 5596
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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>
ostream &operator<<(ostream &out, vector<T> const &v) {
    for (auto &&a : v) out << a << " ";
    out << endl;
    return out;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    string s;
    cin >> s;

    if (s[2] != s[3] || s[4] != s[5]) {
        cout << "No";
        return;
    }

    cout << "Yes";
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3628
using System; using System.Linq; using System.Collections.Generic; using System.IO;

class A {
	static void Main() {
		var n = int.Parse(Console.ReadLine());
		var a = 0;
		for(int i = 1;i <= n;i++) {
			a += i;
		}
		Console.WriteLine(a);
	}
}


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


int main() {
        int n; scanf("%d", &n);
        multiset< int > s;
        for(int i = 0; i < n; i++) {
                int x; scanf("%d", &x);
                s.insert(x);
        }

        deque< int > q;

        long long ans = 0LL;
        while( !s.empty() ) {
                if( q.empty() ) {
                        auto it = s.begin();
                        q.push_back( *it );
                        s.erase(it);
                        continue;
                }
                auto L = s.begin();
                auto R = s.end(); R--;

                int st = q.front();
                int ed = q.back();

                ans += max( max( abs(*L - st), abs(*L - ed) ), max( abs(*R - st), abs(*R - ed) ) );
                if( max( abs(*L - st), abs(*L - ed) ) > max( abs(*R - st), abs(*R - ed) ) ) {
                        if( abs(*L - st) > abs(*L - ed) ) {
                                q.push_front(*L);
                                s.erase(L);
                        } else {
                                q.push_back(*L);
                                s.erase(L);
                        }
                } else {
                        if( abs(*R - st) > abs(*R - ed) ) {
                                q.push_front(*R);
                                s.erase(R);
                        } else {
                                q.push_back(*R);
                                s.erase(R);
                        }
                }
        }



        printf("%lld\n", ans);


        return 0;
}


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

int main(){
  int a,b,max_num,min_num;
  cin>>a;
  max_num=0;
  min_num=1000;
  for(int i=0;i<a;i++){
    cin>>b;
    if(max_num<b){
      max_num=b;
    }
    if(min_num>b){
      min_num=b;
    }
  }
  cout<<max_num-min_num;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL A,V,B,W,T;
  cin>>A>>V>>B>>W>>T;
  LL vdif = V-W;
  if(vdif*T>=abs(A-B)){
    cout<<"YES"<<endl;

  }else{
    cout<<"NO"<<endl;
  }


  return 0;
}


Measured memory_bytes: 3636
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;

void main(){
	auto Q=readln.split.to!(int[]),A=Q[0],B=Q[1];
	if(A+B<10)writeln(A+B);
	else writeln("error");
}

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

int main() {
  
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++)
  {
    string S;
    cin >> S;
    
    if (S == "Y")
    {
      cout << "Four" << endl;
      return 0;
    }
  } 
  cout << "Three" << endl;
  return 0;
}


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

int main(){
	int n;
	char s[4001];
	scanf("%d%s", &n, s);
	long num[3] = {0};
	for(int i=0; i < n; i++) {
		if(s[i] == 'R') num[0]++;
		if(s[i] == 'G') num[1]++;
		if(s[i] == 'B') num[2]++;
	}
	long ans = num[0] * num[1] * num[2];
	for(int i=0; i < n-2; i++) {
		for(int j=i+1; 2*j-i < n; j++) {
			if(s[i] != s[j] && s[i] != s[2*j-i] && s[j] != s[2*j-i])
				ans--;
		}
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 3844
n,d,a = map(int,input().split())
xh = [list(map(int,input().split())) for _ in range(n)]

xh.sort()
j = 0
cnt = [0] * n
taken = 0

# def problem(h):
#     if h <= 0:return 0
#     ans = h//a
#     if h%a :
#         ans += 1
#     return ans

for i in range(n):
    [x,h] = xh[i]
    while xh[j][0] + 2*d < x:
        taken -= cnt[j]
        j += 1
    if taken * a >= h:
        continue
    if h % a == 0:
        cnt[i] = h//a - taken
    else:
        cnt[i] = h//a - taken + 1
    #cnt[i] = problem(h - taken * a)
    taken += cnt[i]
print(sum(cnt))


Measured memory_bytes: 82392
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  string s; cin>>s;
  bool f;
  if(s[0]=='B')
  f=0;
  else
  f=1;
  int k=0;
  rep(i,s.size()){
    if(f){
      if(s[i]=='B'){
        k++;f=0;
      }
    }else{
      if(s[i]=='W'){
        k++;f=1;
      }
    }
  }
  cout<<k<<endl;

  return 0;
}


Measured memory_bytes: 512
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math;
const dx = [1,0,-1,0], dy = [0,1,0,-1];
const readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};
void read(T...)  (auto ref T args){ mixin(readMixin);}
void readArray(T)(auto ref T args){ mixin(readMixin);}
void times(int n,void delegate() stmt){foreach(i;iota(n))stmt();}

auto sieve(){
	const primeMax = 150000;
	bool[primeMax] notPrime;
	notPrime[0] = notPrime[1] = true; 
	for(int i = 2; i * i < primeMax; i++){
		if (notPrime[i]) continue;
		for(int j = i; i * j < primeMax; j++){
			notPrime[i * j] = true;
		}
	}
	return notPrime;
}
void main(){
	int[] primes_;
	foreach(int i,np;sieve()){if(!np)primes_ ~= i;}
	auto primes = primes_.assumeSorted;
	int n,p;
	while(read(n,p),n!=-1 && p != -1){
		auto starts = primes.upperBound(n)[0..p].array;
		int[] m ;
		foreach(i,s1;starts){
			foreach(s2;starts[i..$]){
				m ~= s1 + s2;
			}
		}
		m.sort[p-1].writeln;
	}
}

Measured memory_bytes: 6072
from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]

d = Counter()
for x in a:
    d[x] += 1

if d[0] == n:
    print('Yes')
elif len(d.keys()) == 2 and d[0] == n//3:
    print('Yes' if d[0] == n//3 else 'No')
elif len(d.keys()) == 3:
    p, q, r = d.keys()
    if d[p] == d[q] and d[q] == d[r] and p ^ q ^ r == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

#define MAXN 305
#define int long long
#define INF (int)0x3f3f3f3f*(int)0x3f3f3f3f

int n,m,l;
int a[MAXN][MAXN];
int f[MAXN][MAXN];

void rd()
{
	cin >> n >> m >> l;
	memset(a,0x3f,sizeof(a));
	for(int i = 1; i <= m; i ++) {
		int x,y,c;
		cin >> x >> y >> c;
		a[x][y] = c;
		a[y][x] = c; 
	}
}

signed main()
{
	rd();
//	cout<<INF<<"\n"<<a[1][1]<<"\n";
	for(int k = 1; k <= n; k ++)
		for(int i = 1; i <= n; i ++)
			for(int j = 1; j <= n; j ++)
				a[i][j] = min(a[i][j],a[i][k] + a[k][j]);
	memset(f,0x3f,sizeof(f));
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= n; j ++)
			if(i  != j && a[i][j] <= l) {
				f[i][j] = 1;
			}
	for(int k = 1; k <= n; k ++)
		for(int i = 1; i <= n; i ++)
			for(int j = 1; j <= n; j ++)
				f[i][j] = min(f[i][j],f[i][k] + f[k][j]);
	int q;
	cin >> q;
	while(q --)
	{
		int s,t;
		cin >> s >> t;
		if(f[s][t] >= INF) cout<<-1<<"\n";
		else cout<<f[s][t]-1<<"\n";
	}
		
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
using ll = long long int;

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  double prob = 0.0;
  REP(i, N) {
    int point = i + 1;
    double p = 1.0;
    REP(j, K) {
      if(point >= K) break;
      point *= 2;
      p *= 0.5;
    }
    prob += p / N;
  }
  cout << std::setprecision(12) << prob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T> inline T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  string s,ans="";cin>>s;
  rep(i,0,siz(s)){
      if(s[i]=='0'){
          ans.pb('0');
      }else if(s[i]=='1'){
          ans.pb('1');          
      }else{
          if(siz(ans))ans.pop_back();
      }
  }
  cout<<ans<<ENDL;

}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
n,k=map(int,input().split())
p_list=list(map(int,input().split()))
Sum=0
for i in range(k):
    Sum+=p_list[i]
Max=Sum
for i in range(k,n):
    Sum=Sum+p_list[i]-p_list[i-k]
    Max=max(Max,Sum)
ans=(Max+k)/2
print(ans)


Measured memory_bytes: 71792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  string ans;
  
  for (int i = 0; i < s.length(); i++) {
    if (i%2 == 0)
      ans += s[i];
  }
  
  cout << ans;
}

Measured memory_bytes: 3672
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=998244353;


//mod演算ライブラリ
//mod=1000000007

LL add(LL a,LL b){
  return (a+b)%mod;
}

LL sub(LL a,LL b){
  return (a+mod-b)%mod;
}

LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法 単品利用可
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

LL dvs(LL a,LL b){
  return mul(a,power(b,mod-2));
}

const int SIZE_mod=200005;
int invfact[SIZE_mod];
int fact[SIZE_mod];

void factset(int a){//aまでの階乗%mod表を作成
  fact[0]=1;
  FORQ(i,1,a){
    fact[i]=mul(fact[i-1],i);
  }
}

void cmbset(int a){//1~aまでの階乗と階乗数の逆元のmod(mod)を用意 O(a)
  factset(a);
  invfact[a]=power(fact[a],mod-2);
  invfact[0]=1;
  FORD(i,a,1){
    invfact[i]=mul(invfact[i+1],i+1);
  }

}

LL cmb(int n,int r){//nCr%mod  (cmbset後に使用)
  if(n<r||r<0||n<0)return 0;
  return mul(fact[n],mul(invfact[r],invfact[n-r]));
}

LL prm(int n,int r){//nPr%mod
    return mul(cmb(n,r),fact[n]);
}

LL homo(int n,int r){//nHr%mod
  return cmb(n+r-1,r);
}


int main(){
	int n,k;
    cin>>n>>k;
    vi l(k),r(k);
    vl d(2*n+1,0);
    FOR(i,0,k){
        cin>>l[i]>>r[i];
    }
    d[0]=1;d[1]=-1;
    FOR(i,0,n){
        if(i!=0)d[i]=add(d[i],d[i-1]);
        FOR(j,0,k){
            d[i+l[j]]=add(d[i],d[i+l[j]]);
            d[i+r[j]+1]=sub(d[i+r[j]+1],d[i]);
        }
    }
    cout<<d[n-1];


}


Measured memory_bytes: 6356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int nmax=3e5+5;
char s[nmax];
long long sol,p,n;
int main()
{
    ios::sync_with_stdio(false);
    cin.getline(s+1,nmax-2);
    n=strlen(s+1);
    p=n;
    for(int i=n;i>=1;--i)
    {
        if(s[i]=='B')
        {
            sol+=p-i;
            --p;
        }
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}

vector<double> p;

int main()
{
    int N;
    cin >> N;
    p.resize(N + 1);
    rep(i, N) cin >> p[1 + i];
    vector<vector<double>> dp(N + 1, vector<double>(N + 1));
    dp[0][0] = 1;
    rep2(i, 1, N + 1)
    {
        rep2(j, 0, i + 1)
        {
            if (j > 0 and i > 0)
                dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1.0 - p[i]);
            else if (j == 0 and i > 0)
                dp[i][0] = dp[i - 1][0] * (1.0 - p[i]);
        }
    }
    double ans = 0;
    rep2(i, N / 2 + 1, N + 1)
    {
        ans += dp[N][i];
    }
    cout <<setprecision(10)<< ans;
    return 0;
}

Measured memory_bytes: 70784
from collections import Counter


def main():
  n, *lst = map(int, open(0).read().split())
  c1, c2 = [(0, 0)] + sorted(Counter(lst[::2]).items(), key=lambda x: x[1]), [(0, 0)] + sorted(Counter(lst[1::2]).items(), key=lambda x: x[1])
  if c1[-1][0] != c2[-1][0]:
    print(n - c1[-1][1] - c2[-1][1])
  else:
    print(n - max(c1[-2][1] + c2[-1][1], c1[-1][1] + c2[-2][1]))


if __name__ == '__main__':
  main()

Measured memory_bytes: 20520
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;}


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


int N; cin >> N;

VI A(N-1); invec(A);
VI ans(N+1, 0);

for(int a: A){
    ++ans[a];
}

rep(i, 1, N+1)
    cout << ans[i] << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 6364
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S;
    cin >> S;
    Yes((S[2]==S[3])&&(S[4]==S[5]));
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        List<String> list01 = Arrays.asList(mylist.get(0).split(" "));
        List<String> list02 = Arrays.asList(mylist.get(1).split(" "));

        int n = Integer.valueOf(list01.get(0));
        int k = Integer.valueOf(list01.get(1));

        List<Integer> list03 = list02.stream().map(Integer::valueOf).collect(Collectors.toList());

        Long result1 = list03.stream().filter(s -> s >= k).count();
        System.out.println(result1);

    }

}


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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var r = vals[0];
        var g = vals[1];
        var b = vals[2];
        var n = vals[3];

        int count = 0;
        for (int rr = 0; rr <= n; rr += r)
        {
            for (int gg = 0; rr + gg <= n; gg += g)
            {
                var x = n - (rr + gg);
                if (x == 0 || x % b == 0)
                {
                    count++;
                }
            }
        }

        Console.WriteLine(count);
    }
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 ///   freopen("input.txt", "r", stdin);

    string s, t;
    cin >> s >> t;

    int n = s.size();
    int m = t.size();

    vector <vector <int> > dp(n + 1, vector <int>(m + 1));

    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
            if(s[i - 1] == t[j - 1])
                dp[i][j] = 1 + dp[i - 1][j - 1];
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

    string ans;
    while(n && m)
    {
        if(s[n - 1] == t[m - 1])
        {
            ans.push_back(s[n - 1]);
            --n, --m;
        }else
        if(dp[n - 1][m] > dp[n][m - 1])
            --n;
        else
            --m;
    }

    reverse(ans.begin(), ans.end());
    cout << ans << '\n';

    return 0;
}



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

int func(int A,int B,int C,int count){
    if(A%2==1 || B%2==1 || C%2==1){
      return count;
    }
  return func((B+C)/2,(C+A)/2,(A+B)/2,count+1);
}
    
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B && B==C && A%2==0){
    cout << -1 << endl;
  }
  else{
    cout << func(A,B,C,0) << endl;
  }
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

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

struct node {
	int s, e;
	string name;
};
bool operator<(const node& lhs, const node& rhs) {
	return lhs.s < rhs.s;
}

int main() {
	int n, q;
	while(cin >> n >> q, n||q) {
		vector<node> vn;
		rep(i, n) {
			node in;
			int era;
			cin >> in.name >> era >> in.e;
			in.s = in.e - era + 1;
			vn.push_back(in);
		}
		sort(vn.begin(), vn.end());
		rep(i, q) {
			int y;
			cin >> y;
			bool found = false;
			rep(j, n) {
				if(vn[j].s<=y && y<=vn[j].e) {
					cout << vn[j].name << ' ' << y-vn[j].s+1 << endl;
					found = true;
					break;
				}
			}
			if(!found) {
				cout << "Unknown" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1288
N, K = map(int, input().split())
L = [[int(i) for i in input().split()] for j in range(N)]
L.sort(key=lambda x:x[0])
t = 0
for i in L:
    if t < K - i[1]:
        t += i[1]
    else:
        print(i[0])
        break



Measured memory_bytes: 22872
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long x,long y){
    if(y==0)return x;

    return gcd(y,x%y);
}
long long lcm(long x,long y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main()
{
    int N;
    double V[60]={},ans=0;
    cin>>N;

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

    sort(V,V+N);

    ans=(V[0]+V[1])/2.000000000;

    for(int i=2;i<N;i++){
        ans=(ans+V[i])/2.000000000;
    }

    cout<<fixed<<setprecision(10);
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//ofstream cout("output.out");

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }

#define ll long long
//int n, m, k, q;

int main(){
	fast();
	int n, k, d;
	cin >> n >> k;
	vector<int> Free(n + 1, 0);
	for(int i = 0; i < k; ++i){
		cin >> d;
		int x;
		while(d--){
			cin >> x;
			Free[x]++;
		}
	}
	int rs = 0;
	for(int i = 1; i <= n; ++i){
		if(!Free[i]){
			rs ++;
		}
	}
	cout << rs;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <stack>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using P1 = pair<int, int>;

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

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define debug(a,n) for(i=0;i<n;i++)cout<<a[i]<<" ";
#define d(x) cout<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
vector<int>adj [T];
			/*brownsands IIITA*/

void solve()
{  int n,a;
    cin>>n;
    n--;
    a=(n)*(n+1);
    cout<<a/2;
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
                           }		
} 
               
			
 

				
		
		




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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll x; cin >> x;
	ll m = 100;
	for (int i = 1;; i++) {
		m = m + m / 100;
		if (m >= x) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var blue = new Dictionary<string, int>();
		for(int i = 0; i < n; i++)
		{
			var str = Console.ReadLine();
			if(!blue.ContainsKey(str))
				blue.Add(str, 0);
			
			blue[str]++;
		}
		var red  = new Dictionary<string, int>();
		var m = Console.ReadLine().ToInt();
		
		for(int i = 0; i < m; i++)
		{
			var str = Console.ReadLine();
			if(!red.ContainsKey(str))
				red.Add(str, 0);
			
			red[str]++;
		}
		long max = -999999;
		foreach(var key in blue.Keys)
		{
			var cur = blue[key];
			if(red.ContainsKey(key))
			{
				cur -= red[key];
			}
			max = Math.Max(cur, max);
		}
		Console.WriteLine(Math.Max(0, max));
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<iomanip>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N,Q;
string s;
char t[200002],d[200002];
int binary_search(int x){
    for(int i = 0; i < Q; i++){
        if(s[x] == t[i]){
            if(d[i] == 'R') x++;
            else x--;
        }
        if(x == -1) return -1;
        if(x == N) return 1;
    }
    return 0;
}
int main(){
    cin >> N >> Q;
    cin >> s;
    vector<int> go(N+1,-2);
    for(int i = 0; i < Q; i++){
        cin >> t[i] >> d[i];
    }
    int l = -1;
    int r = N;
    int mid;
    while(l < r -1){
        mid = (l+r)/2;
        if(binary_search(mid) == -1) l = mid;
        else r = mid;
    }
    int z = l;
    l = -1; 
    r = N;
    while(l < r-1){
        mid = (l+r)/2;
        if(binary_search(mid) == 1) r = mid;
        else l = mid;
    }
    int zz = r;
    cout << zz - z - 1 << endl;
}



Measured memory_bytes: 1796
#include <iostream>
#include <string>
#include <deque>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> B(N);
    for(int i=1; i<N; i++) {
        cin >> B[i];
    }

    vector<ll> A(N+1);
    for(int i=1; i<N; i++) {
        if(i==1) {
            A[i] = B[i];
        } else if(A[i] > B[i]) {
            A[i] = B[i];
        }
        A[i+1] = B[i];
    }

    ll sum = 0;
    for (ll i = 1; i <= N; i++) {
        sum += A[i];
    }
    cout << sum << endl;

    return 0;


}


Measured memory_bytes: 256