akhauriyash/Code-Regression huggingface dataset:
n=int(input())
S=[int(0) for i in range(1,14)]
H=[int(0) for i in range(1,14)]
D=[int(0) for i in range(1,14)]
C=[int(0) for i in range(1,14)]
for i in range(n):
    K,y=[(i) for i in input().split()]
    if K=='S':
        S[int(y)-1]=1
    elif K=='H':
        H[int(y)-1]=1
    elif K=='D':
        D[int(y)-1]=1
    else:
        C[int(y)-1]=1
for i in range(1,14):
    if S[int(i)-1]==0:
        print('S',"{0}".format(i))
for i in range(1,14):
    if H[int(i)-1]==0:
        print('H',"{0}".format(i))
for i in range(1,14):
    if C[int(i)-1]==0:
        print('C',"{0}".format(i))
for i in range(1,14):
    if D[int(i)-1]==0:
        print('D',"{0}".format(i))

Measured memory_bytes: 7804
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, ans(2), result(0);
    cin >> n;
    for (int i = 1; i <= n; i += 2)
    {
        ans = 2;
        for (int j = 3; j < n / 2; ++j)
        {
            if (i % j == 0)
                ans++;
        }
        if (ans == 8)
            result++;
    }
    cout << result << endl;
}

Measured memory_bytes: 256
dic = {}
for i in range(3):
  arr = input().split()
  for j in range(3):
    dic[arr[j]] = (i,j)
    
n = int(input())
appear=[[False for _ in range(3)] for __ in range(3)]

for _ in range(n):
  b = input()
  if b in dic:
    i, j = dic[b]
    appear[i][j] = True

ans = 'No'
for i in range(3):
  if appear[i][0] and appear[i][1] and appear[i][2]:
    ans = 'Yes'
    break
  if appear[0][i] and appear[1][i] and appear[2][i]:
    ans = 'Yes'
    break
if appear[0][0] and appear[1][1] and appear[2][2]:
  ans = 'Yes'
if appear[0][2] and appear[1][1] and appear[2][0]:
  ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
movable [] = True
movable (x:xs) = if (x!!0 >= x!!1 + x!!2) && (x!!0 - x!!1 - x!!2) `mod` 2 == 0 then movable xs else False
 
main = do
  _ <- getLine
  ls <- lines <$> getContents
  let xys = map (map read . words) $ ls
  putStrLn $ if movable xys
             then "Yes"
             else "No"

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

#define INF 1e9
#define MAX 1005
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define ull long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
#define zai <<' '<<
#define all(a) a.begin(),a.end()
#define pc __builtin_popcount
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

char a[MAX][MAX];
int d[MAX][MAX];

int ans=0;
int n,m;
int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> a[i][j];
		}
	}
	bool did=0;
	memset(d,-1,sizeof d);
	queue<ii> q;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(a[i][j]=='#'){
				q.push({i,j});
				d[i][j]=0;
			}
		}
	}
	while(!q.empty()){
		ii u=q.front();q.pop();
		for(int i=0;i<4;i++){
			int x=u.xx+dx[i];
			int y=u.yy+dy[i];
			if(x<0 || x>n-1 || y<0 || y>m-1)continue;
			if(d[x][y]==-1){
				d[x][y]=d[u.xx][u.yy]+1;
				q.push({x,y});
			}
		}
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			ans=max(ans,d[i][j]);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 13328
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();


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


Measured memory_bytes: 256
from itertools import permutations
def dist(a,b):
    return ((a[0]-b[0])**2+(a[1]-b[1])**2)**0.5
n = int(input())
coords =[ ]
for _ in range(n):
    coords.append(tuple(int(x) for x in input().split()))
c=0
d = 0
for perm in permutations(range(n), n):
    for i, val in enumerate(perm[1:]):
        d += dist(coords[perm[i]], coords[val])
    c+=1
print(d / c)

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

void c_p_c()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

bool sortKhela(const pair< int, int > &a,
               const pair< int, int > & b)
{
    return (a.first < b.first);
}

int main()
{
    c_p_c();
    int n, m;
    cin >> n >> m;
    int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];

    sort(arr, arr + n);
    int sum = 0;
    for (int i = 0; i < m; i++)
        sum += arr[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3688
program sample
	implicit none
    integer(8) :: i,j,k,l,m
    real(8),allocatable :: a(:)

    read(*,*) i
    read(*,*) j,k
    
    allocate(a(i))
    
    read(*,*) a
    
    do l=1,i
    	a(l)=j-a(l)*0.006-k
        a(l)=abs(a(l))
    end do
    
    m=1
    do l=1,i
    	if (a(l)<a(m)) then
        	m=l
        end if
        !write(*,*) a(l),a(m),m
    end do
    
    write(*,*) m
    !write(*,*) a
    
    stop
end program sample

Measured memory_bytes: 2872
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');

            if (int.Parse(s[0]) > 8 || int.Parse(s[1]) > 8)
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine("Yay!");
            }
        }
    }
}


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

using namespace std;

const int N = 100005;

int n;

int a[N], b[N], c[N];

int dp[N][5];

int main() {

	cin >> n;

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

	for (int i = 1; i <= n; i ++) {
		dp[i][1] = max(dp[i - 1][2], dp[i - 1][3]) + a[i];
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][3]) + b[i];
		dp[i][3] = max(dp[i - 1][1], dp[i - 1][2]) + c[i];
	}

	int ans = dp[n][1];
	ans = max(ans, dp[n][2]);
	ans = max(ans, dp[n][3]);

	for (int i = 1; i <= n; i ++) {
		cerr << i << ' ' << dp[i][1] << ' ' << dp[i][2] << ' ' << dp[i][3] << '\n';
	}
	
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll N;
    cin >> N;

    map<ll, ll> m;
    rep (i, N) {
        ll A;
        cin >> A;
        m[A]++;
    }

    auto rbegin = m.rbegin();
    auto rend = m.rend();
    ll memo1 = 0;
    ll memo2 = 0;
    for (auto it = rbegin; it != rend; it++) {
        if (it->second >= 4 && !memo1 && !memo2) {
            memo1 = it->first;
            memo2 = it->first;
            break;
        } else if (it->second >= 2 && !memo1) {
            memo1 = it->first;
        } else if (it->second >= 2 && memo1) {
            memo2 = it->first;
            break;
        }
    }

    cout << memo1*memo2 << endl;
    return 0;
}

Measured memory_bytes: 6528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????



		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> list = new ArrayList<Integer>();

		Boolean isContinue = true;

		while(isContinue){

			int intNum = 0;
			try {

				String strIn = insBR.readLine();
				intNum = Integer.parseInt(strIn);

				if(intNum != 0 ){
					list.add(intNum);

				}else{
					isContinue = false;
				}

			}catch(IOException e){
				System.out.println(e);

			}catch(NumberFormatException e){
				System.out.println(e);
			}


		}

		for(int i = 0; i < list.size(); i++){

			System.out.print("Case " + (i + 1) + ": ");
			System.out.println(list.get(i));
		}
	}
}

Measured memory_bytes: 27412
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def nCr_table(n):
    table = [[None] * (n + 1) for _ in range(n + 1)]
    for i in range(n + 1):
        for j in range(i + 1):
            if j == 0 or j == i:
                table[i][j] = 1
            else:
                table[i][j] = table[i - 1][j - 1] + table[i - 1][j]
    return table


def main():
    N, P = map(int, input().split())
    A_list = list(map(int, input().split()))

    nCr = nCr_table(100)

    e, o = 0, 0
    for a in A_list:
        e += a % 2 == 0
        o += a % 2 == 1

    a = 0
    for i in range(0, e + 1):
        a += nCr[e][i]
    if P == 0:
        b = sum([nCr[o][i] for i in range(0, o + 1, 2)])
        print(a * b)
    else:
        b = sum([nCr[o][i] for i in range(1, o + 1, 2)])
        print(a * b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3692
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;
int main(){
    int N,ans=MOD,a=0,b=0; cin >> N;
    int W[N+10];
    for(int i=0; i<N; i++) cin >> W[i];
    for(int i=0; i<N; i++){
        b+=W[i];
        for(int j=i+1; j<N; j++){
            a+=W[j];
        }
        ans=min(ans,abs(a-b));
        a=0;
    }
    cout << ans << endl;

}

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

int main()
{
	int m = 0 , n = 0 , boxa[256][256] = {} ,boxb[256] = {} ;
	cin >> n >> m ;
	for ( int i = 0 ; i < n ; i++ )
	{
		for ( int j = 0 ; j < m ; j++ )
		{
			cin >> boxa[i][j] ;
		}
	}
	for ( int k = 0 ; k < m ; k++ ) cin >> boxb[k] ;
	for ( int i2 = 0 ; i2 < n ; i2++ )
	{
		int c = 0 ;
		for ( int j2 = 0 ; j2 < m ; j2++ )
		{
			c += boxa[i2][j2] * boxb[j2] ;
		}
		cout << c << endl ;
	}
	return 0;
}



Measured memory_bytes: 3364
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
/// khodaya komak kon
/// ya navid navid
/// ye tec khaphan ke yadam bemone : age jayi didi soale masir hamiltoni mikhad rasasho bokon yal oilery;https://mobomovie1.top/series/%D8%AF%D8%A7%D9%86%D9%84%D9%88%D8%AF-%D8%B3%D8%B1%DB%8C%D8%A7%D9%84-%D9%81%D8%B1%DB%8C%D9%86%D8%AC-fringe-2008-2013-%D8%A8%D8%A7-%D8%B2%D9%8A%D8%B1%D9%86%D9%88%D9%8A%D8%B3-%D9%81%D8%A7%D8%B1/
/// age ye ja mikhasti to dp az ozv i k ta entekhab koni bejash ye log bezan (nominal) hamoon 2**k va o 1 ent kon
const int N=2e5+100,inf=1e9+100;
ll t[N];
ll a[N];
ll c[N];
int32_t main(){
    sync;
    ll n,m;
    cin >> n >> m;
    ll ans=0;
    for (int i=1;i<=n;i++){
        ll x;
        cin >> x;
        c[i]=x;
        if (!t[x]){
            t[x]++;
            a[x]++;
            if (a[x]==1)
                ans++;
          //  cout << x << endl;
        }
        else{
            t[x]++;
            if (x-t[x]+1>0 && a[x-t[x]+1]==0){
                ans++;
            }
            if (x-t[x]+1>0)
                a[x-t[x]+1]++;
          //  cout << x << " " << x-t[x]+1 << endl;
        }
    }
   // cout << ans << endl;
    for (int i=0;i<m;i++){
        ll id,x;
        cin >> id >> x;
        ll v=c[id];
        if (v-t[v]+1>0)
            a[v-t[v]+1]--;
        if (v-t[v]+1>0 && a[v-t[v]+1]==0){
            ans--;
        }
       // for (int j=1;j<=5;j++){
         //   cout << j << " " << t[j] << " " << a[j] << " " << ans << endl;
        //}
        t[v]--;
        //cout << endl;
        c[id]=x;
        t[x]++;
        if (x-t[x]+1>0 && a[x-t[x]+1]==0){
            ans++;
        }
        if (x-t[x]+1>0)
            a[x-t[x]+1]++;
       // for (int j=1;j<=5;j++){
         //   cout << j << " " << t[j] << " " << a[j] << endl;
        //}
        cout << n-ans << '\n';
    }

}


Measured memory_bytes: 6144
// Maximmize the Formula
#include <iostream>
#include <algorithm>
using namespace std;

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

    if (max({a, b, c}) == a) cout << a * 10 + b + c << endl;
    else if (max({a, b, c}) == b) cout << a + b * 10 + c << endl;
    else if (max({a, b, c}) == c) cout << a + b + c * 10 << endl;
}

Measured memory_bytes: 256
import numpy as np
import math
import copy 
N = input()
N = np.int64(N)
# print(np.sqrt(N))
l = []
x  = 2
xen = np.sqrt(N)
while N>1:
    if N%x ==0:
        l.append(x)
        N = N/x
    else:
        x = x + 1
        if x > xen:
            l.append(int(N))
            break
# l = [2, 2, 2, 3, 3, 3, 5, 5, 5, 6079, 6079]
# l = [2, 2, 2, 3]
l2 = []
while l!=[]:
#     print(l)
    i = l[0]
    n = l.count(i)
    l = l[n:]
    l2.append(n)
    if l==[]:break
# print(l2)
# print('///')

i = 0
m = 0
l2 = np.array(l2)
# print(l2)
ans = 0
while True:
    i += 1
#     m = m + i
#     print(m)
    l2 = l2-i
    l2 = l2[l2>=0]
    ans = ans + len(l2)
#     print(l2)
    if len(l2)==0:break
print(ans)

Measured memory_bytes: 27328
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
long long n,ans,a,b,c;
string s;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        int j=s.size();
        if(s[j-1]=='A')a++;
        if(s[0]=='B')b++;
        if(s[j-1]=='A' && s[0]=='B')c++;
        for(int k=0;k<j-1;k++){
            if(s.substr(k,2)=="AB")ans++;
        }
    }
    if(a+b==0){}
    else if(a==b && b==c)ans+=min(a,b)-1;
    else ans+=min(a,b);
    cout<<ans<<endl;
}


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

int main(){
    int  a, b, c, d; cin >> a >> b >> c >> d;
    rep(i, 1000){
        c -= b;
        if(c <= 0){
            cout << "Yes" <<endl;
            break;
        }
        a -= d;
        if(a <= 0){
            cout << "No" <<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
<?php
$N = (int)fgets(STDIN);
$S = [];
$S['AC'] = 0;
$S['WA'] = 0;
$S['TLE'] = 0;
$S['RE'] = 0;
for ($i = 0; $i < $N; $i++) {
    $s = trim(fgets(STDIN));
    $S[$s] += 1;
}

foreach ($S as $key => $value) {
    echo "{$key} x {$value}\n";
}

Measured memory_bytes: 16212
/* while(!success_achieved())
      work_hard();

   code by:aman_ayush
  */
#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}
bool vis[100001];

void bfs(int s,int n,vi v[])
{
    vis[s]=true;
    queue<int> q;
    q.push(s);
    while(!q.empty())
    {
        int r=q.front();
        q.pop();
        for(int i=0;i<v[r].size();i++)
        {
            int ch=v[r][i];
            if(!vis[ch])
            {
                q.push(ch);
                vis[ch]=true;
            }
        }
    }
}
int main()
{
    for(int i=0;i<=100000;i++)
     vis[i]=false;
    fast;
     int n,m;
     cin>>n>>m;
     vi v[n+1];
     for(int i=1;i<=m;i++)
     {
         int x,y,z;
         cin>>x>>y>>z;
         v[x].push_back(y);
         v[y].push_back(x);
     }
     int count=0;
     for(int i=1;i<=n;i++)
     {
         if(!vis[i])
         {
             count++;
             bfs(i,n,v);
         }
     }
     cout<<count<<"\n";
     return 0;
}

Measured memory_bytes: 6648
W,H,N = map(int,input().split())
G = {1:[],2:[],3:[],4:[]}
for _ in range(N):
    x,y,a = map(int,input().split())
    if a==1 or a==2:
        G[a].append(x)
    else:
        G[a].append(y)
xmin = 0
xmax = W
ymin = 0
ymax = H
if len(G[1])>0:
    xmin = max(G[1])
if len(G[2])>0:
    xmax = min(G[2])
if len(G[3])>0:
    ymin = max(G[3])
if len(G[4])>0:
    ymax = min(G[4])
if xmax>=xmin and ymax>=ymin:
    print((xmax-xmin)*(ymax-ymin))
else:
    print(0)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes";
	else cout<<"No";
	cout<<"\n";
	return 0;
}


Measured memory_bytes: 380
using System;

namespace ITP_2_A
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] temp = Console.ReadLine().Split(' ');
            int a = int.Parse(temp[0]);
            int b = int.Parse(temp[1]);

            if(a > b){
                Console.WriteLine("a > b");
            }else if(a == b){
                Console.WriteLine("a == b");
            }else{
                Console.WriteLine("a < b");
            }
        }
    }
}

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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}


int main(){
    int L, R, d;
    cin >> L >> R >> d;
    cout << R/d - (L-1)/d;
    return 0;
}

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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int t=1;
	//cin>>t;
	//SieveOfEratosthenes(1000000);
    while(t--){
        ll n,k;
        cin>>n>>k;
        ll a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        int dp[k+1]={0};
        for(int i=0;i<=k;i++){
            for(int j=0;j<n;j++){
                if(i>=a[j])
                    dp[i]=dp[i]|(!dp[i-a[j]]);
            }
        }
        if(dp[k])
            cout<<"First";
        else
            cout<<"Second";
    }
}

Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()

#define fast cin.tie(0); ios::sync_with_stdio(false)
#define int long long

int32_t main(){ fast;
	string s;
	int n, r = 0, g = 0, b = 0;
	cin>>n>>s;
	for(char ch : s){
		if(ch == 'R') r++;
		if(ch == 'G') g++;
		if(ch == 'B') b++;
	}
	int answer = r * g * b;
	rep(i, n){
		for(int j = 1; j < n; j++){
			int l = i - j;
			int rr = i + j;
			if(l >= 0 && l < n && rr >= 0 && rr < n && s[l] != s[i] && s[rr] != s[i] && s[l] != s[rr]){
				answer--;
			}
		}
	}		
	cout<<answer<<endl;
}


Measured memory_bytes: 3660
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String input = sc.next();
		int N = sc.nextInt();
      int K = sc.nextInt();
      if(N % K == 0){
        System.out.println("0");
      }else{
        System.out.println("1");
      }
		//Long tmp = sc.nextLong();
      	
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it!= v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
#define MOD 1000000007
//////////////////////////////////////////

int main(){
  inl(a,b);
  if(a<=0&&0<=b) die("Zero");
  if(a>0) die("Positive");
  ll c = a - b + 1;
  out(c&1 ? "Negative" : "Positive");

}

Measured memory_bytes: 256
H, W = map(int, input().split())
A = []
for i in range(H):
  A.append(list(map(str, input().split())))

A_int = []
for a in A:
  temp = []
  for i in range(W):
    if a[0][i] == '.':
      temp.append(0)
    else:
      temp.append(1)
  if sum(temp)>0:
    A_int.append(temp)

import numpy as np
A = np.array(A_int)
del_columns=[]
for i in range(len(np.all(A==0, axis=0))):
  if np.all(A==0, axis=0)[i]==True:
    del_columns.append(i)
A_del = np.delete(A, del_columns, axis=1)

for i in range(A_del.shape[0]):
  ans=""
  for j in range(A_del.shape[1]):
    if A_del[i][j]==0:
      ans += "."
    else:
      ans += "#"
  print(ans)

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

#define int long long

main()
{
  int a, b;
  
  cin >> a >> b;

  int val = 1, sum = 0, g = 1;
  while(val <= b) val *= 2;
  val /= 2;
  while(val < a) {
    a -= val, b -= val;
    while(b < val) val /= 2;
  }
  
  while(b - val >= g) g *= 2;
  cout << (val - a) + min(val, g + (val - a)) << endl;
  return (0);
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);
int div(int n)
{
	int t = 0;
	for(int i=1 ; i<=n ; i++)
	{
		if(n%i==0)
			t++;
	}
	return (n%2 == 1 && t == 8);
}
int32_t main()
{
	fast;
	int n;
	cin >> n;
	int ans = 0;
	f(i,1,n+1)
		ans += div(i);
	cout << ans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const int Nmax=2e5+1;
const int Nd=61;
const int INF=1e5;

int main(){
  string s,t;
  cin>>s>>t;
  int ns=s.size();
  int nt=t.size();

  int now=0;
  int ans=INF;
  rep(i,ns){// sのi文字目から置き換える場合，
    now=0;
    if(i+nt<=ns){//文字置き換えできるばあい
      rep(j,nt){
        if(s[i+j]!=t[j]){
          now++;
        }
      }
      ans=min(ans,now);
    }
  }

  cout<<ans<<endl;



}


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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define tc ll t; cin >> t; while (t--)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define sz(c) (ll) c.size()
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define dm(m) trav(x,m) cout << x.f << "->" << x.s << endl;
#define godspeed cin.tie(0) -> sync_with_stdio(0);

const int INFI = 2e9 + 5;
const ll INFLL = 1e18 + 5;
const ll N = 2e5 + 5;
const ll MOD = 1e9 + 7;
const ld PIE = acos(-1.0);

int main() {
    godspeed;

 	ll n; cin >> n;
    cout << 2 * PIE * n;
}

Measured memory_bytes: 3756
x=require('fs').readFileSync('/dev/stdin','utf8').trim().split(/\s/).sort(function(a,b){return a-b;});
//console.log(x);
for(mode=[],cnt=0,i=0;i<x.length;i++){
    temp_cnt=1;
    for(j=i+1;j<x.length;j++){
        if(x[i]==x[j]){
            temp_cnt++;
        }
    }
    mode.push(temp_cnt);
}
max=Math.max.apply(null,mode);
k=1;
while(max==Math.max.apply(null,mode)){
    console.log(x[mode.indexOf(Math.max.apply(null,mode))+k++]);
    //console.log(mode.indexOf(Math.max.apply(null,mode)));
    mode.splice(mode.indexOf(Math.max.apply(null,mode)),1);
    
    //console.log(mode);
}

Measured memory_bytes: 15556
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int N;
    cin >> N;
    double ans = 0.0;
    for(int i=0; i<N; i++){
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY")
            ans += x;
        else
            ans += x*380000;
    }
    cout << fixed << setprecision(32) << ans << endl;
    return 0;
}

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

int main(){
	int a,b;
	cin >> a >> b;

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

}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
    int n;
    pair<int,int> Max,Min;
    cin>>n;
    rep(i,n){
        int a;
        cin>>a;
        if(i==0){
            Max.first=Min.first=a;
            Max.second=Min.second=1;
        }
        else{
            if(a==Max.first)Max.second++;
            if(a==Min.first)Min.second++;
            if(a>Max.first){
                Max.first=a;
                Max.second=1;
            }
            if(a<Min.first){
                Min.first=a;
                Min.second=1;
            }
        }
    }
    if(Max.first-Min.first>1)cout<<"No"<<endl;
    else{
        if(Max.first==Min.first){
            if(n-1==Max.first||Max.first*2<=n)cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
        else{
            if(Min.second<Max.first&&(Max.first-Min.second)*2<=Max.second)cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ii pair<int,int>
#define ll long long int
#define F first
#define S second
using namespace std;
const int M = 1e5 + 7, mod = 1e9 + 7;

int a[107];

int main(){

  #ifndef ONLINE_JUDGE
  //freopen("i.txt", "r", stdin);
  //freopen("o.txt", "w", stdout);
  #endif

  int n;
  cin >> n;

  int ans = 0;

  for(int i=0; i<n; i++){
    int tmp;
    cin >> tmp;
    if(a[tmp]==0)ans++, a[tmp] = 1;
  }

  cout << ans << endl;


}


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

# define ll long long
ll mod=pow(10,9)+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    
}



Measured memory_bytes: 3636
use std::str::FromStr;
use std::io::stdin;

fn main() {
    let a = read::<i32>();
    let s = read::<String>();
    if a >= 3200 {
        println!("{}", s);
    } else {
        println!("{}", "red");
    }
}

fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
n = int(input())
t = list(map(int, input().split(' ')))
m = int(input())

for mi in range(m):
  tt = list(x for x in t)
  p, x = map(int, input().split(' '))
  del tt[p-1]

  res = 0
  for value in tt:
    res += value
  print(res + x)

Measured memory_bytes: 3060
import copy
H,W=map(int,input().split())
a=[input() for i in range(H)]
flag=True
while flag:
    if '.'*W in a:
        a.remove('.'*W)
        H-=1
    else:
        flag=False
b=[0]*H
f=True
while f:
    c=copy.deepcopy(a)
    g=False
    for i in range(W):# i列
        if g:
            break
        for j in range(H):
            b[j]=a[j][i]
        if ''.join(b)=='.'*H:
            for k in range(H):
                s=list(a[k])
                del s[i]
                a[k]=''.join(s)
            W-=1
            g=True
            break
    if c==a:
        f=False
for i in range(H):
    s=''.join(a[i])
    print(s)

Measured memory_bytes: 4084
#include<stdio.h>
int main()
{
  int n=0,y=0,sen=0,gosen=0,man=0,flag=0;
  int a,b,c;
  scanf("%d %d",&n,&y);
  for(sen=0;sen<=n;sen++){
    for(gosen=0;gosen<=n;gosen++){
      man=n-(sen+gosen);
      if(sen*1000+gosen*5000+man*10000==y&&
         sen+gosen+man==n&&man>=0){
        a=man;b=gosen;c=sen;flag=1;break;}
      //else{flag=0;}
    }
  }
  if(flag==1) printf("%d %d %d",a,b,c);
  else printf("-1 -1 -1");
    return 0;
  }


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int H, W;
string S[100];
char T[100][100];



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

    std::cin >> H >> W;

    for(int i=0;i<H;++i){
        std::cin >> S[i];
    }

    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            if(S[i][j] == '#'){
                T[i][j] = '#';
                continue;
            }
            
            int cnt = 0;
            
            for(int k=0;k<8;++k){
                int ni = i + dx[k], nj = j + dy[k];
                if(ni < 0 || ni >= H || nj < 0 || nj >= W){
                    continue;
                }

                if(S[ni][nj] == '#'){
                    ++cnt;
                }
            }

            T[i][j] = '0' + cnt;
        }
    }

    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            cout << T[i][j];
        }
        std::cout << std::endl;
    }
}


Measured memory_bytes: 256
A = list(map(int, input().split()))
A.sort()
c = 0
a1 = A[2] - A[1]
a2 = A[2] - A[0]
if (a2 - a1) % 2 != 0:
    c += 1
    A[2] += 1
    if a1 < a2:
        A[0] += 1
    else:
        A[1] += 1
a1 = A[2] - A[1]
a2 = A[2] - A[0]
if a1 < a2:
    c += a1
    c += (a2 - a1) / 2
else:
    c += a2
    c += (a1 - a2) / 2
print(int(c))

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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < (int)k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    int w, h, c;
    cin >> w >> h >> c;
    int tmp = gcd(w, h);
    cout << ((w * h) / (tmp * tmp)) * c << endl;
    return 0;
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
#define MAX 40
using namespace std;
const int MOD=1000000007;
const int INF=9000000009;

signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b==c+d)cout<<"Balanced"<<endl;
  else if(a+b<c+d)cout<<"Right"<<endl;
  else cout<<"Left"<<endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))

x = [A[i-1]-i for i in range(1, N+1)]
x.sort()
if len(x)%2==1:
    mid = x[len(x)//2]
    ans = 0
    for i in range(1, N+1):
        ans += abs(A[i-1]-(mid+i))
    print(ans)
else:
    mid1 = x[len(x)//2-1]
    mid2 = x[len(x)//2]
    ans1 = ans2 = 0
    for i in range(1, N+1):
        ans1 += abs(A[i-1]-(mid1+i))
        ans2 += abs(A[i-1]-(mid2+i))
    print(min(ans1, ans2))

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

using namespace std;

typedef long long ll;

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

	int N;
	cin >> N;

	if(N % 2 == 0){
		cout << N * (N - 1) / 2 - N / 2 << endl;
		for(int i = 1; i <= N; i++){
			for(int j = i + 1; j <= N; j++){
				if(i + j == N + 1) continue;
				cout << i << " " << j << endl;
			}
		}
	}else{
		cout << N * (N - 1) / 2 - (N-1)/ 2 << endl;
		for(int i = 1; i <= N; i++){
			for(int j = i+1; j <= N; j++){
				if(i + j == N) continue;
				cout << i << " " << j << endl;
			}
		}
	}


}


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

int main(){
    string s;
    cin >> s;
    int ans=101;
    set<char> st0;
    map<char,int> mp0;
    for(int i = 0;i < s.size();i ++){
        st0.insert(s[i]);
        mp0[s[i]] ++;
    }
    for(int i = 'a';i < 'a'+26;i ++){
        set<char> st1(st0);
        map<char,int> mp1(mp0);
        string s1 = s;
        int cnt=0;
        while(st1.size()>1){
            for(int j = 0;j < s1.size()-1;j ++){
                if(s1[j]!=i&&s1[j+1]==i){
                    mp1[s1[j]] --;
                    if(!mp1[s1[j]]) st1.erase(s1[j]);
                    s1[j] = s1[j+1];
                    mp1[s1[j+1]] ++;
                }
            }
            mp1[s1.back()] --;
            if(!mp1[s1.back()]) st1.erase(s1.back());
            s1.pop_back();
            cnt ++;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1LL << 60;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


// 入力
int N;
ll h[100010];

// DP テーブル
ll dp[100010];

int main() {
    int N; cin >> N;
    rep1(i, N) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    rep1(i, 100010) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    rep1(i, N) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;


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

    ll n;
    cin >> n;
    vector<ll> cnt(65);
    rep(i,n) {
        ll a;
        cin >> a;
        ll ele=1;
        int c=0;
        while (a>0) {
            ele*=2;
            if (a%ele>0) ++cnt[c];
            a=a-a%ele;
            ++c;
        }
    }
    ll ele=1,ans=0;
    rep(i,62) {
        ans+=(ele*(cnt[i]*(n-cnt[i])%MOD)%MOD)%MOD;
        ans=ans%MOD;
        ele=(ele*2)%MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
main = do
    s <- getLine
    let (sy, s') = splitAt 4 s
        (sm, s'') = splitAt 2 (drop 1 s')
        (sd, s''') = splitAt 2 (drop 1 s'')
        m = read sm
    if m <= 4 then putStrLn "Heisei"
              else putStrLn "TBD"

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const ll M = 7ll + (long long) 1e9;
const int NMAX = 1 + (int) 2e5;

vector <ll> inv(NMAX);


ll mpow(ll x, ll n){ 
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
/*
ll mpow(ll x, ll n){ 
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}*/

ll Comb_(ll n, ll k){
    ll tmp=1;
    for(ll i=1; i<=k; i++){
        tmp = tmp*(n+1-i)%M;
    }
    for(ll i=1; i<=k; i++){
        tmp = tmp*inv[i]%M;
    }

    return tmp;
}

/*
ll fac(ll x){
    ll fac0;
    fac0 = 1;
    for(ll i = 0; i<x; i++){
        fac0 = fac0*(i+1) % M;  
    }
    return fac0;
}

long long pow_mod(long long a, long long b, long long m) {
  long long res=1;
  for(;b;b>>=1, a=a*a%m) {
    if(b&1) res=res*a%m;
  }
  return res;
}

ll ifac(ll x){
    ll ifac0;
    ifac0 = pow_mod(fac(x), M-2, M);  
    //ifac0 = mpow(fac(x), M-2);

    return ifac0;
}
 
ll comb(ll a, ll b){ 
    if(a == 0 && b == 0)return 1;
    if(b == 0) return 1;
    if(a < b || a < 0 || b<0)return 0;

    ll ifac_ab, ifac_b, fac_a;

    ifac_ab = ifac(a-b);
    ifac_b = ifac(b);
    fac_a = fac(a);    

    ll tmp = ifac_ab* ifac_b % M;
    return tmp * fac_a % M;
}
*/
 
int main()
{
    ll N,a,b;
    cin >> N >> a >> b;
    ll nCa, nCb, ans;

    for(int i=1; i<=(int) max(a,b); i++){
        inv[i] = mpow((long long) i, M-2);
        //cout << "i inv[i] " << i << " " << inv[i] << endl;
    }


    nCa= Comb_(N, a);
    nCb= Comb_(N, b);
    //ans = fac(N-a);
    ll sum = mpow(2,N);
    ll sub = (1 + nCa + nCb)%M;
    if( sum >= sub ){
        ans = ( sum - sub ) % M;
    }else{
        ans = (sum + M - sub) % M;
    }
    //cout << "mpow(2,N), nCa, nCb " << mpow(2,N) << " " << nCa << " " << nCb << endl;
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 4632
<?php
  
 fscanf(STDIN,"%d%d",$n,$q);
 $s = trim(fgets(STDIN));
 $quetion = array();
 $memo = array();

 $c = 0;
 $flag = false;
 for($i=0;$i<$n;$i++){
   //echo $s[$i]."\n";
   //echo $flag."\n";
   if($s[$i]=='A'){
     $flag = true;
   }elseif($s[$i]=='C' && $flag){
     $c++;
     $flag = false;
   }else{
     $flag = false;
   }
   $memo[$i] = $c;
 }
 
 for($i=0;$i<$q;$i++){
   fscanf(STDIN,"%d%d",$l,$r);
   echo ($memo[$r-1]-$memo[$l-1])."\n";
 }
 
 
 

Measured memory_bytes: 21124
N=int(input())
S=list(str(input()))

e_sum= S.count('E')

w_c=e_c=0
ans = N

for i in range(N):

    if S[i]=='E':
        e_c += 1
    else:
        w_c += 1

    if S[i]=='E':
        k = w_c + e_sum -e_c
    else:
        k = w_c -1 + e_sum -e_c
    
    ans = min(ans,k)

print(ans)


Measured memory_bytes: 5796
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 3000
int dp[MAX+1][MAX+1];
string getLCS(string &s , string &t , int len){
    int i=0 , j=0;
    string LCS;
    while(len>0){
        if(s[i] == t[j]){
           LCS.push_back(s[i]);
           i++;
           j++;
           len--;
        }else{
            if(dp[i][j+1] > dp[i+1][j]){
                j++;
            }else{
                i++;
            }
        }
    }
    return LCS;
}
int lenLCS(string&s , string&t , int i , int j){
   if(i>=s.length() || j>=t.length()){
       return 0;
   }
   if(dp[i][j] != -1){
       return dp[i][j];
   }
   if(s[i] == t[j]){
       return dp[i][j] = 1+lenLCS(s , t , i+1 , j+1);
   }else{
       int opt1 = lenLCS(s , t , i+1 , j);
       int opt2 = lenLCS(s , t , i , j+1);
       return dp[i][j] = max(opt1 , opt2);
   }
}
string solve(string s , string t){
    memset(dp, -1 , sizeof(dp));
    int len = lenLCS(s , t , 0 , 0);
    return getLCS(s , t ,len);
}
int main(){
   string s , t;
   cin>>s>>t;
   cout<<solve(s , t);
   return 0;
}

Measured memory_bytes: 35968
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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 mut $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")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap};
use std::io::{Write, BufWriter, stdout};
use std::iter::FromIterator;
fn main() {
    input! {
        H: usize,
        W: usize,
        N: usize,
        a: [usize; N],
    }

    let mut c = vec![0; H*W];
    a.insert(0, 0);
    for color in 0..N {
        a[color+1] += a[color];
    }

    for color in 0..N {
        for ind in a[color] .. a[color+1] {
            c[ind] = color+1;
        }
    }

    for h in 0..H {
        for w in 0..W {
            if h % 2 == 0 {
                print!("{} ", c[h*W + w]);
            } else {
                print!("{} ", c[h*W + (W-w)-1]);
            }
        }
        print!("\n");
    }
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
long N,a,b=10;
int main(){
  cin>>N;
  if(N&1){
    cout<<0<<endl;
    return 0;
  }
  while(b<=N){
    a+=N/b;
    b*=5;
  }
  cout<<a<<endl;
}


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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int start = max(A, C), end = min(B, D);
  if(end - start > 0) cout << end - start << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 30
using namespace std;
typedef long long ll;
int n,A[N];

unordered_map<ll,double> mem[N];
double calc(double a,double b){return abs(a-b)/a;}

double dfs(int idx,ll num){
  if(idx==n) return 0;
  if(mem[idx].count(num))return mem[idx][num];

  double res=1LL<<55;
  for(int i=idx;i<n;i++){
    ll t =num * ((A[i]-1)/num+1);
    res=min(res,max(calc(A[idx],t),dfs(idx+1,t)));
  }
  return mem[idx][num]=res;
}

double DP(){
  unordered_map<ll,double> dp[2];
  int f=0;  
  dp[0][1] = 0;
  for(int i=0;i<n;i++,f=!f){
    dp[!f].clear();
    for(auto it = dp[f].begin();it!=dp[f].end();it++){
      ll num = it->first;
      double cost = it->second;
      for(int j=num;;j+=num){
	if(dp[!f].count(j))dp[!f][j] = min(dp[!f][j],max(calc(A[i],j),cost));
	else dp[!f][j] = max(calc(A[i],j),cost);
	if(j>A[n-1]) break;
      }
    }
  }

  double res=1LL<<55;
  for(auto it = dp[f].begin();it!=dp[f].end();it++)res=min(res,it->second);
  return res;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
  printf("%.10f\n",DP());
  return 0;
}

Measured memory_bytes: 16976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = pow(10,9)+7;
/*template*/


int main()
{
  ll x;cin>>x;
  ll a,b;
  a=x/500;
  x=x%500;
  b=x/5;
  cout<<a*1000+b*5<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),r=0;
		int[]a=new int[n],c=new int[n-1];
		Arrays.setAll(a,i->s.nextInt());
		for(int i=0;i<n;++i)
			r+=s.nextInt();
		Arrays.setAll(c,i->s.nextInt());

		for(int i=0;i<n-1;++i)
			if(a[i]+1==a[i+1])
				r+=c[a[i]-1];

		System.out.println(r);
	}
}


Measured memory_bytes: 28756