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

using namespace std;

#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define Debug(x) cout << #x " = " << (x) << endl
#define SORT(a) sort(a.begin(), a.end())
#define SORTR(a) sort(a.rbegin(), a.rend())

int main()
{
    IOS;

    int x, sum = 0;
    cin >> x;

    int y = x / 500;

    sum += (2 * y * 500);
    x -= (y * 500);

    y = x / 5;
    sum += (y * 5);

    cout << sum << endl;

    return 0;
}


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

int main() {
    int n,q;
    string s;
    cin >> n >> q >> s;
    vector<int> a(n);
    for(int i = 0; i < n-1; i++) {
        if(s[i]=='A' && s[i+1]=='C') a[i]=1;
    }

    vector<int> b(n+1);
    b[0]=0;
    for(int i = 1; i < n+1; i++) {
        b[i] = b[i-1]+a[i-1];
    }

    for(int i = 0; i < q; i++) {
        int l,r;
        cin >> l >> r;
        if(r==n){
            cout << b[r]-b[l-1] << endl;
            continue;
        }
        if(a[r-1]==1){
            cout << b[r]-b[l-1]-1 << endl;
        }
        else{
            cout << b[r]-b[l-1] << endl;
        }

    }

    return 0;
}

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

int main(){
  int n,k;
  string s;
  cin >> n >> k >> s;
  if(s.at(k-1)=='A'){
    s.at(k-1)='a';
  }else if(s.at(k-1)=='B'){
    s.at(k-1)='b';
  }else{
    s.at(k-1)='c';
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
using System;

namespace _0257
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split();
            if((x[0]=="1"&&x[1]=="1")||x[2]=="1")
            {
                Console.WriteLine("Open");
            }
            else
            {
                Console.WriteLine("Close");
            }
        }
    }
}

Measured memory_bytes: 8880
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
 
int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a + 1 == c) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type Abbreviation ---------- */
using ll = long long;

/* ---------- Constants ---------- */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */
template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    K--;

    ll dp[H+1][W];
    fill(dp[0], dp[H+1], 0);
    dp[0][0] = 1;

    for (int i = 0; i < H; i++) {
        for (int mask = 0; mask < (1 << W-1); mask++) {
            bool flag = false;
            for (int j = 0; j < W-2; j++) {
                if ((mask >> j) % 4 == 3) flag = true;
            }
            if (flag) continue;

            int perm[W];
            for (int i = 0; i < W; i++) perm[i] = i;

            for (int j = 0; j < W-1; j++) {
                if ((mask >> j) & 1 == 1) {
                    perm[j] = j+1;
                    perm[j+1] = j;
                }
            }

            for (int j = 0; j < W; j++) {
                dp[i+1][perm[j]] += dp[i][j];
                dp[i+1][perm[j]] %= MOD;
            }
        }
    }

    cout << dp[H][K] << endl;
}

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


int main(){
    int N;
    cin >> N;
    vector<int> s(N);
    for(int i=0; i<N; i++) cin >> s[i];
    
    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    
    int sum=0;
    for(int i=0; i<N; i++){
        sum += s[i];
    }
    
    bool flag=false;
    if(sum%10!=0){
        cout << sum << endl;
        flag=true;
    }
    else{
        for(int i=N-1; i>=0; i--){
            if(s[i]%10==0) continue;
            sum -= s[i];
            if(sum%10!=0){
                cout << sum << endl;
                flag=true;
                break;
            }
        }
    }
    if(!flag) cout << 0 << endl;
}


Measured memory_bytes: 256
class List
  attr_accessor :value, :prev, :next

  def initialize(value, prev, nxt)
    @value = value
    @prev = prev
    @next = nxt
  end
end

@bampei = List.new(nil, nil, nil)

def insert(x)
  list = List.new(x, nil, @bampei.prev)
  if(@bampei.prev.nil?)
    @bampei.prev = list
    @bampei.next = list
  else
    @bampei.prev.prev = list
    @bampei.prev = list
  end
end

def delete(x)
  target = @bampei.prev
  while(!target.nil?)
    if target.value == x
      if target.next && target.prev
        target.next.prev = target.prev
        target.prev.next = target.next
      elsif target.next
        target.next.prev = nil
        @bampei.prev = target.next
      elsif target.prev
        @bampei.next = target.prev
        target.prev.next = nil
      else
        @bampei.prev = nil
        @bambei.next = nil
      end
      break
    end
    target = target.next
  end
end

def deleteFirst
  @bampei.prev = @bampei.prev.next
  if @bampei.prev
    @bampei.prev.prev = nil
  end
end

def deleteLast
  if(@bampei.next&.prev)
    @bampei.next.prev.next = nil
    @bampei.next = @bampei.next.prev
  else
    @bampei.next = nil
    @bampei.prev = nil
  end
end

n = gets.to_i
n.times do
  input = gets.split(" ")
  if input.size == 2
    send(input[0], input[1].to_i)
  else
    send(input[0])
  end
end

target = @bampei.prev
outputs = []
while(!target.nil?)
  outputs << target.value
  target = target.next
end
puts outputs.join(' ')



Measured memory_bytes: 59224
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = list(map(lambda x: int(x) - 1, S()))
    ans = 1
    if not 1 in a:
        ans *= 2
        for i in range(n):
            a[i] >>= 1
    res = 0
    for i in range(n):
        #  ~ Lucas の定理から ~
        #  n C k において
        #  k の bitが立っているところについて
        #  n の bitが立っていない場合 n C k が 2の倍数になる
        #  これを超簡単にする方法 (Touristの提出を見た)
        if ((n - 1) & i == i):
            res ^= a[i] & 1
    print(res * ans)

    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 148268
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static class Lunch implements Comparable<Lunch>{
		String name;
		int weight;
		int capacity;
		int number;

		Lunch (String name, int weight, int capacity) {
			this.name = name;
			this.weight = weight;
			this.capacity = capacity;
			this.number = 0;
		}

		public int compareTo(Lunch o) {
			if (o.number != this.number) {
				return this.number - o.number;
			} else {
				return o.weight - this.weight;
			}
		}
	}

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		Lunch lunch[];
		int sumWeight;

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			lunch = new Lunch[n];
			sumWeight = 0;
			for (int i = 0; i < n; i++) {
				String name = sc.next();
				int weight = sc.nextInt();
				int capacity = sc.nextInt();
				lunch[i] = new Lunch(name, weight, capacity);
				sumWeight += weight;
			}
			Arrays.sort(lunch);
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (lunch[j].number == 0 && sumWeight - lunch[j].weight <= lunch[j].capacity) {
						lunch[j].number = i + 1;
						sumWeight -= lunch[j].weight;
						break;
					}
				}
			}
			Arrays.sort(lunch);
			for (int i = 0; i < n; i++) {
				System.out.println(lunch[i].name);
			}
		}
	}
}

Measured memory_bytes: 12000
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

const int MOD = 998244353;
const int MAX = 2100000;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

ll rui(ll a,ll b){
     ll ans=1;
     while(b>0){
        if(b&1) ans=ans*a%MOD;
        a=a*a%MOD;
        b/=2;
    }
     return ans;
}

int main() {
    int n, m, k; cin >> n >> m >> k;
    COMinit();

    ll sum = 0;
    rep(i, k+1){
        ll num = (m * rui(m-1, n-1-i) % MOD) * COM(n-1, i) % MOD;
        sum = (sum + num) % MOD;
    }
    cout << sum  << ln;
}


Measured memory_bytes: 52844
# include <iostream>
using namespace std;
int main(){
    int month,day,sum;
    cin >> month >> day;
    while(month != 0){
        sum = 0;
        switch(month){
            case 1: sum = day; break;
            case 2: sum = 31+day; break;
            case 3: sum = 60+day; break;
            case 4: sum = 91+day; break;
            case 5: sum = 121 + day;break;
            case 6: sum = 152 + day;break;
            case 7: sum = 182 +day;break;
            case 8: sum = 213 + day;break;
            case 9: sum = 244 +day;break;
            case 10: sum = 274 +day;break;
            case 11: sum = 305 + day;break;
            case 12: sum = 335 +day;break;
            }
            sum %= 7;
        switch(sum){
            case 1: cout << "Thursday" << endl ;break;
            case 2: cout << "Friday" << endl ;break;
            case 3: cout << "Saturday" << endl ;break;
            case 4: cout << "Sunday" << endl ;break;
            case 5: cout << "Monday" << endl ;break;
            case 6: cout << "Tuesday" << endl ;break;
            case 0: cout << "Wednesday" << endl ;break;
        }
        cin >> month >> day;
        }
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
#define INF 1e9
typedef pair<int, int> P;

/* 　"assert"    assert(A：条件式)で　Aが真なら処理は続行、偽ならプログラムを終了する　*/

/*　　ラムダ式　　 auto a = [キャプチャ](パラメータ){ 処理 }  */

/* string型　メンバ関数　substr()    replace()  */

int main (){
    int n; cin >> n;
    vector<pair<int, int>> p(n);
    rep(i,n){
        int x, l; cin >> x >> l;
        p[i].first = x + l;
        p[i].second = x - l;
    }
    sort(all(p));
    int now = p[0].first;
    int ans = 1;
    rep2(i,1,n){
        if(now <= p[i].second){
            ans++;
            now = p[i].first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,a,b,count=0;
    int food[40]={0};
    cin >> n >> m ;
    for(int i=0;i<m+1;i++){
        food[i]=0;
    }
    for(int i=0;i<n;i++){
        cin >> a;
        for(int j=0;j<a;j++){
            cin >> b;
            food[b]++;
        }
    }
    for(int i=0;i<m+1;i++){
        if(food[i]==n){
            count +=1;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	int N;
	cin >> N;

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

	ll ans = 0;

	// 倒せるだけ倒す
	for (int i = 0; i < N; i++) {

		if (A[i] < B[i]) {
			ans += A[i];
			B[i] -= A[i];
			A[i] = 0;

			if (A[i + 1] <= B[i]) {
				ans += A[i+1];
				A[i +1] = 0;
			}
			else {
				ans += B[i];
				A[i + 1] -= B[i];
			}

		}
		else {
			ans += B[i];
			A[i] -= B[i];
		}
	}

	cout << ans;







}




Measured memory_bytes: 1792
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<pair<ll, ll>> v(n);
    rep(i, n) {
        ll x, l;
        cin >> x >> l;
        v[i] = make_pair(x+l, x-l);
    }
    sort(v.begin(), v.end());
    int ans = 0;
    ll now = -1e18;
    rep(i, n) {
        if (now <= v[i].second) {
            ++ans;
            now = v[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4808
#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; using namespace atcoder;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int H, W;
string S[50];
vector<pair<int,int>> circles;
int dist[101][50][50];
ll BASE = inf;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> H >> W;
	rep(y, 0, H) cin >> S[y];

	int id = 0;
	rep(y, 0, H) rep(x, 0, W) if (S[y][x] == 'o') {
		circles.push_back({ x, y });
		rep(xx, 0, W) rep(yy, 0, H) dist[id][yy][xx] = inf;
		queue<tuple<int,int, int>> que;

		dist[id][y][x] = 0;
		que.push(make_tuple(x, y, 0));
		while (!que.empty()) {
			int x, y, cst;
			tie(x, y, cst) = que.front(); que.pop();

			if (x + 1 < W && S[y][x + 1] != '#' && dist[id][y][x + 1] == inf) {
				dist[id][y][x + 1] = cst + 1;
				que.push(make_tuple(x + 1, y, cst + 1));
			}

			if (y + 1 < H && S[y + 1][x] != '#' && dist[id][y + 1][x] == inf) {
				dist[id][y + 1][x] = cst + 1;
				que.push(make_tuple(x, y + 1, cst + 1));
			}
		}

		id++;
	}

	mcf_graph<int, ll> g(H * W + id + 2);
	int st = H * W + id;
	int gl = st + 1;

	rep(i, 0, id) {
		g.add_edge(st, H * W + i, 1, 0);
		rep(y, 0, H) rep(x, 0, W) if (dist[i][y][x] < inf) g.add_edge(H * W + i, y * W + x, 1, BASE - dist[i][y][x]);
	}
	rep(y, 0, H) rep(x, 0, W) if (S[y][x] != '#') g.add_edge(y * W + x, gl, 1, 0);
	
	ll ans = -(g.flow(st, gl).second - BASE * id);
	cout << ans << endl;
}







Measured memory_bytes: 9820
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
using namespace std;
 
int main() {
  ll D, N;
  cin >> D >> N;
  if(D == 0) {
    if(N == 100) cout << 101 << endl;
    else cout << N << endl;
  }
  else if(D == 1) {
    if(N == 100) cout << 10100 << endl;
    else cout << N * 100 << endl;
  }
  else if(D == 2) {
    if(N == 100) cout << 1010000 << endl;
    else cout << N * 10000 << endl;
  }
}


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

#define mod 1000000007
#define ll long long int
#define mk make_pair
#define pb push_back
#define xx first
#define yy second
#define ar array
#define del 1e-8

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }

double pi=3.141592653589793238;
const int M = 998244353;
const int Nmax=5005;
const int MM = 998244353;
const int N=1000005;


int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0);
	int T=1;
	//cin>>T;
	while(T--){
      int n;
      cin>>n;
      int k;
      cin>>k;
      vector<int> v;
      vector<ar<int,2>> kk;
      ll dp[n+1]={},sdp[n+1]={};
      while(k--){
        int l,r;
        cin>>l>>r;
        kk.pb({l,r});
      }
      sort(kk.begin(),kk.end());
      dp[1]=1,sdp[1]=1;
      for(int i=2;i<=n;i++){
        for(auto x:kk){
            if(x[0]>=i)break;
            else{
                int k=x[1];
                int f=min(k,i);
                int l=max(0,i-f-1);
                int r=i-x[0];
                (dp[i]+=(sdp[r]-sdp[l]+M)%M)%=M;
            }
        }
        sdp[i]=sdp[i-1];
        (sdp[i]+=dp[i])%=M;
      }
      cout<<dp[n]<<"\n";
    }
	return 0;
}


Measured memory_bytes: 6772
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N; cin >> N;
  string S; cin >> S;
  ll ans = 0;
  rep(i,10){
    rep(j,10){
      rep(k,10){
        int n1 = i;
        int n2 = j;
        int n3 = k;
        int now = 0;
        rep(n,N){
          if(now==0){
            if(S[n]-'0' == n1){
              now++;
            }
          }
          else if(now==1){
            if(S[n]-'0' == n2){
              now++;
            }
          }
          else if(now==2){
            if(S[n]-'0' == n3){
              now++;
            }
          }
        }
        if(now == 3) ans++;
      }
    }
  }

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


Measured memory_bytes: 384
<?php
$n = int();
$a = ints();

$total = array_sum($a);
$sub = 0;
$minDiff = 10**10;
foreach($a as $b){
  $sub+=$b;
  $diff = abs($total - $sub * 2);
  $minDiff = min($minDiff, $diff); 
}
echo $minDiff;

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n = read(), ans = 1;
  while (ans <= n)
    ans *= 2;
  print(ans / 2);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++)
		cin>>a[i];
	int c=0;
	for(int i=1; i<n-1; i++){
		if((a[i]>a[i-1] && a[i]<a[i+1]) || (a[i]<a[i-1] && a[i]>a[i+1]))
			c++;
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
root = {}
children = [0] * n

for i in range(n):
  id, k, *c = list(map(int, input().split()))
  for j in c:
    root[j] = id
  children[id] = c

for i in range(n):
  print('node {}: parent = '.format(str(i)), end='')
  p = [i]
  while True:
    try:
      p.append(root[p[-1]])
    except:
      break
  if len(p) == 1:
    print('-1, depth = 0, root, {}'.format(children[i]))
  else:
    print('{}, depth = {}'.format(str(p[1]), str(len(p) - 1)), end='')
    if children[i] == []:
      print(', leaf, []')
    else:
      print(', internal node, {}'.format(children[i]))



Measured memory_bytes: 24232
S = input()
Slist = list(S)
L = len(S)
if S[0] == 'A' and 'C' in S[2:L-1] and Slist.count('C') == 1:
    Slist.remove('A')
    Slist.remove('C') 
    flag = True
    for s in Slist:
        if s.isupper():
            flag = False
    if flag:
        print('AC')
        exit()
print('WA')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


int fun(vector<int> &v)
{
	sort(v.begin(),v.end());

	if(v.size()%2 == 1)
	{
		int ans = 0;
		int m = v[(v.size()/2)];

		for(int i = 0; i < v.size(); i++)
		{
			ans += abs(v[i]-m);
		}
		return ans;
	}
	else
	{
		int ans1 = 0,ans2 = 0;
		int m1 = v[v.size()/2];
		int m2 = v[v.size()/2 - 1];
		for(int i = 0; i < v.size(); i++)
		{
			ans1 += abs(v[i]-m1);
			ans2 += abs(v[i]-m2);
		}
		return min(ans1,ans2);
	}
}
int32_t main()
{

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

    IOS


    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; i++)cin >> v[i];

   	sort(v.begin(),v.end());

   int ans = 0;
   	for(int i = 0; i< k; i++)ans += v[i];


   		cout << ans;




    return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>
#include <set>

using namespace std;

#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int mod = 1e9 + 7;

inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }

inline int sub(int a, int b) { return a >= b ? a - b : a - b + mod; }

inline int mul(int a, int b) { return llint(a) * b % mod; }

int main(void) {
  ios_base::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;

  N *= 2;

  vector<int> A(K), B(K);
  for( int i = 0; i < K; ++i) {
    cin >> A[i] >> B[i];
    --A[i], --B[i];
  }

  vector<int> h(N+1);
  for (int i = 0; i <= N; i += 2) {
    h[i] = 1;
    for (int j = 0; j < i/2; ++j) {
      h[i] = mul(h[i], i - 2*j - 1);
    }
  }

  vector<vector<int>> f(N, vector<int>(N));
  vector<vector<int>> g(N, vector<int>(N));

  vector<bool> bio(N);

  int ret = 0;
  for (int d = 1; d < N; d += 2) {
    for (int i = 0; i + d < N; ++i) {
      int j = i + d;

      for (int k = 0; k < N; ++k) {
        bio[k] = false;
      }

      int done_in = 0, done_out = 0, ok = true;
      for (int k = 0; k < K; ++k) {
        if (i <= A[k] && A[k] <= j && i <= B[k] && B[k] <= j) {
          bio[A[k]] = bio[B[k]] = true;
          done_in += 2;
        } else if (!(i <= A[k] && A[k] <= j) && !(i <= B[k] && B[k] <= j)) {
          done_out += 2;
        } else {
          ok = false;
          break;
        }
      }

      if (!ok) continue;

      int cnt_in = d + 1 - done_in;
      int cnt_out = N - (d + 1) - done_out;

      int ways = h[cnt_in];
      int cnt = 0;
      for (int k = j; k > i; --k) {
        if (k != j) {
          ways = sub(ways, mul(h[cnt], f[i][k]));
        }
        if (!bio[k]) cnt++;
      }

      f[i][j] = ways;
      g[i][j] = mul(ways, h[cnt_out]);

      ret = add(ret, g[i][j]);
    }
  }

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


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

int f(int x){
	return x*x;
}
int main(){
	int i, n, d, S;
	while(cin >> d){
		S = 0;
		n = 600 / d;
		for (i = 1; i < n; i++) {
			S += f(i*d)*d;
		}
		cout << S << endl;
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using static System.Math;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] p = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int ans = 0;
        for (int i = 1;i < n - 1; i++)
        {
            if (p[i - 1] > p[i] && p[i] > p[i + 1])
                ans++;
            if (p[i - 1] < p[i] && p[i] < p[i + 1])
                ans++;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
// AtCoder Beginner Contest 096 - Problem B: Maximum Sum (https://atcoder.jp/contests/abc096/tasks/abc096_b) 
#include <bits/stdc++.h>

using namespace std;

int solve(int K, vector<int>& xs)
{
    sort(xs.begin(), xs.end());

    xs.back() *= (1 << K);

    return accumulate(xs.begin(), xs.end(), 0);
}

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

    vector<int> xs(3);

    for (int i = 0; i < 3; ++i)
        cin >> xs[i];

    int K;
    cin >> K;

    auto ans = solve(K, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
typedef long long ll;
using namespace std;

int main(void){
    int n;cin>>n;
    int a=n/100,b=(n%100)/10,c=n%10;
    if(a==9){
        cout<<999<<endl;
    }else{
        if(a==b&&b==c)cout<<n<<endl;
        else{
            if(n<=a*100+a*10+a)cout<<a*100+a*10+a<<endl;
            else cout<<(a+1)*100+(a+1)*10+a+1<<endl;
        }
    }
    
    return 0;
}

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

int main(void){
    int n, r;
    cin >> n >> r;
    
    int i;
    if (n >= 10) i = r;
    else i = r +  (100 * (10 - n));
    
    cout << i << endl;
}

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

#define MAX_N 1000
#define MAX_M 1000

int n, m;
string s, t;

int dp[MAX_N+1][MAX_M+1];

void solve() {
    for (int i=0; i<n; ++i) {
        for (int j=0; j<m; ++j) {
            if (s[i] == t[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else {
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }
}

int main() {
    int cnt;
    cin >> cnt;
    for(int i = 0; i < cnt; i++){
        cin >> s >> t;
        n = s.length();
        m = t.length();
        solve();
        cout << dp[n][m] << endl;
    }

}


Measured memory_bytes: 7080
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 101, K = 1e5+10;

int n, k;
int a[N];
int dp[2][K];

int add(int p, int q) {
  p += q;
  if (p >= MOD) p -= MOD;
  return p;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < K; i++) {
    dp[0][i] = 1;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      dp[1][j] = add(dp[0][j], MOD - (j - a[i] - 1 >= 0 ? dp[0][j-a[i]-1] : 0));
    }
    for (int j = 1; j <= k; j++) {
      dp[1][j] = add(dp[1][j-1], dp[1][j]);
    }
    swap(dp[0], dp[1]);
  }
  cout << (dp[0][k] + MOD - dp[0][k-1]) % MOD << nl;
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

char M(char a, char b){
    if(a=='T' && b=='F') return 'F';
    return 'T';
}

int main(){
    int n;
    cin >>n;
    vector<char> p(n);
    rep(i,n) cin >>p[i];

    char c = M(p[0], p[1]);
    for(int i=2; i<n; ++i) c = M(c,p[i]);
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 3196
import bisect
MOD = 1_000_000_007
n = int(input())
b = [int(input()) - 1 for _ in range(n)]

idx = 0
a = []
while idx < n:
    a.append(b[idx])
    while idx + 1 < n and b[idx] == b[idx + 1]:
        idx += 1
    idx += 1
n = len(a)


pos = [[] for _ in range(200001)]
for i in range(n):
    pos[a[i]].append(i)

dp = [0] * (n + 1)
dp[0] = 1
for i in range(n):
    j = bisect.bisect_right(pos[a[i]], i)
    if j < len(pos[a[i]]):
        dp[pos[a[i]][j]] += dp[i]
        dp[pos[a[i]][j]] %= MOD
    dp[i+1] += dp[i]
    dp[i+1] %= MOD

print(dp[n])


Measured memory_bytes: 50868
import java.awt.Point;
import java.util.Scanner;
import java.util.Set;
import java.util.function.LongSupplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static final long[] fal_rnd(long[] ar,LongSupplier sp){
		int l=-1,r=ar.length;
		while(l+1!=r)
			ar[Math.random()<0.5?++l:--r]=sp.getAsLong();
		return ar;
	}
	static final IntStream REPS(int v){
		return IntStream.range(0,v);
	};
	public static void main(String[] __){
		int n;
		while((n=s.nextInt())!=0) {
			Set<Point> set=REPS(n).mapToObj(i->new Point(s.nextInt(),s.nextInt())).collect(Collectors.toSet());
			int a=s.nextInt(),x=10,y=10;
			set.remove(new Point(x,y));
			
			for(int i=0;i<a;i++) {
				String m=s.next();
				int v=s.nextInt();
				for(int j=0;j<v;j++) {
					switch(m){
					case "N":
						y++;
						break;
					case "S":
						y--;
						break;
					case "W":
						x--;
						break;
					case "E":
						x++;
						break;
					}
					//System.out.printf("%d %d\n",x,y);
					set.remove(new Point(x,y));
				}
			}
			//System.out.println(set);
			System.out.println(set.isEmpty()?"Yes":"No");
		}
	}
}

Measured memory_bytes: 47068
def gcd(c,d):
    if c%d==0:
        return d
    else:
        return gcd(d,c%d)

def lcm(c,d):
    return c*d//gcd(c,d)

a,b,c,d = map(int,input().split())

l = lcm(c,d)
res = 0
bal = b-a+1
print(bal - ( (b//c-(a-1)//c) + (b//d-(a-1)//d) - (b//l-(a-1)//l) ))


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
ll n,a,b,ans;
int main(){
	n=read(),a=read(),b=read();
	ans+=n/(a+b)*a;
	n%=a+b;
	ans+=min(n,a);
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	string str,str2;
	
	if(s.size()%2==0)
	{
		for(int i=0; i<s.size()/2; i++)
			str+=s[i];
		for(int i=s.size()/2; i<s.size(); i++)
			str+=s[i];
	}
	else
	{
		for(int i=0; i<s.size()/2; i++)
			str+=s[i];
		for(int i=s.size()/2+1; i<s.size(); i++)
			str2+=s[i];
	}
	
	if(str==str2)
		cout<<"Yes"<< endl;
	else
		cout<<"No"<< endl;
		
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ull = unsigned long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i < n; ++i)
#define pb push_back
#define mp make_pair
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> H) {
  // main coding
  H[0]--;
  rep1(i,N){
    if(H[i]-H[i-1]>0) H[i]--;
    else if(H[i]==H[i-1]) continue;
    else{
      cout<<NO<<endl;
      return;
    }
  }
  cout<<YES<<endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> H(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &H[i]);
  }
  solve(N, std::move(H));
  return 0;
}


Measured memory_bytes: 1024
n=int(input())
arms=[]
for _ in range(n):
    x,l=map(int,input().split())
    arms.append([x-l,x+l])
arms.sort()
now=arms[0][1]
cnt=0
for arm in arms[1:]:
    if now<=arm[0]:
        now=arm[1]
    elif now<=arm[1]:
        cnt+=1
    else:
        cnt+=1
        now=arm[1]
print(n-cnt)

Measured memory_bytes: 20480
#include<iostream>
using namespace std;
int main()
{
    int n,b;
    cin>>n;
    b=n;
    int sum=0;
    while(n>0)
    {
      sum+=n%10;
      n/=10;
    }
    if(b%sum==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
 #include <cmath>
 
 using namespace std;
 
int main(){
long double a,b,c;
cin >> a >> b >> c;
long long d = c - a - b;
if ((d > 0) && (d * d > 4 * a * b))
cout << "Yes" ;else cout << "No";
return 0;
 }

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

int main() {
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n;
	cin>>n;
	int d[n];
	for(int i=0;i<n;i++)
		cin>>d[i];
	
	sort(d,d+n);
	cout<<d[n/2]-d[(n/2)-1]<<endl;
	return 0;
}


Measured memory_bytes: 640
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <set>
#include <cmath>
#include <algorithm>
#include <locale>

//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define For(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define F first
#define S second
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define ELM 100001 //問題によっては1000000001に変更

//限定
using namespace std;

signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    incin(h);
    incin(w);
    vector<string> a(h+2);
    string t;
    For(w+2, i){
        t.push_back('.');
    }
    
    For(h, i){
        cin >> a.at(i+1);
        a[i+1].insert(a[i+1].begin(), '.');
        a[i+1].push_back('.');
    }
    
    a[0]=t;
    a[h+1]=t;
    
//    For(h+2, i){
//        Pr(a[i]);
//    }
   string asn = "Yes";
    for (int i=1; i<=h; i++) {
        for (int j=1; j<=w; j++) {
            if (a[i][j]=='#') {
                int c = 0;
                if (a[i+1][j]=='#') {
                    c++;
                }
                if (a[i-1][j]=='#') {
                    c++;
                }
                if (a[i][j+1]=='#') {
                    c++;
                }
                if (a[i][j-1]=='#') {
                    c++;
                }
                
                if (c==0) {
                    asn = "No";
                }
            }
        }
    }
    Pr(asn);
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll x, y,a,b;
	cin>>x>>y;
	if(y%2==1) cout<<"No";
	else {
		b=y/2-x;
		a=x-b;
		if(a>=0 && b>=0) cout<<"Yes";
		else cout<<"No";
	}
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 5005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n; ulint prod = 1; bool of = false;
    const ulint M = 1e18;
    rep(i, n){
        ulint a; cin >> a;
        if(a == 0){
            prod = 0; of = false; continue;
        }
        if(M < prod*a || M/a < prod){
            of = true; continue;
        }
        prod *= a;
    }
    if(of) out(-1); else out(prod);
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

const ll INF = 1LL << 60;
const ll MOD = 1e9+7;

int main()
{
    int N,M;
    cin >> N >> M;
    vll dp(N+1);
    vint oks(N+1,true);
    REP(i,M){
        int a;
        cin >> a;
        oks[a] = false;
    }
    dp[0] = 1;
    for(int i=1; i<N+1; i++){
        if(oks[i]){
            dp[i] += dp[i-1];
            dp[i] %= MOD;
            if(i != 1){
                dp[i] += dp[i-2];
                dp[i] %= MOD;
            }
        }
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 4576
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define mod 1000000007
ll powe(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}

ll s;
ll p[2001];

int main(){
  scanf("%lld",&s);

  p[0]=0;
  p[1]=0;
  p[2]=0;
  p[3]=1;
  for(int i=4;i<=s;i++){
    p[i]=p[i-1]+p[i-3];
    p[i]%=mod;}
  printf("%lld\n",p[s]);
  
  return 0;
}


Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
int n,a[maxn],res[maxn],ttt=0;
vector<int> ver[maxn];
long long ans=0;
inline void dfs(int x,int fat)
{
	res[x]=a[++ttt];
	for(int i=0;i<(int)ver[x].size();i++)
	{
		int y=ver[x][i];
		if(y==fat) continue;
		dfs(y,x);
	}
}
int main()
{
	cin>>n;
	for(int i=1,x,y;i<n;i++)
	{
		cin>>x>>y;
		ver[x].push_back(y);
		ver[y].push_back(x);
	}
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1,greater<int>());
	for(int i=2;i<=n;i++) ans+=a[i];
	dfs(1,0);
	cout<<ans<<endl;
	for(int i=1;i<=n;i++) cout<<res[i]<<' ';
}

Measured memory_bytes: 6592
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)

int gcd(int x,int y){ return (!y ? x : gcd(y, x%y)); }
const int maxn = 1e6 + 10;
int a[maxn], b[maxn];
bool cmp(int i,int j){
	return b[i] < b[j];
}
int32_t main(){
	IOS;
	int n;
	cin >> n;
	vi v;
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i];
		v.push_back(i);
	}
	sort(all(v), cmp);
	int tim = 0, can = 1;
	for(int i : v){
		tim += a[i];
		if(tim > b[i])
			can = 0;
	}
	cout << (can ? "Yes" : "No") << endl;
}


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

int abc(int s, int i)
{
	if (i==1)
	{
		return s;
	}
	else
	{
		if (s % 2 == 0)
		{
			return s / 2;
		}
		if (s % 2 == 1)
		{
			return 3 * s + 1;
		}
	}

}
int main()
{
	int s;
	cin >> s;
	int i = 0;
	int e = 0;
	int so[1000000];
	int n = 0;
	while (e == 0)
	{
		i++;
		so[i] = s;
		s = abc(s, i);
		n = 0;
		while (n < i )
		{
			if (so[n] == s)
			{
				e = 1;
			}
			n++;
		}
	}

	cout << i << endl;
	return 0;
}



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

int main(){
	int N;
	long T;
	cin>>N>>T;
	long t[N];
	for(int i=0;i<N;++i)cin>>t[i];
	long ans=0;
	for(int i=0;i<N-1;++i){
		if(t[i]+T<t[i+1]){
			ans+=T;
		}
		else{
			ans+=t[i+1]-t[i];
		}
	}
	ans+=T;
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = input()
d = 0
for i in range(len(n)):
    d += int(n[i])
if int(n)%d == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
n = int(input())
p = [int(a) for a in input().split()]

ans = 0
for i in range(n-2):
  if (p[i] < p[i+1] and p[i+1] < p[i+2]) or (p[i] > p[i+1] and p[i+1] > p[i+2]):
    ans += 1
print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef pair<int, int> P;

int main()
{
	int n;
	scanf("%d", &n);
	long long int A[100000];
	for(int i=0; i<n; i++){
		scanf("%lld", &A[i]);
	}
	vector<int> v[100000];
	map<P, int> e;
	for(int i=0; i<n-1; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
		e[P(a, b)]=i;
		e[P(b, a)]=i;
	}
	int d[100000];
	fill(d, d+n, -1);
	d[0]=0;
	queue<int> que;
	que.push(0);
	while(!que.empty()){
		int x=que.front();
		que.pop();
		for(int i=0; i<v[x].size(); i++){
			if(d[v[x][i]]==-1){
				d[v[x][i]]=d[x]+1;
				que.push(v[x][i]);
			}
		}
	}
	multimap<int, int> dmp;
	for(int i=0; i<n; i++){
		dmp.insert(make_pair(-d[i], i));
	}
	long long int m[100000];
	for(auto itr=dmp.begin(); itr!=dmp.end(); itr++){
		int x=itr->second;
		if(x!=0){
		int vp=-1;
		long long int sum=0;
		if(v[x].size()==1){
			m[e[P(x, v[x][0])]]=A[x];
		}else{
		for(int i=0; i<v[x].size(); i++){
			if(d[v[x][i]]<d[x]){
				vp=v[x][i];
			}else{
				sum+=m[e[P(x, v[x][i])]];
			}
		}
		
		if(vp!=-1) m[e[P(x, vp)]]=2*A[x]-sum;
		}
		}else{
			if(v[0].size()==1){
				if(m[e[P(0, v[0][0])]]!=A[0]){
					printf("%s\n", "NO");
					return 0;
				}
			}else{
				long long int sum=0;
				for(int i=0; i<v[0].size(); i++){
					sum+=m[e[P(0, v[0][i])]];
				}
				if(2*A[0]!=sum){
					printf("%s\n", "NO");
					return 0;
				}
			}
		}
	}
	for(int x=0; x<n; x++){
		if(v[x].size()!=1){
			for(int i=0; i<v[x].size(); i++){
				if(m[e[P(v[x][i], x)]]>A[x] || m[e[P(v[x][i], x)]]<0){
					printf("%s\n", "NO");
					return 0;
				}
			}
		}
	}
	printf("%s\n", "YES");
	return 0;
}


Measured memory_bytes: 27008
n = gets.to_i
S = []
s = []
i = 0
a = []
answer = []

for j in 0..n-1

    S[j] = gets.chomp
    s[j] = S[j].unpack("C*")

end

while i <= 30

    a[i] = []

    for j in 0..n-1

        a[i][j] = s[j].count(i+97)

    end

    if a[i].min > 0

        for j in 0..a[i].min-1

            answer.push(i+97)

        end

    end

    i += 1

end

puts answer.pack("C*")

Measured memory_bytes: 1788