akhauriyash/Code-Regression huggingface dataset:
/*
  Reference:-
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
#define all(vec) vec.begin(),vec.end()
ll mod=1000000007;
const int N=2e5 + 5;
ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<a*b;

    return 0;
}


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int h, m, H, M, K;
    cin >> h >> m >> H >> M >> K;

    cout << (60 * H + M) - (60 * h + m) - K << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3608
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

#define whole(xs) (xs).begin(),(xs).end()

vector< vector<int> > G1, G2;
int V;
vector<bool> used;
void init() {
    G1.clear(); G1.resize(V);
    G2.clear(); G2.resize(V);
    used.clear(); used.resize(V);
}
void addEdge(int from, int to) {
    G1[from].push_back(to);
    G2[to].push_back(from);
}
vector<int> vs;
void dfs1(int v) {
    used[v] = true;
    for (int i = 0; i < G1[v].size(); i++) {
        if (!used[ G1[v][i] ]) dfs1(G1[v][i]);
    }
    vs.push_back(v);
}
void dfs2(int v, int k, vector<int>& order) {
    used[v] = true;
    order[v] = k;
    for (int i = 0; i < G2[v].size(); i++) {
        if (!used[ G2[v][i] ]) dfs2(G2[v][i], k, order);
    }
}
int solve(vector<int>& ord) {
    fill(whole(used), false);
    vs.clear();
    for (int v = 0; v < V; v++) {
        if (!used[v]) dfs1(v);
    }
    fill(whole(used), false);
    int k = 0;
    ord.clear(); ord.resize(V, -1);
    for (int i = vs.size() - 1; i >= 0; i--) {
        if (!used[vs[i]]) dfs2(vs[i], k++, ord);
    }
    return k;
}

int main() {
    int E;
    scanf("%d %d\n", &V, &E);
    init();
    for (int i = 0; i < E; i++) {
        int s, t; scanf("%d %d\n", &s, &t);
        addEdge(s, t);
    }
    vector<int> ord;
    solve(ord);
    vector< pair<int, int> > p;
    for (int i = 0; i < V; i++) {
        p.push_back(make_pair(ord[i], i));
    }
    sort(whole(p));
    for (int i = 0; i < V; i++) {
        printf("%d\n", p[i].second);
    }
    return 0;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define Si size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define Em empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define Fi first
#define Se second
#define Pi acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>

void FAST();
LL big_mod(LL val,LL pow,LL mod);
LL mod_inverse(LL val,LL mod);









int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int n,k;
    cin >> n >> k;
    cout << n-k+1;
    return 0;
}







void FAST()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

LL big_mod(LL val,LL pow,LL mod)
{
    LL res = 1;
    val = val % mod;
    while(pow > 0)
    {
        if(pow & 1)
        {
            res = (res*val) % mod;
        }
        pow = pow >> 1;
        val = (val*val) % mod;
    }
    return res;
}

LL mod_inverse(LL val,LL mod)
{
    LL mod1 = mod;
    if(mod == 1)
    {
        return 0;
    }
    LL y = 0;
    LL x = 1;
    LL quotient,temp;
    while(val > 1)
    {
        quotient = val / mod;
        temp = mod;
        mod = val % mod;
        val = temp;
        temp = y;
        y = x - quotient * y;
        x = temp;
    }
    if(x < 0)
    {
        x += mod1;
    }
    return x;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd, sqrt
from operator import mul
from functools import reduce
from operator import mul
from pprint import pprint



sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
a = LI()

y = 0
flg = 0

for ai in a[2:]:
    y = y ^ ai

x = a[0] + a[1] - y
if x < 0 or x % 2:
    flg = 1

x //= 2
a1 = x

if a1 > a[0]:
    flg = 1

for i in reversed(range((a[0] + a[1]).bit_length())):
    if y & (1 << i):
        if x & (1 << i):
            flg = 1
        if a1 + 2 ** i <= a[0]:
            a1 += 2 ** i

if a1 == 0:
    flg = 1

print(a[0] - a1 if flg == 0 else -1)











Measured memory_bytes: 81008
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k,m=0,n;
  cin>>a>>b>>c>>k;
  n=a+b+c;
  m=max({a,b,c});
  n-=m;
  for(int i=0;i<k;i++){
    m*=2;
  }
  n+=m;
  cout<<n;
}

Measured memory_bytes: 256
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

#define ll long long int
using namespace std;


ll power(ll x, ll y) { ll temp; if( y == 0) return 1; temp = power(x, y/2); if (y%2 == 0) return temp*temp; else return x*temp*temp; } 

int main()
{
	fast;
	int h,w,k;cin>>h>>w>>k;
	char c[h][w];
	for(int i=0; i<h; i++)
	{
		for(int j=0; j<w; j++)
			cin>>c[i][j];
	}	

	int ans=0;

	for(int i=0; i<=power(2,h)-1; i++)
	{
		
		for(int j=0; j<=power(2,w)-1; j++)
		{
			//cout<<i<<" "<<j<<" "<<"\n";

			vector<int> row;
			vector<int> col;
			int y=0;
			while((1<<y)<=i)
			{
				if((1<<y) & i)
				{
					//cout<<y<<" ";
					//exit(0);
					row.p_b(y);
				}
				y++;
			}

			y=0;
			while((1<<y)<=j)
			{	
				if((1<<y) & j)
				{
					//cout<<"yeah"<<"\n";
					col.p_b(y);
				}
				y++;
			}
		
			//cout<<row.size()<<" "<<col.size()<<"\n";

			char temp[h][w];
			for(int i=0; i<h; i++)
			{
				for(int j=0; j<w; j++)
					temp[i][j]=c[i][j];
			}
			for(auto i:row)
			{
				for(int j=0; j<w; j++)
					temp[i][j]='-';
			}
			for(auto j:col)
			{
				for(int i=0; i<h; i++)
					temp[i][j]='-';
			}
			int count=0;
			for(int i=0; i<h; i++)
			{
				for(int j=0; j<w;j++)
				{
					//cout<<temp[i][j]<<" ";
					if(temp[i][j]=='#')
						count++;
				}
				//cout<<"\n";
			}
			//cout<<count<<"\n";
			if(count==k){
				//cout<<i<<" "<<j<<"\n";
				//cout<<"yeah"<<"\n";
				ans++;
			}
			
		}
		
	}
	cout<<ans<<"\n";


}


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

using namespace std;
#define int long long
int MOD = 1000000007;

signed main(){
    int N,A,B;
    string S;
    cin >> N >> A >> B >> S;
    
    int tuuka = 1,b=1;
    
    for(int i=0;i<N;i++){
        if(S[i] == 'a' && tuuka<=A+B){
            cout << "Yes" << endl;
            tuuka++;
        }else if(S[i] == 'b' && tuuka<=A+B && b<=B){
            cout << "Yes" << endl;
            b++;
            tuuka++;
        }else if(S[i] == 'b'){
            b++;
            cout << "No" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


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

int main(){
    int d, n;
    cin >> d >> n;
    if(n==100) n++;

    if(d==0){
        cout << n << endl;
    }
    else if(d==1){
        cout << 100*n << endl;
    }
    else if(d==2){
        cout << 10000*n << endl;
    }
    

    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <numeric>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int  m[4][3][10]={};
    for(int i=0;i<n;++i){
        int b,f,r,v;
        cin>>b>>f>>r>>v;
        b=b-1;
        f=f-1;
        r=r-1;
        m[b][f][r]+=v;
    }
    for(int i=0;i<4;++i){
        for(int j=0;j<3;++j){
            for(int k=0;k<10;++k){
                cout<<" "<<m[i][j][k];
            }
            cout<<endl;
        }
        if(i!=3){
            cout<<"####################"<<endl;
        }
    }
    return 0;
}



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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<vector<int>> g(n);
  vector<int> colors(n, -1);
  colors[0] = 1;
  colors[colors.size() - 1] = 0;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  stack<pair<int, int>> st;
  vector<int> vp(n, -1);
  st.push({0, 0});
  while (!st.empty()) {
    auto [idx, p] = st.top();
    st.pop();
    if (vp[idx] >= 0) {
      continue;
    }

    vp[idx] = p;
    for (auto ch : g[idx]) {
      st.push({ch, idx});
    }
  }

  int cur = n - 1;
  vector<int> vpath;
  while (cur != 0) {
    cur = vp[cur];
    if (cur != 0) {
      vpath.push_back(cur);
    }
  }

  int turns = vpath.size() / 2;
  int turn_f = turns + vpath.size() % 2, turn_s = turns;
  for (int i = 0; i < vpath.size(); ++i) {
    colors[vpath[i]] = i >= turn_s;
  }

  auto dfs = [&](int c, int init) {
    stack<int> st;
    vector<bool> seen(n, false);
    st.push(init);
    int ans = 0;
    while (!st.empty()) {
      auto idx = st.top();
      st.pop();
      if (seen[idx] || (colors[idx] != -1 && colors[idx] != c)) {
        continue;
      }

      ans += colors[idx] == -1;
      seen[idx] = true;
      colors[idx] = c;
      for (auto ch : g[idx]) {
        st.push(ch);
      }
    }

    return ans;
  };

  turn_f += dfs(1, 0);
  turn_s += dfs(0, n - 1);

  cout << (turn_f == turn_s || turn_s > turn_f ? "Snuke" : "Fennec") << '\n';
  return 0;
}

Measured memory_bytes: 10680
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int A = int.Parse(strs[0]);
            int B = int.Parse(strs[1]);

            Console.WriteLine(A*B);
        }
    }
}


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

int main() {
	int n;
	cin>>n;
	vector<int>arr(n+1);
	for(int i=1;i<=n;i++) cin>>arr[i];
	vector<int>dp(n+1);
	dp[1]=0;
	dp[2]=abs(arr[2]-arr[1]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 4044
#include <iostream>

#define ll long long int
using namespace std;

ll mod = 1000000007;

ll factorials[1000005];
ll inv[1000005];

ll mod_pow(ll k, ll pow) {
  ll ans = 1;
  while (pow > 0) {
    if (pow & 1) ans = ans * k % mod;
    k = k * k % mod;
    pow >>= 1;
  }
  return ans;
}

int main() {
  ll n;
  cin >> n;
  factorials[0] = 1;
  inv[0] = 1;

  for (int i = 1; i < 1000005; i++) {
    factorials[i] = (factorials[i - 1] * i) % mod;
    inv[i] = (inv[i - 1] * mod_pow(i, mod - 2)) % mod;
  }
  
  ll min_score = (n + 1) / 2;
  ll max_score = n - 1;
  ll ans = 0;
  ll prev = 0;
  for (int i = min_score; i <= max_score; i++) {
    ll cnk = ((factorials[i - 1] * inv[n - 1 - i] % mod) * inv[2 * i - n] % mod) % mod;
    ll add = (cnk * factorials[i] % mod) * factorials[n - 1 - i] % mod;
    ans = (ans + (((add - prev + mod) % mod) * i) % mod) % mod;
    prev = add;
  }
  cout << ans;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,N); for (int i = 0; i<N; i++)
 
int main() {
  int K;
  cin >> K;
  queue<int64_t> xq;
  rep(i,9) {
    int64_t ii = i;
    xq.push(ii+1);
  }
  rep(i,K) {
    int64_t x = xq.front();
    if (i==K-1) {
      cout << x << endl;
      break;
    }
    xq.pop();
    if (x%10 != 0) xq.push(10*x + x%10 -1);
    xq.push(10*x + x%10);
    if (x%10 != 9) xq.push(10*x + x%10 +1);
  }
}

Measured memory_bytes: 1792
// Vicfred
// https://atcoder.jp/contests/abc057/tasks/abc057_c
// math
import std.algorithm;
import std.stdio;

int digits(long n) {
    int count = 0;

    while(n > 0) {
        n /= 10;
        count += 1;
    }

    return count;
}

void main() {
    long n;
    readf("%s\n", &n);

    int ans = digits(n);

    for(long d = 1; d*d <= n; d++) {
        if(n%d != 0) continue;
        const long b = n/d;

        const int local = max(digits(d), digits(b));
        ans = min(ans, local);
    }

    ans.writeln;
}



Measured memory_bytes: 2772
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return read.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtype!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int d = rint;
	long g  = rlong;
	
	X[] xs;
	foreach(k; 0 .. d) xs ~= X((k + 1) * 100, rint, rlong);
	log("xs:", xs);
	
	long best = 1_000_000_999;
	foreach(m; 0 .. 1L<<d){
		long sum;
		long cnt;
		foreach(i, x; xs) if((1L<<i) & m){
			sum += x.p * x.v + x.c;
			cnt += x.p;
		}
		log("m:", m, "sum:", sum, "cnt:", cnt);
		if(sum >= g) best = min(best, cnt);
		else{
			X xmax;
			foreach(i, x; xs) if(!((1L<<i) & m)){
				xmax = x;
			}
			if(sum + (xmax.p - 1) * xmax.v >= g){
				while(sum < g){
					sum += xmax.v;
					cnt += 1;
				}
				if(sum >= g) best = min(best, cnt);
			}
			log("m:", m, "xmax.v:", xmax.v);
		}
		log("m:", m,  "sum:", sum, "cnt:", cnt, "best:", best);
	}
	best.writeln;
	
}

struct X{
	int v;
	int p;
	long c;
}


Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/



int main() {
int A,B,C;
cin>>A>>B>>C;
cout<<max(C-(A-B),0)<<endl;;
return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
const int N = 200002;
const int M = 1e9 + 7;
const int oo = INT_MAX;
int n,m;
vi g[N];
bool vis[N];
int dfs(int u){
    vis[u]=true;
    int c=0;
    for(int i=0;i<g[u].size();i++){
        int v=g[u][i];
        if(!vis[v]){
            c+=dfs(v);
        }
    }
    return 1+c;
}
int main(){
    cin>>n>>m;
    for(int a,b,i=0;i<m;i++){
        cin>>a>>b;
        g[--a].pb(--b);
        g[b].pb(a);
    }
    int mx=-oo;
    for(int i=0;i<n;i++)
        if(!vis[i])
            mx=max(mx,dfs(i));
    
    cout<<mx;
}


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

int main() {
  int N, cnt=0;
  cin >> N;
  vector<int> P(N);
  rep(i, N) cin >> P.at(i);
  rep(i, N-2){
   if((P.at(i)<P.at(i+1) && P.at(i+1)<P.at(i+2)) || (P.at(i)>P.at(i+1) && P.at(i+1)>P.at(i+2))) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define pb push_back
#define pp(a, b) pair <a, b>
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define itr iterator
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
 
 
using namespace __gnu_pbds;
using namespace std;
 
template <class T> T printr(T p){ cout << p << '\n'; return 0; }
template <class T> T printe(T p){ cout << p << '\n'; exit(0); }
template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
 
 
//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set;  

#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif
 
ll power(ll x, ll y, ll p){ 
   ll res = 1;
   x = x % p;  
   while (y > 0) {
      if (y & 1) 
         res = (res * x) % p; 
      y = y >> 1;
      x = (x * x) % p; 
   }
   return res;
}

const ll INF = (ll)(8e18);
const ll MOD = 1e9 + 7;
const ll HMOD = (ll)4222234727;
const ll hashprime = (ll)31;
 
const int maxn = 200005;

ll a[maxn];
map <ll, ll> mp;

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ll n,m; cin >> n >> m;
    for(ll i = 1; i <= n; i++) cin >> a[i];
    for(ll i = 1; i <= n; i++){
        ll val = a[i];
        ll cnt = 0;
        while(val % 2 == 0){
            val /= 2;
            cnt += 1;
        }
        mp[cnt] += 1;
    }
    if((ll)mp.size() > 1){
        cout << 0 << '\n';
        return 0;
    }
    for(ll i = 1; i <= n; i++) a[i] /= 1LL * 2;
    ll lcm = 1;
    for(ll i = 1; i <= n; i++){
        lcm = (lcm * a[i]) / (__gcd(lcm, a[i]));
        if(lcm > m){
            cout << 0 << '\n';
            return 0;
        }
    }
    m = m / lcm;
    m += 1;
    m /= 2;
    cout << m << '\n';
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

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

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

    long long res = 0;
    if (a[0] > x) {
        res += a[0] - x;
        a[0] = x;
    }

    for (int i = 1; i < n; i++) {
        if (a[i] > x - a[i - 1]) {
            res += a[i] - (x - a[i - 1]);
            a[i] = x - a[i - 1];
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 640
n,k=map(int,input().split())
p=list(map(int,input().split()))
max=0
sum=0
for i in range(0, k):
    sum += p[i]
max=sum
for i in range(1,n-k+1):
    sum+=p[k-1+i]-p[i-1]
    if sum>max:
        max=sum
ans=(max+k)*0.5
print(ans)

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

namespace AtCoder.Abc173
{
    class B
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());

            var count = new Dictionary<string, int>();
            count["AC"] = 0;
            count["WA"] = 0;
            count["TLE"] = 0;
            count["RE"] = 0;

            for (int i = 0; i < n; i++)
            {
                var s = Console.ReadLine();
                count[s]++;
            }

            foreach (var item in count)
                Console.WriteLine(item.Key + " x " + item.Value);
        }
    }
}


Measured memory_bytes: 31116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
int a,b,t,ans;
int main(){
    cin>>a>>b>>t;
    int sum = 0;
    for(int i=1;i<=1000;i++){
        sum+=a;
        if(sum<=t){ans+=b;}
        else break;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int main()
{
  double a, b, C, c;
  double S, L, h;
  cin >> a >> b >> C;
    
  c = M_PI * C / 180;

  S = a * b * sin(c) / 2;
  L = sqrt(a * a + b * b - 2 * a * b * cos(c)) + a + b;
  h = b * sin(c);

  printf("%f %f %f\n", S, L, h);

  return 0;
}


Measured memory_bytes: 3448
#include <iostream>
#include <algorithm>
#include <iomanip>
#include"stdio.h"
#include <cstring>
#include<math.h>
#include<map>
#include<queue>
#include<stack>
#include"time.h"
#define MAX_INT  ((unsigned)(-1)>>1)
#define MIN_INT  (~MAX_INT)
#define db printf("where!\n");
#define pb push_back
using namespace std;
#define ll long long
ll gcd(ll x,ll y){return y ? gcd(y,x%y) : x;}
template<class T>inline void read(T &res){
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int k[200005];
int main(){
	int n;
	cin>>n;
	int a;
	for(int i=2;i<=n;i++){
        cin>>a;
        k[a]++;
	}
	for(int i=1;i<=n;i++) cout<<k[i]<<endl;
	return 0;
}

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

int main() {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  A.push_back(A[0] + K);
  int diff = 0;
  for (int i = 1; i <= N; i++)
    diff = max(A[i] - A[i - 1], diff);
  cout << K - diff << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,t,x,y;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
	{
        cin>>t>>x>>y;
        if(!(x+y<=t&&(t-x-y)%2==0))
		{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;

cc_hash_table<int,vector<pair<int,int> > > mx;

signed main()
{
	ios::sync_with_stdio(false);
	int x,d,n;
	cin>>n>>x>>d;
	if(d==0ll){
		if(x==0ll) cout<<1ll<<endl;
		else cout<<n+1ll<<endl; 
		return 0;
	}
	if(d<0ll){
		x=-x;
		d=-d;
	}
	for(int i=1;i<=n;i++){
		int minv=i*(i-1ll)/2ll;
		int maxv=(n-1ll+n-i)*i/2ll;
		int num=(i*x)/d;
		if((i*x)%d!=0) num++;
		int rem=(i*x)-num*d;
		mx[rem].push_back(make_pair(num+minv,num+maxv));
	}
	mx[0ll].push_back(make_pair(0ll,0ll));
	int ans=0ll;
	for(cc_hash_table<int,vector<pair<int,int> > >::iterator it=mx.begin();it!=mx.end();it++){
		vector<pair<int,int> > v=it->second;
		sort(v.begin(),v.end());
		int maxv=0;
		for(int i=0;i<v.size();i++){
			if(i==0){
				ans+=v[i].second-v[i].first+1ll;
				maxv=v[i].second;
			}
			else{
				if(v[i].first>maxv){
					ans+=v[i].second-v[i].first+1ll;
					maxv=v[i].second;
				}
				else if(v[i].second>maxv){
					ans+=v[i].second-maxv;
					maxv=v[i].second;
				}
			} 
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 19948
K = int(raw_input())

div = int(K / 50)
mod = K % 50

a = range(49, -1, -1)
for i in range(50):
    if i < mod:
        a[i] += (1 + div)
    else:
        a[i] += div

print(50)
print(' '.join(map(str, a)))

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


int main() {
  // 科目の数Nを受け取る
  int N;
  int flag =0;
  cin >> N;
  vector<string> colors(N);

  for (int i=0; i<N; i++){
    cin >> colors.at(i);
    if (colors.at(i)=="Y"){
      cout << "Four" << endl;
      flag = 1;
      break;
    }
    //cout << i << endl;
  }

  if (flag ==0){
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000

int n, m;

set<pair<int,int>> s;
long cnt[10];

int input() {
	int k;
	if (scanf("%d %d %d", &n, &m, &k) < 0) return 0;
	for (int i=0; i<k; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		s.insert({x, y});
	}
	return 1;
}

void init() {
	memset(cnt, 0, sizeof(cnt));
}

int solve() {
	cnt[0] = long(n-2) * (m-2);
	for (auto p: s) {
		int pi = p.first, pj = p.second;
		for (int i=pi-2; i<=pi; i++) {
			if (i<1 || i+2>n) continue;
			for (int j=pj-2; j<=pj; j++) {
				if (j<1 || j+2>m) continue;
				int k = 0;
				int ok = 1;
				for (int di=0; di<3; di++) {
					for (int dj=0; dj<3; dj++) {
						int ni = i+di, nj = j+dj;
						if (s.count({ni, nj})) {
							if (ni < pi || (ni==pi && nj < pj)) {
								ok = 0;
								break;
							}
							k++;
						}
					}
				}
				cnt[k] += ok;
			}
		}
	}
	for (int i=1; i<10; i++)
		cnt[0] -= cnt[i];
	return 1;
}

void output(int ans) {
	for (int i=0; i<10; i++)
		printf("%ld\n", cnt[i]);
}

void cleanup() {
	s.clear();
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 4864
// csa_200131_e
// D - Greedy customers
// https://atcoder.jp/contests/code-festival-2016-qualb/tasks/codefestival_2016_qualB_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int cur = 2;
    ll ans = A[0] - 1;
    REPN(i, 1, N){
        if (A[i] == cur){
            cur++;
        } else {
            ans += (A[i] - 1) / cur;
        }
    }
    print(ans);


    return 0;
}


Measured memory_bytes: 640
n, m = [int(i) for i in input().split()]

N, M = [], []
for i in range(n):
    N.append(list(input()))
for i in range(m):
    M.append(list(input()))

# print(N)
# print(M)

def check():
    for i in range(n-m+1):
        for j in range(n-m+1):
            flag = True
            for ii in range(m):
                for jj in range(m):
                    flag &= N[i+ii][j+jj] == M[ii][jj]
                    if not flag: break
                if not flag: break
            if flag: return "Yes"
    return "No"

print(check())



Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    abc = [tuple(map(int, input().split())) for _ in range(N)]
    dp = [[0] * 3 for _ in range(N+1)]
    for i in range(3):
        dp[0][i] = 0
    for i in range(1, N+1):
        for today in range(3):
            for yesterday in range(3):
                if today == yesterday:
                    continue
                dp[i][today] = max(dp[i][today], dp[i-1][yesterday] + abc[i-1][today])
    ans = 0
    for i in range(3):
        ans = max(ans, dp[N][i])
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 70492
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	cout << 800*n-200*(n/15) << endl ;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

using Lint=long long;
using Graph=vector<vector<int>>;

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

    int N; cin>>N;
    Graph G(N);
    for(int i=0;i<N;i++){
        int u,k; cin>>u>>k;
        u--;
        while(k--){
            int v; cin>>v;
            v--;
            G[u].push_back(v);
        }
    }
    vector<int> d(N,-1),f(N);
    int time=1;
    function<void(int)> dfs=[&](int v)
    {
        d[v]=time++;
        for(int u:G[v]) if(d[u]==-1){
            dfs(u);
        }
        f[v]=time++;
    };

    for(int i=0;i<N;i++) if(d[i]==-1){
        dfs(i);
    }
    for(int i=0;i<N;i++){
        cout<<i+1<<' '<<d[i]<<' '<<f[i]<<endl;
    }
    return 0;
}


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

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

    deque<char> dq;
    for(int i=0; i<s.length(); i++) dq.push_back(s[i]);


    int flag = 0;
    for(int i=0; i<q; i++){
        int type;
        cin >> type;

        if(type == 1){
            flag = (flag + 1) % 2;
        }
        if(type == 2){
            int f; char c;
            cin >> f >> c;
            if(flag == 0 && f == 1) dq.push_front(c);
            if(flag == 0 && f == 2) dq.push_back(c);
            if(flag == 1 && f == 1) dq.push_back(c);
            if(flag == 1 && f == 2) dq.push_front(c);
        }
    }
    
    while(dq.empty() == false){
        char c;
        if(flag == 0){
            c = dq.front(); dq.pop_front();
        }
        if(flag == 1){
            c = dq.back(); dq.pop_back();
        }
        cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const long long INF = 1e18+3;
#define maxn 1000100
map <int, int> M;
ll firstlen = 0, seclen = 0;

int main()
{
	int n, a;
	boost;
	cin >> n;
	FOR(i, 1, n) {
		cin >> a;
		M[-a]++;
	}
	
	for (auto u : M) { 
		//cout << u.e1 << ' ' << u.e2 << endl;
		if (u.e2 < 2) continue;
		if (u.e2 >= 2) {
			if (firstlen == 0) u.e2 -= 2, firstlen = u.e1;
			else {
				seclen = u.e1;
				OUT(seclen * firstlen);
			}
		}
		if (u.e2 >= 2) {
			if (firstlen == 0) u.e2 -= 2, firstlen = u.e1;
			else {
				seclen = u.e1;
				OUT(seclen * firstlen);
			}
		}
	}
	
	cout << 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[51];

int main(void){
	scanf("%d",&n);
	bool flag=true;
	int big=0;
	int mini=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		big=max(big,a[i]);
		mini=min(mini,a[i]);
		if(i==0){
			big=a[i],mini=a[i];
		}
	}
	vector<P> ans;
	int v=0;
	if(big>=abs(mini)){
		for(int i=0;i<n;i++){
			if(a[i]==big)v=i;
		}
		for(int i=0;i<n;i++){
			ans.push_back(P(v+1,i+1));
		}
		for(int i=0;i<n-1;i++){
			ans.push_back(P(i+1,i+2));
		}
	}else{
		for(int i=0;i<n;i++){
			if(a[i]==mini)v=i;
		}
		for(int i=0;i<n;i++){
			ans.push_back(P(v+1,i+1));
		}
		for(int i=n-1;i>0;i--){
			ans.push_back(P(i+1,i));
		}
	}
	printf("%d\n",ans.size());
	for(int i=0;i<ans.size();i++){
		printf("%d %d\n",ans[i].first,ans[i].second);
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<stack>
#include<queue>
using namespace std;
int main(){
    stack<int>S;
    queue<int>Q;
    int train;
    while(scanf("%d",&train)!=EOF){

        if(train)S.push(train);
        else{
            Q.push(S.top());
            S.pop();
        }
    }
    while(!Q.empty()){
        printf("%d\n",Q.front());
        Q.pop();
    }

    return 0;
}

Measured memory_bytes: 1036
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
int N;
int C[505], S[505], F[505];

/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N-1){
        cin>>C[i]>>S[i]>>F[i];
    }

    REP(i,0,N){
        int t = 0;
        REP(j,i,N-1){

            if(t <= S[j]) t = S[j];
            else if(t % F[j] == 0) ;
            else t = t + F[j] - (t % F[j]);

            t += C[j];
        }
        cout<<t<<endl;
    }

    return 0;
}


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

int main()
{
    int W, H, x, y, r;

    cin >> W >> H >> x >> y >> r;

    if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

const int kN = 100'000 + 5;
char s[kN];

int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    if (s[1] == '0' || s[n] == '1') {
        puts("-1");
        return 0;
    }
    for (int i = 1; i <= n - 1; ++i) {
        if (s[i] != s[n - i]) {
            puts("-1");
            return 0;
        }
    }
    vector<pair<int, int>> ed;
    int x = 0, y = 1;
    for (int i = 2, j = 1; i <= n; ++i) {
        if (s[i] == '1') {
            int r = y++;
            ed.emplace_back(r, x);
            for (int k = 0; k < i - j - 1; ++k) ed.emplace_back(r, y++);
            x = r;
            j = i;
        }
    }
    assert(y == n - 1);
    ed.emplace_back(y, x);
    assert(ed.size() == n - 1);
    for (auto e : ed) printf("%d %d\n", e.first + 1, e.second + 1);
    return 0;
}


Measured memory_bytes: 2420
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long LL;
LL x, y;
int main() {
	scanf("%lld%lld", &x, &y);
	int ans = 0;
	while(x <= y) {
		x = x * 2LL;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include "bits/stdc++.h"

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a-1;i>=0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7


ll gcd(ll x, ll y) {
    return y ? gcd(y, x%y) : x;
}

int main() {
    ll n;
    VE a;
    cin >> n;
    a.push_back(0);
    REP(i, n) {
        ll A;
        cin >> A;
        a.push_back(A);
    }

    ll l[100003], r[100003];
    REP(i, 100002)l[i] = r[i] = 0;
    l[0] = 0;
    r[n + 1] = 0;
    rep(i, 1, n + 2)l[i] = gcd(l[i - 1], a[i - 1]);
    for (ll i = n; i >= 0; i--)r[i] = gcd(r[i + 1], a[i]);
    ll ans = 0;
    REP(i, n + 1)ans = max(ans, gcd(l[i], r[i + 1]));
    print(ans);
}

Measured memory_bytes: 2676
#include<stdio.h>
int main() {
	char S[4];
	scanf("%3s", S);
	int i, pay;
	i = 0;
	pay = 700;
	do {
		if (S[i]== 'o') {
			pay += 100;
		}
		i += 1;
	} while (i < 3);
	printf("%d\n", pay);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,i,j;
cin>>a;
int b,c=0;
for(i=1;i<=a;i++){
    cin>>b;
    if(i%2==1 && b%2==1)
        c++;
}
cout<<c<<endl;
return 0;}


Measured memory_bytes: 3620
//#include<MrUnknown.h>
//#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f_(i,a,b) for (ll i=a;i>=b;i--)
#define f(i,a,b) for (ll i=a;i<=b;i++)
const ll mod=1000000007;

ll ans[10],n,h,w;
vector<pair<ll,ll> > v;
int main() {
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	scanf("%lld %lld %lld", &h, &w, &n);
	f(i,1,n) {
		ll ai,bi;
		scanf("%lld %lld", &ai, &bi);
		f(j1,max(ai-2,1ll)+2,min(ai+2,h)) f(j2,max(bi-2,1ll)+2,min(bi+2,w)) v.push_back(make_pair(j1,j2));
	}
	sort(v.begin(),v.end());
	int dem=0;
	ans[0]=(h-2)*(w-2);
	for (int i=0;i<v.size();i++) {
		if (i==0) dem=1;
		else if (v[i]!=v[i-1]) dem=1; else dem++;
		ans[dem]++;
		ans[dem-1]--;
	}
	for (int i=0;i<=9;i++) printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 18792
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main( int argc, char **argv )
{
    int H, W;
    cin >> H >> W;

    vector<vector<int>> A( H, vector<int>( W, 0 ) );
    vector<vector<int>> B( H, vector<int>( W, 0 ) );

    for ( int h = 0; h < H; h++ )
        for ( int w = 0; w < W; w++ ) cin >> A[h][w];

    for ( int h = 0; h < H; h++ )
        for ( int w = 0; w < W; w++ ) cin >> B[h][w];

    int M = 80 * ( H + W - 1 );

    vector<vector<vector<bool>>> dp(
        H, vector<vector<bool>>( W, vector<bool>( M + 1, false ) ) );

    dp[0][0][abs( A[0][0] - B[0][0] )] = true;

    for ( int h = 0; h < H; h++ )
    {
        for ( int w = 0; w < W; w++ )
        {
            for ( int k = 0; k <= M; k++ )
            {
                if ( !dp[h][w][k] ) continue;

                if ( h + 1 < H )
                {
                    int s0 = abs( A[h + 1][w] - B[h + 1][w] );
                    int s1 = abs( k + s0 );
                    int s2 = abs( k - s0 );

                    if ( s1 < M + 1 ) dp[h + 1][w][s1] = true;
                    if ( s2 < M + 1 ) dp[h + 1][w][s2] = true;
                }

                if ( w + 1 < W )
                {
                    int s0 = abs( A[h][w + 1] - B[h][w + 1] );
                    int s1 = abs( k + s0 );
                    int s2 = abs( k - s0 );

                    if ( s1 < M + 1 ) dp[h][w + 1][s1] = true;
                    if ( s2 < M + 1 ) dp[h][w + 1][s2] = true;
                }
            }
        }
    }

    for ( int k = 0; k <= M; k++ )
    {
        if ( dp[H - 1][W - 1][k] )
        {
            cout << k << endl;
            break;
        }
    }

    return 0;
}


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


int main(){
 int N; cin>>N;
  vector<int> A(N);
 for(int i=0;i<N;i++)cin>>A.at(i);

   vector<int> sa(N);
    vector<int> sa2(N);
  
  for(int i=0;i<N;i++){
   for(int j=0;j<N;j++){
     int a=A.at(i)-A.at(j);
       if(a>0)sa2.at(j)=a;
       else sa2.at(j)=-a;
      }
    sort(sa2.begin(),sa2.end());
    reverse(sa2.begin(),sa2.end());
    sa.at(i)=sa2.at(0);
    }
  sort(sa.begin(),sa.end());
  reverse(sa.begin(),sa.end());
  cout<<sa.at(0)<<endl;
}
  

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

int binpow(int a, int b)
{
    int ans = 1;
    if (b == 0)
        return 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int ct = 0;
        int ma = 0;
        for (int i = 0; i < s.size(); ++i)
        {
            if (s[i] == 'R')
            {
                ct++;
                ma = max(ct, ma);
            }
            else
                ct = 0;
        }
        cout << ma << "\n";
    }
}

Measured memory_bytes: 3644
mod=10**9+7
MAX=10**5+100
g1=[1,1]
g2=[1,1]
for i in range(2,MAX+1):
    num_1=g1[-1]*i%mod
    g1.append(num_1)
    g2.append(pow(num_1,mod-2,mod))
def cmb(n,r):
    return g1[n]*g2[r]*g2[n-r]%mod

N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
A=[-float("inf")]+A
mod=10**9+7
ans=0
for i in range(1,N+2-K):
    ans=(ans-A[i]*cmb(N-i,K-1))%mod
for i in range(K,N+1):
    ans=(ans+A[i]*cmb(i-1,K-1))%mod
    
print(ans)

Measured memory_bytes: 70668
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpConsoleApp {

    class Program {

        static int Main() {
            var HM = Console.ReadLine().Split(' ').ToList().Select(a => int.Parse(a)).ToArray();
            var H = HM[0];
            var M = HM[1];
            var N = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).First();
            var aArray = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToList();

            int[] Grid = new int[H * M];
            for (int i = 1; i <= N; i++) {
                for (int h = 0; h < aArray[i - 1]; h++)
                    Grid[h + aArray.Take(i - 1).Sum()] = i;
            }
            for (int j = 0; j < H; j++) {
                var row = Grid.Skip(j * M).Take(M).ToArray();
                if (j % 2 != 0)
                    Array.Reverse(row);
                   //row.Reverse();
                var tmp = row;
                foreach (var g in row)
                    Console.Write(g + " ");
                Console.Write(Environment.NewLine);
            }

            return 0;
        }
    }
}

Measured memory_bytes: 15712
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,x;
    cin >> n >>x;
    int pay;
    int MIN = 10000;
    int ans = n;
    for(int i = 0;i < n;i++){
        cin >> pay;
        x -= pay;
        MIN = min(MIN,pay);
    }
    ans += x/MIN;
    cout << ans << endl;
    return 0;
}


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

int main(){
  map< int,int > d;
  int n,m;
  cin >> n;
  for(int i = 0;i < n;++i){
    int tmp;
    cin >> tmp;
    ++d[tmp];
  }
  cin >> m;
  map< int,int> t;
  set< int > s;
  for(int i = 0;i < m;++i){
    int tmp;
    cin >> tmp;
    s.insert(tmp);
    ++t[tmp];
  }
  for(int i : s){
    if(d[i] < t[i]){
      puts("NO");
      return 0;
    }      
  }
  puts("YES");
  return 0;
}


Measured memory_bytes: 28416