akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

map<ll, ll> num;

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  llvec A(N, 0);
  rep(i, N){
    cin >> A[i];
    ll tmp = A[i];
    for(int j=2;j<=1000;j++){
      ll cnt = 0;
      while(tmp%j==0){
        tmp/=j;
        cnt++;
      }
      num[j]=max(num[j], cnt);
    }
    num[tmp]=max(num[tmp], 1LL);
  }

  ll tmp2=1;
  for(auto i: num){
    tmp2 = mod(tmp2 * modpow(i.first, i.second, MOD), MOD);
  }

  //cout << tmp2 << endl;
  
  ll ans = 0;
  rep(i, N){
    ans =mod(ans + tmp2 * modinv(A[i], MOD), MOD);
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N;
    cin >> N;
    cout << 3 * N * N << endl;
    
    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007
int D[2200][2200];

int main()
{

	int H, W;
	cin >> H >> W;
	vector<string> F(H);
	fx(H) {
			cin >>F.at(x);
	}

	fx(H) {
		fy(W) {
			int sum = 0;
			int start = y;
			while (y<W&&F.at(x).at(y)=='.') {
				y++;
				sum++;
			}
			for (int z = start; z < y;z++) {
				D[x][z] += sum;
			}
		}
	}
	fy(W) {
		fx(H) {
			int sum = 0;
			int start = x;

			while (x<H&&F.at(x).at(y) == '.') {
				x++;
				sum++;
			}
			for (int z = start; z < x; z++) {
				D[z][y] += sum;
			}
		}
	}
	int ans = 0;
	fy(W) {
		fx(H) {
			ans = max(ans,D[x][y]-1);
		}
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 22784
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
ll a[100001],b[100001],c[100001];
ll d[100001]={},ans[100001]={};
int n;

int main() {

	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n)cin>>c[i];
	sort(c,c+n);
	sort(b,b+n);
	sort(a,a+n);
	rep(i,n){
		int left=0,right=n,mid;
		while(left<right){
			mid=(right+left)/2;
			if(a[mid]>=b[i])right=mid;
			if(a[mid]<b[i])left=mid+1;
		}
		d[i]=left;
		d[i]+=d[i-1];
	}
	rep(i,n){
		int l=0,r=n,m;
		while(l<r){
			m=(r+l)/2;
			if(b[m]>=c[i])r=m;
			if(b[m]<c[i])l=m+1;
		}
		ans[i]=d[l-1];
		ans[i]+=ans[i-1];
	}
	cout<<ans[n-1]<<endl;

	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define fi first
#define se second
#define max3(a, b, c) max(a, max(b, c))
using namespace std;

typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int maxn = int(1e7);

int n, prime[maxn+1];
ll res;

void sieve()
{
    for (int i = 1 ; i <= maxn ; i++)
    prime[i] = i;
    for (int i = 2 ; i*i <= maxn ; i++)
    if (prime[i] == i)
    for (int j = i*2 ; j <= maxn ; j += i)
    prime[j] = i;
}

ll f(int x)
{
    if (x == 1) return 1;
    ll cnt = 1;
    ll pre_cnt;
    bool loop = 0;
    while (prime[x] != x)
    {
        int tmp = x;
        pre_cnt = 0;
        while (tmp % prime[x] == 0)
        {
            tmp /= prime[x];
            pre_cnt++;
        }
        x = tmp;
        cnt *= (pre_cnt+1);
    }
    if (x > 1) return cnt*2;
    return cnt;
}

int main()
{
    ios_base::sync_with_stdio(NULL); cin.tie(NULL);
  ///  freopen("t.inp", "r", stdin);
    sieve();
    cin >> n;
    for (int i = 1 ; i <= n ; i++)
    {
        res += i * f(i);
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 42660
#include <stdio.h>
#include <string.h>

int main(void){
	int n, r[1000], w[1000], maxel, sr, sw, i, j, dp[2500], max;
	while(1){
		scanf("%d",&n);
		for(i = 0;i < n;i++)
			scanf("%d%d",&r[i],&w[i]);
		if(!n) break;
		sr = 0;
		sw = 0;
		for(i = 0,maxel = 0;i < n;i++){
			if(r[i] > r[maxel]) maxel = i;
			sr += r[i];
			sw += w[i];
		}
		if(2 * r[maxel] >= sr){
			if(r[maxel] <= (sr - r[maxel]) + (sw - w[maxel])){
				memset(dp,0,sizeof(dp));
				dp[0] = 1;
				for(i = 0;i < n;i++){
					if(i != maxel){
						for(j = 2 * r[maxel] - sr;j >= 0;j--){
							if(dp[j] && j + w[i] <= 2 * r[maxel] - sr){
								dp[j + w[i]] = 1;
							}
						}
					}
				}
				for(j = 2 * r[maxel] - sr;j >= 0;j--){
					if(dp[j]){
						max = j;
						break;
					}
				}
				printf("%d\n",sr + sw + (2 * r[maxel] - sr - max));
			}
			else
				printf("%d\n",2 * r[maxel] + w[maxel]);
		}
		else
			printf("%d\n",sr + sw);
	}
	return 0;
}

Measured memory_bytes: 1052
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main() {
  int a, b; cin >> a >> b;
  int bLen = to_string(b).length();
  int c; c = int(pow(10, bLen)) * a + b;
  if(c % int(sqrt(c)) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func gcd(x, y int) int {
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func main() {
	n := readInt()
	ans := 1
	for i := 0; i < n; i++ {
		t := readInt()
		ans = lcm(ans, t)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
//There was and will always be only one Chester
//RIP legend
#include<bits/stdc++.h>
#define Nilesh ios_base::sync_with_stdio(false)
using namespace std;
int main()
{
    Nilesh;
    int n;
    cin>>n;
    long long answer=0;
    long long q1,q2;
    for(int i=0;i<n;i++)
    {
        cin>>q1>>q2;
        answer+=(abs(q1-q2)+1);
    }
    cout<<answer;


}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1];
        for(int i=1;i<=n;i++) a[i]=sc.nextInt();
        int sum = 0;
        for(int i=1;i<=n;i++){
            if(a[a[i]]==i) sum++;
        }
        System.out.println(sum/2);
    }
}


Measured memory_bytes: 49996
#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 <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
using ll = long long;

#define INF 1000000007
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int)(x).size())
#define MSG(a) cout << #a << " " << a << endl;

int main()
{
    int x;
    cin >> x;
    int cnt500 = x / 500;
    x -= 500 * cnt500;
    int cnt5 = x / 5;
    int ans = cnt500 * 1000;
    ans += cnt5 * 5;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n;
    cin >> n;
    vector<ll> x(n), y(n), p(n);
    REP(i, n){
        cin >> x[i] >> y[i] >> p[i];
    }

    vector<vector<ll>> x2d(1LL << n), y2d(1LL << n);
    REP(i, (1LL << n)){
        vector<ll> xs, ys;
        REP(j, n){
            if((i >> j) & 1){
                xs.push_back(x.at(j));
                ys.push_back(y.at(j));
            }
        }
        sort(ALL(xs));
        sort(ALL(ys));

        x2d[i].resize(n, numeric_limits<ll>::max());
        y2d[i].resize(n, numeric_limits<ll>::max());

        REP(j, n){
            {
                ll dx = abs(x.at(j));
                ll idx = lower_bound(ALL(xs), x.at(j)) - xs.begin();
                if(idx < xs.size()){
                    dx = min(dx, xs.at(idx) - x.at(j));
                }
                if(idx > 0){
                    dx = min(dx, x.at(j) - xs.at(idx - 1));
                }
                x2d.at(i).at(j) = dx;
            }

            {
                ll dy = abs(y.at(j));
                ll idx = lower_bound(ALL(ys), y.at(j)) - ys.begin();
                if(idx < ys.size()){
                    dy = min(dy, ys.at(idx) - y.at(j));
                }
                if(idx > 0){
                    dy = min(dy, y.at(j) - ys.at(idx - 1));
                }
                y2d.at(i).at(j) = dy;
            }
        }
    }

    ll ub = 1;
    REP(i, n){ ub *= 3; }

    vector<ll> ans(n + 1, numeric_limits<ll>::max());

    REP(i, ub){
        ll ix = 0, iy = 0, k = 0;
        {
            ll m = i;
            REP(j, n){
                const ll l = m % 3;
                if(l == 1){
                    ix += (1LL << j);
                    k++;
                }else if(l == 2){
                    iy += (1LL << j);
                    k++;
                }
                m /= 3;
            }
        }

        ll s = 0;
        const auto& dx = x2d.at(ix), dy = y2d.at(iy);
        REP(j, n){
            ll d = min(dx.at(j), dy.at(j));
            s += p.at(j) * d;
        }

        ans.at(k) = min(ans.at(k), s);
    }

    for(auto ai : ans){
        cout << ai << endl;
    }
    return 0;
}


Measured memory_bytes: 13032
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

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

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    map<string, vector<int> > m;
    string str; int n;
    while(cin >> str >> n){
        m[str].pb(n);
    }
    map<string, vector<int> >::iterator it = m.begin();
    for(; it != m.end(); it++){
        sort(all((*it).second));
        cout << (*it).first << endl;
        rep(i, (*it).second.size()) cout << (i?" ":"") << (*it).second[i];
        cout << endl;
    }
}

Measured memory_bytes: 1248
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m,h,w;
  cin >> n >> m >> h >> w;
  ll a[n][m];
  rep(i,n)rep(j,m) a[i][j]=1000;
  for(ll i=h-1; i<n; i+=h) {
    for(ll j=w-1; j<m; j+=w) a[i][j]=-(h*w-1)*1000-1;
  }
  ll sum=0;
  rep(i,n)rep(j,m) sum+=a[i][j];
  if(sum>0) {
    pr("Yes");
    rep(i,n) PR(a[i],m);
  } else pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MOD = 1e9+7;

signed main(){
    ll x;
    cin >> x;
    ll cnt = 1,memo = x;
    while(memo % 360){
        memo += x;
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3648
s = input()
nwse = [0]*4
for i in s:
  if i=="N":
    nwse[0] =1
  elif i=="W":
    nwse[1] =1
  elif i=="S":
    nwse[2]=1
  else:
    nwse[3]=1
    
    
if nwse[0]==nwse[2] and nwse[1]==nwse[3]:
  print("Yes")
else:
  print("No")

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

void solve(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  
  map<int, int> m;
  for (int i = 0; i < n; i++){
    if (!m.count(a[i])) m[a[i]] = 0;
    m[a[i]]++;
  }
  vector<pair<int, int>> v;
  for (auto i : m) v.eb(i);

  if (v[0].ss > 2){
    cout << "Impossible\n";
    return;
  }
  int d = 0;
  if (v[0].ss == 2) d++;

  for (int i = 1; i < (int) v.size(); i++){
    if (v[i].ff - 1 > v[i-1].ff || v[i].ss < 2){
      cout << "Impossible\n";
      return;
    }

    d+=2;
  }

  if (v.back().ff != d){
    cout << "Impossible\n";
    return;
  }

  cout << "Possible\n";
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


Measured memory_bytes: 3476
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 100005
#define X first
#define Y second
#define mod 1000000007
#define inf 1e18
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
ll n,i,j,k;

int main()
{
    fastio;
    ll n;
    cin>>n;
    vector<ll > v(n);
    for(i=0;i<n;i++) cin>>v[i];
    ll num=1,ans=0;
    for(i=0;i<n;i++){
        if(v[i]!=num) ans++;
        else num++;
    }
    if(ans<n) cout<<ans<<endl;
    else cout<<"-1"<<endl;
}


Measured memory_bytes: 1792
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N, M = map(int, input().split())
A = list(map(lambda x: int(x) // 2, input().split()))

def f(n):
    res = 0
    while n % 2 == 0:
        n //= 2
        res += 1
    return res

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

x = f(A[0])
for a in A:
    y = f(a)
    if y != x:
        print(0)
        exit()

lcm = A[0]
for i in range(1, N):
    lcm = lcm * A[i] //  gcd(lcm, A[i])

print((M // lcm + 1) // 2)

Measured memory_bytes: 90620
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  ll n;
  cin >> n;
  ++n;
  vector<vector<ll>> g(n);
  REP(i, n-1) {
    ll p;
    cin >> p;
    g[p].push_back(i+1);
  }

  vector<ll> depth(n);
  function<void(ll,ll)> dep = [&](ll v, ll d) {
    depth[d]++;
    for(auto to: g[v]) {
      dep(to, d+1);
    }
  };

  struct node {
    ll x, y, z;
    node() {}
    node(ll x, ll y, ll z) : x(x), y(y), z(z) {}
    node plus(node n) {
      ll nx = x*n.x % MOD;
      ll ny = (y*n.x % MOD + x*n.y % MOD) % MOD;
      ll nz = (z*(n.x+n.y+n.z) % MOD + y*(n.y+n.z) % MOD + x*n.z % MOD) % MOD;
      return node(nx, ny, nz);
    }
  };

  function<deque<node>(ll)> dfs = [&](ll v) {
    deque<node> ret;
    ll sz = 0;
    for(auto to: g[v]) {
      auto dq = dfs(to);
      if(ret.size() < dq.size()) swap(ret, dq);
      // dq -> retへマージ
      REP(i, dq.size()) ret[i] = ret[i].plus(dq[i]);
      chmax(sz, (ll)dq.size());
    }
    REP(i, sz) {
      (ret[i].x += ret[i].z) %= MOD;
      ret[i].z = 0;
    }
    ret.push_front(node(1, 1, 0));
    return ret;
  };

  dep(0, 0);
  auto ret = dfs(0);

  vector<ll> pow2(n+1);
  pow2[0] = 1;
  FOR(i, 1, n+1) pow2[i] = pow2[i-1] * 2 % MOD;

  ll d = 0, ans = 0;
  for(auto i: ret) (ans += i.y * pow2[n - depth[d++]] % MOD) %= MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 181504
N,M=map(int,(input()).split())
List=[]
for i in range(1,N+1):
  AB=[int(j) for j in (input()).split()]
  List.append(AB)
List.sort()
S=0
P=0
k=0
while S<M:
  a=List[k][0]
  b=List[k][1]
  if S+b<=M:
    P=P+a*b
    S=S+b
  else:
    P=P+a*(M-S)
    S=M
  k=k+1
print(P)

Measured memory_bytes: 21612
import java.util.Scanner;
class Main{
  public static void main(String... args){
    Scanner sc = new Scanner(System.in);

    int N = (sc.nextInt())%26;
    char array[] = sc.next().toCharArray();
    int newarray[] = new int[array.length];

    String result = "";
    for(int i = 0; i < array.length; i++){
      newarray[i] = (int)array[i] + N;
      if(newarray[i] >= 91){
        newarray[i] = newarray[i] - 91 + 65;
      }
      result += (char)newarray[i];
    }

    System.out.println(result);
  }
}

Measured memory_bytes: 147284
s = input()
t = input()
ls = len(s)
lt = len(t)
dp = [[0 for j in range(lt+1)] for i in range(ls+1)]
for i in range(1, ls+1):
  for j in range(1, lt+1):
    if s[i-1] == t[j-1]:
      dp[i][j] = dp[i-1][j-1] + 1
    else:
      dp[i][j] = max(dp[i-1][j], dp[i][j-1])
ans = ""
length = dp[ls][lt]
i = ls
j = lt
while length > 0:
  if s[ls-1] == t[lt-1]:
    ans = s[ls-1] + ans
    ls -= 1
    lt -= 1
    length -= 1
  elif dp[ls-1][lt] == length:
    ls -= 1
  else:
    lt -= 1
print(ans)

Measured memory_bytes: 153024
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = seq { for i in 1..n -> stream.ReadLine() |> f }
  member this.ScanMatrix n f  = seq { for i in 1..n do yield stream.ReadLine().Split() |> Array.map f }
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let a, b = util.Scan2 int

printfn "%d" (a + b/2)

util.Close()


Measured memory_bytes: 14036
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int b[60];
int p3[20];
int cnt[20];
int t[60];
int main(){
	int a;scanf("%d",&a);
	cnt[0]++;

	for(int i=0;i<a;i++)scanf("%d",b+i);
	for(int i=0;i<a;i++)cnt[b[i]]++;
	int ret=0;
	p3[0]=1;

	for(int i=0;i<(1<<13);i++){
		int tmp=99999;
		int sz=0;
		for(int j=0;j<13;j++){
			if(cnt[j]>2||(cnt[j]>1&&j%12==0)){tmp=0;break;}
			if(cnt[j]==2){
				t[sz++]=j;t[sz++]=24-j;
			}
			if(cnt[j]==1){
				if(i&(1<<j))t[sz++]=j;
				else t[sz++]=24-j;
			}
		}
		if(tmp==0)continue;
		std::sort(t,t+sz);
		t[sz]=t[0]+24;
		for(int j=0;j<sz;j++)tmp=min(tmp,t[j+1]-t[j]);
		ret=max(ret,tmp);
	}
	printf("%d\n",ret);
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 

int main()
{
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  
  rep(i, ty- sy)
    cout << 'U';
  rep(i, tx - sx)
    cout << 'R';
  rep(i, ty - sy)
    cout << 'D';
  rep(i, tx - sx)
    cout << 'L';
  
  cout << 'L';
  rep(i, ty- sy + 1)
    cout << 'U';
  rep(i, tx - sx + 1)
    cout << 'R';
  cout << 'D';
  cout << 'R';
  rep(i, ty - sy + 1)
    cout << 'D';
  rep(i, tx - sx + 1)
    cout << 'L';
  cout << 'U';
  
  //cout << fixed << 0.0000001 << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    internal static class CR
    {
        public static string GetText() { return Console.ReadLine(); }
        public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long GetLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
    }

    public class Program
    {
        public static long N { get; private set; }
        public static long M { get; private set; }
        public static List<long> A { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = CR.GetLongs();
            N = inputs[0];
            M = inputs[1];
            A = CR.GetLongs();

            var border = (double)A.Sum() / (4 * M);
            var vote = A.Count(x => x >= border);
            return vote < M ? "No" : "Yes";
        }
    }
}


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

int main() {
  int N, a, b, turn;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i); 
  }
  
  sort(vec.begin(), vec.end()); // まず sort
  reverse(vec.begin(), vec.end()); // 大きい順に並び替え（先に取る人が大きい数字となるように）
  
  turn = 0; // どっちの手番かを判定
  a, b = 0; // 初期化
  
  for (int i = 0; i < N; i++) {
    if (turn % 2 == 0) { // 最初に取る人＝Alice
      a += vec[i];
    }
    else {
      b += vec[i]; // 後から取る人＝Bob
    }
    turn++;
  }

  cout << a-b << endl;
}


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

int main(void){


    string s;
    cin >> s;
    for(int i=0; i<s.size(); i++) {
        if(s.substr(i,1) == "7") {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>0 && b>0)
	{
		printf("Positive");
	}
	else if(a<=0 && b>=0)
	{
		printf("Zero");
	}
	else if(a<0 && b<0 && (a-b)%2==0)
	{
		printf("Negative");
	}
	else
	{
		printf("Positive");
	}
	return 0;
}

Measured memory_bytes: 760
#include<stdio.h>

int main(void){
  char s[10];
  char t[10];
  int a = 0;
  scanf("%s",&s);
  scanf("%s",&t);
  if(s[0] == t[0]) a++;
  if(s[1] == t[1]) a++;
  if(s[2] == t[2]) a++;
  printf("%d",a);
  return 0;
}

Measured memory_bytes: 128
a = int(input())
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = 0
for i in range(a):
  ans += min(b[i],c[i])
  c[i] -= min(b[i],c[i])
  ans += min(b[i + 1], c[i])
  b[i + 1] -= min(b[i + 1], c[i])

print(ans)


Measured memory_bytes: 18476
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <string.h>


typedef struct dice
{
	int label[6];
	int direction[6]; // 転がしたときに対応するラベル

}Dice;


void diceRotation(Dice *dice, char order) {
	int tmpDirc[6] = { 0 };
	for (size_t i = 0; i < 6; i++)
	{
		tmpDirc[i] = dice->direction[i];
	}

	if (order == 'S') {
		dice->direction[0] = tmpDirc[4];
		dice->direction[1] = tmpDirc[0];
		dice->direction[4] = tmpDirc[5];
		dice->direction[5] = tmpDirc[1];
	}
	else if (order == 'N') {
		dice->direction[0] = tmpDirc[1];
		dice->direction[1] = tmpDirc[5];
		dice->direction[4] = tmpDirc[0];
		dice->direction[5] = tmpDirc[4];
	}
	else if (order == 'W') {
		dice->direction[0] = tmpDirc[2];
		dice->direction[2] = tmpDirc[5];
		dice->direction[3] = tmpDirc[0];
		dice->direction[5] = tmpDirc[3];

	}
	else if (order == 'E') {
		dice->direction[0] = tmpDirc[3];
		dice->direction[2] = tmpDirc[0];
		dice->direction[3] = tmpDirc[5];
		dice->direction[5] = tmpDirc[2];
	}
}

/////////////////////////////////////////////////////////////////////////


int main(void) {

	//int result[1001] = { 0 };

	char order1[10] = "SSSWSSS";
	char order2[10] = "EEE";

	int n = 6;

	Dice dice1;
	Dice dice2;
	int init = 0;

	for (; init < n; init++) {
		dice1.label[init] = 0;
		dice1.direction[init] = init;
		dice2.label[init] = 0;
		dice2.direction[init] = init;
	}




	scanf("%d %d %d %d %d %d", &dice1.label[0], &dice1.label[1], &dice1.label[2], &dice1.label[3], &dice1.label[4], &dice1.label[5]);
	scanf("%d %d %d %d %d %d", &dice2.label[0], &dice2.label[1], &dice2.label[2], &dice2.label[3], &dice2.label[4], &dice2.label[5]);




	int top, front;

	top = dice2.label[dice2.direction[0]];
	front = dice2.label[dice2.direction[1]];


	int orderlen = strlen(order1);
	int i = 0;
	for (; i < orderlen; i++) {
		if (dice1.label[dice1.direction[1]] == front) {
			break;
		}
		diceRotation(&dice1, order1[i]);
	}

	orderlen = strlen(order2);
	for (i = 0; i < orderlen; i++) {
		if (dice1.label[dice1.direction[0]] == top) {
			break;
		}
		diceRotation(&dice1, order2[i]);
	}


	// 同一のサイコロならば、ここまでで方向がそろう

	short diffFlag = 0;

	for (size_t i = 0; i < n; i++)
	{
		if (dice1.label[dice1.direction[i]] != dice2.label[dice2.direction[i]]) {
			diffFlag = 1;
			break;
		}
	}

	if (diffFlag == 0) {
		printf("%s\n", "Yes");
	}
	else {
		printf("%s\n", "No");
	}

	return 0;
}



Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int long long ans=0;
    for(int i=1;i<=n;i++)
    {
        if(!((i%3==0 && i%5==0) || (i%3==0) || (i%5==0)))
        {
            ans+=i;
        }
    } 
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>

using namespace std;

vector <int> edges[200000];
int main(){
  int N;
  int M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a;
    int b;
    cin >> a >> b;
    edges[a - 1].push_back(b - 1);
    edges[b - 1].push_back(a - 1);
  }

  queue <int> q;
  for(int i = 0; i < edges[0].size(); i++){
    q.push(edges[0][i]);
  }

  while(!q.empty()){
    int cur_v = q.front();
    for(int i = 0; i < edges[cur_v].size(); i++){
      if(edges[cur_v][i] == N - 1){
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
    q.pop();
  }
  cout << "IMPOSSIBLE" << endl;
  
  return 0;
}


Measured memory_bytes: 12400
#include <bits/stdc++.h>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define yes(i) cout<<(i?"yes":"no")<<endl
using namespace std;
int main(){
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	if(e-a>k){
		cout<<":("<<endl;
	}else{
		cout<<"Yay!"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

h,w,n=MI()
sq=defaultdict(int)
for _ in range(n):
    a,b=MI1()
    for i in range(max(0,a-2),min(h-2,a+1)):
        for j in range(max(0,b-2),min(w-2,b+1)):
            sq[i,j]+=1
cnt=[0]*10
for k,v in sq.items():cnt[v]+=1
cnt[0]=(h-2)*(w-2)-sum(cnt)
print(*cnt,sep="\n")


Measured memory_bytes: 145520
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
using namespace std;

int main()
{
    string str;
    cin>>str;
    int len = str.length();
    if(str[len-1]=='s')
    {
        str = str+"es";
    }
    else
    {
        str = str+"s";
    }
    cout<<str<<endl;
}


Measured memory_bytes: 3600
def selection_sort(A, N):
    sw = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            sw += 1
            A[i], A[minj] = A[minj], A[i]
    return sw


def main():
    N = int(input().rstrip())
    A = list(map(int, input().rstrip().split()))
    
    sw = selection_sort(A, N)
    
    print(' '.join(map(str, A)))
    print(sw)
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 7728
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std; 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string k;
    int d;
    cin>>k>>d;
    reverse(k.begin(),k.end());
    int dp[k.size()+1][d][2];  
    memset(dp,0,(k.size()+1)*d*sizeof(dp[0][0]));
    dp[0][0][0] = 1;
    dp[0][0][1] = 1;
    for(int i=1;i<=k.size();i++){
        for(int j=0;j<d;j++){
            for(int m=0;m<2;m++){
                int lim = (m==0)?9:(k[i-1]-'0');
                for(int l=0;l<=lim;l++){
                    int prevm = m;
                    if(l<(k[i-1]-'0'))prevm=0;
                    dp[i][j][m] = (dp[i][j][m]+dp[i-1][(j+l)%d][prevm])%mod;
                }
            }
        }
    }
    int ans = (dp[k.size()][0][1]-1+mod)%mod;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,A[500005],B[500005];
int main() {
    cin>>n;
    for(long long i=1;i<=n;i++) {
        cin>>a>>b;
        A[i]=a+b;
        B[i]=a-b;
    }
    sort(A+1,A+1+n);
    sort(B+1,B+1+n);
    cout<<max(A[n]-A[1],B[n]-B[1]);
}

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

#define DEBUG if(0)
#define lli long long int

int main()
{
  set<string> st;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
  return 0;
}
/*
  1 3 2 =
  1st step: R =[1,2,3], count=[1,1,1]
  2nd step: R=[1,2,x], count=[1,1,0]
  3rd step: R=[2,2,x], count=[0,2,0]
*/

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

using namespace std;

typedef long long ll;
int n,m;
typedef pair<int,ll> P;
const ll INF = 1e15;
vector<P> g[1005];
ll d[1005];
int main() {
  cin >> n >> m;

  for(int i = 0; i < m; i++) {
    int a,b;
    ll c;
    cin >> a >> b >> c;
    a--; b--;
    g[a].push_back(P(b,-c));
  }

  fill(d,d+n,INF);

  d[0] = 0;

  for(int i = 0; i < n-1; i++) {
    for(int j = 0; j < n; j++) {
      if(d[j] == INF) continue;
      for(int k = 0; k < g[j].size(); k++) {
	int u = g[j][k].first;
	ll c = g[j][k].second;
	if(d[u] > d[j] + c) {
	  d[u] = d[j] + c;
	}
      }
    }
  }
  ll ans = d[n-1];

  for(int i = 0; i < n-1; i++) {
    for(int j = 0; j < n; j++) {
      if(d[j] == INF) continue;
      for(int k = 0; k < g[j].size(); k++) {
	int u = g[j][k].first;
	ll c = g[j][k].second;
	if(d[u] > d[j] + c) {
	  d[u] = d[j] + c;
	}
      }
    }
  }

  if(ans != d[n-1]) cout << "inf" << endl;
  else cout << -ans << endl;
}
  


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len, stones;
    cin >> len >> stones;
    vector<bool> dp(stones + 1, false);
    vector<int> arr(len);
    for(int i = 0; i < len; i++) {
        cin >> arr[i];
    }
    for(int i = 0; i <= stones; i++) {
        bool c;
        if(dp[i] == false) c = true;
        else c = false;
        for(int j = 0; j < len; j++)
            if(i + arr[j] <= stones && !dp[i + arr[j]])
                dp[i + arr[j]] = c;
        //cout << dp << endl;
    }
    if(dp[stones]) cout << "First";
    else cout << "Second";
}



Measured memory_bytes: 3664
import java.util.*;
import java.io.*;


public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = sc.nextInt();
        int M = sc.nextInt();
        if(N==M) out.println("Yes");
        else out.println("No");


        // out.println(result);
        out.flush();
    }
        
}



class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
vector <int> arr;
bool sudah[110];
int solve(int now,int cnt)
{
	if(cnt==5)
	{
		return now;
	}
	if(now%10!=0)
	{
		now/=10;
		now++;
		now*=10;
	}
	int x;
	bool ada=0;
	int ans=999999999;
	for(x=0;x<arr.size();x++)
	{
		if(sudah[x]==0)
		{
			sudah[x]=1;
			ans=min(ans,solve(now+arr[x],cnt+1));
			sudah[x]=0;
		}
	}
	return ans;
}
int main()
{
	int n=5;
	while(n--)
	{
		int a;
		cin>>a;
		arr.push_back(a);
	}
	cout<<solve(0,0)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int sx,sy,tx,ty,xx,yy;
    cin>>sx>>sy>>tx>>ty;
    char x1,x2,y1,y2;
    if(sx<tx){
        x1 = 'R';
        x2 = 'L';
        xx = tx-sx;
    }else{
        x1 = 'L';
        x2 = 'R';
        xx = sx-tx;
    }
    if(sy<ty){
        y1 = 'U';
        y2 = 'D';
        yy = ty-sy;
    }else{
        y1 = 'D';
        y2 = 'U';
        yy = sy-ty;
    }
    for(int i =0;i<xx;i++){
        cout<<x1;
    }
    for(int i =0;i<yy;i++){
        cout<<y1;
    }
    for(int i =0;i<xx;i++){
        cout<<x2;
    }
    for(int i =0;i<yy;i++){
        cout<<y2;
    }
    cout<<x2;
    for(int i =0;i<yy+1;i++){
        cout<<y1;
    }
    for(int i =0;i<xx+1;i++){
        cout<<x1;
    }
    cout<<y2;

    cout<<x1;
    for(int i =0;i<yy+1;i++){
        cout<<y2;
    }
    for(int i =0;i<xx+1;i++){
        cout<<x2;
    }
    cout<<y1;
    return 0;
}

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

using namespace std;

int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	string s;
	cin >> s;

	--A; --B; --C; --D;
	auto f = [&](vector<bool>& d, int S, int T) -> void {
		d[S] = true;
		for (int i = S; i < N; ++i) {
			if (!d[i]) { continue; }
			if (i + 1 <= T and s[i + 1] == '.') {
				d[i + 1] = true;
			}
			if (i + 2 <= T and s[i + 2] == '.') {
				d[i + 2] = true;
			}
		}
	};
	
	vector<bool> da(N, false), db(N, false);
	f(da, A, C);
	f(db, B, D);
	bool ok = da[C] and db[D] and C != D;
	if (C > D) {
		bool tmp = false;
		for (int i = A; i + 2 <= C; ++i) {
			tmp = tmp or (da[i] and da[i + 2] and db[i + 1]);
		}
		ok = ok and tmp;
	}
	cout << (ok ? "Yes" : "No") << "\n";

	return 0;
}


Measured memory_bytes: 3756
n = input()

ans = [2,5,20,63]

if n == 3:
    print 2,5,63
    exit(0)

p = 90
while (n - len(ans))%44 != 0:
    ans.append(p)
    p += 30

while len(ans) < n:
    if p % 2 == 0 or p % 5 == 0 or p % 3 == 0:
        ans.append(p)
    p += 1

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

s = sum(ans)
    
for x in ans:
    print x,
print ""

Measured memory_bytes: 3460
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI mar;
map<in,in> ps;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  in sm=0;
  mar.resize(n);
  forn(i,n){
    cin>>mar[i];
    ps[mar[i]]=0;
  }
  in ct=0;
  fors(i,ps)
    i->second=ct++;
  forn(i,n)
    if(i%2!=ps[mar[i]]%2)
      ++sm;
  sm/=2;
  cout<<sm<<endl;
  return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
int m;
int c;
int e;
while(cin >>n>>m){
if(n==0&&m==0){break;}
int a[m];
int b[m];
c=0;
while(c<m){
cin >>a[c]>>b[c];
c=c+1;}
int d[n];
d[0]=3;
c=1;
while(c<n){
d[c]=0;
c=c+1;}
c=0;
while(c<m){
if(a[c]==1){d[b[c]-1]=2;}
if(b[c]==1){d[a[c]-1]=2;}
c=c+1;}
c=0;
while(c<m){
if(d[a[c]-1]==2&&d[b[c]-1]==0){d[b[c]-1]=1;}
if(d[b[c]-1]==2&&d[a[c]-1]==0){d[a[c]-1]=1;}
c=c+1;}
e=0;
c=1;
while(c<n){
if(d[c]==1||d[c]==2){e=e+1;}
c=c+1;}
cout <<e<<endl;}}

Measured memory_bytes: 1236
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

#define MOD 1000000007LL

int main () {

    ll N,M; cin >> N >> M;

    if(abs(N-M) > 1 ) {
        cout << 0 << endl;
        return 0;
    }

    ll ans1 = 1;
    ll ans2 = 1;

    REP(i,N) {
        ans1 *= (ll)(i+1);
        ans1 %= MOD;
    }

    REP(i,M) {
        ans2 *= (ll)(i+1);
        ans2 %= MOD;
    }

    ans1 *= ans2;
    ans1 %= MOD;

    if(N == M) {
        ans1 *= 2;
        ans1 %= MOD;
    }

    cout << ans1 << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin >> s;
	string s1 = s;
	reverse(s.begin(),s.end());
	for (int i = 0;i < s.size();i++)
	{
		if (s[i] == 'b')
		    s[i] = 'd';
		else if (s[i] == 'd')
		    s[i] = 'b';
		else if (s[i] == 'p')
		    s[i] = 'q';
		else
		    s[i] = 'p';
	}
	if (s1 == s)
	    cout << "Yes\n";
	else
	    cout << "No\n";
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,k,s,mx=1e9; cin>>n>>k>>s;
	vector<ll>v;
	if(s!=mx)
		v.resize(n,mx);
	else
		v.resize(n,1);
	for(int i=0;i<k;i++) v[i]=s;
	for(const auto& x:v) cout<<x<<" ";
	return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int H,W,h,w;
	cin>>H>>W>>h>>w;
	cout<<(H-h)*(W-w)<<endl;
	return 0;
}

Measured memory_bytes: 256