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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(10);
    
    int A, B; cin >> A >> B;
    
    int ans = -1;
    
    for (int i = 1; i <= 2000; ++i) {
        int p8 = (i * 0.08);
        int p10 = (i * 0.10);
        if (p8 == A && p10 == B) {
            ans = i; break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = 0;
    if(k != 1)
        ans = n - k;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from sys import stdin,stdout
from queue import Queue

def solve(K):
    if K < 10: return K
    q = Queue()
    cnt = 0
    for i in range(1,10):
        q.put(i)

    while not q.empty():
        u = q.get()
        cnt += 1
        if cnt == K: return u

        r = u % 10
        if r != 0:
            q.put(10*u + r - 1)

        q.put(10*u + r)
        if r < 9:
            q.put(10*u + r +1)





K = int(stdin.readline())

stdout.write(str(solve(K)))



Measured memory_bytes: 18964
#include <iostream>
#define MAXN 205
using namespace std;

int n, a[MAXN];

int f(int x) {
    int ans = 0;
    while ((x & 1) == 0) {
        x >>= 1;
        ++ans;
    }

    return ans;
}

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

    cin >> n;
    int sol = MAXN;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        sol = min(sol, f(a[i]));
    }

    cout << sol << "\n";


    return 0;
}

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

typedef long long LL;
const int N = 17;
const int Mod = 1e9 + 7;
const int NS = (1 << 17) + 10;
int n, m, ans, a[N], bin[30], fac[NS], inv[NS], f[N][NS];

inline int dec(int x) {return x < 0 ? x + Mod : x;}
inline int inc(int x) {return x >= Mod ? x - Mod : x;}
inline int C(int n, int m) {
	if (n < m || m < 0) return 0;
	return 1LL * fac[n] * inv[m] % Mod * inv[n - m] % Mod;
}

template <class T> inline void in(T &x) {
	x = 0; int f = 0; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x = f ? -x : x;
}

int main() {
	int ret, lim; in(n), in(m), bin[0] = 1;
	for (int i = 1; i < 30; ++i) bin[i] = bin[i - 1] << 1;
	for (int i = 1; i <= m; ++i) in(a[i]);
	fac[0] = fac[1] = inv[0] = inv[1] = 1;
	lim = bin[n]; sort(a + 1, a + m + 1, greater<int>()), f[0][0] = 1;
	for (int i = 2; i <= lim; ++i) inv[i] = 1LL * (Mod - Mod / i) * inv[Mod % i] % Mod;
	for (int i = 2; i <= lim; ++i) fac[i] = 1LL * fac[i - 1] * i % Mod;// printf("%d ", fac[i]); putchar('\n');
	for (int i = 2; i <= lim; ++i) inv[i] = 1LL * inv[i - 1] * inv[i] % Mod;// printf("%d ", inv[i]); putchar('\n');
	for (int i = 0; i < m; ++i)
		for (int s = 0; s < lim; ++s) if (f[i][s]) {
			ret = lim - s - a[i + 1];
			f[i + 1][s] = inc(f[i + 1][s] + f[i][s]);
			for (int k = 0; k < n; ++k) if (!(s & bin[k])) {
				if (ret < bin[k] - 1) break;
				f[i + 1][s | bin[k]] = dec(f[i + 1][s | bin[k]] - 1LL * f[i][s] * C(ret, bin[k] - 1) % Mod * fac[bin[k]] % Mod);
			}
		}
	for (int i = 0; i < lim; ++i)
		ans = inc(ans + 1LL * f[m][i] * fac[lim - i - 1] % Mod);
	ans = 1LL * lim * ans % Mod;
	printf("%d\n", ans);
	return 0;
}

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

int main(){
	ll N,K;
	cin >> N >> K;
	
	vector<ll> p(N);
	rep(i,N){
		cin >> p[i];
	}
	
	ll ans = 0;
	ll temp = 0;
	
	//まず初項からK個の和を計算
	rep(i,K){
		temp += p[i];
	}
	
	ans = max(ans, temp);
	
	//和を更新していく
	rep(i,N-K){
		temp = temp - p[i] + p[K+i];
		ans = max(ans, temp);
	}
	
	printf("%.10f",double(ans+K)/2);
	puts("");
	
    return 0;
}



Measured memory_bytes: 1792
def c_maximal_value():
    N = int(input())
    B = [int(i) for i in input().split()]

    ans = B[0]
    for i in range(N - 2):
        if B[i] > B[i + 1]:
            ans += B[i + 1]
        else:
            ans += B[i]
    ans += B[-1]
    return ans

print(c_maximal_value())

Measured memory_bytes: 3060
program main
      implicit none
      integer :: k, n

      read *, k

      n = mod(k,10)
      if ( ( n == 0) .or.( n == 1 ) .or. ( n == 6 ) .or. ( n == 8 ) ) then
        print *, 'pon'
      else if ( n == 3 ) then
        print *, 'bon'
      else
        print *, 'hon'
      end if

end program main


Measured memory_bytes: 2856
from itertools import product
import copy
H,W,K = map(int,input().split())
C_ary = [[_ for _ in input()] for j in range(H)]
patrn_h = []
patrn_w = []
cntup = 0
for i in product([0,1], repeat = H):
    patrn_h.append(i)
for i in product([0,1], repeat = W):
    patrn_w.append(i)
for i in patrn_h:
    for j in patrn_w:
        cnt = 0
        test_ary = copy.deepcopy(C_ary)
        for h in range(H):
            for w in range(W):
                if i[h] == 0 or j[w] == 0:
                    test_ary[h][w] = "."
            cnt += test_ary[h].count("#")
        if cnt == K:
            cntup += 1
print(cntup)

Measured memory_bytes: 72892
lis = []
lis2 = []
lis3 = []
mi = 100000

for i in range(5):
  a = int(input())
  lis.append(a)
  
for x in lis:
  x2 = x % 10
  if x2 == 0:
    x3 = x
  else:
    x3 = x - x2 + 10
  lis2.append(x2)
  lis3.append(x3)

for i in lis2:
  if i != 0 and i < mi:
      mi = i
if sum(lis2) == 0:
  mi = 0
su = sum(lis3)

ans = su + mi - 10

if sum(lis2) == 0:
  print(su)
else:print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1, r = x;
    while(n){
        if(n % 2) res = res * r % MOD;
        r = r * r % MOD;
        n /= 2;
    }
    return res;
}

int main()
{
    int n, k;
    cin >> n >> k;
    ll a[200005];
    bool f = false;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] > 0) f = true;
    }
    if(n == k){
        ll ans = 1;
        for(int i = 0; i < n; i++){
            ans = ans * ((MOD + a[i]) % MOD) % MOD;
        }
        cout << ans << endl;
        return 0;
    }
    if(k % 2 == 1 && !f){
        ll ans = 1;
        sort(a, a + n, greater<ll>());
        for(int i = 0; i < k; i++){
            ans = ans * ((MOD + a[i]) % MOD) % MOD;
        }
        cout << ans << endl;
        return 0;
    }
    P p[200005];
    for(int i = 0; i < n; i++){
        if(a[i] > 0) p[i] = P(a[i], 1);
        else if(a[i] < 0) p[i] = P(-a[i], -1);
        else p[i] = P(0, 0);
    }
    sort(p, p + n, greater<P>());
    ll ans = 1;
    ll sgn = 1;
    for(int i = 0; i < k; i++){
        ans = ans * p[i].first % MOD;
        sgn *= p[i].second;
    }
    if(sgn >= 0){
        cout << ans << endl;
        return 0;
    }
    ll ln = MOD, lp = MOD, rn = -MOD, rp = -MOD;
    for(int i = k - 1; i >= 0; i--){
        if(p[i].second < 0) ln = min(ln, p[i].first);
        if(p[i].second > 0) lp = min(lp, p[i].first);
    }
    for(int i = k; i < n; i++){
        if(p[i].second <= 0) rn = max(rn, p[i].first);
        if(p[i].second >= 0) rp = max(rp, p[i].first);
    }
    if(lp == MOD || rn == MOD){
        ans = ans * rp % MOD * modpow(ln, MOD - 2) % MOD;
    }
    else if(ln == MOD || rp == MOD){
        ans = ans * rp % MOD * modpow(ln, MOD - 2) % MOD;
    }
    else if(ln * rn > rp * lp){
        ans = ans * rn % MOD * modpow(lp, MOD - 2) % MOD;
    }
    else{
        ans = ans * rp % MOD * modpow(ln, MOD - 2) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 8324
void main() {
	auto ip = readAs!(int[]), A = ip[0], P = ip[1];
	writeln((A * 3 + P) / 2);
}
// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}

T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string S; cin >> S;
    int y,m,d;
    y = 1000*(S[0]-'0') + 100*(S[1]-'0') + 10*(S[2]-'0') + (S[3]-'0');
    m = 10*(S[5]-'0') + (S[6]-'0');
    d = 10*(S[8]-'0') + (S[9]-'0');


    if(y<2019 || (y==2019&&m<4) || (y==2019&&m==4&&d<=30)){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
    return 0;
}

Measured memory_bytes: 3572
# -*- coding: utf-8 -*-
"""
B - Palace
https://atcoder.jp/contests/abc113/tasks/abc113_b

"""
import sys


def solve(N, T, A, places):
    res = []
    for i, h in enumerate(places, start=1):
        t = T - h * 0.006
        res.append([abs(A-t), i])
    return sorted(res)[0][1]


def main(args):
    N = int(input())
    T, A = map(int, input().split())
    places = [int(h) for h in input().split()]
    ans = solve(N, T, A, places)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
const ll mod = 1e9+7;
using namespace std;

map<int, int> prime;

ll POW(ll a, ll k){
    ll ans=1;
    while(k){
        if(k%2) ans = ans*a % mod;
        a = a*a % mod;
        k/=2;
    }
    return ans;
}
ll calc(ll n, ll m){
    ll ans=1,t=1;
    for(ll i=1;i<=m;i++){
        ans = ans*(n-i+1) % mod;
        t = t*i % mod;
    }
    return ans*POW(t,mod-2)%mod;
}
void primeFactors(int n){
    while(n%2 == 0){
        prime[2]++;
        n = n/2;
    }
    for(int i=3; i<=sqrt(n); i=i+2)
        while(n%i == 0){
            prime[i]++;
            n = n/i;
        }
    if(n>2)
        prime[n]++;
    return;
}

int main(){
    int n,m;
    cin>>n>>m;
    primeFactors(m);

    ll ans=1;
    for(auto i=prime.begin();i!=prime.end();i++){
        ans = ans * calc(n+(i->second)-1,(i->second)) % mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var strs = Console.ReadLine().Split();
            var a = int.Parse(strs[0]);
            var b = int.Parse(strs[1]);
            var c = int.Parse(strs[2]);
            var d = int.Parse(strs[3]);

            if (Math.Abs(a - c) <= d)
            {
                Console.WriteLine("Yes");
                return;
            }

            if (Math.Abs(a - b) <= d && Math.Abs(b - c) <= d)
            {
                Console.WriteLine("Yes");
                return;
            }

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


Measured memory_bytes: 11092
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
#include<iomanip>
#include<float.h>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
#define debug(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = (int)4e5+7;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int mod = (int)1e9 + 7;
const int mod1 = (int)1e9 + 9;
const int mod2 = 998244353;
const int mod3 = (int)1e6+3;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;

ll fact[N];
ll power(ll x, ll y) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % mod;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % mod; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll n) 
{ 
    return power(n, mod-2); 
} 
  
 
ll nCrModPFermat(ll n, ll r) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
    return (fact[n]* modInverse(fact[r]) % mod * 
            modInverse(fact[n-r]) % mod) % mod; 
}
void initiate(){
    fact[0]=1;
    int i;
	//FIX here
    rep(i,1,N){
        fact[i]=(fact[i-1]*i)%mod;
    }
}
int main()
{   ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    initiate();
    ll n,k;
    cin>>n>>k;
    ll ans;
    if(n-1>k){
         ans=0;
         rep(i,0,k+1){
             ll temp=(nCrModPFermat(n,i)*nCrModPFermat(n-1,i))%mod;
             ans=(ans+temp)%mod;
         }
    }
    else{
        ans=nCrModPFermat(2*n-1, n);
        //cout<<nCrModPFermat(5, 3);
        //cout<<"case2";
    }
    cout<<ans;
             
    
}

Measured memory_bytes: 3328
N = int(input())
z,w = [],[]
K = 0
for i in range(N):
  x,y = map(int,input().split())
  z.append(x)
  w.append(y)
for j in range(N-2):
  if z[j] == w[j] and z[j+1] == w[j+1] and z[j+2] == w[j+2]:
    K += 1

if K >= 1:
  print("Yes")
else:
  print("No")

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

int main(void){

  int a[100],b[100],c[100],d[100],tmp,check,n,m,i,j,point;

  scanf("%d %d",&n,&m);

  for(i=0;i<n;i++)
    scanf("%d %d",&a[i],&b[i]);
  for(j=0;j<m;j++)
    scanf("%d %d",&c[j],&d[j]);

  for(i=0;i<n;i++){
      tmp = 500000000;
      point = 0;
    for(j=0;j<m;j++){
      check = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(check<tmp){
        tmp = check;
        point = j;
      }
    }
    printf("%d\n",point+1);
  }
  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <bitset>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
const int MOD=1000000007;
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<pii> vpii;
#define DEBUG_CAT
#ifdef DEBUG_CAT
#define dbg(...)   printf( __VA_ARGS__ )
#else 
#define dbg(...)   /****nothing****/
#endif

int rint();char rch();long long rlong();
int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n=rint();
  int a=rint(),b=rint();
  if (abs(a-b)%2) {
    printf("Borys\n");
    
  }
  else printf("Alice\n");
}

int rint()
{
  int xx;scanf("%d",&xx); return xx;
}

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

int main() {
	int H, W, K, ANS = 1000000000;
	cin >> H >> W >> K;
	vector<string> S(H);
	for (int i = 0; i < H; i++) cin >> S[i];
	for (int p = 0; p < (1 << (H - 1)); p++) {
		vector<int> V;
		int I = p;
		for (int j = 0; j < H - 1; j++) {
			if (I % 2 == 1) V.push_back(j);
			I /= 2;
		}
		vector<vector<int> > X(V.size() + 1, vector<int>(W));
		if (p != 0) {
			for (int i = 0; i < W; i++) {
				for (int j = 0; j < V.size(); j++) {
					for (int k = (j == 0 ? 0 : V[j - 1] + 1); k <= V[j]; k++) {
						X[j][i] += S[k][i] - '0';
					}
				}
				for (int j = V[V.size() - 1] + 1; j < H; j++) {
					X[V.size()][i] += S[j][i] - '0';
				}
			}
		}
		else {
			for (int i = 0; i < W; i++) {
				for (int j = 0; j < H; j++) {
					X[0][i] += S[j][i] - '0';
				}
			}
		}
		vector<int> NOW(V.size() + 1, 0);
		int COUNT = 0;
		for (int i = 0; i < W; i++) {
			for (int j = 0; j < X.size(); j++) {
				if (X[j][i] > K) COUNT = 1000000000;
			}
		}
		for (int i = 0; i < W; i++) {
			for (int j = 0; j < X.size(); j++) {
				NOW[j] += X[j][i];
			}
			int MAX = 0;
			for (int j = 0; j < X.size(); j++) {
				MAX = max(MAX, NOW[j]);
			}
			if (MAX > K) {
				COUNT++;
				for (int j = 0; j < X.size(); j++) {
					NOW[j] = X[j][i];
				}
			}
		}
		ANS = min(ANS, COUNT + (int)X.size() - 1);
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int n, k;
    cin >> n >> k;
    
    if(n % k == 0) cout << 0 << endl;
    else cout << 1 << endl;
    
    return 0;

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from bisect import bisect_right

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class BIT2:
    """ 区間加算BIT(区間加算・区間合計取得) """

    def __init__(self, N):
        # 添字0が使えないので、内部的には全て1-indexedとして扱う
        N += 1
        self.N = N
        self.data0 = [0] * N
        self.data1 = [0] * N

    def _add(self, data, k, x):
        k += 1
        while k < self.N:
            data[k] += x
            k += k & -k

    def _get(self, data, k):
        k += 1
        s = 0
        while k:
            s += data[k]
            k -= k & -k
        return s

    def add(self, l, r, x):
        """ 区間[l,r)に値xを追加 """

        self._add(self.data0, l, -x*(l-1))
        self._add(self.data0, r, x*(r-1))
        self._add(self.data1, l, x)
        self._add(self.data1, r, -x)

    def query(self, l, r):
        """ 区間[l,r)の和を取得 """

        return self._get(self.data1, r-1) * (r-1) + self._get(self.data0, r-1) \
             - self._get(self.data1, l-1) * (l-1) - self._get(self.data0, l-1)

N, D, K = MAP()

XH = []
for i in range(N):
    x, h = MAP()
    XH.append((x, h))

XH.sort()
X, H = zip(*XH)
D = D * 2

bit = BIT2(N)
ans = 0
for i, (x, h) in enumerate(XH):
    h -= bit.query(i, i+1) * K
    if h <= 0:
        continue
    cnt = ceil(h, K)
    idx = bisect_right(X, x+D) - 1
    bit.add(i, idx+1, cnt)
    ans += cnt
print(ans)


Measured memory_bytes: 98240
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL digit(LL x) {
	LL digit = 0;
	while (x > 0) {
		x /= 10;
		digit++;
	}

	return digit;
}

int main() {
	LL N; cin >> N;

	LL ans = INF2;
	for (LL i = 1; i*i <= N;i++) {
		if (N%i == 0) {
			ans = min(ans, digit(N/i));
		}
	}

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

Measured memory_bytes: 256
//#define USE_CPP11
// #define USE_PRINTF

#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <complex>
#include <memory>
#include <sstream>

#ifdef USE_CPP11
#include <unordered_map>
#include <unordered_set>
#include <functional>
#endif

#define PRINT(obj) cout << obj << endl
#define REP(i, n) for(int (i) = 0; (i) < (n); i++)
#define SPACE " "

typedef long long ll;

const int INF = 1e9 + 10;

using namespace std;

namespace Scanner {
#ifdef USE_PRINTF
  int    nextInt()    { int    d; scanf("%d" , &d); return d; }
  float  nextFloat()  { float  f; scanf("%f" , &f); return f; }
  double nextDouble() { double f; scanf("%lf", &f); return f; }  
  string nextString() { string s; scanf("%s" , &s); return s; }
  ll     nextll()     { ll     l; scanf("%ll", &l); return l; }
#else
  int    nextInt()    { int    d; cin >> d; return d; }
  float  nextFloat()  { float  f; cin >> f; return f; }
  double nextDouble() { double f; cin >> f; return f; }  
  string nextString() { string s; cin >> s; return s; }
  ll     nextll()     { ll     l; cin >> l; return l; }
#endif

  string getLine() { 
    string input;
    getline(cin, input);
    return input;
  }
};

namespace myLibrary {
  vector<string> split(const string& str, char delim) {
    vector<string> ret;
    size_t current = 0, found;
    while ((found = str.find_first_of(delim, current)) != string::npos) {
      ret.push_back(string(str, current, found - current));
      current = found + 1;
    }
    ret.push_back(string(str, current, str.size() - current));
    return ret;
  }
  
#ifdef USE_CPP11
  ///
  /// higher-order functional
  /// This is something like map in haskell, python, etc.
  /// Sample usage:
  ///   vector<int> a = {1, 2, 3, 4, 5};
  ///   vector<int> b = myLibrary::_Map<int, int>(a, [](int n){
  ///     return n * n;
  ///   });
  /// Result:
  ///   b = 1, 4, 9, 16, 25
  ///
  template<typename T_IN, typename T_OUT, class Functor>
  vector<T_OUT> _Map(vector<T_IN> src, Functor func) {
    vector<T_OUT> ret;
    for (int i = 0; i < src.size(); i++) {
      ret.push_back(func(src[i]));
    }
    return ret;
  }
#endif

};

/// BEGIN //////////////////////////////////////////////////////////

int main() {
  int a = Scanner::nextInt();
  int b = Scanner::nextInt();
  int c = Scanner::nextInt();

  for (int t = 0; ; t++) {
    int m = 60 * t + c;
    if (m < 0) {
      PRINT(-1);
      break;
    }
    int n = m % (a + b);
    if (n <= a) {
      PRINT(m);
      break;
    }
  }

  return 0;
}
/// END   //////////////////////////////////////////////////////////

Measured memory_bytes: 1168
def resolve():
    mod=1e9+7
    n=int(input())
    a=list(map(int,input().split()))
    ans=1
    cnt=[0]*(n+1)
    cnt[0]=3
    for i in range(n):
        if cnt[a[i]]>0:
            ans=(ans*cnt[a[i]])%mod
            cnt[a[i]]-=1
            cnt[a[i]+1]+=1
        else :
            ans=0
    print(int(ans))
resolve()

Measured memory_bytes: 20704
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if(A+B > C+D){
  	cout << "Left" << endl;
  }else if(A+B < C+D){
  	cout << "Right" << endl;
  }else{
  	cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
a[0] -= 1
for i in range(1,n):
    if a[i] > a[i-1]:
        a[i] -= 1
    elif a[i] < a[i-1]:
        print('No')
        break
else:
    print('Yes') 

Measured memory_bytes: 85280
#include<stdio.h>
#include<stdlib.h>
int order(int n,int *s){
  int i,j,num=1,count=1,a;
  for(i=n;i>=1;i--)
    num*=i;
  for(j=0;j<n-1;j++){
    a=0;
    i=0;
    while(i!=j){
      if(s[i]<s[j])
        a++;
      i++;
    }
    num=num/(n-j);
    count+=num*(s[j]-a-1);
  }
  return count;
}

int main(){
  int n,i,a,b;
  scanf("%d",&n);
  int p[n+1],q[n+1];
  for(i=0;i<n;i++)
    scanf("%d",&p[i]);
  for(i=0;i<n;i++)
    scanf("%d",&q[i]);
  a=order(n,p);
  b=order(n,q);
  if(a>b)
    printf("%d\n",a-b);
  else
    printf("%d\n",b-a);
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int N,M;
map<int,int> ct;

int main(){
	cin>>N>>M;
	REP(i,M){
		int a,b;
		cin>>a>>b;
		a--;b--;
		ct[a]++;
		ct[b]++;
	}
	REP(i,N){
		cout<<ct[i]<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int ha,hb,ka,kb,a,b,c,d,x,y;
    scanf("%d %d",&ha,&hb);
    scanf("%d %d",&ka,&kb);
    scanf("%d %d %d %d",&a,&b,&c,&d);
    x=(ha*a)+(hb*b)+(ha/10)*c+(hb/20)*d;
    y=(ka*a)+(kb*b)+(ka/10)*c+(kb/20)*d;
    
    if(x==y)
        printf("even\n");
    else if(y<x)
        printf("hiroshi\n");
    else
        printf("kenjiro\n");
    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a == b && a != c && b != c){
    cout << "Yes" << endl;
  }
  
  else if(b == c && a != b && a != c){
    cout << "Yes" << endl;
  }
  
  else if(c == a && a != b && c != b){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}

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

int main(){
    int n=10;
    cin>>n;
    string str;
    n++;
    while(n--){
        getline(cin,str);
        for(int i=3;i<99;i++){
            if(i%2==0||i%13==0)continue;
            for(int j=0;j<26;j++){
                vector<int>vec;
                for(int k=0;k<26;k++){
                    vec.push_back((i*k+j)%26);
                }
                sort(vec.begin(),vec.end());
                if(unique(vec.begin(), vec.end())!=vec.end())continue;
                string ss=str;
                for(int k=0;k<str.length();k++){
                    if(str[k]>='a'&&str[k]<='z')
                        ss[k]=((i*(str[k]-'a')+j)%26)+'a';
                    else ss[k]=str[k];
                }
                int len=ss.length();
                for(int k=0;k<len-3;k++){
                    if(ss.substr(k,4)=="this"||ss.substr(k,4)=="that"){
                        cout<<ss<<endl;
                        goto next;
                    }
                }
            }
        }
    next:;
    }
}

Measured memory_bytes: 1236
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

S = input()

N = len(S)


if S[0 : int((N - 1)/2)] == S[int((N + 1)/2) : int(N)]:
    print("Yes")
else:
    print("No")

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

int main(){
  string s;
  cin>>s;
  if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
      cout<<"Yes";
      return 0;
  }
  cout<<"No";
 
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define   ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define   ll  long long
#define   pi  pair<int,int>
#define   pb  push_back
const int N=2e5+2;
string s,p;

int main()
{
    ft
    ll t,i,j,n,m;
    cin>>s>>p;
    p+=s;
    cout<<p<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int n;
	scanf("%d", &n);

	int a[n];
	for(int i=0; i<n; i++) {
		scanf("%d", a+i);
	}

	int max = a[0], min = a[0];
	for(int i=0; i<n; i++) {
		if(max < a[i]) {
			max = a[i];
		}
		if(min > a[i]) {
			min = a[i];
		}
	}

	int abs = max - min;

	printf("%d\n", abs);

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    ll n,a,b; cin >> n >> a >> b;
    ll q = n / (a + b);
    n = n - (q* (a+b));
    if(a <= n) cout << q*a + a << endl;
    else cout << q*a + n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4];
    rep(i,1){
        cin >> A[i];
    }
    // sort(A,A+3);
    cout << (A[0]%2==0 ? A[0] : A[0]*2) << endl;
}

Measured memory_bytes: 256
const log = console.log;

const createScanFunctions = (input: string) => {
  const str = input.trim();
  const len = str.length;
  let index = 0;

  const scan = () => {
    const startIndex = index;

    while (index < len) {
      const char = str[index];

      if (char === " " || char === "\n")
        return str.substring(startIndex, index++);

      index++;
    }

    return str.substr(startIndex);
  };

  const scanInt = () => parseInt(scan());

  const scanIntArray = (length: number) => {
    const array = new Array<number>(length);
    for (let i = 0; i < length; i++) array[i] = parseInt(scan());

    return array;
  };

  return { scan, scanInt, scanIntArray };
};

// ----

function Main(input: string): void {
  const { scanInt, scanIntArray } = createScanFunctions(input);
  const [w, h, n] = scanIntArray(3);

  let x1 = 0;
  let y1 = 0;
  let x2 = w;
  let y2 = h;

  for (let i = 0; i < n; i++) {
    const x = scanInt();
    const y = scanInt();
    const a = scanInt();

    switch (a) {
      case 1:
        x1 = Math.max(x, x1);
        break;
      case 2:
        x2 = Math.min(x, x2);
        break;
      case 3:
        y1 = Math.max(y, y1);
        break;
      case 4:
        y2 = Math.min(y, y2);
        break;
    }
  }

  log(Math.max(0, x2 - x1) * Math.max(0, y2 - y1));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const int N=100100;
char col[N];
int f[N],ans,sum,n,vis[N];
set<int>g[N];
queue<int>q;

int dfs(int x,int fa=-1){
	int mx=0;
	for(int i:g[x])if(i!=fa){
		int u=dfs(i,x);
		ans=max(ans,f[x]+u+mx);
		mx=max(mx,u);
	}
	return mx+f[x];
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<n;++i){
		int x,y;cin>>x>>y;
		g[x].insert(y);g[y].insert(x);
	}
	cin>>(col+1);
	for(int i=1;i<=n;++i)if(col[i]=='B'&&(int)g[i].size()<=1)
		q.push(i),vis[i]=1;
	while(!q.empty()){
		int x=q.front();q.pop();
		for(int i:g[x]){
			g[i].erase(x);
			if((int)g[i].size()<=1&&col[i]=='B'&&!vis[i])q.push(i),vis[i]=1;
		}
		g[x].clear();
	}
	int rt=0;
	for(int i=1;i<=n;++i){
		sum+=g[i].size();
		if((col[i]=='W')^(g[i].size()&1))++sum,f[i]=2;
		else f[i]=0;
		if(col[i]=='W')rt=i;
	}
	if(rt)dfs(rt);
	cout<<sum-ans<<'\n';	
	return 0;
}


Measured memory_bytes: 21120
#include<stdio.h>
int main(void)
{
	int a,b,d,r;
	double f;

	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=1.0*a/b;
	printf("%d %d %f\n",d,r,f);

	return 0;
}

Measured memory_bytes: 636
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <iostream>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int main(){
  int N;
  scanf("%d", &N);
  vector<char> s(N, ' ');
  for (int i = 0; i < N; i++){
    scanf(" %c", &(s[i]));
  }
  vector<vector<int> >dp(4, vector<int>(N+1, -1));
  //dp[0][0] = 0, dp[0][1] = 0
  dp[0][0] = 0; dp[0][N] = 0;
  dp[0][1] = 0;
  //dp[1][0] = 0, dp[1][1] = 1
  dp[1][0] = 0; dp[1][N] = 0;
  dp[1][1] = 1;
  //dp[2][0] = 1, dp[2][1] = 0
  dp[2][0] = 1; dp[2][N] = 1;
  dp[2][1] = 0;
  //dp[3][0] = 1, dp[3][1] = 1
  dp[3][0] = 1; dp[3][N] = 1;
  dp[3][1] = 1;  
  for (int x = 0; x < 4 ; x++){
    bool flag = true;
    for (int i = 1; i < N; i++){
      if (dp[x][i+1] == -1){
        if (dp[x][i] == 0){
          if (s[i] == 'o'){
            dp[x][i+1] = dp[x][i-1];
          }else{
            dp[x][i+1] = 1^dp[x][i-1];
          }
        }else{
          if (s[i] == 'o'){
            dp[x][i+1] = 1^dp[x][i-1];
          }else{
            dp[x][i+1] = dp[x][i-1];
          }
        }
      }else{
        if (dp[x][i] == 0){
          if (s[i] == 'o'){
            if (dp[x][i+1] != dp[x][i-1]){
              flag = false;
            }
          }else{
            if (dp[x][i+1] != (1^dp[x][i-1])){
              flag = false;
            }
          }
        }else{
          if (s[i] == 'o'){
            if (dp[x][i+1] != (1^dp[x][i-1])){
              flag = false;
            }
          }else{
            if (dp[x][i+1] != dp[x][i-1]){
              flag = false;
            }
          }
        }
      }
    }
    if (flag){
      if (dp[x][0] != dp[x][N]){
        continue;
      }else if (s[0] == 'o'){
        if (dp[x][0] == 0){
          if (dp[x][N-1] != dp[x][1]){
            continue;
          }
        }else{
          if (dp[x][N-1] != (1^dp[x][1])){
            continue;
          }
        }
      }else{
        if (dp[x][0] == 0){
          if (dp[x][N-1] != (1^dp[x][1])){
            continue;
          }
        }else{
          if (dp[x][N-1] != dp[x][1]){
            continue;
          }
        }
      }
      for (int i = 0; i < N; i++){
        printf("%c", (dp[x][i] == 0)?'S':'W');
      }
      printf("\n");
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define umap unordered_map
#define flush fflush(stdout)
#define all(v) v.begin(),v.end()
#define st first
#define nd second
#define ln '\n'
#define MAX 1000000009
#define MOD 1000000007
#define N 500005
using namespace std;
typedef long long ll;
typedef pair<int ,int > pii;
int n, x, k, dp[N];
int main(){
    #ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    cin >> n >> k;
    vector <int> v;
    while(n--){
        cin >> x;
        v.pb(x);
    }
    sort(all(v));
    int nec = v[0];
    for(int i = 0; i <= k; i++){
        if(i < nec){
            dp[i] = 1;
        }
        else {
            dp[i] = 1;
            for(int j = 0; j < v.size() && v[j] <= i; j++){
                if(dp[i - v[j]] == 1){
                    dp[i] = 0;
                    break;    
                }
            }
        }
        //cout << dp[i] << ln;
    }
    cout << (!dp[k] ? "First" : "Second");
    
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

vec ans;

void dfs(ll pre,ll lef=10) {
  if(pre!=0) {
    ll bef=pre%10;
    pre*=10;
    for(ll i=-1;i<2;i++) {
      if(bef+i<0||bef+i>9) continue;
      ll now=pre+bef+i;
      if(lef>0) {
        dfs(now,lef-1);
      }
      else {
        ans.push_back(now);
      }
    }
  }
  else {
    for(ll i=0;i<10;i++) {
      if(lef>0) {
        dfs(i,lef-1);
      }
      else {
        if(i!=0) ans.push_back(i);
      }
    }
  }
}

int main() {
  ll k;
  cin >> k;
  dfs(0LL);
  cout << ans[k-1] << endl;
}

Measured memory_bytes: 10604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N,A,B;
    int count[3] = {0,0,0};

    cin >> N >> A >> B;
    REP(i,N)
    {
        int tmp;
        cin >> tmp;
        if(tmp <= A) count[0]++;
        else if(A < tmp && tmp <= B) count[1]++;
        else count[2]++;
    }

    cout << min({count[0], count[1], count[2]}) << endl;

}


Measured memory_bytes: 256
from fractions import gcd

N,M = map(int,input().split())
S = input()
T = input()

G = gcd(N, M)
L = N * M // G
ng = N//G
mg = M//G

for i in range(G):
    Nnum = i*ng
    Mnum = i*mg
    if S[Nnum] != T[Mnum]:
        print(-1)
        exit()

print(L)


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

int main(void){
    int d,g;
    cin >> d >> g;
    int p[d],c[d];
    for(int i=0;i<d;i++) cin >> p[i] >> c[i];

    int ans = pow(10,6);
    for(int bit=0;bit<(1<<d);bit++){
        int sum,num,skip_cnt;
        sum = num = 0;
        //ここ-1にする意味わからん
        skip_cnt = -1;
        for(int i=0;i<d;i++){
            if(bit & (1<<i)){
                sum += 100*(i+1)*p[i]+c[i];
                num += p[i];
            }
            else{
                skip_cnt = i;
            }
        }

        if(sum < g){
            int s1 = 100*(skip_cnt+1);
            int diff = (g-sum+s1-1)/s1;
            if(diff >= p[skip_cnt]) continue;
                num += diff;
        }
        ans = min(ans,num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e3 + 10;
char str[N][N];
int ans[N][N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> str[i] + 1;
	for (int i = 1; i <= n; i++)
	{
		int cnt = 0;
		for (int j = 1; j <= m; j++)
		{
			if (str[i][j] != '.') cnt = 0;
			else cnt++;
			ans[i][j] += cnt;
		}
		cnt = 0;
		for (int j = m; j > 0; j--)
		{
			if (str[i][j] != '.') cnt = 0;
			else cnt++;
			ans[i][j] += cnt;
		}
	}
	for (int j = 1; j <= m; j++)
	{
		int cnt = 0;
		for (int i = 1; i <= n; i++)
		{
			if (str[i][j] != '.') cnt = 0;
			else cnt++;
			ans[i][j] += cnt;
		}
		cnt = 0;
		for (int i = n; i >= 1; i--)
		{
			if (str[i][j] != '.') cnt = 0;
			else cnt++;
			ans[i][j] += cnt;
		}
	}
	int res = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			res = max(res, ans[i][j] - 3);
		}
	}
	cout << res << endl;
	return 0;
}

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

typedef long long ll;

int main(void){
    int n;
    cin >> n;
    map<ll,int> mp;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        mp[a]++;
    }
    auto itr = mp.end();
    ll a = 0, b = 0;
    while(itr != mp.begin()){
        itr--;
        if(itr->second < 2){
            continue;
        }else{
            if(a > 0){
                b = itr->first;
                break;
            }else{
                a = itr->first;
                itr->second -= 2;
                itr = mp.end();
                continue;
            }
        }
    }
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(15) << << endl;
#include <cassert>
//#include "atcoder/all"

using namespace std;
//using namespace atcoder;

#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define P pair<int,int>

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;


int main(){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    vector<ll> a(10000004);
    for(int i = 1; i < 10000004; ++i){
        for(int j = 1; j <= 10000004/i; ++j){
            a[i*j]++;
        }
    }

    ll ans = 0;
    ll n; cin >> n;
    for(ll i = 1ll; i <= n; ++i){
        ans += i * a[i];
    }

    cout << ans << endl;
}



Measured memory_bytes: 81224
# coding: utf-8
import itertools
import math
N = int(input())
P = tuple(map(int, input().split(" ")))
Q = tuple(map(int, input().split(" ")))


for idex, j in enumerate(itertools.permutations(range(1, N+1))):
    if P == j:
        a = idex+1
    if Q == j:
        b = idex + 1

print(abs(a-b))


Measured memory_bytes: 8972