akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int main(void){
    
    //入力
    int N;
    cin >> N;
    int mountains[N];
    for (int i = 0; i < N; i++) cin >> mountains[i];
    
    //海を見られる旅館の数をかぞえる
    int tallest_mountain = mountains[0];
    int ans = 1;
    for (int i = 1; i < N; i++){
        if (mountains[i] >= tallest_mountain) {
            ans++;
            tallest_mountain = mountains[i];
        }    
    }
    
    //出力
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static boolean[][] black;
	static int[][] count;
	static int W, H;

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);

		while (true) {
			W = s.nextInt();
			H = s.nextInt();

			if (W == 0 && H == 0)
				break;

			char[][] field = new char[H][W];
			black = new boolean[H][W];
			count = new int[H][W];

			for (int i = 0; i < H; i++) {
				String str = s.next();
				field[i] = str.toCharArray();
			}

			int x = 0, y = 0;

			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (field[i][j] == '.')
						black[i][j] = true;
					else if (field[i][j] == '@') {
						black[i][j] = true;
						x = j;
						y = i;
					} else
						black[i][j] = false;
				}
			}

			Search(x, y);

			// for (int i = 0; i < H; i++) {
			// for (int j = 0; j < W; j++) {
			// // System.out.print(field[i][j]);
			// System.out.print(black[i][j]);
			// }
			// System.out.println();
			// }

			int ans = 0;

			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					ans += count[i][j];
				}
			}

			System.out.println(ans);

		}
		s.close();
	}

	public static void Search(int x, int y) {
		int[] dx = { 1, 0, -1, 0 };
		int[] dy = { 0, 1, 0, -1 };

		black[y][x] = false;
		count[y][x] = 1;

		for (int i = 0; i < dx.length; i++) {
			int sx = x + dx[i];
			int sy = y + dy[i];

			if (sx < W && sy < H && sx >= 0 && sy >= 0)
				if (black[sy][sx])
					Search(sx, sy);
		}
	}
}

Measured memory_bytes: 29340
#include <stdio.h>

int main(void) {
	char string[21];
	int num_s;
	
	scanf("%s", string);
	
	for (num_s = 0; string[num_s] != '\0'; num_s++);
	for (; num_s > 0; num_s--) printf("%c", string[num_s - 1]);
	
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define INF 0x3f3f3f3f3f3f3f3f
#define LL long long
#define MX 55
struct Node
{
    LL x, y;
    bool operator < (const Node &b)const{
        return x<b.x;
    }
}pt[MX];

int k, n;

bool check(LL xa ,LL xb ,LL ya, LL yb,int p)
{
    if (pt[p].x>=xa&&pt[p].x<=xb&&
        pt[p].y>=ya&&pt[p].y<=yb) return 1;
    return 0;
}

LL func(int u, int v)
{
    LL res = INF;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=n;j++)
        {
            LL minx = min( min( min(pt[u].x,pt[v].x), pt[i].x) ,pt[j].x);
            LL maxx = max( max( max(pt[u].x,pt[v].x), pt[i].x) ,pt[j].x);
            LL miny = min( min( min(pt[u].y,pt[v].y), pt[i].y) ,pt[j].y);
            LL maxy = max( max( max(pt[u].y,pt[v].y), pt[i].y) ,pt[j].y);
            int tot = 0;
            for (int z=1;z<=n;z++)
            {
                if (check(minx,maxx,miny,maxy,z)) tot++;
            }
            if (tot>=k)
                res = min(res, (maxy-miny)*(maxx-minx));
        }
    }
    return res;
}

int main()
{
    scanf("%d%d",&n,&k);
    for (int i=1;i<=n;i++)
    {
        scanf("%lld%lld",&pt[i].x, &pt[i].y);
    }
    sort(pt+1,pt+1+n);
    LL area = INF;
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
        {
            if (j==i) continue;
            area = min(area, func(i,j));
        }
    printf("%lld\n",area);
    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc137/tasks/abc137_a
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
// clang-format on
int main()
{
    int A, B;
    cin >> A >> B;
    cout << max({A + B, A - B, A * B}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main(){
    int S;
    cin >> S;
    int h = S/3600;
    int S1 = S % 3600;
    int m = S1/60;
    int s = S1 % 60;
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3088
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

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

            double a = int.Parse (str[0]);
            double b = int.Parse (str[1]);

            int d = (int) (a / b);
            int r = (int) (a % b);
            double f = a / b;

            Console.WriteLine ("{0} {1} {2:0.########}", d, r, f);

        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}


Measured memory_bytes: 17944
#include <iostream>
 
using namespace std;
 
int main()
{
    long long n, W, w[105], v[105];
  long double xd[100000],xd1[100000],xd2[100000],xd3[100000];
    cin>>n>>W;
    for(int i=0; i<n; i++){
      cin>>w[i]>>v[i];
    }
       long long dp[n+1][W+1];
       for(int i=0; i<=W; i++){
         dp[0][i]=0;
       }
       for(int i=0; i<=n; i++){
           for(int j=0; j<=W; j++){
               if((i==0)||(j==0)){
                   dp[i][j]=0;
               }else if(w[i-1]<=j){
                     dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1], dp[i-1][j]);
                     //cout<<dp[i-1][j-w[i-1]]+v[i-1]<<'\n';
               }else{
                     dp[i][j]=dp[i-1][j];
                   }
           }
       }
// for(int i=0; i<=n; i++){
//   for(int j=0; j<=W; j++){
//     cout<<dp[i][j]<<" ";
//   }
//   cout<<'\n';
// }
  // for(int i=0; i<=n; i++){
//   for(int j=0; j<=W; j++){
//     cout<<dp[i][j]<<" ";
//   }
//   cout<<'\n';
// }
  // for(int i=0; i<=n; i++){
//   for(int j=0; j<=W; j++){
//     cout<<dp[i][j]<<" ";
//   }
//   cout<<'\n';
// }
  // for(int i=0; i<=n; i++){
//   for(int j=0; j<=W; j++){
//     cout<<dp[i][j]<<" ";
//   }
//   cout<<'\n';
// }
  // for(int i=0; i<=n; i++){
//   for(int j=0; j<=W; j++){
//     cout<<dp[i][j]<<" ";
//   }
//   cout<<'\n';
// }
  // for(int i=0; i<=n; i++){
//   for(int j=0; j<=W; j++){
//     cout<<dp[i][j]<<" ";
//   }
//   cout<<'\n';
// }
  // for(int i=0; i<=n; i++){
//   for(int j=0; j<=W; j++){
//     cout<<dp[i][j]<<" ";
//   }
//   cout<<'\n';
// }
  // for(int i=0; i<=n; i++){
//   for(int j=0; j<=W; j++){
//     cout<<dp[i][j]<<" ";
//   }
//   cout<<'\n';
// }
  // for(int i=0; i<=n; i++){
//   for(int j=0; j<=W; j++){
//     cout<<dp[i][j]<<" ";
//   }
//   cout<<'\n';
// }
  // for(int i=0; i<=n; i++){
//   for(int j=0; j<=W; j++){
//     cout<<dp[i][j]<<" ";
//   }
//   cout<<'\n';
// }
       cout<<dp[n][W];
    return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define in(_n) int _n; cin >> _n
using namespace std;

const int mod = 1e9+7;
long long modPow(long long a, int p){
    if (p == 0) return 1;
    if (p%2 == 0) {
        long long half = modPow(a, p/2);
        return half * half % mod;
    }
    else return a * modPow(a, p-1) % mod;
}
long long cmb(int n, int r) {
    r = min(r, n-r);
    long long tmpM = 1, tmpD = 1;
    for (int i = 0; i<r; i++) {
        tmpM *= n-i;
        tmpD *= i+1;
        tmpM %= mod;
        tmpD %= mod;
    }
    return tmpM * modPow(tmpD, mod-2) % mod;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    in(X); in(Y);
    if (X > Y) {
        swap(X, Y);
    }
    int dif = Y-X;
    if (X-dif >= 0 && (X-dif) % 3 == 0) {
        printf("%lld\n", cmb(dif+(X-dif)/3*2, (X-dif)/3));
    } else {
        puts("0");
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<map>
using namespace std;
char a[105],b[105],c[105][105];
map<string,int>dis1;
map<string,int>dis2;
int main(){
	int n,m,Max;
	Max=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%s",a+1);
		for(int j=1;j<=strlen(a+1);j++){
			c[i][j]=a[j];
		}
		dis1[a+1]++;
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++){
		scanf("%s",b+1);
		dis2[b+1]++;
	}
	for(int i=1;i<=m;i++){
		if(dis1[c[i]+1]-dis2[c[i]+1]>Max) Max=dis1[c[i]+1]-dis2[c[i]+1];
	}
	if(Max>=0) printf("%d\n",Max);
	else printf("0\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> number(8);
    number[0] = 1;
    number[1] = 2;
    number[2] = 4;
    number[3] = 8;
    number[4] = 16;
    number[5] = 32;
    number[6] = 64;
    number[7] = 128;
    rep(i,8){
        if (N < number[i]){
            cout << number[i - 1] << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  int k = sc.nextInt();
	  int[] h = new int[n];
	  for(int i=0;i<n;i++)h[i]=sc.nextInt();
	  
	  int sum = 0;
	  for(int i=0;i<n;i++)if(h[i]>=k)sum++;
	  
	  System.out.println(sum);
	}
}

Measured memory_bytes: 47700
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInts >>= putStrLn . which "Yes" "No" . ( == 1 ) . length . group

Measured memory_bytes: 380
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,C,K;
int A[100010];

signed main(){
	cin>>N>>C>>K;
	REP(i,N){
		cin>>A[i];
	}
	sort(A,A+N);
	int l=A[0],r=1;
	int ans=0;
	for(int i=1;i<N;i++){
		if(A[i]<=l+K&&r+1<=C){
			r++;
		}
		else{
			l=A[i];
			r=1;
			ans++;
		}
	}
	ans++;
	cout<<ans<<endl;
	return 0;
}


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

int main(){
	ll a,b,ans=0;
	cin>>a>>b;
	if(a==1){
		if(b==1)ans=1000000;
		if(b==2)ans=500000;
		if(b==3)ans=400000;
		if(b>3)ans=300000;
	}
	if(a==2){
		if(b==1)ans=500000;
		if(b==2)ans=400000;
		if(b==3)ans=300000;
		if(b>3)ans=200000;
	}
	if(a==3){
		if(b==1)ans=400000;
		if(b==2)ans=300000;
		if(b==3)ans=200000;
		if(b>3)ans=100000;
	}
	if(a>3){
		if(b==1)ans=300000;
		if(b==2)ans=200000;
		if(b==3)ans=100000;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
//JSD
#include<iostream>
#define ll long long 
#include<vector>
#include<map>
#include<set>
#include<algorithm>
using namespace std;
int main(){
	int m,d;
	cin>>m>>d;
	ll count=0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			if(j%10>=2 && (j/10)>=2){
				if((j%10)*(j/10)==(i)) count++;
			}
		}
	}
	cout<<count;
	return 0;
}


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


ll f(ll n) {
    ll ans = 0;
    while(n) {
        ans += n / 5;
        n /= 5;
    }
    return ans;
}


int main() {
    ll n;
    cin >> n;
    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    cout << f(n / 2) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int data[5];

void sort(int,int);
void change(int,int);
int pair();
int three();
int four();
int straight();

main(){
  int i;
  
  while(1){
    if(scanf("%d", &data[0])==EOF) break;
    for(i=1;i<5;i++){
      scanf(",%d", &data[i]);
    }
    sort(0,4);
    
    if(straight()==1) printf("straight\n");
    else if(four()==1) printf("four card\n");
    else if(pair()==2) printf("two pair\n");
    else if(three()==1){
      if(pair()==1) printf("full house\n");
      else printf("three card\n");
    }
    else if(pair()==1) printf("one pair\n");
    else printf("null\n");
  }
  return 0;
}

void sort(int left, int right){
  int i, j, n;

  i=left;
  j=right;
  n=data[(left+right)/2];

  while(1){
    while(n>data[i]) i++;
    while(n<data[j]) j--;

    if(i>=j) break;

    change(i,j);
    i++;
    j--;
  }

  if(left<i-1) sort(left,i-1);
  if(j+1<right) sort(j+1,right);
}

void change(int a, int b){
  int temp;

  temp=data[a];
  data[a]=data[b];
  data[b]=temp;
}

int pair(){
  int i, count=0;

  for(i=0;i<4;i++){
    if(data[i]==data[i+1]){
      if(i<3){
	if(data[i+1]!=data[i+2]) count++;
      }
      else count++;
      i++;
    }
  }
  if(count==1) return 1;
  else if(count==2) return 2;
  else return 0;
}

int three(){
  int i, count=0;

  for(i=0;i<3;i++){
    if(data[i]==data[i+1] && data[i+1]==data[i+2]) count++;
  }
  return count;
}

int four(){
  int i, count=0;

  for(i=0;i<2;i++){
    if(data[i]==data[i+1] && data[i+1]==data[i+2] && data[i+2]==data[i+3]) count++;
  }
  return count;
}

int straight(){
  int i;

  if(data[0]==1 && data[1]==10 && data[2]==11 && data[3]==12 && data[4]==13) return 1;
  for(i=0;i<4;i++){
    if((data[i+1]-data[i]==1)!=1) return 0;
  }
  return 1;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int preW[300001];
int sufE[300001];
string s;
int N;

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>N>>s;
  for (int i=0;i<N;i++){
    if (s[i]=='W')
      preW[i]++;
    if (i!=0)
      preW[i]+=preW[i-1];
  }
  for (int i=N-1;i>=0;i--){
    if (s[i]=='E')
      sufE[i]++;
    if (i!=N-1)
      sufE[i]+=sufE[i+1];
  }
  int mn=2001001001;
  for (int i=0;i<N;i++)
    mn=min(mn,preW[i]+sufE[i]-1);
  cout<<mn<<endl;
  return 0;
}


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    lli n;
    cin1(n);
    lli a[n];
    ncin1(n, a);

    sort_r(a, a+n);
    lli ans = 0;
    REP(i, 0, n) {
        if (i % 2 == 0)
            ans += a[i];
        else
            ans -= a[i];
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

template<class T>
struct BellmanFord {
private:
    struct Edge { int from, to, cost; };
    vector<Edge> edges;
    int n;
    
public:
    const T inf = numeric_limits<T>::max() / 2 - 1;
    vector<T> dist;
    vector<bool> negative;
    
    BellmanFord() {}
    BellmanFord(int _n) {
        n = _n;
        dist.resize(n);
        negative.resize(n);
    }
    
    void add_edge(int from, int to, int cost) {
        edges.push_back((Edge){from, to, cost});
    }
    
    void get_distance(int from) {
        for (int i = 0; i < n; i++) {
            dist[i] = inf;
            negative[i] = false;
        }
        dist[from] = 0;
        for (int i = 0; i < (n - 1); i++) {
            bool update = false;
            for (auto e : edges) {
                if ((dist[e.from] != inf) && (dist[e.to] > (dist[e.from] + e.cost))) {
                    dist[e.to] = dist[e.from] + e.cost;
                    update = true;
                }
            }
            if (!update) break;
        }
        for (int i = 0; i < n; i++) {
            for (auto e : edges) {
                if ((dist[e.from] != inf) && (dist[e.to] > (dist[e.from] + e.cost))) {
                    dist[e.to] = dist[e.from] + e.cost;
                    negative[e.from] = negative[e.to] = true;
                }
            }
        }
    }
    
    bool find_negative_loop() {
        vector<T> d(n, 0);
        for (int i = 0; i < n; i++) {
            for (int j = 0, el = sz(edges); j < el; j++) {
                Edge e = edges[j];
                if (d[e.to] > (d[e.from] + e.cost)) {
                    d[e.to] = d[e.from] + e.cost;
                    if (i == (n - 1)) return true;
                }
            }
        }
        return false;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    BellmanFord<ll> bf(n);
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        bf.add_edge(a, b, -c);
    }
    bf.get_distance(0);
    if (bf.negative[n - 1]) {
        cout << "inf" << endl;
    }
    else {
        cout << (-bf.dist[n - 1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int x, sum;
	char a[1001];
	
	while(1){
		scanf("%s", a);
		for(x = 0, sum = 0; a[x] != 0x00; x++){
			sum += (a[x] - '0');
		}
		if(sum == 0) break;
		printf("%d\n", sum);
	}
	
	return(0);
}



Measured memory_bytes: 1848
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, H);
    IN(ll, W);
    IN(ll, K);
    AIN(string, c, H);
    ll ans = 0;
    REP(p, 1 << H)
    {
        REP(q, 1 << W)
        {
            ll s = 0;
            REP(i, H)
            {
                REP(j, W)
                {
                    if (c[i][j] == '#' and (((p >> i) & 1) == 0) and (((q >> j) & 1) == 0))
                    {
                        ++s;
                    }
                }
            }
            if (s == K)
            {
                ++ans;
            }
        }
    }
    OUT(ans);
}

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

using namespace std;

long long N;

vector<long long> Primes;
vector<bool>  E;



int main(void)
{
	long long tmp, count = 0, ans = 0;
	vector<pair<long long, long long> > Z;

	cin >> N;

	if (N == 1) {
		cout << 0 << endl;
		return 0;
	}

	tmp = N;
	for (long long i = 2; i <= sqrt(N); i++) {
		count = 0;

		while (N%i == 0) {
			count++;
			N = N / i;
		}

		if(count >0)Z.push_back(make_pair(i, count));
	}
	if (N > 1) {
		Z.push_back(make_pair(N, 1));
	}

	if (Z.size() == 0) {
		cout << 1 << endl;
		return 0;
	}

	for (long long i = 0; i < Z.size(); i++) {
		long long j = 1;
		tmp = Z[i].second;
		while (tmp >= j) {
			ans++;
			tmp = tmp - j;
			j++;
		}
	}

	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

vector<pair<char,int>> runLength(string s) {
  int n = sz(s);
  vector<pair<char,int>> res;
  rep(i,n) {
    int cnt = 1;
    while(i < n-1 && s[i] == s[i+1]) {
      cnt++;
      i++;
    }
    res.push_back(pair<char,int>(s[i],cnt));
  }
  return res;
}
  
int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  vector<pair<char,int>> ans = runLength(s);
  cout << sz(ans) << endl;
  return 0;
}

Measured memory_bytes: 1656
import java.util.Scanner;

public class Main {

    public static void main( String[] args ){

        Scanner in = new Scanner(System.in);

        String[] params = in.nextLine().split(" ");
        int n = Integer.parseInt(params[0]);
        int x = Integer.parseInt(params[1]);
        params = in.nextLine().split(" ");
        int[] ls = new int[n];
        for( int i = 0 ; i < n ; i++ ){
            ls[i] = Integer.parseInt( params[i]);
        }

        int count = 1;
        int totalD = 0;
        for( int i = 0 ; i < n && totalD <= x ; i++ ){
            if( ls[i] + totalD <= x ){
                totalD += ls[i];
                count++;
            }
            else {
                break;
            }
        }

        System.out.println(count);

    }
}

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

ll A, B;

ll func(ll x){
    return floor(A*x/B) - A * floor(x/B);
}

int main(){
    ll N; cin >> A >> B >> N;
    double ok = min(N+1, B);
    double ng = 0;
    for (int i = 0; i < 10000; i++)
    {
        double mid = (ng + ok)/2.;
        double mid1 = (ng * 2 + ok)/3;
        double mid2 = (ng + ok * 2)/3;
        if(func(mid1)>=func(mid2)) ok = mid;
        else ng = mid;
    }

    ll ans = 0;
    for (ll i = max(0LL, (ll)ok-10000000), M = min((ll)ok+10000000, N); i <= M; i++)
    {
        ans = max(ans, (ll)(A*i/B) - A * (ll)(i/B));
    }
    
    cout << ans  << endl;
}

Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int a = 0, b = 0;

		try {
			String[] s = scanner.nextLine().split(" ");
			a = Integer.parseInt(s[0]);
			b = Integer.parseInt(s[1]);
		} catch (NumberFormatException e) {
		} catch (NullPointerException e) {
		}

		scanner.close();
		
		if (((a - b) % 2) != 0) {
			System.out.println("IMPOSSIBLE");
		} else {
		 	int v = Math.abs (a - b) / 2;
		 	
		 	int ret;
		 	if (a > b) {
		 		ret = b + v;
		 	} else {
		 		ret = a + v;
		 	}
		 	System.out.println(ret);
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;

  vector<int> p(n);
  for(int i=0; i<n; i++) {
    cin >> p[i];
  }
  vector<int> q(n);
  for(int i=0; i<n; i++) {
    cin >> q[i];
  }
  vector<int> start, end;
  if(compare_array(p, q) > 0) {
    start = q;
    end = p;
  }
  else {
    start = p;
    end = q;
  }

  int ans = 0;
  while(compare_array(start, end) != 0) {
    next_permutation(start.begin(), start.end());
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<array>
#include<string>

int main() {
	int a, b;
	std::cin >> a >> b;
	if (a<=9&&b<=9) {
		std::cout<<a*b<<std::endl;

	}
	else {
		std::cout<<-1<<std::endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        int[] ai = new int[n];
        for(int i = 0;i < n;i++)    ai[i] = sc.nextInt();
        int id = 0;
        for(int i = 0;i < n;i++){
            if(i == 0)  System.out.print(ai[n-1]);
            else if(i < (n+1)/2)    System.out.print(" "+ai[n-1-2*i]);
            else if(i == (n+1)/2){
                if(n%2 == 0)    System.out.print(" "+ai[0]);
                else    System.out.print(" "+ai[1]);
            }
            else{
                if(n%2 == 0)    System.out.print(" "+ai[(i-(n+1)/2)*2]);
                else    System.out.print(" "+ai[(i-(n+1)/2)*2+1]);
            }
        }
    }
}

Measured memory_bytes: 89520
import sys
from copy import deepcopy
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row_list(N): return [i_list() for _ in range(N)]
sys.setrecursionlimit(10 ** 6)
INF = float('inf')

def main():
    d = i_input()
    c_list = i_list()
    s_list = i_row_list(d)

    output_list = []

    last_list = [0] * 26

    for day in range(1,d+1):
        result = 0
        max_point = -INF
        for i in range(26):
            plus_point = s_list[day-1][i]
            minus_point = 0
            for j in range(26):
                if i == j:
                    continue
                minus_point += c_list[j] * (day - last_list[j])
            sum_point = plus_point - minus_point

            if day != d:
                last_list2 = deepcopy(last_list)
                last_list2[i] = day
                result2 = 0
                max_point2 = -INF
                for k in range(26):
                    plus_point2 = s_list[day][k]
                    minus_point2 = 0
                    for h in range(26):
                        if k == h:
                            continue
                        minus_point2 = c_list[h] * (day+1 - last_list2[h])
                    sum_point2 = plus_point2 - minus_point2

                    if day != d-1:
                        last_list3 = deepcopy(last_list2)
                        last_list3[k] = day + 1
                        result3 = 0
                        max_point3 = -INF
                        for l in range(12):
                            plus_point3 = s_list[day+1][l]
                            minus_point3 = 0
                            for m in range(26):
                                if l == m:
                                    continue
                                minus_point3 = c_list[m] * (day+2 - last_list3[m])
                            sum_point3 = plus_point3 - minus_point3
                        if sum_point3 > max_point3:
                            result3 = l + 1
                            max_point3 = sum_point3
                        last_list3[result3-1] = day + 2
                    else:
                        max_point3 = 0

                    if sum_point2 + max_point3 > max_point2:
                        result2 = k + 1
                        max_point2 = sum_point2 + max_point3
                    last_list2[result2-1] = day + 1
            else:
                max_point2 = 0

            if sum_point + max_point2 > max_point:
                result = i + 1
                max_point = sum_point + max_point2
        output_list.append(result)
        last_list[result-1] = day

    for out in output_list:
        print(out)

if __name__ == '__main__':
    main()


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

using namespace std;

#define ios         ios_base::sync_with_stdio(false);
#define ll          long long
#define ld          long double
#define db(x)       cout << "[" << #x << ": " << (x) << "]\n"
#define db2(x,y)    cout << "[" << #x << ": " << (x) << "]  [" << #y << ": " << (y) << "]\n"
#define db3(x,y,z)  cout << "[" << #x << ": " << (x) << "]  [" << #y << ": " << (y) << "]  [" << #z << ": " << (z) << "]\n"
#define cn          107
#define sn          1007
#define bn          200007
#define M           1000000007
#define inf         LLONG_MAX



int main()
{
        ios;
        bool x; cin >> x; cout << !x;
}




Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int n;


int main()
{
  string s;
  cin >> s;
  for (int i = 0; i < 4; ++i) 
  cout << s[i];
  cout <<  " ";
  for (int i = 4; i < 12; ++i)
  cout << s[i];
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define PI 3.141592

using namespace std;

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

const int N=1e5+5,mod=1000000007;
ll n,a[N],s;
int main() { 
	cin.tie(0); cout.tie(0); 
	ios_base::sync_with_stdio();
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	s=1;
	ll aux=1000000000000000000ll;
	for (int i=0;i<n;i++) if (a[i]==0) { cout<<0; return 0; }
	for (int i=0;i<n;i++) {
		if (a[i]>aux/s) { cout<<-1; return 0; }
		else s*=a[i];
	}
	cout<<s;
	return 0;
}
// Recuerda limites 
// Recuerda casos especiales


Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n,a[101];
    string s[101];
    vector<pair<string,int>> A;
    cin>>n;
    rep(i,n) cin>>s[i]>>a[i],A.push_back(make_pair(s[i],-a[i]));
    sort(A.begin(),A.end());
    rep(i,n)rep(j,n) if(A[i].first==s[j]&&A[i].second==-a[j]) cout<<j+1<<endl;
}

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

const int N =1e5+5;
int n, a[N], b[N];
int64_t ans;

int main()
{
    cin >> n;
    for(int i=1; i<=n+1; ++i) scanf("%d",a+i);
    for(int i=1; i<=n  ; ++i) scanf("%d",b+i);
    for(int i=1; i<=n; ++i) for(int j=0; j<=1; ++j){
        int tmp = min(a[i+j], b[i]);
        a[i+j] -= tmp; b[i] -= tmp;
        ans += tmp;
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define lp(x,y) for(ll i=x;i<y;i++)
#define pb push_back
 
 
  
// Driver code 
int main() 
{ 
    int x,n;
    cin>>x>>n;
    int arr[n],ar[101]={0};
    if(n!=0)
    {
    lp(0,n) {cin>>arr[i]; ar[arr[i]]++;}
    }
    
    sort(arr,arr+n);
    if(ar[x]==0) cout<<x;
    else
    {
        int j=1;
        for(int i=x;i<=100;i++)
        {
            if(ar[x-j]==0) {cout<<x-j; break;}
            else if(ar[x+j]==0) { cout<<x+j; break;}
            j++;
        }
    }
    
} 

Measured memory_bytes: 3624
n, m = map(int, input().split())
s = input()
a = []
for i in range(n):
    if i == 0 or s[i] != s[i - 1]:
        a.append(1)
    else:
        a[len(a) - 1] += 1
for i in range(1, len(a)):
    a[i] += a[i - 1]
cur = int(s[0])
ans = 0
for i in range(len(a)):
    tmp = a[i]
    if cur:
        if i > 2 * m:
            tmp -= a[i - 2 * m - 1]
    else:
        if i > 2 * m - 1:
            tmp -= a[i - 2 * m]
    ans = max(ans, tmp)
    cur = 1 - cur
print(ans)


Measured memory_bytes: 7164
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=200010;
int n,a[N],b[N];
ll ans;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]>i){printf("-1");return 0;}
		b[i]=i-a[i];
	}
	for(int i=0;i<n-1;i++) if(b[i]>b[i+1]){printf("-1");return 0;}
	for(int i=0;i<n;i++){
		while(b[i]==b[i+1]&&i<n-1) i++;
		ans+=a[i];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N;
    string S;
    cin >> N >> S;
    int maxi = 0;
    REPS(i,N-1){
        string inter = "";
        string ea = S.substr(0,i);
        string eb = S.substr(i);
        sort(ALL(ea));
        sort(ALL(eb));
        set_intersection(ALL(eb),ALL(ea),inserter(inter,inter.end()));
        UNIQUE(inter);
        int size = inter.size();
        chmax(maxi,size);
    }
    cout << maxi << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
const int INF = 1<<30;
const int N_MAX = 1000000;

int dp[N_MAX];
int dpOdd[N_MAX];

int main() {
	rep(i,N_MAX) {
		dp[i] = INF;
		dpOdd[i] = INF;
	}
	dp[0] = dpOdd[0] = 0;
	int n=1;
	while(n*(n+1)*(n+2)/6 < N_MAX) {
		int v = n*(n+1)*(n+2)/6;
		for(int i=v; i<N_MAX; i++) {
			dp[i] = min( dp[i], dp[i-v]+1 );
		}
		n++;
	}
	n=1;
	while(n*(n+1)*(n+2)/6 < N_MAX) {
		int v = n*(n+1)*(n+2)/6;
		for(int i=v; i<N_MAX; i++) {
			dpOdd[i] = min( dpOdd[i], dpOdd[i-v]+1 );
		}
		do{ n++; } while((n*(n+1)*(n+2)/6)%2==0);
	}
	while(cin >> n, n) {
		cout << dp[n] << ' ' << dpOdd[n] << endl;
	}
	return 0;
}

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

inline void read(int&x){
	char c11=getchar();x=0;while(!isdigit(c11))c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();
}

const int N=501000;
int ps[N],lim[N],d[N];
int n,Q,x;

int main(){
	read(n);read(ps[0]);
	for(int i=1;i<=n;++i)
		read(d[i]),ps[i]=std::min(ps[i-1],abs(ps[i-1]-d[i]));
	lim[n+1]=1;
	for(int i=n;i;--i)
		if((lim[i+1]<<1)<=d[i])lim[i]=lim[i+1];
		else lim[i]=std::min((int)2e9,lim[i+1]+d[i]);
	read(Q);while(Q--){
		read(x);
		puts(ps[x-1]>=lim[x+1]?"YES":"NO");
	}return 0;
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

const ll mod=1e9+7;
ll qmi(ll a,ll b,ll mod){
    ll res=1;
    while(b){
        if(b&1) res=res*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return res;
}
int main(){
    ll n;
    scanf("%lld",&n);
    if(n==1) printf("0");
    else {
        ll ans=1;
        ans=((qmi(10,n,mod)-2*qmi(9,n,mod)%mod+qmi(8,n,mod))%mod+mod)%mod;
        printf("%lld",ans);
    }
}


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

using namespace std;

const long long int INF = 1LL<<60;
const long long int mod = 1e9+7;

int solve(vector<int> &dp, vector<int> &a, int K) {
  if(dp[K] >=0 ) return dp[K];

  int result;
  for(int i=0; i<a.size(); i++) {
    if(a[i] <= K) {
      result = solve(dp, a, K-a[i]);
      if(result == 0){
        return dp[K] = 1;
      }
    }
  }

  return dp[K] = 0;
}

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

  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }

  vector<int> dp(K+1, -1);
  for(int i=0; i<a[0]; i++) {
    dp[i] = 0;
  }

  solve(dp, a, K);

  if(dp[K]) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }

  return 0;
}

Measured memory_bytes: 6912
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
void slove(int question_num)
{
    while(question_num--)
    {
        unsigned long long n,ans=9999999999999999;cin>>n;
        for(unsigned long long i=1;i<=sqrt(n);i++)
        {
            if(n%i==0)
            {
                ans=min(ans,i+n/i-2);
            }
        }
        cout<<ans<<endl;
    }
}
int main()
{
//    int t;cin>>t;
    slove(1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int count[4][3][10] = { {{}} };
	int b, f, r, v;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		count[b - 1][f - 1][r - 1] += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " ";
				cout << count[i][j][k];
			}
			cout << endl;
		}
		if (i < 3) cout << "####################" << endl;
	}
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
ll mod= 1e9 + 7;



int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n){
    cin>>a[i];
    if(a[i]==0){cout << 0 << endl; return 0;}}
  ll k=1000000000000000000;
  rep(i,n){
    if(k>=a[i]){k/=a[i];}else{cout << -1 << endl; return 0;}}
  ll ans=1;
  rep(i,n){ans*=a[i];}
  cout << ans << endl;
}

Measured memory_bytes: 4380
n,y = gets.chomp.split(" ").map(&:to_i)
temp = y/1000-n
if temp >= 0
  for i in 0..temp/9
    if (temp-i*9)%4 == 0 && n-i-(temp-i*9)/4 >= 0
      puts "#{i} #{(temp-i*9)/4} #{n-i-(temp-i*9)/4}"
      exit
    end
  end
end
puts "-1 -1 -1"

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

#define NIL -1
#define roop(x,a,b) for(int x=a;x<b;x++)
#define max(a,b) (a > b ? a : b)

typedef struct{
    int parent;
	int right;
	int left;
}node;

vector<node> u;

void preorder(int id){
	if(id == NIL)return;
	cout << " " << id;
	preorder(u[id].left);
	preorder(u[id].right);
}

void inorder(int id){
	if(id == NIL)return;
	inorder(u[id].left);
	cout << " " << id;
	inorder(u[id].right);
}

void postorder(int id){
	if(id == NIL)return;
	postorder(u[id].left);
	postorder(u[id].right);
	cout << " " << id;
}

int main(void){
	int n;
	cin >> n;
	u.resize(n);
	roop(i,0,n){
		u[i].parent = NIL;
	}
	roop(i,0,n){
		int id,l,r;
		cin >> id >> l >> r;
		u[id].right = r;
		u[id].left = l;
		if(u[id].right != NIL)u[r].parent = id;
		if(u[id].left != NIL)u[l].parent = id;
	}
	roop(i,0,n){
		if(u[i].parent == NIL){
			cout << "Preorder" << endl;
			preorder(i);
			cout << "\n" << "Inorder" << endl;
			inorder(i);
			cout << "\n" << "Postorder" << endl;
			postorder(i);
		}
	}
	cout << endl;
	return 0;
}


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

using namespace std;

/*****************MACRO*****/

#define ll long long
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

/*******CONSTANT***********/
#define INF (1<<30) //infinity value
#define EPS 1e-9
#define MOD 10000007
#define SIZ 1005
#define PI (acos(-1))


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);
    int a, b;
    cin>>a>>b;
    int cnt = b;
    int val = a;
    if(a>b) val = b, cnt = a;
    for(int i= 0 ; i<cnt;  i++) cout<<val;
    cout<<"\n";


    return 0;
}

/**********************************************************************************







*************************************************************************************/


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int N,a[10000],i,j,sum1,sum2,change;
    while(~scanf("%d",&N))
    {
        sum1=0;
        sum2=0;
        for(i=0; i<N; i++)
        {
            scanf("%d",&a[i]);
        }
        for(i=0; i<N; i++)
            for(j=0; j<N-i-1; j++)
            {
                if(a[j]<a[j+1])
                {
                    change=a[j];
                    a[j]=a[j+1];
                    a[j+1]=change;
                }
            }
        for(i=0;i<N;i++)
        {
            if(i%2==0)sum1+=a[i];
            else sum2+=a[i];
        }
        i=sum1-sum2;
        printf("%d\n",i);
    }
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String S = s.next();
        if (S.equals("ABC")) {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
        s.close();
    }
}

Measured memory_bytes: 35584
#include <iostream>

int main(int argc, const char * argv[]) {
    int K = 0;
    std::cin >> K;

    std::string S = "";
    std::cin >> S;

    std::string ret = "";
    if(S.length() <= K) {
        ret = S;
    } else {
        ret = S.substr(0, K) + "...";
    }

    std::cout << ret;

    return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979

int main(void)          
{
	double a, b, C;
	scanf("%lf %lf %lf", &a, &b, &C);
	
	printf("%f %f %f\n", a * b * sin(C / 360 * 2 * PI) / 2, a + b + sqrt((a * a + b * b) - (2 * a * b * cos(C / 360 * 2 * PI))), b*sin(C / 360 * 2 * PI));

	return 0;
}

Measured memory_bytes: 672
import sys
T = sys.stdin.readline().rstrip('\n')
s = ['A','C','G','T']

out = 0
tmp = 0

l = len(T)

for i in range(l):
	if T[i] in s:
		tmp += 1
	else:
		tmp = 0

	if tmp >= out:
		out = tmp

print (out)



Measured memory_bytes: 3060