akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import Counter, defaultdict
from itertools import product
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(H: int, W: int, N: int, a: "List[int]", b: "List[int]"):
    d = defaultdict(int)
    for ai, bi in zip(a, b):
        for da, db in product((-1, 0, 1), repeat=2):
            aj = ai - 1 + da
            bj = bi - 1 + db
            if 1 <= aj <= H - 2 and 1 <= bj <= W - 2:
                d[aj, bj] += 1
    c = Counter(d.values())
    e = [c[i] for i in range(1, 10)]
    print((H - 2) * (W - 2) - sum(e))
    for ei in e:
        print(ei)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(H, W, N, a, b)


if __name__ == '__main__':
    main()


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

using namespace std;

int N;

int main(){

  while(cin>>N&&N){
    vector<int> v[101];
    for(int i=0;i<N;i++){
      int M;
      cin>>M;
      for(int j=0;j<M;j++){
	int p;
	cin>>p;
	v[i].push_back(p);
      }
    }
    vector<int> ls;
    int K;
    cin>>K;
    for(int i=0;i<K;i++){
      int l;
      cin>>l;
      ls.push_back(l);
    }
    vector<int> ans;
    for(int i=0;i<N;i++){
      bool aa=true;
      for(int j=0;j<(int)ls.size();j++){
	bool ok=false;
	for(int k=0;k<(int)v[i].size();k++){
	  if(v[i][k]==ls[j])ok=true;
	}
	if(!ok){
	  aa=false;
	  break;
	}
      }
      if(aa){
	ans.push_back(i);
	if(ans.size()>=2){
	  break;
	}
      }
    }
    if((int)ans.size()==1)
      cout<<ans[0]+1<<endl;
    else cout<<-1<<endl;
  }

  return 0;
}

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




using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n ,m; int pos=1;
	cin>>n>>m;
	vector<long long>nums(n);
	vector<pair<int,long long> > subs;
	for(int i = 0 ; i< n ; i++){
		cin>>nums[i];
	}
	pair<int,int>f = {0,1};

	subs.push_back(f);

	sort(nums.begin(),nums.end());
	for(int i = 0  ;i< m ; i++){
		int a,b;cin>>a>>b;
		pair<int,long long>f = {b,a};
		subs.push_back(f);
	}

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

	for(int i = 0 ; i<n ; i++){
		if(nums[i]<subs[subs.size()-pos].first){
			nums[i]=subs[subs.size()-pos].first;
			subs[subs.size()-pos].second--;
			if(subs[subs.size()-pos].second==0){
				pos++;
			}
		}
		else{
			break;
		}
	}
	long long sum=0;

	for(int i = 0 ; i< n ; i++){
		sum= sum+nums[i];
	}

	cout<<sum;








}

Measured memory_bytes: 3188
package main

import "fmt"

func main() {
	// Code for A - Prefix and Suffix
	var n int
	fmt.Scanf("%d", &n)

	var s, t string
	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &t)

	var flag int
	for i := 0; i < n; i++ {
		if s[i:n] == t[0:n-i] {
			fmt.Println(n + i)
			flag = 1
			break
		}
	}

	if flag == 0 {
		fmt.Println(2 * n)
	}
}


Measured memory_bytes: 1836
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
B = map(int, input().split())

ans = 0
for i, b in enumerate(B):
    if i == 0:
        ans += b
    else:
        ans += min(b, prev)
    prev = b
ans += prev
print(ans)


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

def show(nums):
    for i in range(len(nums)):
        if i != len(nums)-1:
            print(nums[i],end=' ')
        else:
            print(nums[i])
show(A)
for i in range(1,N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    show(A)


Measured memory_bytes: 5976
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 100000000000
struct max_flow {
    struct edge { ll to, cap, rev; };
    ll V;
    vector<vector<edge>> G;
    vector<ll> itr, level;

    max_flow(ll V) : V(V) { G.assign(V,vector<edge>()); }

    void add_edge(ll from, ll to, ll cap) {
        G[from].push_back((edge) {to, cap, (ll) G[to].size()});
        G[to].push_back((edge) {from, 0, (ll) G[from].size()-1});
    }

    void bfs(ll s) {
        level.assign(V,-1);
        queue<ll> q;
        level[s] = 0; q.push(s);
        while (!q.empty()) {
            ll v = q.front(); q.pop();
            for(auto &e: G[v]){
                if (e.cap > 0 and level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }

    ll dfs(ll v, ll t, ll f) {
        if (v == t) return f;
        for (ll& i = itr[v]; i < (ll) G[v].size(); ++i) {
            edge& e = G[v][i];
            if (e.cap > 0 and level[v] < level[e.to]) {
                ll d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    ll run(ll s, ll t) {
        ll ret = 0, f;
        while (bfs(s), level[t] >= 0) {
            itr.assign(V,0);
            while ((f = dfs(s, t, INF)) > 0) ret += f;
        }
        return ret;
    }
};

int main()
{
    ll N;cin >> N;
    ll ans=0;
    max_flow solve(N+2);
    ll a;
    for (ll i=0;i<N;i++)
    {
        cin >> a;
        if (a<=0)
        {
            solve.add_edge(0,i+1,-a);
            for (ll j=2;j*(i+1)<=N;j++) 
            {
                solve.add_edge(i+1,j*(i+1),INF);
            }
        }
        else
        {
            ans+=a;
            solve.add_edge(i+1,N+1,a);
            for (ll j=2;j*(i+1)<=N;j++) 
            {
                solve.add_edge(i+1,j*(i+1),INF);
            }
        }
    }
    cout << ans-solve.run(0,N+1) << endl;
return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
tree = [int(input()) for _ in range(n)]
tree.sort()
result = float('INF')
cumulative = [0]
for i in range(n - 1):
    cumulative.append(tree[i + 1] - tree[i] + cumulative[i])
for i in range(n - k + 1):
    result = min(result, cumulative[i + k - 1] - cumulative[i])
print(result)


Measured memory_bytes: 11304
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination MOD prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint p(int n, int k) {
        return fact[n]*ifact[n-k];
    }
} comb(10000007);
// comb(5, 2) → 10, comb.p(5, 2) → 20
// comb.fact[4] → 24, 2のN乗 → mint(2).pow(N)

int main() {
    // 同じ色で塗られている組を1から数える
    int N, M, K;
    cin >> N >> M >> K;
    mint ans = 0;
    for (int i = 0; i <= K; i++) {
        // i組、(N-i) ^ M * (N-i-1+i)C(i)
        ans += mint(M) * mint(M-1).pow(N-1-i) * comb(N-1, i);
    }
    cout << ans << '\n';
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> v(n),c(n);
  for(int i = 0; i < n; ++i){
    cin >> v[i];
  }
  for(int i = 0; i < n; ++i){
    cin >> c[i];
  }
  
  int res = 0;
  for(int i = 0; i < n; ++i){
    if(v[i] > c[i]){
      res += v[i] - c[i];
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    VI l(n);
    rep(i,n) cin >> l[i];
    sort(all(l));
    int sum = 0;
    rep(i,n-1) sum += l[i];
    if (l[n-1] < sum) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0; 
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
    int n,k;cin>>n>>k;
    int me;
    rep(i,n){
        int a;cin>>a;
        if(a==1){
            me = i+1;
        }
    }
    int ans =(me-1)/(k-1);
    if((me-1)%(k-1))ans++;
    ans+=(n-me)/(k-1);
    if((n-me)%(k-1))ans++;
    cout<<((n-1)+(k-2))/(k-1)<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define pb push_back
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
/******************************define**********************************/
const int MAX_N = 100000;
vector<vector<int>> G(MAX_N,vector<int>(0));
int used[MAX_N];
/*****************************functions********************************/
void dfs(int x){
    used[x] = 1;
    for(int i = 0;i < G[x].size();i++){
        if(used[G[x][i]] == 0){
            dfs(G[x][i]);
        }
    }
}
/****************************main function*****************************/
int main(void){
    int n,m;cin>>n>>m;
    for(ll i = 0;i < m;i++){
        int x,y,z; cin>>x>>y>>z;
        
            G[--x].pb(--y);
            G[y].pb(x);
        
    }
    int ans = 0;
    for(ll i = 0;i < n;i++){
        if(used[i] == 0){
            ans++;
            dfs(i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int>a(20000);
    vector<int>b(20000);
    char x;
    for (int i=0;i<20000;i++){
        cin>>a.at(i)>>x>>b.at(i);
        if(x=='?'){
            break;
        }
        else if(x=='+'){
            cout<<a.at(i)+b.at(i)<<endl;
        }
        else if(x=='-'){
            cout<<a.at(i)-b.at(i)<<endl;
        }
        else if(x=='*'){
            cout<<a.at(i)*b.at(i)<<endl;
        }
        else{ 
           cout<< a.at(i)/b.at(i)<<endl;
        }
    } 
}


Measured memory_bytes: 3244
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    A_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    A_arr_odd = [A for A in A_arr if A%2==1]
    TF = 'YES' if len(A_arr_odd)%2==0 else 'NO'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)


Measured memory_bytes: 62940
N,M,K = map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

a,b = [0],[0]

for i in range(N):
  a.append(a[i]+A[i])
for i in range(M):
  b.append(b[i]+B[i])
  
ans = 0
j = M

for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans,i+j)

print(ans)

Measured memory_bytes: 47672
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc.Split(bufio.ScanWords)

	n, m := nextInt(), nextInt()
	fmt.Println(float64(100*(n-m)+1900*m) * math.Pow(2, float64(m)))
}

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	if i, err := strconv.Atoi(sc.Text()); err != nil {
		panic(err)
	} else {
		return i
	}
}

func atoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(err)
	} else {
		return i
	}
}

func split(s, seq string) []string {
	return strings.Split(s, seq)
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdbool.h>

typedef double db;
typedef int in;
typedef long int li;
typedef long long int lli;
typedef long ld;
typedef long lld;

#define pi M_PI
#define in scanf
#define out printf
#define inf INT_MAX
#define rep(i,n) for(int i=0;i<n;++i)
#define debugd(d) printf("%d\n",d)
#define debugs(s) printf("%s\n",s)
#define debugc(c) printf("%c\n",c)
#define debugf(f) printf("%f\n",f)


int main (void)
{
  int a,b,c,d;
  int s,e;
  in("%d %d %d %d \n",&a,&b,&c,&d);
  if(a>d||c>b){
    puts("0");
    return 0;
  }
  s = a>=c ? a : c;
  e = b<=d ? b : d;
  printf("%d\n",e-s);
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

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

    int n, k;
    cin >> n >> k;
    vi v(n);
    REP(i, n) cin >> v[i];
    sort(v.begin(),v.end());
    ll ans = 0;
    REP(i, n-k) ans += v[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#define MAX 10010

int main()
{
    int n;
    while(cin >> n)
    {
        if(n==0)break;
        int pointa=0, pointb =0;
        int carda,cardb;
        for(int i=0;i<n;i++)
        {
            cin >> carda >> cardb;
            if( carda > cardb ){pointa += (carda+cardb); continue;}
            else if( carda<cardb ){pointb += (carda+cardb); continue;}
            else
            {
                pointa += carda;
                pointb += cardb;
                continue;
            }
        }
        cout << pointa  << " " << pointb << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0

signed main() {
	int n,mi=1000000000;
	cin >> n;
	int a[150];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = -100; i <= 100; i++) {
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			cnt += (a[j] - i)*(a[j] - i);
		}
		mi = min(mi, cnt);
	}
	cout << mi << endl;

	END;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
ll x,y,a,b,c;
ll p[200005],q[200005],r[200005];
bool cmp(ll a1,ll b1)
{
	return a1>b1;
}
int main()
{
	scanf("%lld%lld%lld%lld%lld",&x,&y,&a,&b,&c);
	for(ll i=0;i<a;i++) scanf("%lld",&p[i]); sort(p,p+a,cmp);
	for(ll i=0;i<b;i++) scanf("%lld",&q[i]); sort(q,q+b,cmp);
	for(ll i=0;i<c;i++) scanf("%lld",&r[i]); sort(r,r+c,cmp);
	ll sum=0;
	for(ll i=0;i<x;i++) sum+=p[i];
	for(ll i=0;i<y;i++) sum+=q[i];
	ll x1=x-1,y1=y-1,z1=0;
	while(x1+y1>=0)
	{
		if(z1==c) break;
		if(x1>=0&&y1>=0)
		{
//			printf("1\n");
			if(p[x1]>q[y1])
			{
				if(r[z1]>q[y1])
				{
					sum=sum-q[y1]+r[z1];
					y1--;
					z1++;
				}
				else
				{
					break;
				}
			}
			else
			{
				if(r[z1]>p[x1])
				{
					sum=sum-p[x1]+r[z1];
					x1--;
					z1++;
				}
				else
				{
					break;
				}
			}
		}
		else if(x1>=0)
		{
//			printf("2\n");
			if(r[z1]>p[x1])
			{
				sum=sum-p[x1]+r[z1];
				x1--;
				z1++;
			}
			else
			{
				break;
			}
		}
		else if(y1>=0)
		{
//			printf("\n");
			if(r[z1]>q[y1])
			{
				sum=sum-q[y1]+r[z1];
				y1--;
				z1++;
			}
			else
			{
				break;
			}
		}
		else
		{
			break;
		}
	}
	printf("%lld",sum);
}

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

int main() {
    int16_t n;
    cin >> n;
    for (int16_t i = 0; i < n; i++) {
        char c;
        cin >> c;
        if (c == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/arc075_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> c(N);
  int ans = 0;
  rep(i, N) {
    cin >> c[i];
    ans += c[i];
  }
  int max = ans;

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

  bool dec = false;
  rep(i, N) {
    if (ans % 10 != 0) break;
    if (c[i] % 10 == 0) {
      dec = true;
      continue;
    } else {
      ans -= c[i];
    }
  }
  if (dec && ans == max) ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

mint factorial(ll n) {
  mint answer = 1;
  while (n > 1) {
    answer *= n;
    n--;
  }
  return answer;
}

mint combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

mint permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

// setprecision(8) 桁数指定
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int r, d, x;
  cin >> r >> d >> x;
  REP(i, 10) {
    x = r * x -d;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	A := sc.nextInts()
	ans := 0
	for _, v := range A {
		ans += v
	}
	if ans >= 22 {
		fmt.Println("bust")

	} else {
		fmt.Println("win")
	}
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
#include<stdio.h>

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    int a = 1;
    int b = n;
    for(int i = 0; i < m; i++) {
        int l, r;
        scanf("%d %d", &l, &r);
        a = max(a, l);
        b = min(b, r);
    }

    if(b < a) printf("%d\n", 0);
    else printf("%d\n", b - a + 1);
    return 0;
}

Measured memory_bytes: 128
#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[i];

    int count = 0;
    for(int i=0; i<N; ++i) {
        if (A[i] % 2 != 0) count++;
    }
    if (count % 2 != 0) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

string change(string s){
    string res = "";
    string boin = "aiueo";
    res += s[0];
    rep(i, 0, s.size()){
        if(boin.find(s[i]) != string::npos){
            if(i != s.size() - 1){
                res += s[i + 1];
            }
        }
    }
    return res;
}

signed main(){
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        vector<string> s(n);
        rep(i, 0, n){
            string in;
            cin >> in;
            s[i] = change(in);
            // cout << s[i] << endl;
        }
        int ans = -1;
        rep(i, 1, 51){
            set<string> st;
            bool f = true;
            rep(j, 0, n){
                string tmp = s[j].substr((int)0, (int)min(i, (int)s[j].size()));
                // cout << tmp << " ";
                if(!st.count(tmp)){
                    st.insert(tmp);
                }else{
                    f = false; break;
                }
            }
            // cout << endl;
            // if(i == 5) break;
            if(f){
                ans = i;
                break;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
void _(ll&a , ll b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;cin >> n;ll a[n];map<ll,ll> m;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];m[a[i]]++;
    }
    ll ans=0;
    for(auto i : m)
    {
        ll d=i.second;
        ans+=(d*(d-1))/2;
    }
    for (int i = 0; i < n; ++i)
    {
        cout << ans-m[a[i]]+1 << "\n";
    }
    }

Measured memory_bytes: 11136
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
int a,b;
scanf("%d %d",&a,&b);
int x[3];
x[0]=a+a-1;
x[1]=b+b-1;
x[2]=a+b;
sort(x,x+3);
printf("%d\n",x[2]);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        long N;
        long A;
        long B;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextLong();
            A = sc.nextLong();
            B = sc.nextLong();
        }
        long C = A+B;
        if(C ==0){
            System.out.println(0);
            return;
        }
        long s = N /C;
        long a = N%C;
        long reult = (s * A) + (A > a ? a:A);
        System.out.println(reult);
    }
}


Measured memory_bytes: 25044
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	long N;
	cin >> N;
	vector<long> H(N);
	for (long i = 0; i < N; ++i)
	{
		cin >> H[i];
	}
	long prev = H[0];
	long count = 0;
	long max_count = 0;
	for (long i = 1; i < N; ++i)
	{
		if (prev >= H[i])
		{
			++count;
		}
		else
		{
			max_count = max(max_count, count);
			count = 0;
		}
		prev = H[i];
	}
	max_count = max(max_count, count);
	cout << max_count << endl;
	return 0;
}


Measured memory_bytes: 1152
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
  var x = chunk.split(" ");
  x[0] = Number (x[0])
  x[1] = Number (x[1])
  x[2] = Number (x[2])
  x[3] = Number (x[3])
  if ((x[0] < x[1]) && (x[1] < x[2])) {
    console.log("Yes")
  } else {
    console.log("No")
  }
});

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

int main(){
  string o,e;
  cin >> o >> e;
  for(int i=0;i<e.size();i++){
    cout << o[i] << e[i];
  }
  if(o.size()!=e.size()){
    cout << o[o.size()-1];
  }
}

Measured memory_bytes: 256
N,M=map(int, input().split())
import sys
def input(): return sys.stdin.readline().strip()
A=list(map(int, input().split()))
BC=[list(map(int,input().split())) for i in range(M)]
A.sort()
BC.sort(key=lambda x: x[1],reverse=True)
from bisect import bisect_left
ans=0
l=0
for m in range(M):
    if BC[m][0]<len(A)-l and A[BC[m][0]+l]<BC[m][1]:
        ans=ans+BC[m][1]*BC[m][0]
        l+=BC[m][0]
    else:     
        r=bisect_left(A[l:],BC[m][1])
        if r:
            ans=ans+BC[m][1]*r
            l+=r
        break
ans+=sum(A[l:])
print(ans)

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

using namespace std;
typedef long long ll;

int main() {
    ll h, w;
    cin >> h >> w;
    ll ans = ((h + 1) / 2) * ((w + 1) / 2) + (h / 2) * (w / 2);
    if (h == 1 || w == 1) ans = 1;
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int X, Y;
    cin >> X >> Y;
    for (int i = 0; i <= X; i++) {
        if (i * 2 + (X - i) * 4 == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main(){
    long long n,m,l;
  cin >> n >> m >> l;
    long long k;
    long long A[n][m];
    long long B[m][l];
    long long i,j;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin >> A[i][j] ;
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            cin >> B[i][j] ;
        }
    }
    long long C[n][l];
    long long num;
    num =0;
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            num=0;
            for(k=0;k<m;k++){
               num = num +  (A[i][k])*(B[k][j]);
            }
            C[i][j] = num;
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            if (j < (l-1)){
                cout << C[i][j] << " " ;
            }
            else if(j == l-1){
                cout << C[i][j] << endl;
            }
             
        }
    }
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    double r;
    cin >> r;
    double pi=3.14159265;
    cout << pi*r*2.0000 << endl;
    return 0;
}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
set<int>s;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int i,n,l,r;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>l;
        if(s.find(l)==s.end())
        {
            s.insert(l);
        }
        else
        {
            s.erase(l);
        }
    }
    cout<<(int)s.size()<<"\n";
    return 0;
}

Measured memory_bytes: 4992
n,k,q = list(map(int,input().split()))
a = [int(input()) for i in range(q)]
np = [0]*n
for i in range(q):
    np[a[i]-1] += 1
for i in range(n):
    if k- (q - np[i]) >= 1:
        print('Yes')
    else:
        print('No')

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

def main():
    A, B = [int(i) for i in input().split()]
    A_o = int(A*100/8)
    B_o = B*10

    if A_o == B_o:
        print(B*10)
    elif A_o > B_o:
        for i in range(B_o,(B+1)*10):
            if int(i * 0.08) == A:
                print(i)
                return
        else:
            print(-1)
    elif A_o < B_o:
        for i in range(A_o,int((A+1)*100/8)):
            if (i * 0.1) == B:
                print(i)
                return
        else:
            print(-1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>

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

using namespace std;

int main(){
  int N;
  cin >> N;
  long long A[N], B[N];
  rep(i, N)
    cin >> A[i] >> B[i];
  // 入力終了

  long long ans = 0;
	         
  for(int i=N-1; i>=0; i--){
    // i+1個目のボタンを押した結果をi個目の整数に反映させる
    A[i] = A[i] + ans;

    // i番目にボタンを最低何回押さないといけないか
    long long tmp;
    // 既に条件を満たしている
    if(A[i]%B[i] == 0)
      tmp = 0;
    // B[i]の倍数までに必要な回数
    else
      tmp = B[i]-(A[i]%B[i]);

    // 累積和的に更新
    ans = ans + tmp;
  }

  //解答
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 5200
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector <long long> a(n);
  long long m = 0;
  for (int i = 0; i < n; i++) {
	  cin >> a[i];
	  m = max(m, a[i]);
	}
  long long ans = 0;
  for (int k = 0; k < 60; k++) {
	  long long i = ((long long) 1) << k;
	  if (i > m) {
		  break;
		}
	  long long c = 0;
	  for (int j = 0; j < n; j++) {
		  if (i & a[j]) {
			  c++;
			}
		}
	  c    = c * (n - c) % mod;
	  ans += (c * (i % mod)) % mod;
	  ans %= mod;
	}
  cout << ans << endl;
  return 0;
}


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

class Program
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);
        int M = int.Parse(input[1]);
        int[] A = new int[N];
        for(int i = 0; i < N; i++)
        {
            A[i] = -1;
        }
        int ans = 0;
        for(int i = 0; i < M; i++)
        {
            input = Console.ReadLine().Split();
            int s = int.Parse(input[0]);
            int c = int.Parse(input[1]);
            if (A[s - 1] >= 0 && A[s - 1] != c)
            {
                ans = -1;
            }
            else
            {
                A[s - 1] = c;
            }
        }
        if (ans != -1)
        {
            if (N >= 2 && A[0] == 0)
            {
                ans = -1;
            }
        }
        if (ans == -1)
        {
            Console.WriteLine(ans);
        }
        else
        {
            for (var i = 0; i < N; i++)
            {
                if (A[i] == -1)
                {
                    if (i == 0 && N >= 2)
                    {
                        A[i] = 1;
                    }
                    else
                    {
                        A[i] = 0;
                    }
                }
                Console.Write(A[i]);
            }
        }

    }
}

Measured memory_bytes: 11092
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

S = input().rstrip()

dp = [[0] * 13 for _ in range(len(S)+1)]
dp[0][0] = 1

#print(dp)

for i in range(len(S)):
	for j in range(13):
		if S[i]=='?':
			for d in range(10):
				nj = (j*10+d)%13
				dp[i+1][nj] += dp[i][j]
		else:
			nj = (j*10+int(S[i]))%13
			dp[i+1][nj] += dp[i][j]
	for j in range(13):
		dp[i+1][j] %= (10**9+7)

#print(dp)
print(dp[len(S)][5])

Measured memory_bytes: 61788
#import <stdio.h>
int main() {
	int n,a;
	scanf("%d",&n);
	long double sum = 0;
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		sum += (long double)1.0/a;
	}
	printf("%Lf\n",1.0/sum);
}

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

const int MAX = 1e6 + 1;
const int MOD = 1e9 + 7;

long long f[MAX], finv[MAX], inv[MAX];

void CombInit() {
  f[0] = f[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    f[i] = f[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long Perm(int n, int k) {
  if (n < k || k < 0) return 0;
  return f[n] * finv[n - k] % MOD;
}

long long Comb(int n, int k) {  // nもkも10^6以下の場合
  if (n < k || k < 0) return 0;
  return f[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long int Conb(long long int a,long long int b){  // nは10^18以下、kは10^6以下の場合
  if(b==1){
    return a;
  }else{
    return (((Conb(a,b-1)*(a-b+1))%MOD)*inv[b])%MOD;
  }
}

int main() {
  CombInit();
  long long int x,y,n,k,kotae;
  cin>>x>>y;
  if((x+y)%3!=0){
    cout<<0;
    return 0;
  }
  n=(x+y)/3;
  k=x-n;
  kotae=Comb(n,k);
  cout<<kotae;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define all(a)                      a.begin(), a.end()
#define pb                          push_back
#define ll							long long
#define index(a)            		order_of_key(a)
#define value(a)					find_by_order(a)
#define count_1 					__builtin_popcount
#define mod(x, m)					((((x) % (m)) + (m)) % (m))
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

ll dp[101][100005], w[100005], c[100005];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout << setprecision(12);

	ll n, C;
	cin >> n >> C;
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> c[i];
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= C; j++) {
			if (j < w[i])
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + c[i]);
		}
	}
	cout << dp[n][C];
	return 0;
}

Measured memory_bytes: 81692
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> vec(N);
  for(ll i=0;i<N;i++) {
cin>>vec[i];
  }
  
vector<bool>dp(K+1);
  dp[0]=false;
  
  for(ll i=1;i<=K;i++) {
for(ll j=0;j<N;j++) {
  
  if(i-vec[j]>=0&&!dp[i-vec[j]]) {
dp[i]=true;
  }
                      }
                      }
                      
                      
                      if(dp[K]) {
cout<<"First"<<endl;
                      }
                      else {
cout<<"Second"<<endl;
                      }
                      }

  
  


Measured memory_bytes: 3648
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long A, B, C;
    scan(A, B, C);
    (B/A).min(C).writeln();    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  string s;cin >> s;
  s.push_back(' ');
  char pre = s[0];
  int count = 0;
  rep(i,N+1){
    if(s[i] != pre)++count;
    pre = s[i];
  }
  cout << count << endl;
  return 0;
}


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

int main(void){
  long long n,d,ans;
  
  
  cin >> n >> d;
  ans = 0;
  for (int i=0; i<n; i++){
    long long x, y;
    cin >> x >> y;
    if (x*x<=d*d-y*y) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

ll gcd( ll a, ll b ){
    if( a < b ) swap(a,b);

    ll t = b;
    while( b ){
        t = b;
        b = a%b;
        a = t;
    }

    return a;

}

int main() {

    ll a,b;
    Scll2(a,b);

    ll c = gcd(a,b);

    int ans = 1;
    ll tmp = 1;

    Repe(i,1111111,2){
        while( c%i == 0 ){
            if( tmp != i ) ans++;
            c /= i;
            tmp = i;
        }
    }
    if( c != 1 ) ans++;

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

    return 0;
}





Measured memory_bytes: 256
import Data.List
main=do
 [a,b,c,d]<-map(map read.words).lines<$>getContents
 let k=a!!3
 let x=take k$f[0]b
 let y=take k$f x c
 let z=take k$f y d
 putStr$unlines$map(show.(0-))z
f a b=sort$[x-y|x<-a,y<-b]

Measured memory_bytes: 487804
from sys import stdin
a = stdin.readline().strip()
b = stdin.readline().strip()
x = [0]
for i in a:
    x.append(x[-1])
    if i=='A':
        x[-1]+=1
    else:
        x[-1] += 2
y = [0]
for i in b:
    y.append(y[-1])
    if i=='A':
        y[-1] += 1
    else:
        y[-1] += 2
    
q = int(stdin.readline())
for _ in xrange(q):
    x1,y1,x2,y2 = map(int,stdin.readline().split())
    fir = x[y1] - x[x1-1];
    sec = y[y2] - y[x2-1];
    fir%=3
    sec%=3
    fir = (fir + 3)%3
    sec = (sec + 3)%3
    if fir==sec:
        print 'YES'
    else:
        print 'NO'

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

using ll = long long;

template <typename T>
class node {
public:
	node<T> *l, *r;
	T val, add;
	node(T val_ = 0, node<T>* l_ = nullptr, node<T>* r_ = nullptr)
		: l(l_), r(r_), val(val_), add(0) {}
};

template <typename T>
class RARS {
	const ll n;
	node<T> *root;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	T sub(ll l, ll r, node<T>* n, ll lb, ll ub) {
		if (!n || ub <= l || r <= lb) return 0;
		if (l <= lb && ub <= r) return n->val + n->add * (ub - lb);
		return sub(l, r, n->l, lb, (lb + ub) / 2) + sub(l, r, n->r, (lb + ub) / 2, ub) + n->add * (min(r, ub) - max(l, lb));
	}
	node<T>* suc(ll l, ll r, node<T>* n, ll lb, ll ub, T val) {
		if (ub <= l || r <= lb) return n;
		if (!n) n = new node<T>;
		if (l <= lb && ub <= r) {
			n->add += val;
			return n;
		}
		n->val += val * (min(r, ub) - max(l, lb));
		n->l = suc(l, r, n->l, lb, (lb + ub) / 2, val);
		n->r = suc(l, r, n->r, (lb + ub) / 2, ub, val);
		return n;
	}
public:
	RARS(ll n_) : n(size(n_)), root(nullptr) {}
	void add(ll l, ll r, T val) {
		root = suc(l, r + 1, root, 0, n, val);
	}
	T getSum(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	RARS<ll> lst(n);
	for (int i = 0, type, s, t, x; i < q; i++) {
		cin >> type >> s >> t; s--; t--;
		if (type) {
			printf("%lld\n", lst.getSum(s, t));
		}
		else {
			cin >> x;
			lst.add(s, t, x);
		}
	}
	return 0;
}

Measured memory_bytes: 9340
#include <bits/stdc++.h>
    using namespace std;
    typedef long long llong;
     
    int a[200005];
     
    int main()
    {
        int n;
        scanf("%d", &n);
        for (int i = 0; i < n; i++)
        {
            scanf("%d", &a[i]);
        }
        llong last = a[0], sum = 0;
        for (int i = 1; i < n; i++)
        {
            if (a[i] < last)
            {
                sum += last - a[i];
            }
            else 
            {
                last = a[i];
            }
        }
        printf("%lld\n", sum);
        return 0;
    }

Measured memory_bytes: 4428