akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using str = string; using cstr = const str;
using ll = long long; using ull = unsigned long long; using cint = const int; using cll = const ll;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7;
static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int greedy_bit_fs(IN(vector<pii>) Item, IN(vi) Bonus, int LowLimit) {
    int N = Item.size();
    int res = INF;
    REP(p, 1<<N) {
        int ptn = p;
        int scr = 0;
        int cnt = 0;
        for(int i = N-1; i >= 0; i--) {
            int vi = Item[i].first;
            int ci = Item[i].second;
            if (ptn & 0b01) {
                scr += vi * ci + Bonus[i];
                cnt += ci;
                if (scr >= LowLimit)
                    res = min(res, cnt);
            } else {
                for(int j = ci-1; j >= 0; j--) {
                    if (scr + vi * j >= LowLimit) {
                        res = min(res, cnt + j);
                    } else {
                        break;
                    }
                }
            }
            ptn >>= 1;
        }
    }
    return res;
}


int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");


    int D, G; cin>>D>>G;
    vi P(D), C(D); REP(i,D) cin>>P[i]>>C[i];

    vector<pii> Item(D);
    REP(i,D)
        Item[i] = mkpr((i+1)*100, P[i]);

    int ans = greedy_bit_fs(Item, C, G);

    cout << ans << endl;


    return 0;
}


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

int main(){
  int n, p;
  while(true){
    cin>>n>>p;
    if(n==0 && p==0)break;
    ll turn=0;
    int a[n], pn=p;
    memset(a, 0, sizeof(a));
    while(true){
      if(pn!=0){
        a[turn%n]++;
        pn--;
      }
      else{
        pn=a[turn%n];
        a[turn%n]=0;
      }
      if(a[turn%n]==p)break;
      turn++;
    }
    cout<<turn%n<<endl;
  }
  return 0;
}

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

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

Measured memory_bytes: 1164
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) { cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=a; i<(int)b; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int maxN = 2e5+2;


void solve()
{   
    ll n;
    lscn(n);

    vl a(n);

    for(auto& x : a)
        lscn(x);

    ll ans = 0, sum = a[0] % mod;

    rep(i, 1, n) {
        ll here = (sum * a[i]) % mod;

        ans = (ans + here) % mod;

        sum = (sum + a[i]) % mod;
    }

    lprin(ans);
} 

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

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

const int maxn = 1e5+10;
const long long mod = 1e9+7;
const long double eps = 1e-10;

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

int n;

set<int> s1;

bool check(vector<int> &v)
{
    int g = 0;
    for (int x : v)
        g = gcd(g, x);
    if (g != 1)
        return false;

    int s = 0;
    for (int x : v)
        s += x;

    for (int x : v)
    if (gcd(x, s-x) < 2)
        return false;

    s1.clear();
    for (int x:v)
        s1.insert(x);

    return s1.size() == v.size();
}

vector<int> tmp;

void build_set(vector<int> &v)
{
    int lim=30000;
    v.clear();
    v.push_back(3);
    v.push_back(9);
    int a=0, b=0, c=2;
    int d = 0;
    while(v.size() + tmp.size()<n)
    {
        if (a+b>0 && c>0 && 6+6*d<=lim)
        {
            tmp.push_back(6+6*d);
            d++;
        }else
        if (4+a*6<=lim && 2+b*6<=lim)
        {
            v.push_back(4+a*6);
            v.push_back(2+b*6);
            a++;
            b++;
        }else
        if (3+(c+1)*6 <= lim)
        {
            v.push_back(3+c*6);
            v.push_back(3+(c+1)*6);
            c+=2;
        }
    }
    while (v.size() + tmp.size() > n)
        tmp.pop_back();
    for (int x:tmp)
        v.push_back(x);
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    if (n==3)
    {
        cout << "2 5 63\n";
        exit(0);
    }
    vector<int> v;//({4,2,3,9,});
    /*while (v.size() < n)
    {
        for (int i =1;;++i)
        {
            v.push_back(i);
            if (check(v))
                break;
            v.pop_back();
        }
    }*/
    build_set(v);
    for (int i=0;i+1<v.size();++i)
        printf("%d ", v[i]);
    printf("%d\n", v[v.size() - 1]);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, a, b, c, d;
map<ll, ll> mp;

ll dfs(ll x){
	if(mp.find(x) != mp.end()){return mp[x];}
	if(x == 0){return 0;}
	if(x == 1){return d;}
	
	ll res = INF;
	
	if(x / 5 <= 1e9){
		if(x % 5 == 0){
			res = min(res, dfs(x / 5) + min(c, 4 * d * (x / 5)));
		}else if(x % 5 <= 2){
			ll r = x % 5;
			res = min(res, dfs((x - r) / 5) + d * r + min(c, 4 * d * ((x - r) / 5)));
		}else{
			ll r = 5 - x % 5;
			res = min(res, dfs((x + r) / 5) + d * r + min(c, 4 * d * ((x + r) / 5)));
		}
	}else{
		if(x % 5 == 0){
			res = min(res, dfs(x / 5) + c);
		}else if(x % 5 <= 2){
			ll r = x % 5;
			res = min(res, dfs((x - r) / 5) + d * r + c);
		}else{
			ll r = 5 - x % 5;
			res = min(res, dfs((x + r) / 5) + d * r + c);
		}
	}
	
	if(x / 3 <= 1e9){
		if(x % 3 == 0){
			res = min(res, dfs(x / 3) + min(b, d * 2 * (x / 3)));	
		}else if(x % 3 == 1){
			res = min(res, dfs((x - 1) / 3) + d + min(b, 2 * d * ((x - 1) / 3)));
		}else{
			res = min(res, dfs((x + 1) / 3) + d + min(b, 2 * d * ((x + 1) / 3)));
		}
	}else{
		if(x % 3 == 0){
			res = min(res, dfs(x / 3) + b);	
		}else if(x % 3 == 1){
			res = min(res, dfs((x - 1) / 3) + d + b);
		}else{
			res = min(res, dfs((x + 1) / 3) + d + b);
		}
	}
	
	if(x / 2 <= 1e9){
		if(x % 2){
			res = min(res, dfs((x + 1) / 2) + d + min(a, d * (x + 1) / 2));
			res = min(res, dfs((x - 1) / 2) + d + min(a, d * (x - 1) / 2));
		}else{
			res = min(res, dfs(x / 2) + min(a, d * x / 2));
		}
	}else{
		if(x % 2){
			res = min(res, dfs((x + 1) / 2) + d + a);
			res = min(res, dfs((x - 1) / 2) + d + a);
		}else{
			res = min(res, dfs(x / 2) + a);
		}
	}
	return mp[x] = res;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll t; cin >> t;
	while(t--){
		cin >> n >> a >> b >> c >> d;
		
		map<ll, ll> tmp;
		mp.swap(tmp);
		
		print(dfs(n));
	}
	return 0;
}

Measured memory_bytes: 5220
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str_scan = scan.nextLine();
    // int型へ変換
    var N = Integer.parseInt(str_scan);

    String str_scan2 = scan.nextLine();
    // スペース区切りで分ける
    var A = str_scan2.split(" ");
    long[] work = new long[N];
    long base_sum = 0;
    long MOD = 1000000007;
    long ans = 0;

    //long型に変換&&基本の和を求める
    for (var x = 0;x < N;x++){
      work[x] = Long.parseLong(A[x]);
      base_sum += work[x];
      base_sum %= MOD;
    }

    for (var i = 0;i < N-1;i++){
      base_sum -= work[i];
      if (base_sum < 0){
        base_sum += MOD;
      }
      ans += (work[i] * base_sum) % MOD;
    }

    ans %= MOD;

    System.out.println(ans);
    scan.close();
  }
}

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

int p[200];
int main() {
	int m, s, g;
	while (scanf("%d%d%d", &m, &s, &g), m) {
		rep(i, m)scanf("%d", &p[i]);
		sort(p, p + m, greater<>());
		int Max = 0, cnt;
		for (int i = s - 1; i < g; i++) {
			if (p[i] - p[i + 1] >= Max) {
				Max = p[i] - p[i + 1];
				cnt = i + 1;
			}
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 3252
x = input()
for i in range(int(input())):
	o = input().split()
	a,b = map(int,o[1:3])
	b+=1
	t = o[0][2]
	if t == 'i':
		print(x[a:b])
	elif t =='p':
		x = x[:a] + o[3] + x[b:]
	else:
		x = x[:a] + x[a:b][::-1] + x[b:]


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

int main() {
  int N; cin >> N;
  vector<pair<int, int>> A(N);
  for(int i = 0; i < N; ++i){
    cin >> A.at(i).first;
    A.at(i).second = i+1;
  }
  
  sort(A.begin(), A.end());
  
  for(int i = 0; i < N-1; ++i){
    cout << A.at(i).second << " ";
  }
  
  cout << A.at(N-1).second << endl;
}

Measured memory_bytes: 1664
N, M, C = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
a = []
for i in range(N):
    a.append(list(map(int, input().split(" "))))


ans = 0
for i in range(N):
    score = C
    for j in range(M):
        score += a[i][j] * b[j]
    if score > 0:
        ans += 1

print(ans)



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;
map<int,pair<ll,ll>>mp;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	ll a,b; cin >> a >> b;
	mp[0]=make_pair(a,b);
	for(int i=0;i<12;i++){
		if(i%2==0){
			a=a-b;
		}
		else{
			b=a+b;
		}
		mp[i+1]=make_pair(a,b);
	}
	cout << mp[n%12].first << " " << mp[n%12].second << endl;
}


Measured memory_bytes: 3216
#include <stdio.h>

int main(void)
{
	int limit = 10000;
	int H[limit], W[limit];
	int i, j;
	for (i = 0; i < limit; i++) {
		scanf("%d %d", &H[i], &W[i]);
		if (H[i] == 0 && W[i] == 0) {
			break;
		}
	}
	for (j = 0; j < i; j++) {
		for (int h = 0; h < H[j]; h++) {
			for (int w = 0; w < W[j]; w++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2096
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;

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

int main(void) { 
  char s[105];
  queue<char> q[3];

  rep(i,3) {
    cin >> s;
    int len = strlen(s);
    s[len] = '\0';
    rep(j,len) q[i].push(s[j]);
  }

  char tmp, ans;
  tmp = ans = '\0';

  while(1) {
    /*cout <<"start tmp = "<< tmp << endl;
    cout <<"now these sizes are" << endl;
    cout << "A " << q[0].size() << endl;
    cout << "B " << q[1].size() << endl;
    cout << "C " << q[2].size() << endl;*/
    if (tmp == '\0') {
      tmp = q[0].front();
      q[0].pop();
    } else if (tmp == 'a') {
      if(!q[0].empty()) {
        tmp = q[0].front();
        q[0].pop();
      } else {
        ans = 'A';
        break;
      }
    } else if (tmp == 'b') {
      if(!q[1].empty()) {
        tmp = q[1].front();
        q[1].pop();
      } else {
        ans = 'B';
        break;
      }
    } else if (tmp == 'c') {
      if(!q[2].empty()) {
        tmp = q[2].front();
        q[2].pop();
      } else {
        ans = 'C';
        break;
      }
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h1, m1, h2, m2, k;
  cin>>h1>>m1>>h2>>m2>>k;
  int c1,c2;
  c1 = 60*h1 + m1;
  c2 = 60*h2 + m2;
  int km=0; 
  if(c1>=c2){
      km=1440-(c1-c2)-k;
  }else if(c2>c1){
      km = c2-c1-k;
  }

    cout<<km<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cmath>
#include <random>
using namespace std;
random_device rd;
mt19937 mt(rd());

int n;
double x[111], y[111];

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> x[i] >> y[i];

  double ans = 0.0;
  uniform_real_distribution<> rand(-1.0, 1.0);
  for(int a = 0; a < 10000; ++a) {
    x[n] = rand(mt), y[n] = rand(mt);

    double px = 0.0, py = 0.0;
    for(int i = 0; i < n; ++i) {
      if(x[i]*x[n] + y[i]*y[n] >= 0) px += x[i], py += y[i];
    }
    ans = max(ans, px*px + py*py);
  }
  cout << fixed << setprecision(15) << sqrt(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N, M;
bool visited[50];
bool gragh[50][50];
int a[50], b[50];
//グローバル関数は0かfalseで初期化される。

void dfs(int v)
{
    visited[v] = true;
    for (int i = 0; i < N; i++)
    {
        if (gragh[v][i] == true)
        {
            if (visited[i] == true) continue;
            dfs(i);
        }else
        {
            continue;
        }
        
    }
    
}

int main(int argc, char const *argv[])
{
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        gragh[a[i]][b[i]] = true;
        gragh[b[i]][a[i]] = true;
    }

    int ans = 0;

    for (int i = 0; i < M; i++)
    {
        gragh[a[i]][b[i]] = false;
        gragh[b[i]][a[i]] = false;

        for (int i = 0; i < N; i++)
        {
            visited[i] = false;
        }
        dfs(0);
        
        bool bridge = false;
        for (int j = 0; j < N; j++)
        {
            if (visited[j] == false) bridge = true;
        }
        if (bridge) ans += 1;
        
        gragh[a[i]][b[i]] = true;
        gragh[b[i]][a[i]] = true;
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
a_list = list(map(int, input().split()))
LARGE = 10**9 + 7


# cumsum
b_list = [0] * N
b = 0

for i in range(N):
    a = a_list[i]
    b = a ^ b
    b_list[i] = b

v_all_dict = dict()
for b in b_list:
    v_all_dict[b] = [0, 0, 1]

zeros = 0



for i in range(N):

    b = b_list[i]

    t = v_all_dict[b][0]

    # new b
    if t < zeros:
        v_all_dict[b][2] = (v_all_dict[b][2] + v_all_dict[b][1] * (zeros - t)) % LARGE
        v_all_dict[b][0] = zeros

    # up
    v_all_dict[b][1] = (v_all_dict[b][1] + v_all_dict[b][2]) % LARGE

    # zeros
    if b == 0:
        zeros += 1

# res
if b_list[-1] == 0:
    res = 0
    for v in v_all_dict.keys():
        if v != 0:
            res = (res + v_all_dict[v][1]) % LARGE
        else:
            res = (res + 2 ** (zeros - 1) - 1) % LARGE
    res += 1

else:
    v = b_list[-1]
    res = v_all_dict[v][2]

print(res % LARGE)


Measured memory_bytes: 130000
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};

int main(){
  vector<int> dp(1000010, INF), odddp(1000010, INF);
  dp[0] = 0, odddp[0] = 0;
  for(int i = 1;; i++){
    int num = i * (i+1) * (i+2) / 6;
    if(num > 1000010) break;
    for(int j = num; j < 1000010; j++){
      dp[j] = min(dp[j], dp[j-num] + 1);
      if(num % 2) odddp[j] = min(odddp[j], odddp[j-num] + 1);
    }
  }
  while(true){
    int n; cin >> n;
    if(n == 0) break;
    cout << dp[n] << " " << odddp[n] << endl;
  }




}



Measured memory_bytes: 10636
// type a
//a...いけそう
//b...自信がない
//c...お試し
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
#include <atcoder/all>
// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000
#define mod (lint)1000000007
#pragma endregion

class UnionFind {
	vector<int> par;
public:
	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }
	lint root(int x) {//根を出す
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}
	bool same(int x, int y) {//同じ集合なのかを調べる
		return root(x) == root(y);
	}
	bool unite(int x, int y) {//xの根とyの根をつなげる
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return -par[root(x)];
	}
};
int n, q;
void solve() {
	cin >> n >> q;
	UnionFind u(n);
	for (int i = 0; i < q; i++) {
		int a, b, c; cin >> a >> b >> c;
		if (a == 0) {
			u.unite(b, c);
		}
		else {
			if (u.same(b, c)) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}
}

int main(void) {
	solve();

	return 0;
}

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

int main() {
  int N;
  string S;
  cin>>N>>S;
  int n=S.size();
  
  for(int i=0; i<n; i++){
    int a = S.at(i)+N;
    if(a<='Z') S.at(i) = (char)a;
    else S.at(i) = (char)(a-26);
  }
  cout<<S<<endl;
}

Measured memory_bytes: 3620
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;		\
                               c > 0 ? i < b : i > b;	\
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) a.begin(), a.end()
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) cerr << #x << " = " << (x) << " " << endl;
#else
const bool test = false;
#define dump(x) 
#define dumpl(x) 
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep))
    {
      v.push_back(buffer);
    }
  return v;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}
 
template<typename T>
T gcd(T a, T b)
{
  T c;
  while (a != 0) {
    c = a; a = b%a;  b = c;
  }
  return b;
}
 
class Solver {
public:
  int N;
  vector<int> a;

  void solve() {
    cin >> N;
    a.resize(N);
    rep(i, N) cin >> a[i];
    sort(all(a));

    map<int, int> m;
    rep(i, N) m[a[i]] += 1;

    int cnt = 0;
    for (auto itr = m.begin(); itr != m.end(); itr++) {
      int b = itr->first;
      int c = itr->second;
      if (b <= c) cnt += abs(b - c);
      else cnt += c;
    }
    cout << cnt << endl;
  }
};
 
signed main()
{
  srand(time(NULL));
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {    
  //     auto ptr = new Solver();
  //     ptr->solve();
  //     delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'


Measured memory_bytes: 7040
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T& x, const T& y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T& x, const T& y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main
int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) {cin >> p[i]; --p[i];}
    
    vector<int> idx(n + 1, -1);
    rep(i, n) idx[p[i]] = i;
    
    int ans = n;
    int now = 0;
    while (now < n) {
        int old = now;
        while (now < n) {
            if (idx[now] > idx[now + 1]) break;
            ++now;
        }
        chmin(ans, n - (now - old + 1));
        now += 1;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int sum=0;
  for (int i=0;i<4;i++){
    if (s[i]=='+'){
      sum++;
    }
    else{
      sum--;
    }
  }
  cout << sum << endl;
}

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

int main(){
	char S[10], T[10], U[10];
	int A,B;

	scanf("%s",&S);
	scanf("%s",&T);
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%s",&U);

	if(strcmp(S,U) == 0){
		printf("%d %d",A-1, B);
	}

	else{
		printf("%d %d",A, B-1);
	}

	return 0;

}

Measured memory_bytes: 128
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

int main(){
  int k,x;
  cin>>k>>x;
  if(500*k>=x)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int INF=1000000;
int N,A,B,C;
vector<int> l(8);
int dfs(int cur,int a,int b,int c);
int main(){
    cin >> N >> A >> B >>C;
    for(int i=0;i<N;i++) cin >> l[i];
    cout << dfs(0,0,0,0);
}

int dfs(int cur,int a,int b,int c){
    if(cur==N){ 
        if(min(a,min(b,c))>0) return abs(a-A)+abs(b-B)+abs(c-C)-30;
        else return INF;
    }
    int ret0=0,ret1=0,ret2=0,ret3=0;
    ret0=dfs(cur+1,a,b,c);
    ret1=dfs(cur+1,a+l[cur],b,c)+10;
    ret2=dfs(cur+1,a,b+l[cur],c)+10;
    ret3=dfs(cur+1,a,b,c+l[cur])+10;
    return min(min(ret0,ret1),min(ret2,ret3));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

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

  int N, K;
  cin >> N >> K;
  int ans = 1;
  int M = K;
  while(true){
    if(N >= M){
      ans++;
      M *= K;
    }
    else{
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 3
#define LIMIT 30

int piace[N][N]; //パズル
int tmp[N][N]; //保存

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

int result;

int dfs(int ,int ,int ,int ,int );
int cal();


int main(){
  int i,j,k=0;
  int x,y;


  for(i = 0;i<N;i++){
    for(j=0;j<N;j++){
      scanf("%d",&piace[i][j]);
    }
  }

  for(i = 0 ;i <N ;i++){
    for(j = 0;j<N;j++){
      if(piace[i][j]==0){
	x = j;
	y = i;
      }
    }
  }

  while(1){

    for(i = 0;i<N;i++){
      for(j = 0;j<N;j++){
	tmp[i][j] = piace[i][j];
      }
    }

    result = dfs(x,y,-1,0,k);

    if(result !=-1){
      printf("%d\n",result);
      break;
    }

    for(i =0;i<N;i++){
      for(j=0;j<N;j++){
	piace[i][j] = tmp[i][j];
      }
    }

    result = -1;

    k++;

    }

    
  
     
  return 0;
}

 
int dfs(int x,int y,int p,int depth,int l){ //depth first search
  int i;
  int sum;
  int x_2,y_2;
  int res;


  int hozon;
  
  sum = cal();
  
  if(sum==0) {
    return depth;
  }
  
  if(depth+sum > l) {
    return -1;
  }
   
  for(i=0;i<4;i++){
    x_2 = x+dx[i];
    y_2 = y+dy[i];
    
    if(p!=-1 && i ==(p+2)%4) continue;

    if(x_2 < 0 || x_2 >= 3 || y_2 < 0 || y_2 >= 3) continue;
 

    hozon=piace[y][x];
    piace[y][x]=piace[y_2][x_2];
    piace[y_2][x_2]=hozon;

 
    res = dfs(x_2,y_2,i,depth+1,l);
     
    if(res!=-1) {
      return res;
    }

    hozon=piace[y][x];
    piace[y][x]=piace[y_2][x_2];
    piace[y_2][x_2]=hozon;
  }
  return -1;
}
 
int cal(){
  int i;
  int hozon;
  int sum=0;

  int z[2]; //絶対値

  for(i = 0;i < 9;i++){

    hozon = piace[i/3][i%3];
    
    if(hozon!=0) {
      hozon--;

      z[0]= i/3 - hozon/3;
      if(z[0]<0)z[0]*=-1;

      z[1]= i%3 - hozon%3;
      if(z[1] < 0)z[1]*=-1;


      sum += z[0] + z[1];
    }
  }
  return sum;
}




Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;
int main() {
  long long a, b, n, x;
  cin >> a >> b >> n;
  x = min(n, b-1);
  cout << a*(x%b)/b << endl;
}

Measured memory_bytes: 3156
#pragma region
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define dump(x) cerr << #x << " = " << x << endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
int dig(int n){return (int)(log10(n) + 1);}
int abc(char x){return (int)(x)-(int)('a');} // 0~25
char abc(int x){return (char)(x+(int)('a'));} 
int ABC(char x){return (int)(x)-(int)('A');}
char ABC(int x){return (char)(x+(int)('A'));}
void solve();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}
#pragma endregion

void solve() {
	int N, R;
	cin >> N >> R;
	if (N < 10) R = R + 100 * (10 - N);
	cout << R << endl;
}

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

double cx[2],cy[2],x[100],y[100];


int cirxy(double x1,double y1,double x2,double y2) {
 double x3,y3,x4,y4,k,r;
 x3=(x1+x2)/2; y3=(y1+y2)/2;
 k=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
 if ((1-k*k)<0) return 1;
 r=sqrt(1-k*k);
 if (x1==x2) {cx[0]=x3+r; cy[0]=cy[1]=y3; cx[1]=x3-r; return 0;}
 if (y1==y2) {cx[0]=cx[1]=x3; cy[0]=y3+r; cy[1]=y3-r; return 0;}
 x4=fabs((y1-y2))*(r/(2*k)); y4=fabs((x1-x2))*(r/(2*k));
 if ((y1-y2)/(x1-x2)<0) { cx[0]=x3+x4; cy[0]=y3+y4 ; cx[1]=x3-x4; cy[1]=y3-y4;}
 else {cx[0]=x3+x4; cy[0]=y3-y4; cx[1]=x3-x4; cy[1]=y3+y4;}
 return 0;
}

int main() {
	int n,i,j,k,h,c,mx;
	while(true) {
		cin >> n;
		mx=1;
		if (n==0) break;
		for (k=0;k<n;k++) scanf("%lf,%lf",&x[k],&y[k]);
		for (i=0;i<n-1;i++) {
			for (j=i+1;j<n;j++) {
				 if (cirxy(x[i],y[i],x[j],y[j])==1) continue; 
				 for (h=0;h<2;h++) {
                  c=0;
				  for (k=0;k<n;k++) if (sqrt((cx[h]-x[k])*(cx[h]-x[k])+(cy[h]-y[k])*(cy[h]-y[k]))<=1.000001) c++;
				  mx=max(c,mx);
				 }
			}
		}
        cout << mx << endl;
	}
   return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int f[100][100];
int main(){
    int a,b,i,j,k,s,t;
    scanf("%d%d",&a,&b);
    //a>=b
    if(a==0){
        printf("1 1\n#\n");
        return 0;
    }
    if(b==0){
        printf("1 1\n.\n");
        return 0;
    }
    printf("100 100\n");
    for(i=0;i<50;i++)for(j=0;j<100;j++)f[i][j]=0;//o->B->#
    for(i=50;i<100;i++)for(j=0;j<100;j++)f[i][j]=1;//1->A->.
    a--;b--;
    for(i=0;i<49&&a>0;i++)
        for(j=i%3;j<99&&a>0;j+=3){
            f[i][j]=1;
            a--;
        }
    for(i=51;i<100&&b>0;i++)
        for(j=i%3;j<99&&b>0;j+=3){
            f[i][j]=0;
            b--;
        }
    for(i=0;i<100;i++){
        for(j=0;j<100;j++){
            if(f[i][j]==0)printf("#");else printf(".");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}  //親は-1

    int root(int x) {
        if (par[x] < 0)
            return x;  //自身が親
        else
            return par[x] = root(par[x]);  //再帰
    }

    bool same(int x, int y) { return root(x) == root(y); }

    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;  //既に同じ根
        // xとyのサイズの大きいほうにまとめたい
        if (size(x) < size(y)) swap(x, y);
        par[x] += par[y];  //根のparは-(要素数)になる
        par[y] = x;        //親を更新
        return;
    }

    int size(int x) { return -par[root(x)]; }
};

signed main() {
    int n, m;
    cin >> n >> m;
    UnionFind tree(n);
    set<pint> st;
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (a > b) swap(a, b);
        st.insert({a, b});
    }
    for (auto p : st) {
        int a = p.first, b = p.second;
        tree.merge(a, b);
    }
    int ans = 1;
    rep(i, 0, n) { ans = max(ans, tree.size(i)); }
    cout << ans << "\n";
}

Measured memory_bytes: 17156
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		vector<int> a;
		for(int i=0;i<n;i++){
			int b;
			cin>>b;
			a.push_back(b);
		}
		vector<int> sum;
		for(int j=0;j<a.size();j++){
			int s=0;
			for(int k=j;k<a.size();k++){
				s += a[k];
				sum.push_back(s);
			}
		}
		sort(sum.begin(),sum.end());
		cout<<sum[sum.size()-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 34516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl0

ll modpow(ll x, ll y, ll m){
    if(y==0) return 1;
    ll res = modpow(x,y/2,m);
    return res * res % m * (y&1 ? x : 1) % m;
}

int h,w,n,k;

int ask(int a, int b, int c, int d){
    printf("? %d %d %d %d\n", a, b, c-1, d-1);
    fflush(stdout);
    int p;
    cin >> p;
    return p;
}

int ans[50][50];

void solve(int i1, int j1, int i2, int j2, int n){
    int h = i2 - i1;
    int w = j2 - j1;
    if(n == 0 || n == h*w){
        for(int i = i1; i < i2; ++i){
            for(int j = j1; j < j2; ++j){
                ans[i][j] = n == 0 ? 0 : 1;
            }
        }
    } else {
        if(h > w){
            int x = ask(i1, j1, i1 + h/2, j2);
            solve(i1, j1, i1 + h/2, j2, x);
            solve(i1 + h/2, j1, i2, j2, n - x);
        } else {
            int x = ask(i1, j1, i2, j1 + w/2);
            solve(i1, j1, i2, j1 + w/2, x);
            solve(i1, j1 + w/2, i2, j2, n - x);
        }
    }
}

int main(){
    cin >> h >> w >> n >> k;
    memset(ans, -1, sizeof ans);
    solve(0, 0, h, w, n);

    rep(i,h){
        solve(i, 0, i, w, ask(i, 0, i, w));
    }

    // rep(i,h){
    //     rep(j,w){
    //         cerr << ans[i][j];
    //     }
    //     cerr << endl;
    // }

    ll sigma = 0;
    rep(i,h)rep(j,w){
        sigma += ans[i][j] * modpow(2, i*w + j, k);
        sigma %= k;
    }
    cout << "! " << sigma << endl;
}


Measured memory_bytes: 724
// Vivek Rai
// Blazer_007

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/detail/standard_policies.hpp>

#define fastio 		ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp	     make_pair
#define inf         0x3f3f3f3f
//#define INF         0x3f3f3f3f3f3f3f3fLL
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define ppi	    pair<ll,pii>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define see(x)	    cout<<x<<endl;
#define see2(x,y)   cout<<x<<" "<<y<<endl;
#define see3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define bit(x, y)   (((x)>>(y))&1)
#define bpt(x)      (__builtin_popcount(x))
#define bptl(x)     (__builtin_popcountll(x))
#define loop(i,a,b)  for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define N 2000010

using namespace std;
//using namespace __gnu_pbds;

//typedef priority_queue<int> maxHeap;
//typedef priority_queue<int,vector<int>,greater<int>()) minHeap;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// find_by_order(index) -> value at given index or Kth smallest element in set
// order_of_key(X) -> number of elements strictly less than X
//typedef tree<pii , null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

string solve(vector<int>& v,int k){
    bool dp[k+1];
    memset(dp,0,sizeof dp);

    for(int i=1;i<=k;i++){
        for(auto move:v){
            if(move > i)
                continue;
            if(dp[i-move] == 0)
                dp[i] = 1;
        }
    }
    return dp[k] == 1 ? "First" : "Second" ;
}

void solution(){
    int n , k;
    cin >> n >> k;
    vector<int> arr(n);
    loop(i,0,n) cin >> arr[i];
    cout << solve(arr,k) << endl;
}

signed main(){
    fastio
    // #ifndef ONLINE_JUDGE
    // 	freopen("input.txt", "r" , stdin);
    // 	freopen("output.txt", "w", stdout);
    // #endif

    ll t=1;
    // cin>>t;
    loop(i,1,t+1){
    	//cout<<"Case #"<<i<<": ";
    	solution();
    }
}




Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#define rep(i,x) for(int i=0;i<x;i++)

using namespace std;

int main(){
  int N;
	cin>>N;
  int d[N];
  for(int i=0;i<N;i++){
  	cin>>d[i];
  }
  
 	long long sum=0;
  
  rep(i,N){
  	for(int j=i+1;j<N;j++){
    	sum+=d[i]*d[j];
    }
  }
  
  cout<<sum;
  
}

Measured memory_bytes: 888
//ABC078-A
#include <stdio.h>
 
int main(){
	char X, Y;
	scanf("%c %c", &X, &Y);
	if(X < Y){
		printf("<\n");
	}
	else if(X > Y){
		printf(">\n");
	}
	else{
		printf("=\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <float.h>
using namespace std;

// 問1
//int main()
//{
//	long lnTime1;
//	long lnTime2;
//	cin >> lnTime1;
//	cin >> lnTime2;
//
//	long lnStart = lnTime1 + lnTime2;
//	if (lnStart > 23)
//		lnStart = lnStart-24;
//
//	cout << lnStart;
//
//	return 0;
//}

// 問2

class cPOINT{
public:
	long lnX;
	long lnY;
	cPOINT() { lnX = 0; lnY = 0; };
	cPOINT& operator=(const cPOINT &obj);
	cPOINT operator-(const cPOINT &obj);
	double calc();
};
cPOINT& cPOINT::operator=(const cPOINT &obj)
{
	lnX = obj.lnX;
	lnY = obj.lnY;
	return *this;
}
cPOINT cPOINT::operator-(const cPOINT &obj)
{
	cPOINT cTmp;
	cTmp.lnX =  this->lnX - obj.lnX;
	cTmp.lnY = this->lnY - obj.lnY;
	return cTmp;
}

double cPOINT::calc()
{
	return abs(lnX) + abs(lnY);
	//double dbPowX = pow(lnX, 2);
	//double dbPowY = pow(lnY, 2);
	//return sqrt(dbPowX + dbPowY);
}


int main()
{
	long lnCntN;
	long lnCntM;
	cin >> lnCntN;
	cin >> lnCntM;

	vector<cPOINT> vecN(lnCntN);
	vector<cPOINT> vecM(lnCntM);

	for (int i = 0; i < lnCntN; i++)
	{
		cPOINT stAdd;
		cin >> stAdd.lnX;
		cin >> stAdd.lnY;
		vecN[i] = stAdd;
	}
	for (int i = 0; i < lnCntM; i++)
	{
		cPOINT stAdd;
		cin >> stAdd.lnX;
		cin >> stAdd.lnY;
		vecM[i] = stAdd;
	}

	for (int i = 0; i < lnCntN; i++)
	{
		int nIdxM=0;					// 1番近いチェックポイントデータのIndex;
		double dbNearVal = DBL_MAX;	// 1番近いチェックポイントまでの距離
		for (int j=0; j < lnCntM; j++)
		{
			cPOINT cTmp = vecN[i] - vecM[j];
			double dbVal = cTmp.calc();
			if (dbVal < dbNearVal)
			{
				dbNearVal = dbVal;
				nIdxM = j;
			}
		}
		if (i == lnCntN-1)
			cout << nIdxM + 1;
		else
			cout << nIdxM + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

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

    vector<int> v(m);
    for(int i = 0; i < m; i++)  cin >> v[i];
    sort(v.begin(), v.end());

    ll ans = 0;
    vector<int> diff;
    for(int i = 0; i < m-1; i++){
        ans += v[i+1]-v[i];
        diff.push_back(v[i+1]-v[i]);
    }
    sort(diff.rbegin(), diff.rend());

    for(int i = 0; i < min(n-1,m-1); i++){
        ans -= diff[i];
    }

    cout << ans << endl;

    return 0;
}

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

#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin >> tt; rep1(qq,1,tt)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12

#define lnode (2 * node + 1)
#define rnode (2 * node + 2)

using namespace std;

typedef pair<int, int> pii;

const int N = 200005;

int n;
int dp[N], sz[N], fac[N], inv[N], ways[N], res[N];
vector<int> g[N];

int add(int x, int y){
  int res = (x + y) % MOD;
  return res;
}

int mul(int x, int y){
  int res = (x * y) % MOD;
  return res;
}

int modexp(int x, unsigned int y){
  int res = 1;
  x %= MOD;
  if(!y) return 0;
  while(y > 0){
    if(y & 1) res = mul(res, x);
    y >>= 1;
    x = mul(x, x);
  }
  return res;
}

int modularInverse(int a){
  return modexp(a, MOD - 2) % MOD;
}

void dfs(int u, int p = -1){
  sz[u] = 1;
  for(int v : g[u]){
    if(v == p) continue;
    dfs(v, u);
    sz[u] += sz[v];
  }
}

void dfs1(int u, int p = -1){
  dp[u] = 1;
  ways[u] = 1;
  for(int v : g[u]){
    if(v == p) continue;
    dfs1(v, u);
    dp[u] = mul(dp[u], dp[v]);
    ways[u] = mul(ways[u], inv[sz[v]]);
  }
  ways[u] = mul(ways[u], fac[sz[u] - 1]);
  dp[u] = mul(dp[u], ways[u]);
}

void dfs2(int u, int p = -1){
  res[u] = dp[u];
  int prior = dp[u];
  for(int v : g[u]){
    if(v == p) continue;
    // remove v's contribution as child
    dp[u] = mul(dp[u], modularInverse(dp[v]));
    dp[u] = mul(dp[u], inv[sz[u] - 1]);
    dp[u] = mul(dp[u], fac[sz[v]]);
    sz[u] -= sz[v];
    dp[u] = mul(dp[u], fac[sz[u] - 1]);
    // add u's contribution to v
    dp[v] = mul(dp[v], inv[sz[v] - 1]);
    dp[v] = mul(dp[v], inv[sz[u]]);
    sz[v] += sz[u];
    dp[v] = mul(dp[v], fac[sz[v] - 1]);
    dp[v] = mul(dp[v], dp[u]);
    dfs2(v, u);
    sz[v] -= sz[u];
    sz[u] += sz[v];
    dp[u] = prior;
  }
}

int32_t main(){

  FIO
  //cout << fixed << setprecision(10);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  
  fac[0] = 1;
  for(int i = 1; i < N - 1; ++i){
    fac[i] = mul(i, fac[i - 1]);
  }
  inv[0] = 1;
  for(int i = 1; i < N - 1; ++i){
    inv[i] = modularInverse(fac[i]);
  }
  cin >> n;
  for(int i = 0; i < n - 1; ++i){
    int x, y;
    cin >> x >> y;
    g[x].pb(y);
    g[y].pb(x);
  }
  dfs(1); // get size
  dfs1(1); // solve for root 1
  dfs2(1); // reroot
  for(int i = 1; i <= n; ++i){
    cout << res[i] << '\n';
  }
	return 0;
}



Measured memory_bytes: 24048
N = int(input())

a = input().split()

A = [int(s) for s in a]   #strのリストをintのリストに変換


Time = 0
i = 0


while i < N:
	if A[i] % 2 == 0:
		i += 1

		if i == N:
			for j in range(N):
				A[j] = A[j] / 2
			
			Time += 1
			i = 0

	elif A[i] % 2 == 1:
		break

	
	

print(Time)



Measured memory_bytes: 3060
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
using namespace std;
 
typedef long long ll;

int main(){
	string s,ss,s1,s2,_s1,_s2;
    cin >> s;
    int n= s.size();
    ss = s;
    reverse(ss.begin(), ss.end());
    s1 = s.substr(0,(n-1)/2);
    _s1 = s1;
    reverse(s1.begin(),s1.end());
    s2 = s.substr((n-1)/2+1);
    _s2 = s2;
    reverse(s2.begin(),s2.end());
    bool f = true;
    if(s != ss) f =false;
    if(s1 != _s1) f =false;
  	if(s2 != _s2) f =false;
    if(f){ 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)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000005;

int main()
{
	ll k,a,b;
	cin >> k >> a >> b;
	ll K = k;
	ll ans = 1;
	if(b-a>2)
	{
		ans += a-1;
		k -= a-1;

		if(k>=2)
		{
			ans += (b-a)*(k/2);
			k %=2;
			ans += k;
			cout<<ans<<endl;
		}
		else
		{
			cout<<K+1<<endl;
		}
		
	}
	else
	{
		cout<<k+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256