akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){ll c; while(b!=0){c=a%b; a=b; b=c;} return a;}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a * c%mod;} a=a * a%mod; b>>=1;} return c;}
vi calc(ll x){vi res; while(x>0){res.pb(x%10); x/=10;} reverse(all(res)); return res;}

void solve_A() {
  int n,r;
  cin>>n>>r;
  if(n<10) out(r+100*(10-n));
  else out(r);
}
void solve_B() {
  int n,k,ans=0;
  cin>>n>>k;
  while(n>0){
    n/=k;
    ans++;
  }
  out(ans);
}
void solve_C() {
  int n,ans=INF;
  cin>>n;
  vi x(n);
  rep(i,n) cin>>x[i];
  sort(all(x));
  REP(a,x[0],x[n-1]+1){
    int p=0;
    rep(i,n) p+=(a-x[i])*(a-x[i]);
    chmin(ans,p);
  }
  out(ans);
}

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


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
string a,b="CF";
int al,bl;
int main(void){
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++){
    	if(a[i]==b[bl]){
            bl++;
            if(bl==2)break;
        }
	}
    if(bl==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main(void){
    int A,B,C;
    cin>>A>>B>>C;
    if(A+B+C==17&&((A==5||A==7)&&(B==5||B==7)&&(C==5||C==7)))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a; cin >> n >> a;
  vector<int> X(n); rep(i, n) cin >> X[i];
  int mx = 50*n;
  vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(n+1, vector<ll>(mx+1)));
  dp[0][0][0] = 1;
  rep(i, n) {
    rep(j, n+1) {
      rep(k, mx+1) {
        dp[i+1][j][k] += dp[i][j][k];
        if(j+1<n+1 && k+X[i]<mx+1) {
          dp[i+1][j+1][k+X[i]] += dp[i][j][k];
        }
      }
    }
  }
  ll ans = 0;
  REP(j, 1, n+1) {
    ans += dp[n][j][a*j];
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 55128
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz
 

	int n, m, k, x, y;
	cin >> n >> m >> k;	
	int a[n], b[m];
	ini(a, 0);
	ini(b, 0);
	int c, d;
	c=d=0;
	map<pii,int> mp;
	for(int i=0; i<k; i++){
		cin >> x >> y;
		x--;
		y--;
		a[x]++;
		b[y]++;
		c=max(c, a[x]);
		d=max(d, b[y]);
		mp[{x,y}]++;
	}	
	vi arr, brr;
	int ans = c+d-1;
	for(int i=0; i<n; i++){
		if(a[i]==c)arr.pb(i);
	}
	for(int i=0; i<m; i++){
		if(b[i]==d)brr.pb(i);
	}
	for(int i=0; i<sz(arr); i++){
		for(int j=0; j<sz(brr); j++){
			if(!mp[{arr[i], brr[j]}]){
				cout << ans+1 << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
 
	return 0;
}  

Measured memory_bytes: 34968
#include <iostream>
#include <sstream>
#include <stack>
#include <cstdlib>
#include <string>

using namespace std;

void solve()
{
	string str;
	string a;
	while(getline(cin, str))
	{
		stack<double> Stack;
		stringstream ss;
		ss << str;
		while(ss >> a)
		{
			if(a == "+" || a == "-" || a == "*" || a == "/")
			{
				double num[2];
				num[0] = Stack.top();
				Stack.pop();
				num[1] = Stack.top();
				Stack.pop();
				if(a == "+")
				{
					Stack.push(num[1] + num[0]);
				}
				else if(a == "-")
				{
					Stack.push(num[1] - num[0]);
				}
				else if(a == "*")
				{
					Stack.push(num[1] * num[0]);
				}
				else if(a == "/")
				{
					Stack.push(num[1] / num[0]);
				}
			}
			else
			{
				Stack.push(atof(a.c_str()));
			}
		}
		printf("%.6f\n", Stack.top());
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    string S;
    cin >> S;

    REP(i, S.size()) {
        if((i%2==0 && S[i] != 'h') || (i%2==1 && S[i] != 'i')) {
            cout << "No" << endl;
            return 0;
        }
    }

    if(S.size()%2!=0) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;


    return 0;
}

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

using namespace std;

long long inf=1000000007;

int main(){
	double a,b,h,m;
	cin>>a>>b>>h>>m;

	double kakudoA=360*h/12;
	double kakudoB=360*m/60;
	kakudoA+=30*m/60;
	double pi =2.0*asin(1.0);

	kakudoA=kakudoA/180*pi;
	kakudoB=kakudoB/180*pi;

	double ax=sin(kakudoA)*a;
	double ay=cos(kakudoA)*a;
	double bx=sin(kakudoB)*b;
	double by=cos(kakudoB)*b;

	double ans=pow(abs(ax-bx)*abs(ax-bx) + abs(ay-by)*abs(ay-by),0.5);

	cout<<fixed<<setprecision(10)<<ans<<endl;

	return 0;
}


Measured memory_bytes: 4168
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int v ,e;
int sta[10001];
vector <int> gin[10001],gout[10001],ans;
queue <int> Q;

void toporogical_sort(){
  for(int i=0;i<v;i++)
    if(!gin[i].size())Q.push(i);
  
  while(!Q.empty()) {
    int t = Q.front(); Q.pop();
    ans.push_back(t);
 
    for(int i=0;i<gout[t].size();i++){
      int nx = gout[t][i];
      int size = gin[nx].size();
      for(int j=0;j<size;j++)
	if(gin[nx][j] == t){
	  gin[nx].erase(gin[nx].begin()+j);
	  break;
	}
      if(!gin[nx].size()) Q.push(nx);
    }
  }
}
 
 
int main() {
  cin >> v >> e;
   for(int i=0;i<e;i++) {
    int s,t;
    cin >> s >> t;
    gin[s].push_back(t);
    gout[t].push_back(s);
   }
  toporogical_sort();
  for(int i=ans.size()-1;i>=0;i--) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 2592
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.nextLine();
		String b = sc.nextLine();
		sc.close();
		String ans = "";
		for(int i=0;i<a.length();i++){
			ans += a.charAt(i);
			if(i<b.length()) ans += b.charAt(i);
		}
		System.out.println(ans);
	}
}

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

int main() {
  int a,aux=1,ans=0,c;
  cin>>a;
  for (int v=0;v<a;v++){
    cin>>c;
    if(c==aux){
      aux++;
    }
    else{
      ans++;

    } 
  }if(ans==a){cout<<-1;}else{cout<<ans;}
}

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

#define ALL(container) (container).begin(), (container).end()
#define INF 1000000007
typedef long long ll;

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; }
ll GCD (ll a, ll b) { return b ? GCD(b, a % b) : a; }

using namespace std;

int main()
{
    string s;
    int ans = 753;
    cin >> s;
    for (int i = 2; i < s.size(); i++) {
        int sum = int(s[i] - '0') + int(s[i-1] - '0') * 10 + int(s[i-2] - '0') * 100;
        // cout << ans << endl;
        chmin(ans, abs(753-sum));
    }

    cout << ans << endl;

    return 0;
}


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

bool is_month(int x)
{
  if(x>=1&&x<=12){
    return true;
  } else {
    return false;
  }
}

void check(int x, int y)
{
  if(is_month(x)&&is_month(y)){
    cout << "AMBIGUOUS" << endl;
  } else if(is_month(x)) {
    cout << "MMYY" << endl;
  } else if(is_month(y)) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
}

int main()
{
  int x;
  cin >> x;
  int y = x%100;
  x = x/100;
  check(x,y);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#define mod 998244853 
using namespace std;
struct tree{
  bool vu = false;
  bool tr = false;
  vector<int>son;
  int va=0;
};
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, q, a, b;
	cin >> n >> q;
	tree t[n+1];
	for(int i = 0; i < n-1; i++)
	{
	    cin >> a >> b;
	    t[a].son.push_back(b);
	    t[b].son.push_back(a);
	}
	for(int i = 0; i < q; i++)
	{
	    cin >> a >> b;
	    t[a].va+=b;
	}
	vector<int>v;
	v.push_back(1);
	int j=0;
	while(j < v.size())
	{
	    int l=v.size();
	    while(j < l)
	    {
	        t[v[j]].vu=true;
	        t[v[j]].tr=true;
	        for(int k = 0; k < t[v[j]].son.size(); k++)
	        {
	            if(!t[t[v[j]].son[k]].tr)
	                t[t[v[j]].son[k]].va+=t[v[j]].va;
	            if(!t[t[v[j]].son[k]].vu)
	            {
	                v.push_back(t[v[j]].son[k]);
	                t[t[v[j]].son[k]].vu=true;
	            }
	        }
	        j++;
	    }
	}
	for(int i = 1; i <= n; i++)
	    cout << t[i].va << ' ';
}


Measured memory_bytes: 18036
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repm(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    int A, B, M;
    cin >> A >> B >> M;
    vi a(A), b(B);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];
    vi x(M), y(M), c(M);
    rep(i, M) cin >> x[i] >> y[i] >> c[i];

    int min_a = a[0], min_b = b[0];
    repm(i, 1, A)
    {
        min_a = min(min_a, a[i]);
    }
    repm(i, 1, A)
    {
        min_b = min(min_b, b[i]);
    }
    int minval = min_a + min_b;
    rep(i, M)
    {
        minval = min(minval, a[x[i] - 1] + b[y[i] - 1] - c[i]);
    }
    
    // int minval = a[0] + b[0];
    // rep(i, A)
    // {
    //     rep(j, B)
    //     {
    //         int max_dis = 0;
    //         rep(k, M)
    //         {
    //             if (x[k] - 1 == i && y[k] - 1 == j)
    //             {
    //                 max_dis = max(max_dis, c[k]);
    //             }
    //         }
    //         minval = min(minval, a[i] + b[j] - max_dis);
    //     }
    // }

    cout << minval << endl;

    return 0;
}

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

int main(){
  int N,sum = 0;
  int i;
  cin >> N;
  i = N;
  while(i > 0){
    sum += i % 10;
    i /=10;
  }
  if(N % sum ==0)
    cout << "Yes" << endl;
  else
    cout << "No" <<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
    }
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			int m = scan.nextInt();
			UnionFind uf = new UnionFind(n);
			edge[] e = new edge[m];
			for(int i = 0;i < m;i++){
				String[] str = scan.next().split(",");
				e[i] = new edge(Integer.parseInt(str[0]),Integer.parseInt(str[1]),Integer.parseInt(str[2])/100-1);
			}
			for(int i = 0;i < m;i++){
				for(int j = m-1;j > i;j--){
					if(e[j-1].cost > e[j].cost){
						swap(e,j,j-1);
					}
				}
			}
			int min = 0;
			for(int i = 0;i < m;i++){
				if(!uf.same(e[i].u,e[i].v)){
					uf.unite(e[i].u,e[i].v);
					min += e[i].cost;
				}
			}
			System.out.println(min);
		}
	}
	public void swap(edge[] e,int i,int j){
		edge t = e[j];e[j] = e[i];e[i] = t;
	}
	public class UnionFind{
		int[] par;
		int[] rank;
		public UnionFind(int n){
			par = new int[n];
			rank = new int[n];
			for(int i = 0;i < n;i++){
				par[i] = i;
				rank[i] = 0;
			}
		}
		public int find(int x){
			if(par[x] == x){
				return x;
			}else{
				return par[x] = find(par[x]);
			}
		}
		public void unite(int x,int y){
			x = find(x);
			y = find(y);
			if(x == y){
				return;
			}
			if(rank[x] < rank[y]){
				par[x] = y;
			}else{
				par[y] = x;
				if(rank[x] == rank[y]){
					rank[x]++;
				}
			}
		}
		public boolean same(int x,int y){
			return find(x) == find(y);
		}
	}
	public class edge{
		int u;
		int v;
		int cost;
		public edge(int u,int v,int cost){
			this.u = u;
			this.v = v;
			this.cost = cost;
		}
	}
}

Measured memory_bytes: 33848
#include <iostream>
#include <vector>
#include <tuple>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <functional>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;


int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n,m,ans=0;
  cin >> n >> m;
  int h[n], a[m], b[m], highest[n], hightemp;
  REP(i,n) cin >> h[i];
  REP(i,m) cin >> a[i] >> b[i];
  REP(i,n) highest[i] = 0;

  REP(i,m){
    if (h[a[i]-1]== h[b[i]-1]){
      hightemp = h[a[i]-1] + 1;
    } else {
      hightemp = max(h[a[i]-1], h[b[i]-1]);
    }
    if (highest[a[i]-1] < hightemp){
      highest[a[i]-1] = hightemp;
    }
    if (highest[b[i]-1] < hightemp){
      highest[b[i]-1] = hightemp;
    }
  }

  REP(i,n){
    if(highest[i] == 0 || highest[i] == h[i]){
      ans ++;
    }
  }

  cout << ans;

}
  

Measured memory_bytes: 5224
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;

vector<vector<int>> tree;
vector<bool> used;
vector<vector<int>> dp;
void input();
void treeDP(int i){
    used[i]=true;
    dp[i][0]=1;dp[i][1]=1;
    for(auto e:tree[i]){
        if(used[e]) continue;
        treeDP(e);
        dp[i][0] *= dp[e][0] + dp[e][1];
        dp[i][1] *= dp[e][0];
        dp[i][0] %= mod;
        dp[i][1] %= mod;
    }
    used[i]=false;
    return ;
}
signed main(){
    input();
    treeDP(0);
    cout<<(dp[0][0]+dp[0][1])%mod<<endl;
}

void input(){
    int N;cin>>N;
    tree.resize(N);
    used.resize(N,false);
    dp.resize(N,vector<int>(2,0));
    REP(i,N-1){
        int a,b; cin>>a>>b;
        a--;b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
}

Measured memory_bytes: 18176
from collections import deque

H,W = map(int,input().split())
C_pos=list(map(lambda x:int(x)-1,input().split()))
D_pos=list(map(lambda x:int(x)-1,input().split()))
Grid=[[c for c in input()] for _ in range(H)]

Dist=[[float("inf")]*W for _ in range(H)]

DX=[0,0,1,-1]

Q=deque()
Q.append((C_pos[0],C_pos[1]))
Dist[C_pos[0]][C_pos[1]]=0

while Q:
    cx,cy = Q.pop()

    for dx,dy in zip(DX,reversed(DX)):
        nx=cx+dx
        ny=cy+dy

        if 0<=nx<H and 0<=ny<W and Grid[nx][ny]=="." and Dist[nx][ny]>Dist[cx][cy]:
            Dist[nx][ny]=Dist[cx][cy]
            Q.append((nx,ny))


    for dx in range(-2,3):
        for dy in range(-2,3):
            nx=cx+dx
            ny=cy+dy
            if dx==0 and dy==0:
                continue

            if 0<=nx<H and 0<=ny<W and Grid[nx][ny]=="." and Dist[nx][ny]==float("inf"):
                Dist[nx][ny]=Dist[cx][cy]+1
                Q.appendleft((nx,ny))


ans=Dist[D_pos[0]][D_pos[1]]
if ans==float("inf"):
    print(-1)
else:
    print(ans)




Measured memory_bytes: 141620
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
const MOD: u64 = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}

fn digit_sum(n: i64, b: i64) -> i64 {
    if n < b {
        n
    } else {
        digit_sum((n as f64/b as f64).floor() as i64, b) + (n % b)
    }
}

fn main() {
    input!{
        N: usize,
    }
    println!("{}", if N % digit_sum(N as i64, 10) as usize == 0 { "Yes" } else { "No" });
}

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

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &e : a) cin >> e;

	reverse(a.begin(), a.end());

	string s;

	for (auto e : a) s += to_string(e) + " ";
	s.pop_back();

	cout << s << endl;
}



Measured memory_bytes: 3284
#pragma region header
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int dp[114][114514];
int weight[114],value[114];
signed main() {
    int n,w;cin >> n >> w;
    rep(i, n)cin >> weight[i] >> value[i];
    rep(i, n) {
        rep(j, w+1) {
            if(j-weight[i]>=0) chmax(dp[i+1][j],dp[i][j-weight[i]]+value[i]);/*dp[i+1][j]=max(dp[i][j],dp[i][j-weight[i]]+value[i]);*/
            chmax(dp[i+1][j],dp[i][j]);
        }
    }
    // rep(i, n) cout << weight[i] << ' ' << value[i] << endl;
    cout << dp[n][w] << endl;
    return 0;
}

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

using namespace std;

int main(){
    long A, B, K;
    cin >> A >> B >> K;

    if(K <= A) cout << A - K << " " << B;
    else if(K > A && K-A <= B) cout << 0 << " " << B-(K-A);
    else cout << 0 << " " << 0;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 1005;
const int mod = 1e9 + 7;
inline int add(int u, int v) {
  return u + v >= mod ? u + v - mod : u + v;
}

int ways[N][N];

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int h, w; cin >> h >> w;
  ways[1][0] = 1;
  for (int i = 1; i <= h; i++) {
    string s; cin >> s;
    for (int j = 1; j <= w; j++) {
      if (s[j - 1] == '.') {
        ways[i][j] = add(ways[i - 1][j], ways[i][j - 1]);
      }
    }
  }
  cout << ways[h][w] << endl;

  return 0;
}


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

int main(){
  int n,cnt=0;
  string c = "YES";
  cin >> n;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    if(a%2) cnt++;
  }
  if(cnt%2) c = "NO";
  cout << c << endl;
}

Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<LL> a(3*n);
		REP(i,3*n) cin >> a[i];
		vector<LL> memol(3*n+1,-1), memor(3*n+1,-1);
		{
			priority_queue<LL,vector<LL>,greater<LL>> qu;
			LL sum = 0;
			REP(i,n){
				sum += a[i];
				qu.push(a[i]);
			}
			memol[n] = sum;
			FOR(i,n,3*n){
				sum += a[i];
				qu.push(a[i]);
				sum -= qu.top();
				qu.pop();
				memol[i+1] = sum;
			}
		}
		{
			priority_queue<LL> qu;
			LL sum = 0;
			RFOR(i,2*n,3*n){
				sum += a[i];
				qu.push(a[i]);
			}
			memor[2*n] = sum;
			RFOR(i,0,2*n){
				sum += a[i];
				qu.push(a[i]);
				sum -= qu.top();
				qu.pop();
				memor[i] = sum;
			}
		}
		LL ans = -1e18;
		dpite(ALL(memol)); dpite(ALL(memor));
		REP(i,3*n+1){
			if(memor[i] != -1 and memol[i] != -1){
				chmax(ans,memol[i]-memor[i]);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct edge{ ll to,cost; };
ll V;
vector<edge> G[500010];
ll d[500010];

void dijkstra(ll s){
    fill(d,d+500010,inf);
    d[s]=0;
    priority_queue<l_l,vector<l_l>,greater<l_l>> que;
    que.push(l_l(0,s));
    while(!que.empty()){
        l_l p=que.top();que.pop();
        ll v=p.second;
        if(d[v]<p.first)continue;
        if(G[v].size()>0){
            rep(i,0,G[v].size()-1){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(l_l(d[e.to],e.to));
                }
            }
        }
    }
}



int main(){fastio
    ll n,m,s,t;cin>>n>>m>>s>>t;
    ll v[m],u[m],a[m],b[m];
    rep(i,0,m-1){
        cin>>v[i]>>u[i]>>a[i]>>b[i];
    }
    edge e;
    rep(i,0,m-1){
        e.cost=a[i];
        e.to=u[i];
        G[v[i]].pb(e);
        e.to=v[i];
        G[u[i]].pb(e);
    }
    dijkstra(s);
    ll mini1[n+1];
    rep(i,1,n){
        mini1[i]=d[i];
    }
    rep(i,0,500000){
        G[i].clear();
    }
    rep(i,0,m-1){
        e.cost=b[i];
        e.to=u[i];
        G[v[i]].pb(e);
        e.to=v[i];
        G[u[i]].pb(e);
    }
    dijkstra(t);
    ll mini2[n+1];
    rep(i,1,n){
        mini2[i]=d[i];
    }
    ll mini[n+1];
    mini[n]=mini1[n]+mini2[n];
    for(ll i=n-1;i>=1;i--){
        mini[i]=min(mini[i+1],mini1[i]+mini2[i]);
    }
    ll ans[n+1];
    rep(i,1,n){
        ans[i]=1000000000000000-mini[i];
    }
    rep(i,1,n){
        cout<<ans[i]<<endl;
    }
    
    
    
    
    return 0;
}



Measured memory_bytes: 28928
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define mset(arr, val) memset((arr), (val), sizeof(arr))
#define For(i, init, n) for (int64_t (i) = (init); (i) < (n); (i)++)
#define ___ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

// const double PI = acos(-1.0), E = exp(1.0), EPS = 1e-9;
const int MOD = (int)1e9 + 7, N = (int)1e5;

int main()
{   
#ifdef MY_PREPROCESSOR
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ___
    
    int x;
    cin >> x;
    int y = x % 500;
    int n = x / 500, m = y / 5;
    int64_t ans = n * (int64_t)1000 + m * 5;
    cout<< ans;
    
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main () {
	int n;
	cin >> n;
	int c[5];
	for (int i = 0; i < 5; ++i)
	{
		c[i] = 0;
	}
	for (int i = 0; i < n; ++i)
	{
		string tmp;
		cin >> tmp;
		if(tmp[0] == 'M'){
			c[0]++;
		}else if(tmp[0] == 'A'){
			c[1]++;
		}else if(tmp[0] == 'R'){
			c[2]++;
		}else if(tmp[0] == 'C'){
			c[3]++;
		}else if(tmp[0] == 'H'){
			c[4]++;
		}
	}
	long long result = 0;
	for (int xi = 0; xi < 5; ++xi)
	{
		for (int yi = 0; yi < xi; ++yi)
		{
			for (int zi = 0; zi < yi; ++zi)
			{
				result += (long long)c[xi] * (long long)c[yi] * (long long)c[zi];
			}
		}
	}
	cout << result << endl;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> a(H,vector<char>(W));
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin >> a.at(i).at(j);
  vector<vector<bool>> b(1,vector<bool>(H,true));
  b.push_back(vector<bool>(W,true));
  for(int i=0;i<H;i++){
    int j=0;
    for(;j<W;j++)
      if(a.at(i).at(j)=='#')
        break;
    if(j==W)
      b.at(0).at(i)=false;
  }
  for(int i=0;i<W;i++){
    int j=0;
    for(;j<H;j++)
      if(a.at(j).at(i)=='#')
        break;
    if(j==H)
      b.at(1).at(i)=false;
  }
  for(int i=0;i<H;i++)
    if(b.at(0).at(i)){
      for(int j=0;j<W;j++)
        if(b.at(1).at(j))
          cout << a.at(i).at(j);
      cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N;
    cin >> N;
    int cnt = 0;
    int ser = 0;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    rep(i, N){
        if(i+1==p[i]){
            ser++;
            cnt++;
            if(ser==2){
                cnt--;
                ser = 0;
            }
        }
        else ser = 0;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main(){
  float a,b;
  int digit = 0;
  float ans = 0;
  int tmp = 0;
  float parse = 0.0;
  /*処理系*/
  cin >> a >> b;
  digit = (int)log10(b) + 1.0;
  a = a * pow(10.0,digit);
  ans = a + b;
  parse = sqrt(ans) / 1.0;
  parse -= (int)parse;
  if (parse == 0.0)
    cout << "Yes";
  else
  {
    cout << "No";
  }

  return 0;
}

Measured memory_bytes: 256
loop do
    x, y, s = gets.split.map(&:to_i)
    break if x == 0 && y == 0 && s == 0
    max = 0
    1.upto(s-1) do |i|
        1.upto(s-1) do |j|
            next if (i * (x + 100) / 100).floor + (j * (x + 100) / 100).floor != s
            max = [max, (i * (y + 100) / 100).floor + (j * (y + 100) / 100).floor].max
        end
    end
    puts max
end

Measured memory_bytes: 6112
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>
#include<iomanip>

#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define MOD 1000000007

using namespace std;
using ll=long long int;

int main(){
    string S;
    cin >> S;
    int ans=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='-'){
            ans--;
        }
        else{
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

def inverse(a,mod): #aのmodを法にした逆元を返す
    return pow(a,mod-2,mod)



#modのn!と、n!の逆元を格納したリストを返す(拾いもの)
#factorialsには[1, 1!%mod , 2!%mod , 6!%mod… , n!%mod] が入っている
#invsには↑の逆元が入っている

def modfac(n, MOD):
 
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


def modnCr(n,r,mod,fac,inv): #上で求めたfacとinvsを引数に入れるべし(上の関数で与えたnが計算できる最大のnになる)

    return fac[n] * inv[n-r] * inv[r] % mod


n,k = map(int,input().split())
mod = 10**9+7

fac,inv = modfac(2*n,mod)
"""
nm1lis = [1]
for i in range(n):
    nm1lis.append(nm1lis[-1] * (n-1) % mod)

print (nm1lis)
"""

if k >= n:
    print (modnCr(2*n-1,n,mod,fac,inv))
    sys.exit()

"""
求めるのは人数の組み合わせ
どうする？
不可能なものの数を数えて引くか？
k+2以上の人数の部屋があったら不可能
k+2人以上が1つあるときの組み合わせ- (2つあるときの組み合わせ) + …

でいけそうかな？
それ以外は可能なのか？

0の数がk恋かの組み合わせ
0の数がk個より大きいなら不可能

0がk+1個…Nこ
"""

ans = modnCr(2*n-1,n,mod,fac,inv)
loop = 1

for i in range(k+1,n):

    bn = n - i - 1
    now = modnCr(n,i,mod,fac,inv) * modnCr(i+bn,bn,mod,fac,inv)

    ans -= now
    
    ans %= mod

    loop += 1

print (ans)

"""

while (k+2)*loop <= n:

    now = modnCr(n,loop,mod,fac,inv) * modnCr(n-1 + (n-(k+2)*loop),n-1,mod,fac,inv)
    if loop % 2 == 1:
        ans -= now
    else:
        ans += now

    ans %= mod

    loop += 1

"""
    

Measured memory_bytes: 71280
import kotlin.math.max

fun main() {
    val (H, W, M) = nextIntList()
    var maxH = 0
    var maxW = 0
    val countH = mutableMapOf<Int, Int>()
    val countW = mutableMapOf<Int, Int>()

    val input = (0 until M).map {
        val (h, w) = nextIntList()
        val valH = countH.getOrDefault(h, 0) + 1
        val valW = countW.getOrDefault(w, 0) + 1
        maxH = max(maxH, valH)
        maxW = max(maxW, valW)
        countH[h] = valH
        countW[w] = valW
        h to w
    }.toSet()
    val targetH = countH.filterValues { it == maxH }.keys
    val targetW = countW.filterValues { it == maxW }.keys
    val result = maxH + maxW - 1
    targetH.forEach { h ->
        targetW.forEach { w ->
            if (!input.contains(h to w)) {
                println(result + 1)
                return
            }
        }
    }
    println(result)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

Measured memory_bytes: 170768
/*input
2 5
2 3



*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
    
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = 1e5+1;
    

int32_t main() {
    IOS;
	int n,k;
    cin>>n>>k;
    int A[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    bool dp[k+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(A[j]<=i){
                if(!dp[i-A[j]]){
                    dp[i] = 1;
                }
            }
        }
    }
    if(dp[k]){
        cout<<"First";
    }
    else{
        cout<<"Second";
    }
	//cout<<dp[k][n]<<endl;
	return 0;
}






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

#define MIN(a, b) ((a<b) ? a : b)

int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  printf("%d\n", MIN(a, b) + MIN(c, d));
  return 0;
}


Measured memory_bytes: 128
import Data.Char

main :: IO ()
main = do
  s <- getString
  putStrLn $ if and [p s, q s, r s] then "AC" else "WA"
  where
    p s = head s == 'A'
    q s = any (== 'C') . init . tail . tail $ s
    r s = countIf isLower s + 2== length s

getString :: IO String
getString = getLine

countIf :: (a -> Bool) -> [a] -> Int
countIf f = length . filter f


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

int main() {
  ll N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  for (int i = 0; i < N; i++) {
    if (C * i - D * (N - 1 - i) <= B - A && B - A <= -C * (N - 1 - i) + D * i) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    vi abc(3);
    rep(i,3) cin >> abc[i];
    sort(abc.begin(),abc.end());
    if(abc[0] == abc[1]) cout << abc[2] << endl;
    else cout << abc[0] << endl;
}

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



int main() {
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> A(N + 1, 0);
	for(int i = 1; i <= M; i++){
		int money_index;
		cin >> money_index;
		A.at(money_index) = 1;
	}
	A.at(0) = 0;
	A.at(X) = 0;
	A.at(N) = 0;
	int ans1 = 0;
	for(int i = 1; i < X; i++){
		ans1 += A.at(i);
	}
	int ans2 = 0;
	for(int i = X + 1; i < N; i++){
		ans2 += A.at(i);
	}
	cout << min(ans1, ans2);
	return 0;
}

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

int main()
{
  int n;	cin>>n;
  map<int, int> A;
  long long int sum=0;
  for(int i=0; i<n; i++)
  {
      int x;    cin>>x;
      A[x]++;
      sum+=x;
  }
  
  int q;    cin>>q;
  while(q--)
  {
      int x, y;   cin>>x>>y;
      if(A.count(x))
      {
          sum -= 1LL*A[x]*x;
          sum += 1LL*A[x]*y;
          A[y] += A[x];
          A.erase(x);
      }
      cout<<sum<<endl;
  }
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s.begin(),s.end());
    long long ans = 0;
    for (int j = 0; j < n-1; j++) {
        if (s[j] == s[j+1]) {
            a[j+1] += a[j] + 1;
        }
        ans += a[j+1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
module Main where

import qualified Data.Vector as Vector
import Data.List

main :: IO ()
main =
    print =<< (vec  Vector.! ) <$> (\a -> a - 1) <$> getInt


getInt :: IO Int
getInt = read <$> getLine

vec :: Vector.Vector Int
vec = Vector.fromList [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]


Measured memory_bytes: 508
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int n,m;
priority_queue<pair<int,int> > pq;

int main(){

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

    for(long long i = 1;i <= n;i++){
        long long tmp;
        scanf("%lld",&tmp);
        pq.push({tmp,1});
    }

    for(long long i = 1;i <= m;i++){
        long long cnt,val;
        scanf("%lld %lld",&cnt,&val);
        pq.push({val,cnt});
    }

    long long sum = 0;

    for(int i = 1;i <= n;i++){
        auto tmp = pq.top();
        pq.pop();
        sum += tmp.first;
        tmp.second--;
        if(tmp.second > 0){
            pq.push(tmp);
        }
    }

    printf("%lld",sum);

    return 0;
}


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

#define ll  long double
#define ld long double
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define nguyendz the_best
#define pii pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;

using namespace std;
const ll maxn=2e3+2;
const ll maxx=1e16;
const ll mod=1e9+7;
const ll mod1=998244353;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
     ll s,w;
     cin>>s>>w;
     if (s>w)
     {
         cout <<"safe";
     }
     else
     {
         cout <<"unsafe";
     }
}


Measured memory_bytes: 3748
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#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 <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vll A(N);
    rep(i, N) cin >> A[i];
    vll sumA(N + 1, 0);
    rep(i, N) {
        sumA[i + 1] = A[i] + sumA[i];
    }
    ll ans = LINF;
    REP(i, 1, N) {
        ll L = sumA[i];
        ll R = sumA[N] - sumA[i];
        ans = min(abs(R - L), ans);
    }

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

Measured memory_bytes: 3456
#include<stdio.h>

int main()
{

    long long int n,a,b,d1,d2,p,sum,i;
    long long int num[100100];
    scanf("%lld %lld %lld",&n,&a,&b);
    for(i=0; i<n; i++)
    {
        scanf("%lld",&num[i]);
    }
     sum=0;
    for(i=0; i<n-1; i++)
    {
        d1=abs(num[i]-num[i+1])*a;
        d2=b;
        if(d1<d2)sum=sum+d1;
        else
            sum=sum+d2;
    }
    printf("%lld\n",sum);


    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int n, p[200005], dp[200005], ans = 1;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	cin >> p[0];
	dp[0] = p[0];
	for (int i = 1; i < n; i++)
	{
		cin >> p[i];
		if (p[i] < dp[i - 1])
		{
			ans++;
		}
		dp[i] = min(dp[i - 1], p[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main{

/*	static boolean EndChk(int i, int n)
	{
		System.out.printf(" %d", i++);

		return ( (i<=n) ? true: false);
	}*/

	static int Include3(int x,int i)
	{
		while(x != 0)
		{
			if(x%10 == 3)
			{
				System.out.printf(" %d", i);
				break;
			}
			else
			{
				x = x/10;//goto EndChk
			}
		}

		return x;
	}

	public static void main(String[] args) {

		int n,i=1,x;

		Scanner scan = new Scanner(System.in);

		n = scan.nextInt();

		while(i <= n)
		{
			x = i;

			if(x%3 == 0)
			{
				System.out.printf(" %d", i);
			}
			else
			{
				x = Include3(x,i);//x???10??§?????£????????????3??????????????????0?????????
			}

			i++;
		}

		System.out.println();

	scan.close();
	}
}

Measured memory_bytes: 41136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int s1s2s3;
  	cin >> s1s2s3;
  	int s1 = s1s2s3/100;
  	int s2 = (s1s2s3-s1*100)/10;
  	int s3 = s1s2s3-s1*100-s2*10;
    cout << s1+s2+s3 << endl;
  	
}

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

int main()
{
    int n;
    cin>>n;
    string str="";
    if(n==0)
        cout<<"0"<<endl;
    else
    {
        while(n!=0)
        {
            if(n%-2!=0)
            {
                str = "1" + str;
                n--;
            }
            else
            {
                str = "0" + str;
            }
            n=n/(-2);
        }

        cout<<str<<endl;
    }

    return 0;

}



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

int main() {
  ios::sync_with_stdio(false);
  int N, Q;
  string S;
  cin >> N >> S >> Q;
  vector<set<int>> V(26);
  for (int i = 0; i < N; i++) V.at(S.at(i) - 'a').insert(i + 1);
  while (Q--) {
    int type;
    cin >> type;
    if (type == 1) {
      int i;
      char c;
      cin >> i >> c;
      V.at(S.at(i - 1) - 'a').erase(i);
      S.at(i - 1) = c;
      V.at(S.at(i - 1) - 'a').insert(i);
    } else {
      int l, r;
      cin >> l >> r;
      int ans = 0;
      for (int i = 0; i < 26; i++) {
        auto iter = V.at(i).lower_bound(l);
        if (iter != V.at(i).end() && *iter <= r) ans++;
      }
      cout << ans << "\n";
    }
  }
}

Measured memory_bytes: 24220