akhauriyash/Code-Regression huggingface dataset:
def distance(p1, p2)
  squareDistance = p1.zip(p2).map { |a|
    (a[0] - a[1]) ** 2
  }.inject(0) { |dsum, d| dsum + d }
  Math.sqrt(squareDistance)
end

N, D = gets().split(" ").map(&:to_i)
points = (1..N).map { gets().split(" ").map(&:to_i) }

count = 0
(1..N).each { |i|
  ((i+1)..N).each { |j|
    d = distance(points[i - 1], points[j - 1])
    if d.to_i == d then
      count += 1
    end
  }
}

puts count


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

using namespace std;

int main()
{
    int H,W,N,Max;
    cin>>H>>W>>N;
    Max=max(H,W);
    if(N%Max==0)
        cout <<N/Max<< endl;
    else
        cout <<N/Max+1<< endl;
    return 0;
}


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

int main()
{
    size_t N;
    std::cin >> N;

    std::vector<int> v;
    for (size_t i = 0; i < N; ++i) {
        int n;
        std::cin >> n;
        v.push_back(n);
    }
    std::sort(v.begin(), v.end());

    double val = v[0];
    for (size_t i = 1; i < N; ++i) {
        val = (val + v[i]) / 2.0;
    }

    std::cout << val << std::endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl
#define MOD  998244353

int main() {
	lint N;
	while (cin >> N, N != 0) {
		N = 1000 - N;
		lint ans = 0;
		ans += N / 500;
		N %= 500;
		ans += N / 100;
		N %= 100;
		ans += N / 50;
		N %= 50;
		ans += N / 10;
		N %= 10;
		ans += N / 5;
		N %= 5;
		ans += N / 1;
		N %= 1;
		cout << ans << enld;
	}
}


Measured memory_bytes: 2984
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

int main() {
	int H, W;
	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0) {
			break;
		}
		for (int j = 0;j < H;j++) {
			for (int i = 0; i < W; i++) {
				if (j%2==1) {
					if (i % 2 == 1) {
						cout << "#";
					}
					else {
						cout << ".";
					}
				}
				else {
					if (i%2==1){
						cout << ".";
					}
					else {
						cout << "#";
					}
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> up, down, flat;
  while (n--) {
    string s;
    cin >> s;
    int l = 0, r = 0;
    for (auto c : s) {
      if (c == '(') {
        l++;
      } else if (c == ')') {
        if (l > 0) {
          l--;
        } else {
          r++;
        }
      }
    }
    if (l > r) {
      up.push_back({l, r});
    } else if (l < r) {
      down.push_back({l, r});
    } else {
      flat.push_back({l, r});
    }
  }

  sort(up.begin(), up.end(), [](pair<int, int> a, pair<int, int> b) { return a.second < b.second; });

  sort(down.begin(), down.end(), [](pair<int, int> a, pair<int, int> b) { return a.first > b.first; });

  bool valid = true;
  int l = 0;
  for (auto e : up) {
    // cerr << e.first << ' ' << e.second << endl;
    if (l < e.second) {
      valid = false;
      break;
    }
    l -= e.second;
    l += e.first;
  }
  for (auto e : flat) {
    // cerr << e.first << ' ' << e.second << endl;
    if (l < e.second) {
      valid = false;
      break;
    }
    l -= e.second;
    l += e.first;
  }
  for (auto e : down) {
    // cerr << e.first << ' ' << e.second << endl;
    if (l < e.second) {
      valid = false;
      break;
    }
    l -= e.second;
    l += e.first;
  }
  if (l != 0) valid = false;
  cout << (valid ? "Yes" : "No") << endl;
}


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

#define pb push_back
#define mk make_pair
#define fr first
#define sc second

using namespace std;

const int N = 1e5 + 11;

int n, c, l;
long long a[N], d[N], sm, flag[N];
int main () {

       cin >> n;
       for(int i = 1;i <= n;i ++)
           cin >> a[i];
       c = n;
       sort(a + 1, a + n + 1);

       for(int i = 1;i < n;i ++)
       {
           sm += a[i];
           if(sm * 2 < a[i + 1]) c -= (i - l), l = i;
       }
       cout << c << endl;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

class stack{
private:
    int array[100];
    int top;
public:
    stack() {
        top = -1;
    }
    void push(int val) {
        top++;
        array[top] = val;
    }
    int pop() {
        int ret = array[top];
        top--;
        return ret;
    }
};


int main(void)
{
    stack st1;
    string s;
    while (cin >> s) {
        if (s == "+") {
            int op2 = st1.pop();
            int op1 = st1.pop();
            st1.push(op1 + op2);
            continue;
        }
        if (s == "*") {
            int op2 = st1.pop();
            int op1 = st1.pop();
            st1.push(op1 * op2);
            continue;
        }
        if (s == "-") {
            int op2 = st1.pop();
            int op1 = st1.pop();
            st1.push(op1 - op2);
            continue;
        }
        st1.push(atoi(s.c_str()));
    }
    cout << st1.pop() << endl;

    return 0;
}

Measured memory_bytes: 3180
package main

import (
  "fmt"
)

func main(){
  var a string
  var ary [26]int
  fmt.Scan(&a)
  for _, k := range a {
    ary[k-97] ++ 
  }

  var f bool
  for i := 0 ; i < 26 ; i ++ {
    if ary[i] % 2 == 1 {
      f = true
    }
  }

  if f == false {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

Measured memory_bytes: 512
#include<iostream>
#include <ctype.h>
#include <string.h>
using namespace std;

int main(){
  int n ;
  cin >> n;
  int ans = 0;
  if(n >= 105) ans++;
  if(n >= 135) ans++;
  if(n >= 165) ans++;
  if(n >= 189) ans++;
  if(n >= 195) ans++;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

const int SHIFT = 1000000003;
const int LIMIT = 2000000010;
map< int, int > data;

void add(long long k, int x)
{
  for(k += SHIFT; k < LIMIT; k += k & -k) {
    data[k] += x;
  }
}

int sum(long long k)
{
  int sum = 0;
  for(k += SHIFT; k > 0; k -= k & -k) {
    if(data.count(k)) sum += data[k];
  }
  return (sum);
}

void solve()
{
  int N;
  cin >> N;
  map< int, vector< tuple< int, int, int > > > query;
  for(int i = 0; i < N; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a == c) {
      if(b > d) swap(b, d);
      query[b].emplace_back(0, a, i);
      query[d].emplace_back(2, a, i);
    } else {
      if(a > c) swap(a, c);
      query[b].emplace_back(1, a, 1);
      query[b].emplace_back(1, c + 1, -1);
    }
  }

  bool update[100000] = {};
  int dp[100000] = {};

  for(auto p : query) {
    sort(begin(p.second), end(p.second));
    for(auto &q : p.second) {
      int a, b, c;
      tie(a, b, c) = q;
      if(a == 1) add(b, c);
      else if(update[c]++) dp[c] += sum(b);
      else dp[c] -= sum(b);
    }
  }
  cout << accumulate(dp, dp + N, 0) << endl;
}

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

Measured memory_bytes: 22576
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 10010000
const ll mod=998244353;

int n,flag,step=1;
ll a,b,k,p,q,ans;
ll fac[N],inv[N];

ll power(ll x,ll y) {
	ll ret=1;
	for (;y;y>>=1,x=x*x%mod)
		if (y&1) ret=ret*x%mod;
	return ret;
}

ll C(int x,int y) {return fac[x]*inv[y]%mod*inv[x-y]%mod;}

int main()
{
	scanf("%d%lld%lld%lld",&n,&a,&b,&k);
	fac[0]=1; for (int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	inv[n]=power(fac[n],mod-2);
	for (int i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	
	for (int i=0;i<=n;i+=step)
		if ((k-a*i)%b==0)
		{
			if (!flag) step=b/__gcd(a,b),flag=1;
			p=i; q=(k-a*i)/b;
			if (q>n || q<0) continue;
			ans=(ans+C(n,p)*C(n,q)%mod)%mod;
		}
	printf("%lld\n",ans%mod);
	return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
int n,m;
long long a=0,b=0,ans=0;
char s[407][407];
int vis[407][407];
const int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
void dfs(int x,int y){
    vis[x][y]=1;
    if(s[x][y]=='#')
        b++;
    else if(s[x][y]=='.')
        a++;
    for(int i=0;i<4;i++)
        if(x+dir[i][0]>0&&x+dir[i][0]<=n&&y+dir[i][1]<=m&&y+dir[i][1]>0&&!vis[x+dir[i][0]][y+dir[i][1]]&&s[x+dir[i][0]][y+dir[i][1]]!=s[x][y])
            dfs(x+dir[i][0],y+dir[i][1]);
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(!vis[i][j])
                a=b=0,dfs(i,j),ans+=a*b;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 8576
unittest
{
	assert( [ "4 5 8", "1 1", "1 4", "1 5", "2 3", "3 1", "3 2", "3 4", "4 4" ].parse.expand.solve == "0\n0\n0\n2\n4\n0\n0\n0\n0\n0" );
	assert( [ "10 10 20", "1 1", "1 4", "1 9", "2 5", "3 10", "4 2", "4 7", "5 9", "6 4", "6 6", "6 7", "7 1", "7 3", "7 7", "8 1", "8 5", "8 10", "9 2", "10 4", "10 9" ].parse.expand.solve == "4\n26\n22\n10\n2\n0\n0\n0\n0\n0" );
	assert( [ "1000000000 1000000000 0" ].parse.expand.solve == "999999996000000004\n0\n0\n0\n0\n0\n0\n0\n0\n0" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hwn = input.front.split.to!( long[] );
	auto abs = new long[ 2 ][ hwn[ 2 ] ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
	}
	return tuple( hwn[ 0 ], hwn[ 1 ], abs );
}

auto solve( long h, long w, long[ 2 ][] abs )
{
	auto cs = new long[ 2 ][ abs.length * 9 ];
	auto ci = 0L;
	foreach( ab; abs )
	{
		auto ym = min( h - 2, ab[ 0 ] );
		auto xm = min( w - 2, ab[ 1 ] );
		for( auto y = max( 1L, ab[ 0 ] - 2 ); y <= ym; y++ )
		{
			for( auto x = max( 1L, ab[ 1 ] - 2 ); x <= xm; x++ )
			{
				cs[ ci ] = [ y, x ];
				ci++;
			}
		}
	}
	cs.length = ci;
	cs.sort();
	
	auto anss = new long[ 10 ];
	anss[ 0 ] = ( h - 2 ) * ( w - 2 );
	foreach( g; cs.group )
	{
		anss[ 0 ]--;
		anss[ g[ 1 ] ]++; 
	}
	return anss.to!( string[] ).join( "\n" );
}


Measured memory_bytes: 20604
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

long power(int a, int x);

int main()
{
	long N;
	cin >> N;

	long ans;
	ans = power(N, 3);

	cout << ans << endl;

	return 0;
}

long power(int a, int x) {
	long result;
	if (x == 0) {
		return 1;
	}

	result = a * power(a, x-1);
	return result;
}

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

int main() {
int A=0;// つるの数
int X=0, Y=0;
int out=0;

cin >> X >> Y;

A = (4*X - Y)/2;

if(A<0 || A>X || ((4*X-Y)%2) !=0 ){
    out++;
}

if(out == 0){
    cout << "Yes" << endl;
}
else{
    cout << "No" << endl;
}

return 0;
}


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

using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<int>V(N);
    vector<int>C(N);
    for(int i=0;i<N;i++){
        cin>>V[i];
    }
    for(int i=0;i<N;i++){
        cin>>C[i];
    }
    vector<int> dist;
    for(int i=0;i<N;i++){
        dist.push_back(V[i]-C[i]);
    }
    int sum=0;
    for(int i=0;i<dist.size();i++){
        if(dist[i]<0) continue;
        sum+=dist[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[1000007]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
*/
using namespace std;
signed main(){
  fast;
  //usefile;
  //test
  {
    int n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    int ans=0;
    for(int i=n-1;i>=0;i--){
      if(p==2&& (s[i]-'0')%2==0)
        ans+=i+1;
    }
    
    for(int i=n-1;i>=0;i--){
      if(p==5&& (s[i]-'0')%5==0)
        ans+=i+1;
    }
    if(p==5||p==2)
      {cout<<ans<<endl;return 0;}
    vector<int> suffix(n+1);
    suffix[n]=0;
    for(int i=n-1;i>=0;i--){
      suffix[i]=suffix[i+1]+(s[i]-'0')*exp(10,n-1-i,p);
      suffix[i]%=p;
    }
    unordered_map<int,int> mp;
    mp[0]++;
    
    
    for(int i=n-1;i>=0;i--){
      ans+=mp[suffix[i]]++;
    }
    cout<<ans<<endl;

  }
  //time("");
  return 0;
}

Measured memory_bytes: 2452
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	for (int i = 0; i < 2; ++i) {
		if (i)cout << " ";
		vector<int>vs(10);
		for (int j = 0; j < 10; ++j) {
			cin >> vs[j];
		}
		sort(vs.begin(), vs.end());
		cout << vs[7] + vs[8] + vs[9];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3000
#include <cstdio>

using namespace std;

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

const int N_MAX = 9;

int N;

void solve() {
  int ans = N * N * N;
  printf("%d\n", ans);
}

void input() {
  scanf("%d", &N);
}

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


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
char ch[10005];
int a,n;
long double res;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a);
		res+=(1.0/a);
	}
	printf("%.8Lf",1.0/res);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll n,m;
  cin>>n>>m;
  ll cw=0,cc=0;
  ll b[n+1]={};
  bool a[n+1]={};
  while(m--) {
    string s;
    ll p; cin>>p>>s;
    if(s[0]=='W') {
    	if(!a[p]) ++b[p];
    }
    if(s[0]=='A') {
       a[p]=1; 
    }
  }
  for(ll i=1;i<=n;++i) {
  	if(a[i]==1) {  ++cc; cw += b[i]; }
  }
    cout<<cc<<" "<<cw;
}


Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    vector<int> rgb;
    rgb.push_back(R);
    rgb.push_back(G);
    rgb.push_back(B);
    sort(rgb.begin(), rgb.end());
    
    int count = 0;
    for(int i = 0; i <= N/rgb[0]; i++){
        int amari = N - rgb[0]*i;
        //cout << rgb[0] * i << " amari " << amari << endl;
        if(amari == 0){

            count++;
            continue;
        }
        for(int j = 0; j <= amari/rgb[1]; j++){
            int amari2 = amari - rgb[1]*j;
            //cout << rgb[0] * i << ", " << rgb[1]*j << "amari " << amari2 << endl;
            if(amari2 == 0){
                count++;
                continue;
            }
            if(amari2 < 0)continue;
            if(amari2%rgb[2] == 0)count++;
        }
    }
    cout << count;


    return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string s, t; cin >> s >> t;
    sort(ALL(s));
    sort(ALL(t), greater<>());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

int main(){
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i =0; i<N ;i++){
    cin >> h.at(i);
  }
  bool ans =true;
  for(int i=0 ;i<N-1;i++){
    if(h[N-1-i]+1 < h[N-2-i]){
      ans =false;
    }
    else if(h[N-1-i]+1 == h[N-2-i]){
      h[N-2-i] =h[N-2-i]-1;
    }
  }
  if(ans){
    cout <<"Yes"<<endl;
  }
  else{
    cout <<"No"<<endl;
  }
 
}

Measured memory_bytes: 768
#include<stdio.h>
int main(){
  int a,N; char S[N];char T[N];
  scanf("%d",&N);
scanf("%*c%1c",&S[0]);
  for(a=1;a<N;a++)
  scanf("%1c",&S[a]);
  
scanf("%*c%1c",&T[0]);
  for(a=1;a<N;a++)
  scanf("%1c",&T[a]);  
  
  for(a=0;a<N;a++){
  printf("%c",S[a]);
  printf("%c",T[a]);  }
return 0;}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long K = sc.nextLong();
		long i = 0;
		
		
		if(A >= K) {
			System.out.println(A-K + " " + B);
		}else if((A < K)&&(B > (K-A))) {
			B -= K-A;
			System.out.println(0 + " " + B);
		}else if(A+B <= K) {
			System.out.println(0 + " " + 0);
		}
	}
}

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

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

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll euclidean_gcd(ll a, ll b) {
  if(a < b) euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll a[100005];
    REP(i,n)cin >> a[i];
    sort(a,a+n);
    cout << a[n/2]-a[n/2-1] << endl;
}


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


using namespace std;

typedef long long ll;
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
    

ll a = 0, b = 0, k = 0;

int main(){
    cin >> a >> b;
    k = a*b;
    ll ans = INT_MAX, j = 0;
    j = gcd(k,gcd(a,b));
    ans = k / j;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int a, b, c, x, count = 0;
	cin >> a >> b >> c >> x;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (i * 500 + j * 100 + k * 50 == x) {
					count++;
				}
			}
		}
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
N,K=map(int,input().split())
L=factorization(K)
ans=1
for i in L:
  ans*=i[0]**(i[1]//N)
print(ans)

Measured memory_bytes: 9448
n = int(input())
alst = [int(input()) for _ in range(n)]
ans = 0
bef = 0
if alst[0] != 0:
    print(-1)
    exit()
    
for num in alst[1:]:
    if num == bef + 1:
        pass
    elif num > bef + 1:
        print(-1)
        exit()
    else:
        ans += bef
    bef = num
ans += bef
print(ans)
    

Measured memory_bytes: 18484
#include<bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
vector<string>v;
void dfs(string str,string t="",int cnt=0){
    if(cnt==2){
        v.push_back(t);
        return;
    }else{
        for(int i=0;i<str.size();i++){
            dfs(str,t+str[i],cnt+1);
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b;
    int n;
    while(cin>>n){
        if(n%2==0)cout<<(n/2)*(n/2)<<endl;
        else cout<<(n/2 +1)*(n/2)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{      
      List<string> youso = new List<string>();
      string line = "";
      while((line=Console.ReadLine()) != null)
      {
        youso.Add(line.ToString());
      }
      int indata_a = int.Parse(youso[0]);
      string indata_s = youso[1];

      string answer = "";
      if (indata_a >= 3200)
      {
        answer = indata_s;
      }
      else
      {
        answer = "red";
      }      
      Console.WriteLine(answer);        
    }
}

Measured memory_bytes: 11092
"use strict";

const main = (arg) => {
  const input = arg.trim().split("\n");
  const N = parseInt(input[0]);
  const K = parseInt(input[1]);
  const X = input[2];
  const array = X.split(" ");
  let result = 0;

  for (let i = 0; i < array.length; i++) {
    let distanceA = parseInt(array[i]) * 2;
    let distanceB = (K - parseInt(array[i])) * 2;
    if (distanceA < distanceB) {
      result += distanceA;
    } else {
      result += distanceB;
    }
  }
  console.log(result);
};
main(require("fs").readFileSync("/dev/stdin", "utf8"));
// https://atcoder.jp/contests/abc074/tasks/abc074_a


Measured memory_bytes: 13384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
	public static void main(String[] args) throws IOException{
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder sb = new StringBuilder();
			int[] counter = new int[26];
			String line; 
			//line = br.readLine();
			char ch = 'a';
			//char[] c = line.toCharArray();
			while((line = br.readLine())!=null){
				char[] c = line.toCharArray();
				for(int i = 0; i < c.length; i++){
					if( c[i] >= 'A' && c[i] <= 'z' ){
						if( Character.isUpperCase(c[i]) ){
							c[i] = Character.toLowerCase(c[i]);
						}
						int num = c[i] - 'a';
						counter[num]++;
					}
				}
			}
			
			for(int i = 0; i < counter.length; i++){
				System.out.println( ch++ + " : " + counter[i]);
			}
		}catch(IOException e){
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 24288
#include<stdio.h>
int main()
{
    int a,i,count=0;
    int b[3];
    scanf("%d",&a);
    for(i=0;a!=0;i++){
    b[i]=a%10;
    a=a/10;
    }
     for(i=0;i<3;i++){
    if(b[i]==1){
        count++;
    }
    }
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

string s[50];
bool isVisited[50][50];
int move_h[4] = {1,-1,0,0};
int move_w[4] = {0,0,1,-1};

int main() {
  int H, W; cin >> H >> W;
  rep(h,H) cin >> s[h];
  // cout << "input ok" << endl;
  
  queue<pair<P,int>> grid;
  grid.push(make_pair(make_pair(0,0), 1));

  int cost = -1;
  bool reach_end = false;
  
  while (!grid.empty() && !reach_end) {
    int temp_h = grid.front().first.first;
    int temp_w = grid.front().first.second;
    int temp_t = grid.front().second;
    // cout << temp_h << "," << temp_w << ": " << temp_t << endl;
    grid.pop();
    rep(i,4) {
      if (temp_h + move_h[i] >= 0 && temp_h + move_h[i] <= H-1 && \
          temp_w + move_w[i] >= 0 && temp_w + move_w[i] <= W-1 && \
          s[temp_h + move_h[i]][temp_w + move_w[i]] == '.' && \
          (!isVisited[temp_h + move_h[i]][temp_w + move_w[i]])) {
            if (temp_h + move_h[i] == H-1 && temp_w + move_w[i] == W-1) {
              cost = temp_t + 1;
              isVisited[H-1][W-1] = true;
              reach_end = true;
            }
            else {
              grid.push(make_pair(make_pair(temp_h + move_h[i], temp_w + move_w[i]), temp_t+1));
              isVisited[temp_h + move_h[i]][temp_w + move_w[i]] = true;
            }
      }
    }
  }
  if (cost == -1) cout << -1 << endl;
  else {
    int total_white = 0;
    rep(i,H) rep(j,W) {
      if (s[i][j]=='.') total_white++;
    }
    cout << total_white - cost << endl;
  }

  return 0;
}

Measured memory_bytes: 3184
// ~maqsat~
/*
*/

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 2e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 1e10 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

bool u[N];
int cnt[N];
vector<vector<int>> g(N);

inline void dfs(int v = 1) {
	u[v] = true;

	for(int to: g[v]) {
		if(!u[to]) {
			cnt[to] += cnt[v];
			dfs(to);
		}
	}
}

int main() {
    fre("");
    ACCELERATE;
	
	int n, q;
	cin >> n >> q;

	for(int i = 1; i < n; i++) {
		int a, b;
		cin >> a >> b;

		g[a].pb(b);
		g[b].pb(a);
	}

	while(q--) {
		int p, x;
		cin >> p >> x;

		cnt[p] += x;
	}

	dfs(1);

	for(int i = 1; i <= n; i++) cout << cnt[i] << ' ';
    return 0;
}
/*
 
*/


Measured memory_bytes: 19584
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"sync"
)

func main() {
	n := scanSplitedFloat64()
	x := scanSplitedFloat64()
	t := scanSplitedFloat64()

	totalTime := math.Ceil(n/x) * t
	fmt.Printf("%.0f\n", totalTime)
}

var once sync.Once
var scanner *bufio.Scanner

func scanSplitedFloat64() float64 {
	once.Do(func() {
		scanner = bufio.NewScanner(os.Stdin)
		scanner.Split(bufio.ScanWords)
	})
	scanner.Scan()
	val, err := strconv.ParseFloat(scanner.Text(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return val
}


Measured memory_bytes: 1836
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	ll n;
	cin >> n;
	map<int,ll> m;
	//まず2~nまで約数をmapに入れてく
	FOR(i,2,n+1){
		int sub = i;
		while (sub%2==0) {
			m[2]++;
			sub /= 2;
		}
		for(int j=3;j<=sub;j+=2){
			while(sub%j==0){
				m[j]++;
				sub /= j;
			}
		}
	}
	ll ans = 1;
	for (auto&item : m){
	//	cout << ans << " " << item.first << "  "<< item.second << endl;
		ans *= item.second + 1;
		ans %= 1000000007;
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    int N, K;
    cin >> N >> K;

    map<int, int> table;
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int A;
            cin >> A;
            table[A]++;
        }
    }

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (table.end() == table.find(i)) {
            ans++;
        }
    }

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


Measured memory_bytes: 3164
from collections import deque
h,w=map(int,input().split())
p=[list("#"*(w+2))]+[list("#"+input()+"#") for i in range(h)]+[list("#"*(w+2))]
s0,s1=1,1
g0,g1=h,w
p[s0][s1]=0
d=[(1,0),(-1,0),(0,1),(0,-1)]
q=deque([[s0,s1]])
while q:
    x,y=q.popleft()
    for dx,dy in d:
        if p[x+dx][y+dy]==".":
            p[x+dx][y+dy]=p[x][y]+1
            q.append([x+dx,y+dy])
if p[g0][g1]=='.':
    print(-1)
else:
    yy=0
    for i in range(1,h+1):
        for j in range(1,w+1):
            if p[i][j]=='#':
                yy+=1
    print(h*w-p[g0][g1]-yy-1)


Measured memory_bytes: 40688
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
    return 0;
}


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

#define endl '\n'
#define int long long
#define MAX 3000
int dp[MAX + 1][MAX + 1];
string getLCS(string &s, string &t, int len)
{
	string LCS;
	int i = 0, j = 0;
	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)
{
	//base case
	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
	{
		return dp[i][j] = max(lenLCS(s, t, i + 1, j), lenLCS(s, t, i, j + 1));
	}
}

string solve(string s, string t)
{
	memset(dp, -1, sizeof dp);
	int len = lenLCS(s, t, 0, 0);
	return getLCS(s, t,len);
}
signed main()
{
	string s, t;
	cin >> s >> t;
	cout << solve(s, t);
}

Measured memory_bytes: 74340
h,w,d=map(int,input().split())
p=[0]*(h*w+d*2)
s=[0]*(h*w+d*2)
for x in range(h):
	y=1
	for a in map(int,input().split()):
		p[a]=[x,y]
		y+=1
for i in range(1,h*w+1-d):
	s[i+d]=s[i]+abs(p[i+d][0]-p[i][0])+abs(p[i+d][1]-p[i][1])
for i in range(int(input())):
	l,r=map(int,input().split())
	print(s[r]-s[l])

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


int main()
{
	int n, i, k;
	cin >> n;
	vector<int> a(n);


	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(rbegin(a),rend(a));

	k = a[n / 2 - 1] - a[n / 2];
	cout << k << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>

using namespace std;
const double PI = (acos(-1));
const long long MOD = pow(10, 9) + 7;
long long kaizyou(int N);
long long POW(int J);

bool judge(int dt, int dx, int dy);

int main()
{
    int N;
    cin >> N;
    int t[N + 1], x[N + 1], y[N + 1];

    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for (int i = 1; i <= N; i++)
    {
        cin >> t[i] >> x[i] >> y[i];
    }

    int dt, dx, dy;
    bool result = true;
    for (int i = 0; i < N; i++)
    {
        dt = t[i + 1] - t[i];
        dx = x[i + 1] - x[i];
        dy = y[i + 1] - y[i];

        if (judge(dt, dx, dy))
        {
            continue;
        }
        else
        {
            result = false;
            break;
        }
    }

    if (result)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

bool judge(int dt, int dx, int dy)
{
    int dl = abs(dx) + abs(dy);

    if (dl <= dt && (dl % 2 == dt % 2))
    {
        //cout << "true";
        return true;
    }
    else
    {
        //cout << "false";
        return false;
    }
}


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

int main()
{
    int n, ac = 0, tle = 0, wa = 0, re = 0;
    scanf("%d", &n);
    char arr[5];
    char AC[5] = "AC", WA[5] = "WA", TLE[5] = "TLE", RE[5] = "RE";
    for(int i = 1; i <= n; i++){
        scanf("\n");
        scanf("%s", &arr);
        if (strcmp(arr, AC) == 0){
            ac++;
        }
        else if (strcmp(arr, WA) == 0){
            wa++;
        }
        else if (strcmp(arr, TLE) == 0){
            tle++;
        }
        else if (strcmp(arr, RE) == 0){
            re++;
        }
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);


    return 0;
}


Measured memory_bytes: 1736
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(long[]);

    auto ts = new int[](N);
    ts[N-1] = 2;
    foreach (i; 0..N-1) {
        if (AS[i] < AS[i+1]) {
            ts[i] = 1;
        } else if (AS[i] > AS[i+1]) {
            ts[i] = 2;
        }
    }
    long m = 1000L, a;
    foreach (i; 0..N) {
        if (ts[i] == 1) {
            auto x = m / AS[i];
            m -= x * AS[i];
            a += x;
        } else if (ts[i] == 2) {
            m += a * AS[i];
            a = 0;
        }
    }
    writeln(m);
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    cout << setprecision(20);

    ll N;
    cin >> N;
    string S;
    cin >> S;

    vll rs(N, 0), gs(N, 0), bs(N, 0);
    irep(i, N){
        rs[i] = rs[min(i+1, N-1)];
        gs[i] = gs[min(i+1, N-1)];
        bs[i] = bs[min(i+1, N-1)];
        if(S[i]=='R') ++rs[i];
        else if(S[i]=='G') ++gs[i];
        else if(S[i]=='B') ++bs[i];
    }

    ll total = 0;
    rep(i, N){
        if(S[i]=='R'){
            REP(j, i+1, N){
                if(S[j]=='G') total += bs[j] - (2*j-i<N&&S[2*j-i]=='B'? 1 : 0);
                else if(S[j]=='B') total += gs[j] - (2*j-i<N&&S[2*j-i]=='G'? 1 : 0);
            }
        }
        else if(S[i]=='G'){
            REP(j, i+1, N){
                if(S[j]=='B') total += rs[j] - (2*j-i<N&&S[2*j-i]=='R'? 1 : 0);
                else if(S[j]=='R') total += bs[j] - (2*j-i<N&&S[2*j-i]=='B'? 1 : 0);
            }
        }
        else{
            REP(j, i+1, N){
                if(S[j]=='R') total += gs[j] - (2*j-i<N&&S[2*j-i]=='G'? 1 : 0);
                else if(S[j]=='G') total += rs[j] - (2*j-i<N&&S[2*j-i]=='R'? 1 : 0);
            }
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define ll  long long int
#define PB push_back
#define M  1000000007
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define sz size()
#define endl "\n"
#define vll vector<ll>
#define vii vector<int> 
#define mll map<ll,ll>
#define frl(i,a,n) for(ll i=a;i<n;i++) 
#define cases ll t;cin>>t;while(t--)
using namespace std;
//vector<ll> adj[200005];
//vll v(200005,0);
//vector<bool> vis(200005,0);
bool isPrime(long long n) 
{
 	if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
 
    return true;
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
ll lcm(ll a,ll b)
{
	ll x=a*b;
	return (x/gcd(a,b));
}
ll logint(ll a,ll b)
{
	ll i=0;
	ll k=1;
	while(a>k)
	{
		i++;
		k=pow(b,i);
		//cout<<i<<" ";
	}
	return i-1;
}
void printDivisors(ll n, vector<ll> &v1)
{
    for (int i = 1; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            if (n / i == i)
            {
                v1.PB(i);
            }
            else
            {
                v1.PB(i);
                v1.PB(n / i);
            }
        }
    } 
}
void solve()
{
	ll n,k;cin>>n>>k;
	ll a[n];
	frl(i,0,n)
	cin>>a[i];
	vii dp(k+1,-1);
	dp[0]=0;
	for(int i=1;i<=k;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(a[j]<=i)
			{
				if(dp[i-a[j]]==0)
				{
					dp[i]=1;break;
				}
			}
		}
		if(dp[i]==-1)
		dp[i]=0;
	}
	if(dp[k])
	cout<<"First"<<endl;
	else
	cout<<"Second"<<endl;
}
	
int main ()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
//	cases
	{
		solve();
	}
}

Measured memory_bytes: 3760
#include<iostream>
#include<vector>
#include<bitset>
#define MAX_N 1001
using namespace std;
typedef unsigned long long ll;

ll a[MAX_N];
bool is_checked[1000005];
vector<ll> is_beautiful;

/*
バグの原因: a_countがKより大きい時, 1番大きい値から&していくのがよくない.
ex) K = 4の時
    110000000
     11111111
     11111111
     11111111
     11111111
    のような値が候補に出てきた場合, 上から取ってしまうため0になってしまう.
*/

int main() {
    int N, K;
    cin >> N >> K;
    a[0] = 0LL;
    ll max_a = 0LL;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for (int i = 1; i <= N; i++) {
        for (int j = i; j <= N; j++) is_beautiful.push_back(a[j] - a[i - 1]);
    }
    /*
    for (int i = 0; i < is_beautiful.size(); i++) {
        if (is_beautiful[i] > max_a) max_a = is_beautiful[i];
    }
    int bit_count = 0;
    while (max_a > 0) {
        max_a /= 2;
        bit_count++;
    }
    */
    bitset<64> bit_ans(0);
    for (int i = 60; i >= 0; i--) {
        // iはビット列の何桁目を見ているか
        int a_count = 0;
        for (int j = 0; j < is_beautiful.size(); j++) {
            if (is_checked[j]) continue;
            if (((is_beautiful[j] >> i) & 1) == 1) a_count++;
        }
        if (a_count >= K) {
            for (int j = 0; j < is_beautiful.size(); j++) {
                if (((is_beautiful[j] >> i) & 1) != 1) is_checked[j] = true;
            }
            bit_ans.set(i);
        }
    }
    ll ans = bit_ans.to_ullong();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6512
result = {
	"AC": 0,
  	"WA": 0,
    "TLE": 0,
    "RE": 0
}

n = int(input())
for i in range(n):
    s = input()
    result[s] += 1

print(f'AC x {result["AC"]}')
print(f'WA x {result["WA"]}')
print(f'TLE x {result["TLE"]}')
print(f'RE x {result["RE"]}')


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  int n;
  cin >> n;
  set<string> pq;
  string t;
  for(int i = 0 ; i < n; i ++ ){
    cin >> t;
    pq.insert(t);
  }
  cout << pq.size() << "\n";
  return 0;
}

Measured memory_bytes: 19252
#include <iostream>
#include <algorithm>

using namespace std;

bool check(int x) {
    int n[3];
    for (int i = 0; i < 3; i++) {
        n[i] = x % 10;
        x /= 10;
    }
    return n[0] == n[1] && n[1] == n[2];
}

int main() {
    int x;
    cin >> x;
    for (int i = x; i <= 999; i++) {
        if (!check(i)) continue;
        cout << i << endl;
        break;
    }
}

Measured memory_bytes: 256
'use strict';
(function(stdin) {
    var inputs = stdin.toString();
    var params = inputs.split('\n')[0].split(' ').map(Number);
    (function(W, H, x, y, r) {
        if (W >= x + r && H >= y + r && 0 <= x - r && 0 <= y - r) {
            console.log('Yes');
        } else  {
            console.log('No');
        }

    }(params[0], params[1], params[2], params[3], params[4]));
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7380
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int a;
  cin>>a;
  vector<string> b(a),g(a);
  vector<pair<int,string>> c(a);
  rep(i,a)
    cin>>b[i];
  sort(all(b));
  b.push_back(" ");
  int d=0;
  int f=0;
  rep(i,a){
    d++;
    if(b[i]!=b[i+1]){
    c[f].second=b[i];
    c[f].first=d;
    f++;
  d=0;
  }
  }
  sort(all(c));
  reverse(all(c));
  int e=c[0].first;
  int t=0;
  rep(i,a){
    if(c[i].first==e)
     g[t]=c[i].second;
      t++;
      }
  sort(all(g));
  rep(i,t){
    if(g[i]!="")
  cout<<g[i]<<endl;
    }
}

Measured memory_bytes: 20992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	int p[A], q[B], r[C];
	for(int i = 0; i < A; i++) cin >> p[i];
	for(int i = 0; i < B; i++) cin >> q[i];
	for(int i = 0; i < C; i++) cin >> r[i];

	sort(p, p + A, greater<int>());
	sort(q, q + B, greater<int>());
	sort(r, r + C, greater<int>());

	vector<int> v;
	for(int i = 0; i < X; i++) v.push_back(p[i]);
	for(int i = 0; i < Y; i++) v.push_back(q[i]);
	for(int i = 0; i < C; i++) v.push_back(r[i]);
	sort(v.begin(), v.end(), greater<int>());

	ll ans = 0;
	for(int i = 0; i < X + Y; i++) ans += v[i];

	cout << ans;
	return 0;
}


Measured memory_bytes: 6436
n,m,c = map(int, input().split())
bl = list(map(int, input().split()))
cnt = 0

for i in range(n):
    r = c
    al = list(map(int, input().split()))
    for j in range(m):
        r+= bl[j]*al[j]
    if r>0:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int ans = 0;
    string S;
    cin >> S;
    for (int i = 0; i < S.size() - 1; i++) {
        if (S.at(i) != S.at(i + 1)) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

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

  map<pair<int, int>, int> cnt;
  REP(i, N) {
    REP(j, N) {
      if (i == j) continue;
      cnt[make_pair(x[i]-x[j], y[i]-y[j])]++;
    }
  }

  int m = 1;
  for (auto v : cnt) {
    m = max(m, v.second);
  }

  cout << max(N-m, 1) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
const int MAX_V=500000;
typedef long long ll;
int n,op[MAX_V][2];
ll s[MAX_V],ns[MAX_V],num[MAX_V],d[MAX_V];
void calc(int v){
	int a=op[v][0],b=op[v][1];
	num[v]=num[a]+num[b];
	ns[v]=ns[a]+ns[b]+num[v];
	s[v]=min(ns[v],1+s[a]+d[v]+1+s[b]);
	s[v]=min(s[v],ns[a]+num[a]+1+s[b]);
	s[v]=min(s[v],ns[b]+num[b]+1+s[a]);
}
int main(){
	cin>>n;
	rep(i,n-1){
		scanf("%d%d",&op[i][0],&op[i][1]);
		op[i][0]--,op[i][1]--;
		d[op[i][0]]=d[i]+1;
		d[op[i][1]]=d[i]+1;
	}
	num[n-1]=1;
	s[n-1]=0;
	ns[n-1]=0;
	for(int i=n-2;i>=0;i--) calc(i);
	cout<<min(s[0],ns[0])<<endl;
}

Measured memory_bytes: 20764