akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    cout << n * n * n << endl;
}

Measured memory_bytes: 256
// #define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, k; std::cin >> n >> k;
  std::vector<int> a(n); std::cin>>a;
  int ans = (n-1+k-2) / (k-1);
  std::cout << ans << std::endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int sum;
  sum = 0;
  for(int i = 0; i < N; i++) {
    int x, y;
    cin  >> x >> y;
    sum += (y - x + 1);
  }
  cout << sum << endl;
}

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

using namespace std;

int main() {
  int n;cin>>n;
  long double cnt=0;
  rep(i,n){
    double x;
    string u;
    cin>>x>>u;
    if(u=="JPY")x=x;
    else x=x/1*380000.0;
    cnt+=x;
  }
  cout<<cnt<<endl;
}
  

Measured memory_bytes: 3700
import scala.math.pow

object Main {
  def main(args: Array[String]): Unit = {
    val List(n, k) = io.StdIn.readLine.split(' ').toList.map(c => c.toInt)
    val answer = k * pow((k - 1), (n - 1)).toLong

    println(answer)
  }
}


Measured memory_bytes: 21552
#include <bits/stdc++.h>
using namespace std;
long long c(long long x) {
	if(x == 1) {
		return 1;
	}
	return 1 + c(x / 2) * 2;
}
int main() {
	long long h;
	cin >> h;
	cout << c(h);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Task "A"

using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int a;
    string s;
    cin >> a >> s;
    if (a < 3200) cout << "red";
    else cout << s;
    return 0;
}


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

int     main() {
        int N;
        cin >>N;
        long HH=1;
        for (int i=0; i<N; i++) {
                long H;
                cin >>H;
                if (H<HH) {
                        cout <<"No" <<endl;
                        return 0;
                }
                if (H-HH>0) H--;
                HH=H;
        }
        cout <<"Yes" <<endl;
        return 0;
};

Measured memory_bytes: 256
S = input()
q = int(input())

for idx in range(q):
    e = input().split()
    a = int(e[1])
    b = int(e[2])

    if e[0] == "print":
        print(S[a:b+1])
    elif e[0] == "reverse":
        SS = S[a:b+1]
        S = S[:a] + SS[::-1] + S[b+1:]
    elif e[0] == "replace":
        S = S[:a] + e[3] + S[b+1:]



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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const double DINF = 5e14, eps = 1e-10;
const long long MOD = 1e9 + 7, INF = 5e18;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

// mod. m での a の逆元 a^{-1} を計算する
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

ll n, ans, sum, a[100010], fact = 1, ifact[100010], invv[100010];

int main() {
	cin >> n;
	for (int i = 0;i < n;i++)cin >> a[i];
	for (ll i = 2;i <= n;i++) {
		fact *= i;
		fact %= MOD;
	}
	for (int i = 0;i < n;i++) {
		ifact[i + 1] = modinv(i + 1, MOD);
		sum += fact * ifact[i + 1] % MOD;
		sum %= MOD;
	}
	for (int i = 1;i <= n;i++) {
		invv[i] = fact * ifact[i] % MOD;
	}
	ans += sum * a[0] % MOD;
	for (int i = 1;i < n;i++) {
		sum -= invv[n - i + 1];
		sum += MOD;
		sum %= MOD;
		sum += invv[i + 1];
		sum %= MOD;
		ans += sum * a[i] % MOD;
		ans %= MOD;
	}
	cout << ans % MOD << endl;
	return 0;
}


Measured memory_bytes: 2560
def main():
    import math
    H = int(input())
    if H == 1:
        print(1)
    else:
        count = int(math.log(H,2))
        ans = 0
        for i in range(count+1):
            ans += 2**(i)
        print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

vvl matmul(vvl &a, vvl &b, ll m){
    vvl c(a.size(), vl(b[0].size()));
    for(int i=0; i<a.size(); i++){
        for(int k=0; k<b.size(); k++){
            for(int j=0; j<b[0].size(); j++){
                c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % m;
            }
        }
    }
    return c;
}

vvl matpow(vvl a, ll n, ll m){
    vvl b(a.size(), vl(a.size()));
    for(int i=0; i<a.size(); i++) b[i][i] = 1;
    while(n > 0){
        if(n & 1) b = matmul(b,a,m);
        a = matmul(a,a,m);
        n >>= 1;
    }
    return b;
}

int main(){
    ll L,a,b,m; cin >> L >> a >> b >> m;
    ll now = 10;
    ll ans = 0;
    ll num = 0;
    ll B = 0;
    REP(k,1,19){
        if(a >= now){
            now *= 10;
            continue;
        }
        vvl c(3,vl(3));
        c[0][0] = now%m; c[0][1] = 1; c[0][2] = a % m;
        c[1][0] = 0; c[1][1] = 1; c[1][2] = b % m;
        c[2][0] = 0; c[2][1] = 0; c[2][2] = 1;
        if(a + b * (L - 1) >= now){
            ll nxt = (now - a + b - 1) / b;
            c = matpow(c,nxt-num,m);
            num = nxt;
            ll tmp = ans;
            ans = (tmp*c[0][0]%m + B*c[0][1]%m + c[0][2]%m) % m;
            B = (tmp*c[1][0]%m + B*c[1][1]%m + c[1][2]%m) % m;
        }else{
            c = matpow(c,L-num,m);
            ll tmp = ans;
            ans = (tmp*c[0][0]%m + B*c[0][1]%m + c[0][2]%m) % m;
            B = (tmp*c[1][0]%m + B*c[1][1]%m + c[1][2]%m) % m;
            break;
        }
        now *= 10;
    }
    cout << ans << "\n";
}

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

using namespace std;
const int NMAX = 2000;

int v[NMAX+2];
int N, K, Q;
int best = (1 << 30);
int small[NMAX+2], big[NMAX+2];

bool cmp_small(int a, int b)
{
    return v[a] < v[b];
}

bool cmp_big(int a, int b)
{
    return v[a] > v[b];
}

int block[NMAX+2];

int number(int lef, int rig)
{
    memset(block, 0, sizeof(block));
    for( int i = 1;  i <= lef;  ++i ) block[ small[i] ] = 1;
    for( int i = 1;  i <= rig;  ++i ) block[ big[i] ] = 1;
    int ind = 1, cate = 0;
    while( ind <= N ) {
        /// blocat
        while( block[ind] && ind <= N )
            ++ind;
        int pos = ind;
        while( !block[ind] && ind <= N )
            ++ind;

        int lg = ind - pos;
        if( lg >= K )
            cate += (lg - K + 1);
    }
    return cate;
}

vector<vector<int>> get_outputs(int lef)
{
    vector<vector<int>> sol;

    memset(block, 0, sizeof(block));
    for( int i = 1;  i <= lef;  ++i ) block[ small[i] ] = 1;
    int ind = 1, cate = 0;
    while( ind <= N ) {
        /// blocat
        while( block[ind] && ind <= N )
            ++ind;
        int pos = ind;
        while( !block[ind] && ind <= N )
            ++ind;

        int lg = ind - pos;

        if( lg >= K ) {
            cate += (lg - K + 1);

            vector<int> nrs;
            for( int i = pos;  i < ind;  ++i ) nrs.push_back(v[i]);
            sort( nrs.begin(), nrs.end() );
            nrs.resize(lg - K + 1);

            sol.push_back(nrs);
        }

    }
    return sol;
}

int get_val(vector<vector<int>> vec)
{
    vector<int> meh;
    for( auto x : vec )
        for( auto y : x )meh.push_back(y);
    sort(meh.begin(), meh.end());
    if( Q > meh.size() ) return (1 << 30);
    return meh[Q - 1] - meh[0];
}

int main()
{
    cin >> N >> K >> Q;
    for( int i = 1;  i <= N;  ++i ) cin >> v[i], small[i] = i, big[i] = i;
    sort(small+1, small+N+1, cmp_small);
    sort(big+1, big+N+1, cmp_big);
    for( int mici = 0;  mici < N;  ++mici ) {
        if( number(mici, 0) < Q ) continue;
        vector<vector<int>> vec = get_outputs(mici);
        best = min(best, get_val(vec));
    }
    cout << best << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(int argc, char const *argv[]) {
  string w;
  bool tf = true;
  map<char,int> mp;
  cin >> w;
  for (size_t i = 0; i < w.size(); i++) {
    mp[w[i]]++;
  }
  for(auto x: mp){
    if (x.second%2==0) continue;
    else tf = false;
  }
  if (tf) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
ans = sum(A)
dic = defaultdict(int) #初期化する関数。
for num in A:
  dic[num] += 1

Q = int(input())
for i in range(Q):
  b,c = map(int,input().split())
  dif = c-b
  ans += dif*dic[b]
  dic[c] += dic[b]
  dic[b] = 0
  print(ans)

Measured memory_bytes: 24136
main = do
  str <- getLine
  let [a', b'] = words str
      a = read a' ::Int
      b = read b' ::Int
  let num = a * 10^(length b') + b
  let list = map (^2) [1..320]
  if num `elem` list
    then putStrLn "Yes"
    else putStrLn "No"


Measured memory_bytes: 508
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
/*void calc()
{
	for(int i=0;i<2005;i++)
	{
		a[i][0]=1;
		a[i][i]=1;
		for(int j=1;j<i;j++)
		{
			a[i][j]=(a[i-1][j-1]+a[i-1][j])%MOD;	
		}
	}
}*/
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);	
	return 0;
}





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

using namespace std;

typedef long long ll;
ll inf = 1e9 + 7;

int main() {
    ll H, W;    cin >> H >> W;
    string *a = new string[H];
    for (int i = 0; i < H; i++)
        cin >> a[i];

    ll **dp = new ll *[H];
    for (int i = 0; i < H; i++)
        dp[i] = new ll[W];

    dp[0][0] = 1;

    for (int i = 1; i < W; i++) {
        if (a[0][i] == '.')
            dp[0][i] = dp[0][i-1];
    }

    for (int i = 1; i < H; i++) {
        if (a[i][0] == '.')
            dp[i][0] = dp[i-1][0];
    }

    for (int i = 0; i < H-1; i++) {
        for (int j = 0; j < W-1; j++) {
            if (a[i+1][j+1] == '.')
                dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % inf;
            else 
                dp[i+1][j+1] = 0;
        }
    }

    cout << dp[H-1][W-1] << endl;
    return 0;

}

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

using namespace std;
#define ll long long

int main (void) {
    int n;

    scanf("%d", &n);

    if((n/100)==7 || ((n/10)%10)==7 || (n%10)==7){
        printf("%s\n", "Yes");
    } else{
        printf("%s\n", "No");
    }
    return 0;
}

Measured memory_bytes: 3612
N, X = map(int, input().split())
L = list(map(int, input().split()))
D = [0]*(N)
ans = 1
for i in range(N):
    D[i] = D[i-1] + L[i]
    if D[i] <= X:
        ans = ans + 1
    else:
        break
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

typedef std::pair<int, int> P;
int n;
P v[2][100005];
P max[2];

int main(){
	scanf("%d", &n);
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < 100000; j++){
			v[i][j].second = j;
		}
	}
	for(int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		v[i%2][a].first++;
	}
	std::sort(v[0], v[0]+100000, std::greater<P>());
	std::sort(v[1], v[1]+100000, std::greater<P>());
	if(v[0][0].second != v[1][0].second){
		printf("%d\n", n - v[0][0].first - v[1][0].first);
	}else{
		printf("%d\n", std::min(n-v[0][1].first-v[1][0].first, n-v[0][0].first-v[1][1].first));
	}
	return 0;
}


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

using ll = long long;

int main(){
    ll l, r;
    cin >> l >> r;
    ll ans = 3000;
    for(long long i = l; i <= min(r,l+2019) - 1; i++){
        for(long long j = i+1; j <= min(r,l+2019); j++){
            ans = min(ans, (i*j) % 2019);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int Multi(int p, int N) {
	int out = 1;
	for (int i = 0; i < N; i++) {
		out *= p;
	}
	return out;
}

int main() {
	int A[1001];
	int X;
	int cnt = 0;
	for (int i = 1; i <= 1000; i++) {
		A[i] = i;
	}
	scanf("%d", &X);
	for (int i = 2; i <= 6; i++) {
		for (int p = 1; Multi(p, i) <= X; p++) {
			A[Multi(p,i)] = 0;
		}
	}
	for (int i = 1; i <= X; i++) {
		if (A[i] == 0)cnt = i;
	}
	printf("%d\n", cnt);
	return 0;
}

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

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut sorted = a.clone();
    sorted.sort();
    let max = sorted[n-1];
    let secondary_max = sorted[n-2];
    for i in a {
        if i == max { println!("{}", secondary_max) }
        else { println!("{}", max) }
    }
}


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

int main() {long N;
cin >> N;
vector<long> l(N + 1); vector<long> r(N + 1);
erep(i, N) cin >> l.at(i) >> r.at(i);

long ans = 0;
erep(i, N){
  ans += r.at(i) - l.at(i) + 1;
}

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    int n; cin>>n;
    string str; cin>>str;
    int ans = 1;
    for(int i=0;i<n-1;i++)
    {
        if(str[i] != str[i+1]) ans++;
    }
    cout<<ans<<endl;    
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long int ll;
int main(){
	int H, W, D;
	pair<int, int> A[90000];
	int dist[90000];
	int Q;
	int L, R;
	cin >> H >> W >> D;
	fill(dist, dist + 90000, 0);
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			int a;
			cin >> a;
			a--;
			A[a] = make_pair(i, j);
		}
	}
	//for(int i = 0; i < H * W; i++) cout << A[i].first << " " << A[i].second << endl;
	for(int i = 0; i < D; i++){
		int index = i + D;
		while(index < H * W){
			dist[index] = dist[index - D] + abs(A[index].first - A[index - D].first) + abs(A[index].second - A[index - D].second);
			index += D;
		}
	}
	//for(int i = 0; i < H * W; i++) cout << dist[i] << endl;
	//for(int i = 0; i < H * W; i++) cout << A[i].first << " " << A[i].second << endl;
	cin >> Q;
	for(int i = 0; i < Q; i++){
		cin >> L >> R;
		L--; R--;
		cout << dist[R] - dist[L] << endl;
	}
	return 0;
}

Measured memory_bytes: 2176
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, K, x[111];

  std::cin >> N >> K;

  for (int i = 0; i < N; i ++)
    std::cin >> x[i];

  int s = 0;

  for (int i = 0; i < N; i ++)
    s += std::min(x[i], K - x[i]);

  std::cout << s * 2 << std::endl;

  return 0;
}


Measured memory_bytes: 256
/* nothing is impossible */
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;                                                                                           
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}             
const ll N=1000002;
ll par[N];
ll bin(ll n)
{
  vi k;
  while(n)
  {
    k.pb(n%2);
    n/=2;
  }
  ll ans=0;
  ll y=0;
  forn(i,k.size())
  {
    ans+=k[i]*(mpow(10,y));
    y++;
  }
  return ans;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin>>n;
  ll cnt=0;
  forn(i,n)
  {
    ll x;
    cin>>x;
    if(x&1) cnt++;
  }
  if(cnt&1) cout<<"NO";
  else cout<<"YES\n";
  return 0;   
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
from functools import reduce

X = 10 ** 9 + 7

def main() -> int:
    ls = sys.stdin.read().splitlines()
    [n, k] = [int(x) for x in ls[0].split(' ')]
    xs = [int(x) for x in ls[1].split(' ')]
    first = [len([x for x in xs[:i] if x > xs[i]]) for i in range(n)]
    xsxs = xs * 2
    ds = [
            len([x for x in xsxs[:i] if x > xsxs[i]]) - first[i - n]
            for i in range(n, 2 * n)]
    ss = [k * (2 * first[i] + (k - 1) * ds[i]) // 2 for i in range(n)]
    print(sum(ss) % X)
    return 0


if __name__ == "__main__":
    exit(main())

# vim:fenc=utf-8 ff=unix ft=python ts=4 sw=4 sts=4 fdm=indent fdl=0 fdn=1:
# vim: si et cinw=if,elif,else,for,while,try,except,finally,def,class:


Measured memory_bytes: 3940
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

const int MAXN = 300;
const int MOD = 1000000007;
const int INF = 2000000000;
const double PI = 3.14159265358979;
const int dir_4r[] = { -1, 1, 0, 0 };
const int dir_4c[] = { 0, 0, -1, 1 };
const int dir_8r[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int dir_8c[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main()
{
	int n;
	cin >> n;
	cout << "ABC" << n << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
n,q = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n-1)]
e = [list() for _ in range(n)]
for a,b in ab:
    e[a-1] += [b-1]
    e[b-1] += [a-1]
px = [list(map(int,input().split())) for _ in range(q)]
omomi = [0]*n
for p,x in px:
    omomi[p-1] += x

visited = [0]*n
visited[0] = 1
stack = [0]

while stack:
    v = stack.pop()
    for k in e[v]:
        if visited[k]==0:
            omomi[k] += omomi[v]
            visited[k] = 1
            stack.append(k)

print(*omomi)

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

#define N 100010
int ans = 0;
int n, k;
vi a(N);
vii G(N, vi());

int dfs(int now) {
	int i;
	int height = 0;
	for (i = 0; i < G[now].size(); i++) {
		height = max(height, dfs(G[now][i]) + 1);
	}
	if (height == k - 1 && a[now] != 0) {
		ans++;
		return -1;
	}
	else {
		return height;
	}
}

int main() {
	int i, j;
	cin >> n >> k;
	cin >> a[0];
	a[0]--;
	if (a[0] != 0) {
		a[0] = 0;
		ans++;
	}
	for (i = 1; i < n; i++) {
		cin >> a[i];
		a[i]--;
		G[a[i]].push_back(i);
	}
	dfs(0);
	cout << ans << endl;
}

Measured memory_bytes: 10752
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string S; cin >> S;
	if (S == "Sunny") cout << "Cloudy" << endl;
	else if (S == "Cloudy") cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
}


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

int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int B[N];
  for(int i=0;i<N;i++){
    cin >> B[i];
  }
  int C[N-1];
  for(int i=0;i<N-1;i++){
    cin >> C[i];
  }
  int ans = 0;
  for(int i=0;i<N;i++){
    if(A[i-1]+1 == A[i]){
      int iter = A[i-1]-1;
      ans += C[iter] + B[i];
    }else{
      ans += B[i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

string Sp, T;
// vector<int> Vs{};
int lastInd = -1;

bool could(int i) {
  for (int j = 0; j < T.size(); ++j) {
    if ((i + j) < Sp.size()) {
      if (Sp[i + j] != '?' && Sp[i + j] != T[j]) {
        return false;
      }
    }
    else {return false;}
  }
  return true;
}

bool findLast() {
  for (int i = 0; i < Sp.size(); ++i) {
    if (could(i)) {
      lastInd = max(i, lastInd);
    }
  }
  if (lastInd >= 0) {return true;}
  else {return false;}
}

void restore() {
  for (int j = 0; j < T.size(); ++j) {
    Sp[lastInd + j] = T[j];
  }

  for (int i = 0; i < Sp.size(); ++i) {
    if (Sp[i] == '?') {Sp[i] = 'a';}
  }
}

int main(void){
    // Here your code !
    cin >> Sp;
    cin >> T;
    if (!findLast()) {printf("UNRESTORABLE\n");}
    else {
      restore();
      for (int i = 0; i < Sp.size(); ++i) {printf("%c", Sp[i]);}
      printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define ll long long int
#define ld long double
#define ull unsigned long long
const double pi=3.14159265358979323846;
using namespace std;

ll ipow(ll base, ll exp)
{
    ll result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }
    return result;
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    ull gr=pow(10,18);
    ull n;
    cin>>n;
    ull a[n];
    for(ull i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    ull sum=a[0],g=1;
    if(a[0]==0)
    cout<<"0"<<"\n";
    else
    {
        ull temp=gr/a[0];
        for(ull i=1;i<n;i++)
        {
            if(a[i]>temp)
            {
                g=0;
                break;
            }
            else
            {
                sum*=a[i];
                temp=gr/sum;
            }
        }
        if(g==0)
        cout<<"-1"<<"\n";
        else
        cout<<sum<<"\n";
    }
    
}

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

const int MX = 200005;
vector<int> to[MX];
int t[MX];
int c[MX];
ll ans[MX];
ll f(ll n) { return n*(n+1)/2;}

int tfs(int v, int p=-1) {
  t[v] = 1;
  for (int u : to[v]) {
    if (u == p) continue;
    t[v] += tfs(u,v);
  }
  return t[v];
}

stack<int> st[MX];
int d[MX], remsz[MX];
void dfs(int v, int p=-1) {
  st[c[v]].push(v);
  for (int u : to[v]) {
    if (u == p) continue;
    d[v] = t[u];
    dfs(u,v);
    ans[c[v]] -= f(d[v]);
  }
  st[c[v]].pop();
  if (st[c[v]].size()) {
    d[st[c[v]].top()] -= t[v];
  } else {
    remsz[c[v]] -= t[v];
  }
}

int main() {
  int n;
  cin >> n;
  rep(i,n) cin >> c[i], c[i]--;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  tfs(0);
  rep(i,n) ans[i] = f(n);
  rep(i,n) remsz[i] = n;
  dfs(0);
  rep(i,n) ans[i] -= f(remsz[i]);
  rep(i,n) cout << ans[i] << endl;
  return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef double ld;
int main()
{ 
ios_base::sync_with_stdio(false);

cin.tie(NULL);
//freopen("input.txt", "r", stdin);
//freopen("output.txt","w",stdout);
ll a,b;
cin>>a>>b;
ll s[1000];
for(ll i=1;i<=999;i++)
{
   ll k=((i+1)*i)/2;
   s[i]=k;
}
for(ll i=1;i<=999;i++)
{
    if((s[i+1]-s[i])==(b-a))
    {
        cout<<s[i]-a;
        break;
    }
}
return 0;
}		


Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_N = 20050;
int N, K;
int p[MAX_N];
long long a[MAX_N], b[MAX_N];

long long a_pos[MAX_N] = {};
long long b_pos[MAX_N] = {};
long long a_pos_ac[MAX_N] = {};
long long b_pos_ac[MAX_N] = {};

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> p[i];
    }

    for (int i = 1; i <= N; i++) {
        a_pos[p[i]+1] = N - i;
        b_pos[p[i]-1] = N - i;
    }

    for (int i = 1; i <= N; i++) {
        a_pos_ac[i] = a_pos_ac[i-1] + a_pos[i];
    }

    for (int i = N; 1 <= i; i--) {
        b_pos_ac[i] = b_pos_ac[i+1] + b_pos[i];
    }

    for (int i = 1; i <= N; i++) {
        a[i] = i + a_pos_ac[i];
        b[i] = N - i + 1 + b_pos_ac[i];
    }

    for (int i = 1; i <= N; i++) {
        std::cout << a[i];
        if (i == N) {
            std::cout << std::endl;
        } else {
            std::cout << " ";
        }
    }

    for (int i = 1; i <= N; i++) {
        std::cout << b[i];
        if (i == N) {
            std::cout << std::endl;
        } else {
            std::cout << " ";
        }
    }

    return 0;
}

Measured memory_bytes: 1664
use std::io;
fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned();
    let mut ws = s.split_whitespace();
    let n: i32 = ws.next().unwrap().parse().unwrap();
    let a: i32 = ws.next().unwrap().parse().unwrap();
    let b: i32 = ws.next().unwrap().parse().unwrap();
 
    solve(n, a, b);
}

fn ketawa(a: i32) -> i32{
    if a == 0{
        return 0;
    }
    else {
        return a % 10 + ketawa(a/10);
    }
}

fn solve(n: i32, a: i32, b: i32){
    let mut sum = 0;
    for i in (1..n+1){
        if ketawa(i) <= b && ketawa(i) >= a {
            sum += i;
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;
template <class T> using vec_alias = ::std::vector<T>;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        // cout << " " << *t++;
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

template <template <class> class Container> class union_find {
  protected:
    class node_type;

  public:
    using container_type = Container<node_type>;
    using size_type = typename container_type::size_type;

  protected:
    class node_type {
      public:
        typename union_find::size_type parent;
        typename union_find::size_type size;
    };

    container_type tree;

  public:
    union_find() : tree() {}
    explicit union_find(const size_type size) : tree(size, {0, 1}) {
        for(size_type i = 0; i < size; ++i)
            tree[i].parent = i;
    }

    bool empty() const { return tree.empty(); }
    size_type size() const { return tree.size(); }

    size_type find(size_type x) {
        assert(x < size());
        while(tree[x].parent != x)
            x = tree[x].parent = tree[tree[x].parent].parent;
        return x;
    }
    bool same(const size_type x, const size_type y) {
        assert(x < size());
        assert(y < size());
        return find(x) == find(y);
    }
    size_type size(const size_type x) {
        assert(x < size());
        return tree[find(x)].size;
    }

    ::std::pair<size_type, size_type> unite(size_type x, size_type y) {
        assert(x < size());
        assert(y < size());
        x = find(x);
        y = find(y);
        if(x != y) {
            if(tree[x].size < tree[y].size) ::std::swap(x, y);
            tree[x].size += tree[y].size;
            tree[y].parent = x;
        }
        return {x, y};
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    union_find<vec_alias> uf(n);

    int c, x, y;
    rep(i, q) {
        cin >> c >> x >> y;
        if(c)
            cout << uf.same(x, y) << "\n";
        else
            uf.unite(x, y);
    }
}



Measured memory_bytes: 3212
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long H, W;
    scan(H, W);
    long N = lread();
    auto A = aryread();
    auto ans = new long[](H * W);
    {
        long i;
        foreach (j, a; A)
        {
            ans[i .. i + a] = j + 1;
            i = i + a;
        }
    }
    foreach (i; 0 .. H * W)
    {
        long h = i / W;
        long w = (h % 2 == 0) ? (i % W) : (W - (i % W) - 1);
        writeln(ans[h * W + w]);
    }
}


Measured memory_bytes: 2428
ns, _hs, *_ = ARGF.read.split("\n").map { |e| e.split }
hs = _hs.map { |e| e.to_i }
i = 0
as = hs.map {
  0
}
loop {
  ps = hs.zip(as).map { |e|
    h, a = e
    h - a
  }
  # p ps
  if ps.reduce(0) { |acc, e| acc + e } == 0
    puts i
    exit
  end
  flag = false
  ps.map.with_index { |e, i|
    if e == 0
      if flag
        break
      end
    else
      as[i] += 1
      flag = true
    end
    
  }
  i += 1
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int M=200005,Mod=1e9+7;
int n,A[M],B[M],m=0;
ll pre[M],dp[M];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&A[i]);
	for(int i=1;i<=n;i++)
		if(A[i]!=A[i-1])B[++m]=A[i];
	n=m;
	dp[0]=1;
	for(int i=1;i<=n;i++){
		dp[i]=(dp[i-1]+pre[B[i]])%Mod;
		pre[B[i]]=(pre[B[i]]+dp[i-1])%Mod;
	}
	printf("%lld\n",dp[n]);
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  long long t = n / (a + b);
  n -= t * (a + b);
  t *= a;
  t += min(a, n);
  cout << t << endl;
  return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

void Main() {
  int n;
  cin >> n;
  int i = 1;
  rep(j, n) {
    int a;
    cin >> a;
    if (a == i) {
      i++;
    }
  }
  if (i == 1) {
    cout << -1 << endl;
    return;
  }
  cout << n - i + 1 << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
open String

let still_tbd s =
  let y,m,d = ( int_of_string (sub s 0 4),
                int_of_string (sub s 5 2),
                int_of_string (sub s 8 2) )
  in
    if y >= 2020 then "TBD"
                 else if y = 2019 then if m >= 5 then "TBD"
                                                 else "Heisei"
                                  else "Heisei"

let () = Scanf.scanf "%s" still_tbd |> Printf.printf "%s\n"

Measured memory_bytes: 3700
#include<bits/stdc++.h>
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define fori(i,a,b) for(int i=a;i<=b;i++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define fs first
#define sc second


int main()
{
    ll n,tmp,ans=0;
    cin>>n;
    unordered_map<ll,ll> umap;
    ll cnt=0;
    for(ll i=1;i<n+1;i++)
    {   
        umap[i]=cnt++;
    }
    for( ll i =0;i<n;i++)
    {
        cin>>tmp;
        if(umap[tmp]!=i)ans++;
    }
    if(!(ans == 0 || ans == 2))
    cout<<"NO";
    else
    {
        cout<<"YES";
    }
    return 0;
}

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

#define MAX_N (55L)
#define MAX_A (55555L)

int main() {
  // read inputs
  int N;
  scanf("%d", &N);

  // find primes less than or equal to 55,555
  int is_primes[MAX_A + 1];
  for (int i = 2; i <= MAX_A; i++) {
    is_primes[i] = 1;
  }
  for (int i = 2; i <= MAX_A; i++) {
    if (is_primes[i]) {
      for (int j = 2 * i; j <= MAX_A; j += i) {
        is_primes[j] = 0;
      }
    }
  }

  // find primes where mod 5 is equal to 1
  int cnt = 0;
  for (int i = 2; i <= MAX_A; i++) {
    if (is_primes[i] && i % 5 == 1) {
      printf("%d ", i);
      cnt++;
      if (cnt >= N) {
        break;
      }
    }
  }
  printf("\n");
}

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

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

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

  int n;
  cin >> n;

  string command;
  int x, y;
  string sr;
  rep(i, n) {
    cin >> command;
    if(command == "replace") {
      cin >> x >> y >> sr;
      s.replace(x, y-x+1, sr);
    } else {
      cin >> x >> y;
      if(command == "reverse") {
        reverse(&s[x], &s[y]+1);
      }
      if(command == "print") {
        cout << s.substr(x, y-x+1) << endl;
      }
    }
  }
}



Measured memory_bytes: 3164
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define ll long long

// dp[i][j] : ホテルiからpow(2,j)日で移動できる最も右のホテル
int dp[100000][31];

// ホテルsからk日後にどのホテルに行くか
int get(int s, int k) {
	int h = s;
	for (int i = 0; i < 31; ++i)
		if ((1 << i) & k)
			h = dp[h][i];
	return h;
}

// ホテルsからホテルtまでの必要日数
int days(int s, int t) {
	if (s > t) return days(t, s);
	int ng = 0, ok = 1000000001;
	while (ok - ng > 1) {
		int mid = (ok + ng) / 2;
		if (get(s, mid) >= t) ok = mid;
		else ng = mid;
	}
	return ok;
}

signed main() {
	int n; cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; ++i)
		cin >> x[i];
	int l; cin >> l;

	/* dpを構築 */
	// j = 0を計算
	for (int i = 0; i < n; ++i) {
		auto iter = upper_bound(x.begin(), x.end(), x[i] + l);
		dp[i][0] = iter - x.begin() - 1;
	}
	// j > 0を構築
	for (int j = 1; j < 31; ++j)
		for (int i = 0; i < n; ++i)
			dp[i][j] = dp[dp[i][j - 1]][j - 1];

	int q; cin >> q;
	while (q--) {
		int a, b; cin >> a >> b;
		cout << days(--a, --b) << endl;
	}

	return 0;
}

Measured memory_bytes: 13312
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
    if A[i] == 0:
        print(0)
        exit()
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > 1e18:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 21568
N,h=gets.chomp.split(" ").map(&:to_i)
array=[]
max_a = 0
sorted_b = []
N.times do
    a,b=gets.chomp.split(" ").map(&:to_i)
    if max_a < a
        max_a = a
    end
    index = sorted_b.bsearch_index {|x|x>=b} || -1
    sorted_b.insert(index, b)
end

ret = 0
sorted_b.reverse.each do |b|
    break if b < max_a
    h -= b
    ret+=1
    if h <= 0
        puts ret
        exit
    end
end
ret += h/max_a
ret += 1 if h%max_a != 0
puts ret


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

int main(){
  vector<int> a(5),b(5),c(5);
  for(int i=0;i<5;i++){
    cin >> a[i];
    b[i]=(a[i]+9)/10*10;
    c[i]=b[i]-a[i];
  }
  cout << b[0]+b[1]+b[2]+b[3]+b[4]-max({c[0],c[1],c[2],c[3],c[4]})<< endl;
}

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

#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>

const int MOD = 100000007;
const int maxn = 2e5 + 10;
const int maxm = 3e5 + 10;
const double PI = acos(-1.0);



int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin >> n;
    cout << 180 * (n - 2) << endl;
}



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

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

	char c[2][3];
	for (int i = 0; i < 2; i++)for (int j = 0; j < 3; j++) {
		cin >> c[i][j];
	}
	if (c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]) {
		cout << "YES";
		return 0;
	}
	cout << "NO";
}

Measured memory_bytes: 256
N = int(input())
x = []
y = []
for i in range(0,N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
#print(x)
total=0
for j in range(0,N):
    if x[j]<y[j]:
        total=total+y[j]-x[j]+1
    elif x[j]==y[j]:
        total+=1    
print(total)

Measured memory_bytes: 3064
import java.util.Scanner;

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

        while (sc.hasNextInt()) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(String.valueOf(a+b).length());
        }
    }
}


Measured memory_bytes: 26520
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
ll n,a,b,t,ans;
int main(){
	cin>>n>>a>>b;
	t=n/(a+b);
	n%=(a+b);
	ans=t*a+min(n,a);
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    ll x,k,d;
    cin>>x>>k>>d;
    if(x==0){
        if(k&1)cout<<d;
        else cout<<0;
    }
    else if(x>0){
        if(k==x/d)cout<<abs(x-k*d);
        else if(k>(x/d)){
            if((k-(x/d))&1)cout<<abs(x-(x/d)*d-d);
            else cout<<abs(x-(x/d)*d);
        }
        else cout<<abs(x-k*d);
    }
    else {
        if(k==x/d)cout<<abs(x+k*d);
        else if(k>abs(x/d)){
            if((k-abs(x/d))&1)cout<<abs(x-(x/d)*d+d);
            else cout<<abs(x-(x/d)*d);
        }
        else cout<<abs(x+k*d);

    }









    
    return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=998244353;
struct UnionFind{
    vector<int> par,sizes;
    UnionFind(int n):par(n+1),sizes(n+1,1){
        rep2(i,1,n)par[i]=i;
    }
    int find(int x){
        return (x==par[x]?x:par[x]=find(par[x]));
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return ;
        if(sizes[x]<sizes[y]){
            swap(x,y);
        }
        par[y]=x;
        sizes[x]+=sizes[y];
    }
    bool same(int x,int y) {return (find(x)==find(y));}
    int size(int x) {return sizes[find(x)];}
};
int solve_min(vector<pii> G,int n){
    UnionFind uf(n);
    for(auto e:G){
        uf.unite(e.first,e.second);
    }
    int cnt=0;
    rep2(i,1,n){
        if(uf.par[i]==i)cnt++;
    }
    return cnt-1;
}

main(){
    int n;
    cin>>n;
    cout<<(n-1)/2;
}


Measured memory_bytes: 256
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| iterator.next().unwrap().parse().unwrap())
        .collect();

    if n % 3 != 0 {
        return if a.iter().all(|it| *it == 0) {
            "Yes".to_string()
        } else {
            "No".to_string()
        }
    }

    let mut counts: HashMap<usize, usize> = HashMap::new();
    for ai in a {
        *counts.entry(ai).or_insert(0) += 1;
    }

    let len = counts.len();
    return if len == 1 {
        if counts.contains_key(&0) {
            "Yes".to_string()
        } else {
            "No".to_string()
        }
    } else if len == 2 {
        if !counts.contains_key(&0) {
            return "No".to_string();
        }

        let count_zero = counts.get(&0).unwrap();
        if n / 3 == *count_zero {
            "Yes".to_string()
        } else {
            "No".to_string()
        }
    } else if len == 3 {
        let vec: Vec<usize> = counts.keys().map(|it| *it).collect();
        let a = vec[0];
        let b = vec[1];
        let c = vec[2];
        if *counts.get(&a).unwrap() == n / 3
            && *counts.get(&b).unwrap() == n / 3
            && *counts.get(&c).unwrap() == n / 3
            && a ^ b ^ c == 0 {
            "Yes".to_string()
        } else {
            "No".to_string()
        }
    } else {
        "No".to_string()
    }
}


Measured memory_bytes: 12540