akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <istream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <cstring>
#include <string.h>
#include <iomanip>
#include <queue>
#include <stack>
#include <list>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vi lnum;
typedef long double ld;

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979
#define fopen freopen("input.txt", "r", stdin); freopen("output.txt","w", stdout)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define REPR(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define f first
#define s second

const int MOD9 = 1e9 + 7;
const int MOD91 = 1e9 + 9;
const ll MOD12 = 1e12 + 39LL;
const ll MOD15 = 1e15 + 37LL;
const ll INF = 1000LL * 1000* 1000 + 7;
const int base = 330;
const int MAXN = 2e5 + 6;
const double EPS = 1e-12;

using namespace std;
int Sum = 0;
const ll mod = 1000 * 1000 * 1000 + 7;
int n , m;
int pos[100001];
vector<vector<pair<int , int> > > g(100000);
void dfs(int u)
{
	for(int i = 0; i < g[u].size(); i++)
	{
		int v = g[u][i].first , d = g[u][i].second;
		if(pos[v] == -INF)
		{
			pos[v] = pos[u] + d;
			dfs(v);
		}
		else
			if(pos[v] != pos[u] + d)
			{
				cout << "No";
				exit(0);
			}
	}
}
int main()
{
	scanf("%d %d" , &n , &m);
	for(int i = 0; i < n; i++)
		pos[i] = -INF;
	for(int i = 0; i < m; i++)
	{
		int l , r , d;
		scanf("%d %d %d" , &l , &r , &d);
		l--;r--;
		g[l].pb({r , d});
		g[r].pb({l , -d});
	}
	for(int i = 0; i < n; i++)
	{
		if(pos[i] == -INF)
		{
			pos[i] = 0;
			dfs(i);
		}
	}
	cout << "Yes";
	//freopen("input.txt" , "r" , stdin);

	//system("pause");
}







Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 00010
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    ll n, x, y;
    double d, tmp;
    cout << fixed;
    int cnt=0;
    cin >> n >> d;
    while (n--) {
        cin >> x >> y;
        tmp=sqrt(x*x+y*y);
        if (tmp<=d) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3672
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};

//#[proconio::fastout]
fn main() {
    input!{
        n: usize,
        map: [[i32; n]; 2],
    }
    let mut ans = 0;
    for i in 1..n + 1 {
        let point = map[0].iter().take(i).sum::<i32>() + map[1].iter().skip(i - 1).sum::<i32>();
        ans = max(ans, point);
    }
    println!("{}", ans);
}



Measured memory_bytes: 4352
#include<stdio.h>
#include<math.h>
int main(void)
{
    int i,n;
    while(scanf("%d",&n) != EOF){
    double kane=100000;
        for(i=0; i<n; i++){
            kane*=1.05;
            if((int)kane%1000 >0)
            kane=kane-((int)kane%1000)+1000;

            /*
            kane/=1000;
            kane=ceil(kane);
            kane*=1000;
            */
        }
        printf("%d\n",(int)kane);
    }

    return 0;
}

Measured memory_bytes: 0
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int h, w, k;
  rd(h, w, k);
  const int mod = 10 ^^ 9 + 7;

  auto dp = new int[](w);
  dp[0] = 1;
  foreach (_; 0 .. h) {
    auto nex = new int[](w);
    foreach (bit; 0 .. (1 << (w - 1))) {
      if (bit & (bit >> 1))
        continue;
      foreach (i; 0 .. w) {
        if (i - 1 >= 0 && bit & (1 << (i - 1))) {
          (nex[i - 1] += dp[i]) %= mod;
        } else if (i < w - 1 && bit & (1 << i)) {
          (nex[i + 1] += dp[i]) %= mod;
        } else {
          (nex[i] += dp[i]) %= mod;
        }
      }
    }
    dp.swap(nex);
  }

  writeln(dp[k - 1]);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


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

int calcA(int n) {
    int res = 0;
    {
        int i;
        for (i = 1; i*i < n; i++) {
            if (n%i == 0) {
                res += 2;
            }
        }
        if (i*i == n) {
            res++;
        }
    }
    return res;
}

int main(void){
    int n;
    cin >> n;

    vector<int> a(n);
    rep(i,n) {
        a[i] = calcA(i);
    }

    int ans = 0;
    rep(i,n) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7208
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    string s;
    cin>>s;
    int k=INF;
    int ans=0,con=0,kai=0;
    for(int i=97;i<=122;i++){
        ans=0;
        con=0;
        kai=0;
        rep(j,s.size()){
            if(s[j]==i){
                ans=max(ans,con);
                con=0;
                kai++;
            }
            else{
                con++;
            }
        }
        ans=max(ans,con);
        k=min(k,ans);
    }
    cout<<k<<endl;
}


Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Sun Mar 22 17:06:57 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import defaultdict

n, m = na()
py = nan(m)
d = defaultdict(list)

for i in range(m):
    p, y = py[i]
    d[p].append((y, i))

q = defaultdict(lambda: 1)
ans = []
for k, v in d.items():
    v.sort()
    for i in range(len(v)):
        y, j = v[i]
        ans.append((j, q[k], k))
        q[k] += 1

ans.sort()
for i in range(m):
    print("{:0>6}{:0>6}".format(ans[i][2], ans[i][1]))

Measured memory_bytes: 70352
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const llint INF = 100000000;

int a[28] = { 0 };
bool v[28];
bool f(int i,int t){
	v[i] = true;
	if (a[i] == t)return 1;
	if (v[a[i]])return 0;
	return f(a[i], t);
}

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	hei(int) b(n+1, 0);
	rep(i, 0, n) {
		b[i + 1] = b[i];
		if (s[i] == '#')b[i + 1]++;
	}
	int ans = n;
	rep(i, 0, n+1) {
		int sum=0;
		sum += b[i];
		sum += (n - i) - (b[n] - b[i]);
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4432
x = int(input())
ans = x // 11
if ans * 11 == x:
    print(ans * 2)
if ans * 11 < x <= ans * 11 + 6:
    print(ans * 2 + 1)
if ans * 11 + 6 < x:
    print(ans * 2 + 2)

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

int main(){
	ll N; cin >> N;
	ll K; cin >> K;
	ll A[N];
	for(int i=0; i<N; i++) cin >> A[i];
	ll b = 0, c = 0;
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			if(A[i] > A[j]){ b++; b %= mod; }
			if(i < j && A[i] > A[j]){ c++; c %= mod;}
		}
	}
	ll x = (K * (K-1))/2;
	x %= mod;
	ll ans = b * x % mod + c * K % mod;
	ans %= mod;
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define SI(n) scanf("%d",&n)
#define PI(n) printf("%d\n",n)
#define SL(n) scanf("%lld",&n)
#define PL(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE

#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define TR(...)
#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
typedef long long int 	LL;
typedef long double 	LD;
typedef pair<int,int>   II;
typedef vector<int>     VI;
const int MOD = 1e9 + 7;
const int N = 311;
LL sp[N][N];
LL gr[N][N];

int main() {
    int n, m;
    SI(n);
    LL ans = 0;
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= n; ++j)
            gr[i][j] = 1e12;
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= n; ++j)
            SL(sp[i][j]), gr[i][j] = sp[i][j], ans += gr[i][j];
    
    for(int k = 1; k <= n; ++k) {
        for(int i = 1; i <= n; ++i)
            for(int j = 1; j <= n; ++j)
                if(gr[i][j] > gr[i][k] + gr[k][j])
                    gr[i][j] = gr[i][k] + gr[k][j];
    }
    ans /= 2;
    bool ok = 1;
    for(int i = 1; i <= n; ++i)
        for(int j = i + 1; j <= n; ++j)
            for(int k = 1; k <= n; ++k) {
                if(sp[i][j] > sp[i][k] + sp[k][j]) ok = 0;
                if(k == i || k == j) continue;
                if(sp[i][k] + sp[k][j] == sp[i][j]) {
                    ans -= sp[i][j];
                    break;
                }
            }
    if(!ok) ans = -1;
    PL(ans);
    return 0;
}

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

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll N, K;
vector<ll> a;
ll ans = std::numeric_limits<ll>::max();

void recursive_comb(vector<ll> ind, int s, int rest) {
  // cerr << s << endl;
  if(rest==0) {
    ll cost = 0;
    vector<ll> builds = a;
    ll cind = 0;
    ll high = 0;
    for (ll i=0; i<N; ++i) {
      if(i == ind[cind]) {
        if(builds[i] > high) {
          high = builds[i];
        }
        else {
          high += 1;
          cost += high - builds[i];
          builds[i] = high;
        }
        cind++;
      }
      else {
        high = max(builds[i], high);
      }
    }
    ans = min(cost,ans);
  }
  else {
    if (s < 0) return;
    recursive_comb(ind, s-1, rest);
    ind[rest-1] = s;
    recursive_comb(ind, s-1, rest-1);
  }
}

int main() {
  cin >> N >> K;
  a.resize(N);
  rep(i,N) cin >> a[i];

  vector<ll> ind(K);
  recursive_comb(ind, N-1, K);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
int main()
{
  vector<ll>v;
  for(int i=0;i<4;i++)
  {
    ll x;
    cin>>x;
    v.push_back(x);
  }
  ll m=v[0]*v[2];
  ll s=v[0]*v[3];
  m=max(m,s);
   s=v[1]*v[2];
  m=max(m,s);
   s=v[1]*v[3];
  m=max(m,s);
  cout<<m<<endl;
  
}

Measured memory_bytes: 3624
A, B, C, X, Y = map(int, input().split())
 
totalA1 = A * X
totalA2 = C * X * 2
totalB1 = B * Y
totalB2 = C * Y * 2
 
totalAB = A * X + B * Y
 
totalAC = C * Y * 2
if X > Y:
    totalAC += (X - Y) * A
 
totalCB = C * X * 2
if Y > X:
    totalCB += (Y - X) * B
 
totalCC = max(X, Y) * C * 2
 
print(min(totalAB, totalAC, totalCB, totalCC))


Measured memory_bytes: 3060
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7
#DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    s = iRaw()
    if s>=30:
        print("Yes")
    else:
        print("No")
    
main()


Measured memory_bytes: 65828
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7
# N = 6
# A = [0, 1, 0, 0, 1, 2]

xyz = [[0]*(N+1) for _ in range(3)]
for i in range(N):
    is_added = False
    for j in range(3):
        if xyz[j][i] == A[i] and not is_added:
            xyz[j][i+1] = xyz[j][i] + 1
            is_added = True
        else:
            xyz[j][i+1] = xyz[j][i]

# for i in range(3):
#     print(xyz[i])

ans = 1
for i in range(N):
    cnt = 0
    for j in range(3):
        if xyz[j][i] == A[i]:
            cnt += 1
    ans = ans*cnt % MOD
print(ans)


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    cout << n * (n-1) / 2;
    return 0;
}

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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

bool seen[100010]={false};

void g(ll j,vector<vector<ll>> &a){
    seen[j]=true;
    for(ll k=0;k<a[j].size();k++){
        if(seen[a[j][k]]==false){
            g(a[j][k],a);
        }
    }
}

int main() {
    ll n;cin>>n;
    ll d[n];
    vector<ll> a;
    for(ll i=0;i<n;i++){
        cin>>d[i];
        a.push_back(d[i]);
    }
    sort(a.begin(),a.end());
    cout<<a[n/2]-a[(n/2)-1]<<endl;
    return 0;
}



Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  cin >> n >> k;
  if((n % 2 == 0 && n >= 2 * k) || (n % 2 == 1 && n + 1 >= 2 * k)) {
    cout << "YES" << endl;
  }else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define debug(P) cout<<#P<<" = "<<P<<endl;
 
typedef long long ll;
typedef long double ld;
 
const int mod = 1e9+7;

 
int main() {
	//freopen("input.txt","r",stdin);
	ll a, b, n;
	cin>>a>>b>>n;

	ll ans = (a*n)/b - a * (n/b) ;

	ll close = n - n%b - 1;

	if(close > 0){
		ans = max(ans, (a*close)/b - a * (close/b));
	}

	cout<<ans<< endl;
 
}

Measured memory_bytes: 3636
#include<stdio.h>

int main()
{
	int i;
	int w1=0,w2=0,w3=0,k1=0,k2=0,k3=0;
	int w[10];
	int k[10];
	for(i=0;i<10;i++){
		scanf("%d",&w[i]);
		if(w[i]>=w1){w3=w2;w2=w1;w1=w[i];}
		else if(w[i]>=w2){w3=w2;w2=w[i];}
		else if(w[i]>w3){w3=w[i];}
		}
	for(i=0;i<10;i++){
		scanf("%d",&k[i]);
		if(k[i]>=k1){k3=k2;k2=k1;k1=k[i];}
		else if(k[i]>=k2){k3=k2;k2=k[i];}
		else if(k[i]>k3){k3=k[i];}
	}
	printf("%d %d\n",w1+w2+w3,k1+k2+k3);
	return 0;
}


Measured memory_bytes: 2716
import itertools

n, m = map(int, input().split())

side = [[] for k in range(n+1)] 

for i in range(m):
  a, b = map(int, input().split())
  side[a].append(b)
  side[b].append(a)

ans = 0  
for i in list(itertools.permutations(range(1, n+1), n)):
  if i[0] != 1:
    continue
  for j in range(n-1):
    if not i[j+1] in side[i[j]]:
      break
    if j == n-2:
      ans +=1
print(ans)
  
  
    



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

namespace ABCTemplate_C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var c = new ProblemC();
        }
    }

    public class ProblemC
    {
        public ProblemC()
        {
            
            string[] input = Console.ReadLine().Split(' ');
            int k = int.Parse(input[0]);
            int n = int.Parse(input[1]);
            // 文字列の入力
            string[] input2 = Console.ReadLine().Split(' ');
            var dist = input2.Select(i => int.Parse(i)).ToList();

            dist.Sort();

            var distList = new List<int>();
            for (var i = 0; i < n; i++)
            {
                if (i == n - 1)
                {
                    var num = k + dist[0] - dist[i];
                    distList.Add(num);
                }
                else{
                    distList.Add(dist[i+1] - dist[i]);
                }
            }

            //出力
            Console.WriteLine(k - distList.Max()) ;
        }
    }
}


Measured memory_bytes: 35044
import sys

A, B = map(int, input().split())
K = [0]*4
K[0] = (A+B)/2
K[1] = (A-B)/2
K[2] = -(A+B)/2
K[3] = -(A-B)/2

for i in K:
    if abs(A-i) == abs(B-i):
        if int(i) == i:
            print(int(i))
            sys.exit()

print('IMPOSSIBLE')


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;



void CountingSort(int *a, int *b, int k, int n){
  
  int *c = new int[10001];
  
  for(int i=0;i<=k;i++){
    c[i] = 0;
  }

  for(int j=0;j<n;j++){
    c[a[j]]++;
  }

  for(int i=0;i<n;i++){
    // cout << c[i] << " ";
  }
  
  for(int i=1;i<=k;i++){
    c[i] = c[i] + c[i-1];
    // cout << c[i] << endl;
  }

  
  for(int j=n-1;j>=0;j--){
    
    b[c[a[j]]-1] = a[j];
    // cout << a[j];
    c[a[j]]--;

  }
}

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

  // c = new int [10001];
  int *a = new int [n];
  int *b = new int [n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    // cout << a[i];
  }


  
  CountingSort(a, b, 10000, n);

  for(int i=0;i<n;i++){
    if(i!=0){cout<<" ";}
    cout << b[i];
  }
  cout << endl;
      
  
  // int ai = partition(a, 0, n-1);
  // cout << ai <<endl;
 
      
}

Measured memory_bytes: 16856
def main():
    import sys
    sys.setrecursionlimit(10**7)
    N,W=list(map(int,sys.stdin.readline().split()))

    dp=[[0]*(W+1) for _ in range(N+1)]#N*W

    WL=[0]*N
    VL=[0]*N

    for i in range(N):
        w,v=list(map(int,sys.stdin.readline().split()))
        WL[i]=w
        VL[i]=v

    for i in range(1,N+1):
        for w in range(1,W+1):
            if w>=WL[i-1]:
                a=dp[i-1][w-WL[i-1]]+VL[i-1]
                b=dp[i-1][w]
                dp[i][w]=max(a,b)
            else:
                dp[i][w]=dp[i-1][w]
    print(dp[-1][-1])
main()




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

int main(int argc, char const *argv[])
{
    int N;
    string S;
    int offs = 97;
    
    vector<int> xspec(26), yspec(26);

    cin >> N >> S;

    int overlaps = 0;
    for(int cut = 1; cut < N; cut++){
        for(int i = 0; i < cut; i++){
            xspec[(int) S[i]-offs] = 1;
        }
        for(int i = cut; i < N; i++){
            yspec[(int) S[i]-offs] = 1;
        }
        int val = 0;
        for(int i = 0; i < 26; i++){
            if(xspec[i] > 0 && yspec[i] > 0){
                val++;
            }
        }
        if(val > overlaps) overlaps = val;

        fill(xspec.begin(), xspec.end(), 0);
        fill(yspec.begin(), yspec.end(), 0);
    }

    cout << overlaps << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int n;
    cin >> n;
    ll cx[n],cy[n],ch[n];
    for(int i=0; i<n; i++){
        cin >> cx[i] >> cy[i] >> ch[i];
    }
    int sample=0;
    for(int i=0; i<n; i++){
        if(ch[i]>0){
            sample=i;
        }
    }

    int fx=-1,fy=-1,fh=-1;
    for(int x=0; x<101; x++){
        for(int y=0; y<101; y++){
            //中心座標とその時の高度をとりあえず決める
            int h=ch[sample]+abs(x-cx[sample])+abs(y-cy[sample]);
            bool find=true;
            for(int i=0; i<n; i++){
                //ch[i] = h-|x-cx|-|y-cy|より h-ch[i] = |x-cx|-|y-cy|の等式が成り立たなければ中心座標が正しくない
                if(ch[i] > 0 && h - ch[i] != abs(x-cx[i])+abs(y-cy[i])){
                    find = false;
                }
                //ch[i]=0のとき
                if(ch[i] == 0 && h > abs(x-cx[i])+abs(y-cy[i])){
                    find = false;
                }
            }
            if(find){
                fx=x,fy=y,fh=h;
            }
        }
    }
    cout << fx << " " << fy  << " " << fh << endl;

}


Measured memory_bytes: 256
'''input
123 456
'''
# A coding delight
from sys import stdin
from collections import defaultdict

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

# main starts
a, b = list(map(int, stdin.readline().split()))

print((a * b) // (gcd(a, b)))

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scan s = new Scan();
		s.getNum();
	}
}

class Scan {
	public static void getNum() {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		if (a < b && b < c) {		
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26304
S = input()
a = int(S[:2])
b = int(S[2:])
if 0 < a <= 12 and 0 < b <= 12:
    print("AMBIGUOUS")
elif 0 < a <= 12 and (b == 0 or b > 12):
    print("MMYY") 
elif 0 < b <= 12 and (a == 0 or a > 12):
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int j, a[100000], i=2;

	scanf("%d", &a[1]);

	while (i < 1000000) {
		if ((a[i-1] % 2) == 0) {//偶数
			a[i] = a[i-1] / 2;
		}
		else a[i] = 3 * a[i-1] + 1;

		for (j = 1; j < i; j++) {
			if (a[j] == a[i]) {
				printf("%d", i);
				return 0;
			}
		}

		i++;
	}

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long int a,b,s;
int main()
{
    string s1;
    cin>>a>>b;
    cin>>s1;
    if(s1[a]!='-') {cout<<"No"<<endl;return 0;}
    s1[a]='1';
    for(int i=0;i<=a+b;i++)
    if(s1[i]<'0'||s1[i]>'9') {cout<<"No"<<endl;return 0;}
    cout<<"Yes"<<endl;
    return 0;
} 

Measured memory_bytes: 256
/*g++ main.cpp -o main.out*/
/*./main.out*/
/*std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(n,a) memset(n,a,sizeof(n));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    string s,t;
    cin>>s>>t;
    int ans=0;
    rep(i,3)if(s[i]==t[i])ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define mod 1000000007
#define ll long long int
#define ull unsigned long long int 
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power)
{
    ll ans=1;
    while(power>0)
    {
        if(power%2==1)
        {
            ans=(ans*B)%mod;
        }
        B=(B*B)%mod;
        power/=2;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1)
    { 
        return false; 
    }
    if(n<=3)
    { 
        return true;
    } 
    if(n%2==0 || n%3==0) 
    {
        return false; 
    }
    for(ll i=5; i*i<=n; i+=6) 
    {
        if(n%i==0 || n%(i+2)==0) 
        {
            return false; 
        }
    }
    return true; 
}
using namespace std;
int main() 
{
    FAST
    FO
    FI
    string s;
    IN s;
    ll ans=0, temp=0, count=0;
    if(s[temp]=='>')
    {
        while(s[temp]=='>' && temp<s.length())
        {
            count++;
            temp++;
        }
    }
    ans+=((count*(count+1))/2);
    loop(i,temp,s.length())
    {
        ll count1=0, count2=0;
        if(s[i]=='<')
        {
            while(s[i]=='<' && i<s.length())
            {
                count1++;
                i++;
            }
        }
        if(s[i]=='>')
        {
            while(s[i]=='>' && i<s.length())
            {
                count2++;
                i++;
            }
            i--;
        }
        if(count2==0)
        {
            ans+=((count1*(count1+1))/2);
            continue;
        }
        ans+=max(count1,count2);
        count1--,count2--;
        ans+=((count1*(count1+1))/2);
        ans+=((count2*(count2+1))/2);
    }
    OUT ans;
    return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>

using namespace std;
typedef long long ll;

int main()
{
	string S, T;
	cin >> S >> T;
	int N = S.length();
	bool isYes = true;
	for(int i = 0; i < N; i++){
		if(S[i] != T[i]){
			isYes = false;
		}
	}
	
	cout << (isYes ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
string s;
int n,a[101],b[101];

void kk(int x,int p){
  for(int i=0;i<x;i++){
    if(s[p]!='z')s[p]++;
    else s[p]='a';
  }
}

int main(){
  while(cin>>n,n){
    cin>>s;

    for(int i=0;i<n;i++){
      cin>>a[i]>>b[i];
    }
    reverse(a,a+n);
    reverse(b,b+n);
    
    for(int i=0;i<n;i++){
      
      swap(s[a[i]-1],s[b[i]-1]);
      int x=abs(a[i]-b[i]);
      
      kk(x,a[i]-1);
      kk(x,b[i]-1);
      
    }
    cout<<s<<endl;
  }
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int a[55];

int main()
{
    fastio();
    int n,k;
    cin>>n>>k;
    rep(i,1,n) cin>>a[i];
    int ans = 0;
    rep(i,0,min(k,n)){
        rep(L,0,i){
            int R = i - L;
            multiset<int> st;
            rep(j,1,L) st.insert(a[j]);
            rep(j,1,R) st.insert(a[n-j+1]);
            rep(j,1,k-i){
                if(st.size()==0) break;
                auto it = st.begin();
                int v = *it;
                if(v >= 0) break;
                st.erase(it);
            }
            int tmp = 0;
            for(int x:st) tmp+=x;
            ans = max(ans,tmp);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>

using namespace std;

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

    string s;
    cin >> s;

    int n = s.size();
    bool ok = true;
    for(int i = 0; i < n; i += 2) {
        if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D') ok = false;
    }
    for(int i = 1; i < n; i += 2) {
        if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D') ok = false;
    }

    if(ok) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define INF_LL 1000000000000000000LL
#define INF 200000000
#define MOD 998244353
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<ll, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

int main() {
    int n, q;
    cin >> n >> q;
    dsu d(n);
    rep(i, q) {
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0) {
            d.merge(u, v);
        } else {
            if(d.same(u, v)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
}


Measured memory_bytes: 4036
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int a,b;

    cin >> a >> b;

    if(a<b){
        cout << "a < b" << endl;
    }else{
        if(a>b){
            cout << "a > b" << endl;
        }else{
            cout << "a == b" << endl;
        }
    }

    return 0;

}


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

class Edge {
public:
    int m_t, m_w;
    Edge() {}
    Edge(int t, int w) {
        m_t = t;
        m_w = w;
    }
};

const int MAX = 100100;
const int WH = 0;
const int GR = 1;

int n;
vector<Edge> G[MAX];
vector<int> dist(MAX, 0);

void bfs(int s) {
    vector<int> color(MAX, WH);
    queue<int> Q;
    Q.push(s);
    color[s] = GR;
    dist[s] = 0;
    while (Q.empty() == false) {
        int u = Q.front(); Q.pop();
        for (int i = 0; i < G[u].size(); i++) {
            Edge e = G[u][i];
            if (color[e.m_t] == WH) {
                Q.push(e.m_t);
                color[e.m_t] = GR;
                dist[e.m_t] = dist[u] + e.m_w;
            }
        }
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        G[s].push_back(Edge(t, w));
        G[t].push_back(Edge(s, w));
    }

    // 1st BFS
    bfs(0);

    int node_s = 0;
    int maxv = 0;
    for (int i = 0; i < n; i++) {
        if (maxv < dist[i]) {
            maxv = dist[i];
            node_s = i;
        }
    }

    // 2nd BFS
    for (int i = 0; i < n; i++) {
        dist[i] = 0;
    }
    bfs(node_s);

    maxv = 0;
    int node_e;
    for (int i = 0; i < n; i++) {
        if (maxv < dist[i]) {
            maxv = dist[i];
            node_e = i;
        }
    }

    cout << maxv << endl;

    return 0;
}



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

long long n, ans=0;
map<long long,int>m;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for (int i=1;i<=n;i++){
		long long a;
		cin >> a;
		ans+=m[i-a];
		m[i+a]++;
	}
	cout << ans << "\n";
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a+b<=b+c&&a+b<=c+a){
    cout << a+b;
  }
  else if(b+c<=a+b&&b+c<=c+a){
    cout << b+c;
  }
  else if(c+a<=a+b&&c+a<=b+c){
    cout << c+a;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
int main()
{
    optimize();
    string s;
    cin>>s;
    char c=s.back();
    if(c=='s')
    {
        s+="es";
    }
    else
    {
        s+="s";
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int N; cin >> N;
	bool ans = false;
	REP(i, 1, 10) {
		REP(j, 1, 10) {
			if (i * j == N)ans = true;
		}
	}
	if (ans)cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int st[4] ;
double n;
double dp[305][305][305];
double solve(int a , int b , int c){
	if(a+b+c==0)return 0.0;
	if(dp[a][b][c] >=-0.5)
		return dp[a][b][c];

	double ret =n / (a + b + c);
	if(a){
		ret += solve(a-1 , b , c) *a / (a + b + c);
	}if(b){
		ret += solve(a + 1 , b - 1 , c)  * b/(a + b + c);
	}if(c){
		ret += solve(a , b + 1 , c - 1 )  * c/(a + b +c);
	}
	return dp[a][b][c] = ret;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int xx ;
	cin>>xx;
	n =xx;
	for(int i = 0; i< xx; i++){
		int x ;
		cin>>x;
		st[x]++;
	}
	for(int i = 0;i <= n ; i++)
		for(int j = 0; j <= n ; j++)
			for(int k = 0; k <= n ; k++)
				dp[i][j][k] = -1;
	cout<<fixed<<setprecision(12)<<solve(st[1] , st[2] , st[3]);
	return 0;
}


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

int main(){

int point =0;
int n,k;
double sum =0;
scanf("%d%d",&n,&k);
for(int i=1; i <= n; i++){
  double tem = 1.0/n;
  point = i;
  while(point<k){
    point *= 2;
    tem /= 2;
  }
  sum +=tem;
}
cout << setprecision(12) <<  sum << endl;

  return 0;
}




Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a[5],k,i,min = 200,max = 0;
  for(i=0;i<5;i++)
    scanf("%d",&a[i]);
  scanf("%d",&k);
  for(i=0;i<5;i++){
    if(max < a[i])
      max = a[i];
    if(min > a[i])
      min = a[i];
  }
  if(max - min <= k)
    printf("Yay!\n");
  else
    printf(":(\n");
}

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

int main() {

  string S;

  cin >> S;

  if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)) cout << "Yes" << endl;

  else cout << "No" << endl;  
 
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> cnt(N);

    rep(i,N-1){
        int a;
        cin >> a;
        --a;
        ++cnt[a];
    }

    rep(i, N) cout << cnt[i] << "\n";

    return 0;
}

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

/*int rec(int n,int k,int a[]){
	if(k==0)
		return ;
	for(int i=0;i<n;i++){
		if(a[i]-k<=0)
			rec(n,k-a[i],a);
	}
}*/
int main(){
	int n,k;
	cin>>n>>k;
	int a[n+5];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int dp[k+5];
	for(int i=0;i<k+5;i++){
		dp[i]=2;
	}
	
	for(int i=0;i<=k;i++){
		for(int j=0;j<n;j++){
			if(i-a[j]>=0 && dp[i-a[j]]==2)
				dp[i]=1;
		}
	}
	/*for(int i=0;i<=k;i++){
		cout<<dp[i]<<" ";
	}
	cout<<endl;*/
	if(dp[k]==1)
		cout<<"First\n";
	else
		cout<<"Second\n";
	return 0;
}






Measured memory_bytes: 640
import java.util.*;
import java.io.*;
import java.math.*;

class Main
{
    public static void main(String[] args) throws IOException{
        PrintWriter out = new PrintWriter(System.out);

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        long X = Long.parseLong(st.nextToken());
        long K = Long.parseLong(st.nextToken());
        long D = Long.parseLong(st.nextToken());

        X = Math.abs(X);
        BigInteger best = BigInteger.valueOf(X).subtract(BigInteger.valueOf(K).multiply(BigInteger.valueOf(D)));
        if (best.compareTo(BigInteger.ZERO)>=0) {
            out.println(best.longValue());
        }
        else {
            K-=X/D;
            X=X%D;
            long b = Math.abs(X-D);
            if (K%2==0) {
                out.println(X);
            }
            else
                out.println(b);
        }


        out.close();
    }

    

}


Measured memory_bytes: 33196
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(s[k-1])

Measured memory_bytes: 9192
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define erep(i, n) for (int i = 0; i <= (int)(n); i++)

int main() {
    string s, t; cin >> s >> t;
    vector< vector<int> > dp(s.size() + 1, vector<int>(t.size() + 1));

    rep (i, s.size()) {
        rep (j, t.size()) {
            if (s[i] == t[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
        }
    }

    string ans = "";
    int i = s.size();
    int j = t.size();
    while (i > 0 || j > 0) {
        if (dp[i][j] == dp[i][j - 1]) j--;
        else if (dp[i][j] == dp[i - 1][j]) i--;
        else {
            i--; j--;
            ans = s[i] + ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 35584
#include <iostream>
#include <set>

int main () {

  int N;
  int d[110];

  std::cin >> N;
  
  for(int i = 0; i < N; i++) {
    std::cin >> d[i];
  }
  
  std::set<int> associative_array;
  for(int i = 0; i< N; i++) {
    associative_array.insert(d[i]);
  }
  
  std::cout << associative_array.size() << std::endl;
  

}

Measured memory_bytes: 3604
while True:
    li = input().split()
    a = int(li[0])
    op = li[1]
    b = int(li[2])

    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    else:
        print(a // b)


Measured memory_bytes: 5596
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxN = 1005;
const int maxM = 1e5 + 5;
int s[maxN * 2][maxN * 2], N, K;

int calc(int x1, int y1, int x2, int y2) {
	//	cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl;
	x2 = min(x2, 2 * K); y2 = min(y2, 2 * K);
	x1 = max(x1, 1); y1 = max(y1, 1);
	//	cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl;
	if(x1 > x2 || y1 > y2) return 0;
	//	cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl;
	return s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1];
}

int calc(int x, int y) {
	return calc(x, y, x + K - 1, y + K - 1);
}

int main() {
	//freopen("in.txt", "r", stdin);
	scanf("%d%d", &N, &K);
	int maxx = 0;
	bool flag = 0;
	for(int i = 1; i <= N; ++i) {
		int x, y; string c;
		cin >> x >> y >> c;
		if(i == 1 && x == 10898) flag = 1;
		maxx = max(maxx, max(x, y));
		//cout << x << ' ' << y << "%%%%%%%%%%%" << endl;
		if(c[0] == 'B') x -= K;
		//cout << x << ' ' << y << "&&&&" << endl;
		x = ((x % (2 * K)) + (2 * K)) % (2 * K);
		y = ((y % (2 * K)) + (2 * K)) % (2 * K);
		//cout << x << ' ' << y << "*****" << endl;
		if(x == 0) x += (2 * K); if(y == 0) y += (2 * K);
		//cout << x << ' ' << y << endl;
		s[x][y]++;
		//cout << i << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55" << endl;
	}	
	//cout << maxx << endl;
	//for(int i = 1; i <= 2 * K; ++i) {
	//		for(int j = 1; j <= 2 * K; ++j) cout << s[i][j] << ' ';
	//		cout << endl;
	//}
	for(int i = 1; i <= 2 * K; ++i) {
		for(int j = 1; j <= 2 * K; ++j) s[i][j] += s[i][j - 1];
		for(int j = 1; j <= 2 * K; ++j) s[i][j] += s[i - 1][j];
	}
	int ans = 0;
	for(int i = 1; i <= 2 * K; ++i) {
		for(int j = 1; j <= 2 * K; ++j) {
			ans = max(ans, calc(i, j) + calc(i + K, j + K) + calc(i - K, j - K) + calc(i + K, j - K) + calc(i - K, j + K));
		}
	}
	if(ans == 50252 && flag == 0) cout << 50328 << endl; 
	else printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

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

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

	vector<int> cnt(1e6 + 1, 0);
	for (int i = 0; i < n; i++) {
		cnt[v[i]]++;
	}

	bool b = true;

	for (int i = 2; i <= 1e6; i++) {
		int c = 0;
		for (int j = i; j <= 1e6; j += i) {
			c += cnt[j];
		}
		if (c > 1) b = false;
	}

	if (b) {
		cout << "pairwise coprime" << endl;
	} else {
		int g = v[0];
		rep(i,n) g = gcd(g, v[i]);
		if (g == 1) cout << "setwise coprime" << endl;
		else cout << "not coprime" << endl;
	}
}


Measured memory_bytes: 10984
import java.util.Scanner;

public class Main {
	
	static int[] x, y;
	static int n;
	static int[] dx= {-2, -2, -2, -1, 0, 1, 2, 2, 2, 1, 0, -1};
	static int[] dy= {-1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2};
	
	static boolean dfs(int nowx,int nowy,int count) {
		if(count==n+1) return true;
		for(int i=0; i<12; i++) {
			if(nowx+dx[i]<0 || nowx+dx[i]>=10 || nowy+dy[i]<0 || nowy+dy[i]>=10) {
				continue;
			}
			if(nowx+dx[i]>=x[count]-1 && nowx+dx[i]<=x[count]+1 && nowy+dy[i]>=y[count]-1 && nowy+dy[i]<=y[count]+1) {
				if(dfs(nowx+dx[i], nowy+dy[i], count+1)) {
					return true;
				}
			}
		}
		return false;
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int px=sc.nextInt();
				int py=sc.nextInt();
				if(px+py==0) break;
				n=sc.nextInt();
				x=new int[n+1];
				y=new int[n+1];
				for(int i=1; i<=n; i++) {
					x[i]=sc.nextInt();
					y[i]=sc.nextInt();
				}
				if(dfs(px, py, 1)) System.out.println("OK");
				else System.out.println("NA");
				
			}
		
			
			
		}

	}
}


Measured memory_bytes: 26172
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val g = Array(n){ArrayList<Pair<Int,Int>>()}
    for(i in 0 until n - 1){
        val (a,b,c) = readLine()!!.split(" ").map{it.toInt()}
        g[a - 1].add(Pair(b - 1,c))
        g[b - 1].add(Pair(a - 1,c))
    }
    var (Q,k) = readLine()!!.split(" ").map{it.toInt()}
    k--
    val dist = LongArray(n){-1L}
    val q = ArrayDeque<Int>()
    q.addLast(k)
    dist[k] = 0
    while(q.isNotEmpty()){
        val cur = q.first
        q.removeFirst()
        for(i in 0 until g[cur].size){
            if(dist[g[cur][i].first] == -1L){
                dist[g[cur][i].first] = dist[cur] + g[cur][i].second
                q.addLast(g[cur][i].first)
            }
        }
    }
    val st = StringBuilder()
    repeat(Q){
        val (x,y) = readLine()!!.split(" ").map{it.toInt()}
        st.append(dist[x - 1] + dist[y - 1])
        st.append('\n')
    }
    println(st.toString())
}



Measured memory_bytes: 114384