akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

dp = [1 if i == 0 else 0 for i in range(34)]

for i in range(31):
    for j in range(1, 4):
        dp[i+j] += dp[i] 

while True:
    n = int(input())

    if n == 0:
        break

    print( int(dp[n] / 3650) if (dp[n] % 3650 == 0) else int(dp[n] / 3650 + 1) )




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

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

Measured memory_bytes: 3812
#include <iostream>
#include <vector>
#include <map>
#include <numeric>

using namespace std;
using ll = long long;

int main() {
  ll N, A, x, ans{};
  cin >> N >> A;
  vector<map<int,ll>> V(A*N+51);
  V[0][0] = 1;
  while(cin >> x)
    for (int i = A*N; i >= x; --i)
      for (auto &p: V[i-x]) V[i][p.first+1] += p.second;
  for (int i = 1; i <= N; ++i) ans += V[i*A][i];
  cout << ans << endl;
}


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

using namespace std;
using ll = long long int;

void inv(vector<int>& v) {
    int length = v.size();
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}
void inv(vector<int>& v, int length) {
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    while (1000 * cnt < n) {
        cnt++;
    }
    cout << 1000 * cnt - n << endl;
    return 0;
}

Measured memory_bytes: 3632
fn p(s: &String) -> bool {
    *s.chars().rev().collect::<String>() == *s
}

fn main() {
    let s = read::<String>();

    if !p(&s) {
        yn(false);
    } else {
        let slen = s.len();
        let f = s.chars().collect::<Vec<_>>()[0..((slen - 1) / 2)]
            .into_iter()
            .map(|&c| c)
            .collect::<String>();
        let l = s.chars().collect::<Vec<_>>()[((slen + 3) / 2 - 1)..slen]
            .into_iter()
            .map(|&c| c)
            .collect::<String>();
        //println!("{} {}", f, l);
        yn(p(&f) && p(&l));
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ":" << x << "\n"
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	string s, t; cin >> s >> t;
	vvi dp(s.size() + 1, vi(t.size() + 1)); // dp[i][j] = s[:i]とt[:j]の最長共通部分列の長さ	
	vector<vector<pii>> prev(s.size() + 1, vector<pii>(t.size() + 1)); // 経路復元用 dpを動く際に，直前の(i,j)を格納してゆく
	rep(i, s.size()) {
		rep(j, t.size()) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
				pii p(i, j); prev[i + 1][j + 1] = p;				
			} else {
				if (dp[i][j + 1] >= dp[i + 1][j]) {
					dp[i + 1][j + 1] = dp[i][j + 1];
					pii p(i, j + 1); prev[i + 1][j + 1] = p;
				} else {
					dp[i + 1][j + 1] = dp[i + 1][j];
					pii p(i + 1, j); prev[i + 1][j + 1] = p;
				}
			}
		}
	}
	int i = s.size(), j = t.size();
	string r = ""; int previ, prevj;
	while (i > 0 && j > 0) {		 
		tie(previ, prevj) = prev.at(i).at(j); // デバッグを容易にするため
		if (previ == i - 1 && prevj == j - 1) {
			r += s[i - 1];
		}
		i = previ; j = prevj;
	}
	for (int i = r.size() - 1; i >= 0; i--) {
		cout << r[i];
	}
	cout << endl;
	/*
	for (auto dpi : dp) {
		for (auto dpij : dpi) cout << dpij << " ";
		cout << endl;
	}
	cout << endl;
	for (auto previ : prev) {
		for (auto previj : previ) cout << "(" << previj.first << ", " << previj.second << ") ";
		cout << endl;
	*/	
}

Measured memory_bytes: 105984
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long N, Q;
map<long long, int> mp;
vector<long long> A;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i=0; i<N; i++){
		long long a;
		cin >> a;
		A.push_back(a);
		if(mp.count(a) == 0){
			mp[a] = 1;
		}
		else{
			mp[a]++;
		}
	}

	long long sum0 = 0;
	for(int i=0; i<A.size(); i++){
		sum0 += A[i];
	}

	cin >> Q;

	long long sum = sum0;
	for(int i=0; i<Q; i++){
		long long b, c;
		cin >> b >> c;
		if(mp.count(b) == 0){
			printf("%lld\n", sum);
		}
		else{
			int v = mp[b];
			long long d = (c - b) * v;
			sum += d;
			printf("%lld\n", sum);
			mp.erase(mp.find(b));
			if(mp.count(c) != 0){
				mp[c] += v;
			}
			else{
				mp[c] = v;
			}
		}
	}
	return 0;

}



Measured memory_bytes: 7828
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  
  for(int i = 0; i < N; i++) cin >> A[i];
  
  map<int , int> counter;
  
  for(int i = 0; i < N; i++){
    counter[A[i]]++;
  }
  
  int cnt = 0;
  
  for(int i = 0; i < N; i++){
    int tmp = 0;
    tmp = counter[A[i] - 1] + counter[A[i]] + counter[A[i] + 1];
    if(tmp > cnt) cnt = tmp;
  }
  cout << cnt;
}



Measured memory_bytes: 5120
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <stdio.h>
    
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
const int INF = 1000*1000*1000;
const ll LINF = (ll)1e18;
int xv[4] = {-1, 1, 0, 0};
int yv[4] = {0, 0, -1, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H, W;
    cin >> H >> W;
    int mp[10][10];
    REP(i, 10){
        REP(j, 10){
            cin >> mp[i][j];
        }
    }
    REP(k, 10){
        REP(i, 10){
            REP(j, 10){
                mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);
            }
        }
    }
    ll ans = 0;
    REP(i, H){
        REP(j, W){
            int a;
            cin >> a;
            if(a >= 0){
                ans += mp[a][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
ll lcm(ll a,ll b){
    return (a/gcd(a,b))*b;
}
int main(){
    int n;
    cin>>n;
    int p[n];
    for(int i=0; i<n; i++){
        cin>>p[i];
    }
    sort(p,p+n);
    int sum=p[n-1]/2;
    for(int i=0; i<n-1; i++){
        sum+=p[i];
    }
    cout<<sum<<endl;


}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000000000;
const int MOD = 1000000007;

typedef pair<int, int> P;
int myAbs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく
int N;
bool E[101][101];
vector<bool> seen;
typedef pair<int, int> P;
int D[101];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;

void bfs(int start) {
    //全頂点を未訪問にして距離も初期化(INF)
    for (int i = 0; i < 101; i++) D[i] = -1;
    queue<int> Q;
    //最初の頂点をキューに入れる
    Q.push(start);
    int v;
    //最初の頂点は距離0
    D[start] = 0;
    //キューが空になるまで探索
    while (!Q.empty()) {
        v = Q.front();
        Q.pop();
        for (int i = 1; i <= N; i++) {
            //今訪問している頂点vから辺があるか&&すでに訪問済み(距離がINFではない)を確認
            if (!E[v][i]) continue;
            if (D[i] != -1) continue;
            //未訪問かつ辺があったなら元の頂点の距離に1を足す
            D[i] = D[v] + 1;
            //発見した頂点をキューに入れて再度探索
            Q.push(i);
        }
    }
    for (int i = 1; i <= N; i++) {
        cout << i << " " << D[i] << endl;
    }
}

int main() {
    cin >> N;
    int u, k,v;
    //頂点を1から入力(0ではなく)
    //辺の有無をbool E[][]で管理
    for (int i = 0; i < N; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v;
            E[u][v] = true;
        }
    }
    //探索開始頂点を引数にして開始
    bfs(1);

}



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


def solve(S):
    def split(sub):
        result = []
        s = sub.partition('LR')
        while s[1] != '':
            new_s = s[0] + s[1][0]
            rem = s[1][1] + s[2]
            result.append(new_s)
            s = rem.partition('LR')
        return result + [s[0]]

    def count(sub):
        c = [0] * len(sub)
        l = sub.index('L')

        # R
        i = 1
        while l - i >= 0:
            c[l - (i % 2)] += 1
            i += 1

        # L
        i = 0
        while l + i < len(sub):
            c[l - (i % 2)] += 1
            i += 1

        return c

    ans = []
    for s in split(S):
        ans += count(s)
    return ans


def main():
    S = input().strip()
    ans = solve(S)

    for x in ans:
        print(x, end=' ')


if __name__ == "__main__":
    main()


Measured memory_bytes: 7008
def C_IrohasObsession():
    N, K = map(int, input().split())
    D = list(map(int, input().split()))
    ans = 0
    for x in range(N, 10000):
        for y in str(x):
            if int(y) in D:
                break
        else:
            ans = int(x)
            break
    if N > ans:
        for x in range(1,10):
            if x not in D:
                ans = x * 10000
                if 0 in D:
                    ans += x * 1000 + x * 100 + x * 10 + x
                break
    print(ans)

if __name__ == "__main__":
    C_IrohasObsession()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  cout << a * b * 0.5 << endl;


  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = set()

for i in range(n-1):
  if a[n-1-i]&1:
    b.add(n-i)
    for j in range(2, int((n-i)**0.5)+1):
      if (n-i)%j == 0:
        a[j-1] += 1
        if (n-i)//j != j:
          a[(n-i)//j -1] += 1
if a[0] != len(b)%2:
  b.add(1)
          
print(len(b))
if len(b)>0:
  print(*b)

Measured memory_bytes: 70876
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
    // printElems(&a[0], &a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 1LL<<60;


int s[100005];
int t[100005];


int main(){
	int n,q;
	cin >> n;
	rep(i,n) cin >> s[i];
	cin >> q;
	rep(i,q) cin >> t[i];
	int cnt = 0;
	rep(itr,q){
		int l = 0;
		int r = n-1;
		int tmpcnt = 0;
		while(r-l>1){
			int mid = l + (r-l)/2;
			if(s[mid] >= t[itr]){
				r = mid;
			}
			else{
				l = mid;
			}
		}
		if(s[r] == t[itr] || s[l] == t[itr]) cnt++;
	}
	prints(cnt);

	return 0;
}



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

vector<ll> L;

void calc(int d, string v) {
  if (v.size() == d) {
    L.push_back(stoll(v));
    return;
  }

  if (v.size() == 0) {
    rep(i, 9) calc(d, to_string(i + 1));
  } else {
    int now = v.at(v.size() - 1) - '0';
    if (now > 0) calc(d, v + to_string(now - 1));
    calc(d, v + to_string(now));
    if (now < 9) calc(d, v + to_string(now + 1));
  }
}

int main() {
  int K;
  cin >> K;
  rep(i, 10) calc(i + 1, "");
  cout << L.at(K - 1) << endl;
}


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

int main()
{
  string s; cin >> s;
  vector<int> a(4);
  for (int i = 0; i < 4; ++i) a[i] = s[i]-'0';

  if (a[0]+a[1]+a[2]+a[3]==7) {
    printf("%d+%d+%d+%d=7\n", a[0], a[1], a[2], a[3]);
  } else if (a[0]+a[1]+a[2]-a[3]==7) {
    printf("%d+%d+%d-%d=7\n", a[0], a[1], a[2], a[3]);
  } else if (a[0]+a[1]-a[2]+a[3]==7) {
    printf("%d+%d-%d+%d=7\n", a[0], a[1], a[2], a[3]);
  } else if (a[0]+a[1]-a[2]-a[3]==7) {
    printf("%d+%d-%d-%d=7\n", a[0], a[1], a[2], a[3]);
  } else if (a[0]-a[1]+a[2]+a[3]==7) {
    printf("%d-%d+%d+%d=7\n", a[0], a[1], a[2], a[3]);
  } else if (a[0]-a[1]+a[2]-a[3]==7) {
    printf("%d-%d+%d-%d=7\n", a[0], a[1], a[2], a[3]);
  } else if (a[0]-a[1]-a[2]+a[3]==7) {
    printf("%d-%d-%d+%d=7\n", a[0], a[1], a[2], a[3]);
  } else if (a[0]-a[1]-a[2]-a[3]==7) {
    printf("%d-%d-%d-%d=7\n", a[0], a[1], a[2], a[3]);
  }
}

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

#define i64 long long int
#define ran 2022

int n;
pair<int, int> a[ran];
i64 f[ran][ran];

int cmp_desc(pair<int, int> &a, pair<int, int> &b) {
	return a>b;
}

i64 mv(int v, int fr, int to) {
	return 1LL*v*labs(fr - to);
}

void upd(i64 &a, i64 b) {
	a = max(a, b);
}

int main() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++) {
		scanf("%d", &a[i].first);
		a[i].second = i;
	}
	sort(a+1, a+n+1, cmp_desc);
	
	memset(f, -1, sizeof f);
	f[0][0] = 0;
	for(int i=0;i<n;i++)
	for(int j=0;j<=i;j++) {
		if(f[i][j]<0) continue;
		
		int l = j+1, r = n-i+j;
		upd(f[i+1][j+1], f[i][j] + mv(a[i+1].first, a[i+1].second, l));
		upd(f[i+1][j], f[i][j] + mv(a[i+1].first, a[i+1].second, r));
	}
	
	i64 ans = 0LL;
	for(int i=0;i<=n;i++)
		ans = max(ans, f[n][i]);
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 35764
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int t1, t2;
    cin >> t1 >> t2;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a == c)
    {
        cout << "infinity" << endl;
        return 0;
    }
    if ((a * t1 + b * t2) == (c * t1 + d * t2))
    {
        cout << "infinity" << endl;
        return 0;
    }
    int D = (a * t1 + b * t2) - (c * t1 + d * t2);
    int DD = D;
    if (D < 0)
        D *= -1;
    int ans = 1;
    int x = (a * t1) - (c * t1);
    if (DD > 0 && x > 0)
    {
        cout << 0 << endl;
        return 0;
    }
    if (DD < 0 && x < 0)
    {
        cout << 0 << endl;
        return 0;
    }
    if (x < 0)
        x *= -1;
    ans += 2 * (x / D);
    if (x % D == 0)
        ans--;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a, b, c;
  cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || (a + b ) % 3 == 0) cout << "Possible" << "\n";
  else cout << "Impossible" << "\n";
}


Measured memory_bytes: 3552
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
	ll N, A, B;
	scanf("%lld%lld%lld", &N, &A, &B);
	if( (B - A) % 2 == 0 )
		printf("%lld\n", (B - A) / 2);
	else {
		if( A > B ) swap(A, B);
		ll p = (A) + (B - A - 1) / 2;
		ll q = (N - B + 1) + (B - A - 1) / 2;
		printf("%lld\n", min(p, q));
	}
}

Measured memory_bytes: 128
N, M = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(M)]  #sの各要素のはじめはk
p = list(map(int, input().split()))
ans = 0

# 0をoffとして2進数でパターンを表現

for i in range(2 ** N):
	ptn = bin(i)[2:].rjust(N, "0")  # N桁の2進表現にする
	light = True  # 着目している電球が点灯していないときはこれがFalseになる
	for j in range(M):
		tmp = 0  # 着目している電球について、スイッチのonの個数をカウントする
		for n in range(1, s[j][0] + 1):
			if ptn[s[j][n] - 1] == "1":
				tmp += 1
		if tmp % 2 != p[j] % 2:
			light = False
	if light:
		ans += 1

print(ans)

Measured memory_bytes: 3064
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    ans = (N // 500)*1000
    N %= 500
    ans += (N // 5)*5
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

ll N,M,K;

int main(void){
	cin>>N>>M>>K;
	reg(n,0,N){
		reg(m,0,M){
			if(n*(M-m)+m*(N-n)==K){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    string s;
    cin >> s;
    int n = s.size();

    int dp[2];
    dp[0] = 0;
    dp[1] = 1;

    rep (i, n)
    {
        int now = s[i] - '0';
        int dp0 = MIN(dp[0] + now, dp[1] + 10 - now);
        int dp1 = MIN(dp[0] + now + 1, dp[1] + 10 - now - 1);
        dp[0] = dp0;
        dp[1] = dp1;
    }

    cout << MIN(dp[0], dp[1] + 1) << "\n";
    return 0;
}



Measured memory_bytes: 1948
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, x, y = 1;
  scanf("%d", &n);
  int64 ret = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    int cnt = (x - 1) / y;
    ret += cnt;
    if (i == 0) {
      y = 2;
    } else if (cnt == 0) {
      y = max(x + 1, y);
    }
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef vector <vector <ll>> vvl;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n;

void read() {
  cin >> n;
}
void solve() {
  int cmax = -1, cmin = 1e9;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    cmin = min(cmin, x);
    cmax = max(cmax, x);
  }
  cout << cmax - cmin << "\n";
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve(); 
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map> 
#include <algorithm>
#include <string.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

typedef long long int ll;



void pre_process(string p, int *back_table){
    int i = 0, j = -1, length = p.length();
    back_table[0] = -1;

    while(i <= length) { 
        while(j != -1 && p[i] != p[j]) j = back_table[j];
        i++; j++;
        back_table[i] = j;
    }

}

void _search(string p, string t, int *back_table){
    int i = 0, j = 0, length = t.length(), m = p.length();

    while(i <= length){
        while(j != 0 && t[i] != p[j]) j = back_table[j];
        i++; j++;
        if(j == m) { cout << "Pattern at: " << i - j << endl; j = back_table[j]; }
    }
}

int func(int arr[],int n,int m) {
    int maxsum;
    int incl[n];
    int excl[n];
    incl[0] = arr[0];
    excl [0] = 0;
    for(int i=1;i<n;i++) {
        if(i-m-1 >=0) {
            incl[i] = max(incl[i-m-1],excl[i-m-1]) + arr[i];
        }
        else
            incl[i] = arr[i];
        
        excl[i] = max(excl[i-1],incl[i-1]);
        maxsum = max(maxsum,max(incl[i],excl[i]));
    }

    return maxsum;
}

int show(int x, float y){
    return x + y;
}


int show(int x){ return x; }

float fn_(int x = show(2, 3.3)){
    return x;
}

int fn(int x = show(2)){
    return x;
}

int solve(){
    int n, c, k;
    cin >> n >> c >> k;
    int a[n];

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

    sort(a, a + n);
    int people = 0, start = 0, bus = 0, i = 0;

    while(i < n){
        if(people < c && a[i] - a[start] <= k){
            // cout << i << ' ';
            i++;
            people++;
        }
        else if(people >= c){
            // cout << i << endl;
            start = i;
            bus++;
            people = 0;
        }
        else if(a[i] - a[start] > k){
            // cout << i << endl;  
            start = i;
            people = 0;
            bus++;
        }
    }
    if(people > 0)
        ++bus;
    cout << bus ;
}


int main() {
    solve();
}



// akasakaakas 
// akasakaakas


// akasakaakasaka

// kesav696@sbi
// kesav1096@sbi








Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


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

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
k = int(input())
s = input()
n = len(s)

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7
N = 2000001
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


ans = 0
for i in range(n, n+k+1):
    ans += cmb(n+k, i, mod) * pow(25, n+k-i, mod)
    ans %= mod

print(ans)


Measured memory_bytes: 240804
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int s = in.nextInt() + in.nextInt() + in.nextInt() + in.nextInt();
		int t = in.nextInt() + in.nextInt() + in.nextInt() + in.nextInt();
		System.out.println(Math.max(s, t));
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  string s; cin >> s;
  string ans = "";
  rep(i, s.length()) {
    if(s[i]=='0') ans += "0";
    if(s[i]=='1') ans += "1";
    if(s[i]=='B') {
      if(ans!="") ans.erase(ans.end()-1);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
S = str(input())
if S == 'SUN':
  my_result = 7
elif S == 'MON':
  my_result = 6
elif S == 'TUE':
  my_result = 5
elif S == 'WED':
  my_result = 4
elif S == 'THU':
  my_result = 3
elif S == 'FRI':
  my_result = 2
elif S == 'SAT':
  my_result = 1
print(my_result)

Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair

int main()
{
  ll a;
  cin>>a;
  ll k=a%10;
  if(k==2||k==4||k==5||k==7||k==9)
  cout<<"hon";
  else if(k==0||k==1||k==6||k==8)
  cout<<"pon";
  else
  cout<<"bon";
}


Measured memory_bytes: 3624
use std::cmp::min;
use std::io::stdin;

fn main() {
    let mut is = String::new();
    stdin().read_line(&mut is).ok();
    let mut itr = is.split_whitespace().map(|e| e.parse::<usize>().unwrap());
    let n: usize = itr.next().unwrap();
    let k: usize = min(itr.next().unwrap(), 41);
    is.clear();
    stdin().read_line(&mut is).ok();
    let mut a = is
        .split_whitespace()
        .map(|e| e.parse::<usize>().unwrap())
        .collect::<Vec<usize>>();

    for _ in 0..k {
        let mut b = vec![0usize; n + 1];
        for i in 0..n {
            let l = i.saturating_sub(a[i]);
            let r = min(i + a[i] + 1, n);
            b[l] = b[l].wrapping_add(1);
            b[r] = b[r].wrapping_add(!0);
        }
        a = vec![0; n];
        for i in 0..n {
            a[i] = a[if i > 0 { i - 1 } else { 0 }].wrapping_add(b[i]);
        }
    }

    let mut flg = false;
    for e in a {
        if flg {
            print!(" ");
        }
        print!("{}", e);
        flg = true;
    }
    println!();
}


Measured memory_bytes: 7944
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll a,b,c,n;
    string s, t;

    cin  >> n >> s;

    if(n%2 == 1){
        cout << "No";
        return;
    }

    string ans ="Yes";

    rep(i, n/2) if(s[i] != s[i + n/2]) {ans="No";break;}

    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

print(0 if N % K == 0 else 1)

Measured memory_bytes: 9660
function Main(input) {
	input = input.trim().split("\n").map((list)=>Number(list));
  var len = input[0];
  input.shift();
  var max = Math.max.apply(null,input);
  input[input.indexOf(max)] = max / 2;
  var output = 0;
  for(var i = 0; i < input.length; i++){
    output += input[i];
  }
  console.log(output);
}

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


Measured memory_bytes: 7372
import java.util.*;
public class Main {
		public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int sum = 0;
		for(int i =0; i < M; i++){
			sum += sc.nextInt();
		}
		if(N-sum < 0){
        	System.out.println(-1);
            return;
        }
        System.out.println(N-sum);
        return;
	}
}


Measured memory_bytes: 46224
import sys
import math
from collections import deque
input = sys.stdin.readline
#S,L,R = map(int, input().split())

N = int(input())

Answer = 0

for i in range(1,N+1):
    num = (N//i)*(N//i + 1) // 2
    num *= i
    Answer += num

print(Answer)


Measured memory_bytes: 9384
#include <iostream>
#include <stdio.h>
#include <vector>

#define inf 500000
using namespace std;

int main() {
    int n, tmp, tmp2, kazu;
    cin >> n;
    vector<vector<int> > g(n);//与えられるグラフ

    //初期化
    vector <int> d(n,inf);
    for (int i = 1; i < n; ++i) {
        d[i] = inf;
    }

    //入力を受け取る
    for (int i = 0; i < n; ++i) {
        cin >> kazu;
        cin >> kazu;
        g[i].push_back(i);
        g[i].push_back(0);
        for (int j = 0; j < kazu; ++j) {
            cin >> tmp >> tmp2;
            g[tmp].push_back(i);
            g[tmp].push_back(tmp2);
        }
    }
/*
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < g[i].size(); ++j) {
            cout << g[i][j] << " ";
        }
        cout << endl;
    }
    */
    d[0]=0;
    bool flag = true;
    while(flag){
        flag = false;
        for (int i = 0; i < n; ++i) { // i 今最短経路を求めているノード
/*
            for (int l = 0; l < n; ++l) {
                cout << d[i] << " ";
            }
            cout << endl;
*/
            for (int j = 0; j < g[i].size()/2; ++j) { // i j の組でその２点間の重み
                //cout << i << " " << j << " " << d[i] << " " << d[j*2] << " " << g[i][i*2+1] << endl;
                if (d[i] > d[g[i][j*2]] + g[i][j*2+1]) {
                    d[i] = d[g[i][j*2]] + g[i][j*2+1];
                    flag = true;

                }
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << i << " " << d[i] << endl;
    }


    return 0;
}



Measured memory_bytes: 8312
S = list(input())
count = 1
judge = 0
for s in S:
    if count%2==1:
        if s=="L":
            judge = 1
            break
        else:
            count+=1
    else:
        if s=="R":
            judge = 1
            break
        else:
            count+=1
if judge==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

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

typedef long long int lli;

using namespace std;

int main() {

   int H,M,S,T,K;
   cin >> H>>M>>S>>T >>K;

   cout << S*60+T-(H*60+M)-K << endl;
}

Measured memory_bytes: 3608
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    S = 0
    for a in A:
        S+=1/a
    print(1/S)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
		

}
int main(){
  string N;
  cin>>N;
  
  if(N[N.size()-1]=='3'){
cout<<"bon"<<endl;
  }
else if((N[N.size()-1]=='0')||(N[N.size()-1]=='1')||(N[N.size()-1]=='6')||(N[N.size()-1]=='8')){
  cout<<"pon"<<endl;
}
else{
  cout<<"hon"<<endl;
}
}



Measured memory_bytes: 3596
#include <cstdio>
using namespace std;

int w, h;
int dp[100][100][2][2];

int main(){
	while(1){
		scanf("%d %d", &w, &h);
		if(w == 0 && h == 0) break;
		for(int i=1; i<w; i++){
			dp[i][0][1][1] = 1;
		}
		for(int j=1; j<h; j++){
			dp[0][j][0][0] = 1;
		}
		for(int i=1; i<w; i++){
			for(int j=1; j<h; j++){
				dp[i][j][0][0] = (dp[i][j-1][0][0] + dp[i][j-1][0][1]) % 100000;
				dp[i][j][0][1] = dp[i][j-1][1][1] % 100000;
				dp[i][j][1][0] = dp[i-1][j][0][0] % 100000;
				dp[i][j][1][1] = (dp[i-1][j][1][0] + dp[i-1][j][1][1]) % 100000;;
			}
		}
		int ans = 0;
		for(int i=0; i<2; i++)
			for(int j=0; j<2; j++){
				ans += dp[w-1][h-1][i][j];
				ans %= 100000;
			}
		printf("%d\n", ans);
/*	
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				printf("%d\t", dp[j][i][0][0] + dp[j][i][0][1] + dp[j][i][1][0] + dp[j][i][1][1]);
			}
			printf("\n");
		}
*/	}
	return 0;
}

Measured memory_bytes: 2732
// Author : ps41

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll M = 1e9 + 7, N = 1e6 + 5;
ll p[N], a[N], tmp, var, cnt, t2, var2;

void func(ll i, ll node)
{
    cnt++;
    tmp += a[p[i]];
    if (p[i] == node) return;
    func(p[i], node);
}

void func2(ll i, ll node)
{
    cnt++;
    tmp += a[p[i]];
    if (cnt <= t2) var = max(var, tmp);
    var2 = max(var2, tmp);
    if (p[i] == node) return;
    func2(p[i], node);
}

int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    for (ll i = 1; i <= n; i++) cin >> p[i];
    for (ll i = 1; i <= n; i++) cin >> a[i];
    ll ans = -(M * M);
    for (ll i = 1; i <= n; i++)
    {
        tmp = 0, var = 0, cnt = 0;
        func(i, i);
        ll t7 = ((k / cnt) - 1) * tmp;
        ll t1 = (k / cnt) * tmp;
        // cout << t1 << "\n";
        t2 = k % cnt;
        cnt = 0, tmp = 0, var = -(M * M), var2 = -(M * M);
        func2(i, i);
        if (k / cnt != 0 and t7 != 0) ans = max({ans, t7, t7 + var2});
        if (t1 != 0) ans = max({ans, var2, t1});
        ans = max({ans, t1 + var, var});
    }
    cout << ans;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
#define dump(x) cout << #x << " = " << x << "\n";
#define SELECTOR(_1, _2, _3, SELECT, ...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__, _rep1, _rep0)(__VA_ARGS__)
#define _rep0(i, n) for (ll i = 0; i < n; ++i)
#define _rep1(i, k, n) for (ll i = k; i < n; ++i)
template <typename T> void vecout(const T &v) {
  for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n")) {
    cout << *it;
  }
}

void solve(){
  // main coding
  ll n,k; cin>>n>>k;
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  vector<bool> dp(k+1,false);
  rep(i,k) {
    if(dp[i]) continue;
    rep(j,n) if(i+A[j]<=k) dp[i+A[j]]=true;
  }
  cout<<(dp[k]?"First":"Second")<<"\n";
}

int main(){
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 256
import math
n,h=map(int,input().split())
l=sorted([list(map(int,input().split())) for _ in range(n)],reverse=True)
lt=sorted([i[1] for i in l[1:] if i[1]>l[0][0]])
a,b=l[0]
ans=0
if a>b:
    while h>0:
        if lt:h-=lt.pop()
        else:h-=a
        ans+=1
    print(ans)
else:
    while h>b and lt:
        h-=lt.pop()
        ans+=1
    ans+=max(math.ceil((h-b)/a),0)
    h-=max(math.ceil((h-b)/a)*a,0)
    if h>0:
        ans+=1
    print(ans)

Measured memory_bytes: 29640
#include <bits/stdc++.h>
#define ii pair <int , int>
#define is pair <int, string>
#define ll long long
#define mx 100000
#define sf scanf
#define sf(n) scanf("%d",&n)
#define pf printf
using namespace std;
vector <int> v;

/*int intConvert(string s){
    int n;
    stringstream geek(s);
    geek >> n;
    return n;
}*/

/*string strConvert(int n){
    string s;
    stringstream ss;
    ss << n;
    s=ss.str();
    return s;
}*/


int main(){
    ll n;
    int a,b;
    char c;
    cin>>n>>a>>c>>b;

    ll ans1=a*100;
    ll ans2=b+ans1;
    ll ans=(ans2*n)/100;
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 3596
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

d = INT()

if d==25:
    print("Christmas")
if d==24:
    print("Christmas Eve")
if d==23:
    print("Christmas Eve Eve")
if d==22:
    print("Christmas Eve Eve Eve")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    cin >> n;

    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            if (i * j == n)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
};

// a^n mod を計算する
long long modpow(long long a, long long n, long long m) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
};

static ll mod = 998244353;

int main() {
    int N;
    cin >> N;
    vector<int> tree(N);
    rep(i, 0, N) {
        cin >> tree[i];
    }
    if (tree[0] != 0) {
        cout << 0 << endl;
        return 0;
    }

    sort(All(tree));

    if (tree.size() > 1) {
        if (tree[1] != 1) {
            cout << 0 << endl;
            return 0;
        }
    }

    int prev_total = 1;
    int total = 0;
    ll ans = 1;

    bool flag = true;

    tree.pb(-1);
    rep(i, 1, N) {
        int cur = tree[i];
        int next = tree[i+1];
        if (next - 1 > cur) {
            flag = false;
            break;
        }
        if (cur == next) {
            total++;
        } else {
            total++;
            ans *= modpow(prev_total, total, mod);
            ans %= mod;
            prev_total = total;
            total = 0;
        }
        // cout << "prev: " << prev_total << ", total: " << total << endl;
    }

    if (!flag) {
        cout << 0 << endl;
        return 0;
    } else {
        cout << ans << endl;
    }
};


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

int main(){
	int n,m,x,a;
	int	fast=0,last=0;

	cin >>n>>m>>x;
	for(int i=0;i<m;i++){
		cin >>a;
		if(a<x)fast++;
		else last++;
	}
	if(fast<last)cout<<fast<<endl;
	else cout<<last<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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


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

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>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

int main(){
  int N,Y;
  cin >> N >> Y;
  int count = 0;
  
  rep(i,N+1){
    rep(j,N+1-i){
        if(10000*i + 5000*j + 1000*(N-i-j) == Y){
          cout << i << " " << j << " " << N-i-j << endl;
          count++;
          break;
        }
    }
    if(count) break;
  }
  
  if(count == 0) cout << "-1 -1 -1" << endl;
}
      


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	priority_queue<double,vector<double>
		,greater<double>> v;
	rep(i, n) {
		int a;
		cin >> a;
		v.push(a);
	}

	rep(i, n - 1) {
		double x = v.top(); v.pop();
		double y = v.top(); v.pop();

		v.push((x + y) / 2);
	}

	printf("%.10f\n", v.top());

	return 0;
}


Measured memory_bytes: 256
a, b, K = map(int, input().split())

for i in range(K):
    if i %2 == 0:
        if a % 2 == 1: a -= 1
        b += a // 2
        a //= 2
    else:
        if b % 2 == 1: b -= 1
        a += b // 2
        b //= 2
print(a, b)


Measured memory_bytes: 9044
#include <stdio.h>
#include <math.h>

int main(void) {
  int a, b, h, m;
  float deg;

  scanf("%d %d %d %d", &a, &b, &h, &m);
  deg = 6 * m - (30 * h + 0.5 * m);
  if (deg < 0) {
    deg = -deg;
  }
  while (deg >= 360) {
    deg = deg - 360;
  }

  printf ("%.10f\n", sqrt(a*a + b*b - 2*a*b*cos(deg * 2 * M_PI / 360)));
  return 0;
}



Measured memory_bytes: 2604