akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

  // String nyuA=sc.nextLine();
  // String nyuB=sc.nextLine();
 
     String[] O=sc.nextLine().split("");
     String[] E=sc.nextLine().split("");

//int n=Integer.parseInt(nyuA);

//int N=Integer.parseInt(S[0]);
//int M=Integer.parseInt(S[1]);
try{
for(int i=0;i<O.length;i++){

System.out.print(O[i]);
System.out.print(E[i]);

}
}catch(Exception e){}
//long H=Long.parseLong(t[0]);
//long W=Long.parseLong(t[1]);
//long C=Long.parseLong(t[2]);


	}
}

Measured memory_bytes: 23636
#include <stdio.h>

int main( void )
{
	int list[100][100] = {};
	int row, column;
	int row_cou, column_cou, row_sum, column_sum;
	
	row = 0;
	column = 0;
	column_sum = 0;
	
	scanf( "%d %d", &row, &column );
	
	for( row_cou = 0; row_cou < row; row_cou++ )
	{
		for( column_cou = 0; column_cou < column; column_cou++ )
		{
			scanf( "%d", &list[row_cou][column_cou] );
		}
	}
	
	for( row_cou = 0; row_cou < row; row_cou++ )
	{
		row_sum = 0;
		for( column_cou = 0; column_cou < column; column_cou++ )
		{
			row_sum = row_sum + list[row_cou][column_cou];
			printf( "%d ", list[row_cou][column_cou] );
		}
		printf( "%d\n", row_sum );
	}
	
	row_sum = 0;
	
	for( column_cou = 0; column_cou < column; column_cou++ )
	{
		column_sum = 0;
		for( row_cou = 0; row_cou < row; row_cou++ )
		{
			column_sum = column_sum + list[row_cou][column_cou];
		}
		printf( "%d ", column_sum );
		row_sum = row_sum + column_sum;
	}
	printf( "%d\n", row_sum );
	
	return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const ll INF = 1e18;

int main(void){
    int T;
    cin >> T;
    rep(t,T){
        ll n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;
        map<ll,ll> dp;
        using P = pair<ll, ll>;
        priority_queue<P,vector<P>,greater<P>> qu;
        auto update = [&](ll nx, ll nc) {
            if (dp.count(nx) == 0 || dp[nx] > nc) {
                qu.push({dp[nx] = nc, nx});
            }
        };
        qu.push({dp[n] = 0,n});
        while(qu.size()) {
            P top = qu.top(); qu.pop();
            ll cost = top.first;
            ll x = top.second;
            if (x == 0) break;
            if (dp[x] < cost) continue;

            if (x <= (INF - cost)/d) {
                update(0, cost + x*d);
            }

            if (x % 2 == 0) {
                update(x/2, cost + a);
            } else {
                update(x/2, cost + a + d);
                update(x/2 + 1, cost + a + d);
            }

            if (x % 3 <= 1) {
                update(x/3, cost + b + d*(x%3));
            } else {
                update(x/3 + 1, cost + b + d);
            }

            if (x % 5 <= 2) {
                update(x/5, cost + c + d*(x%5));
            } else {
                update(x/5 + 1, cost + c + d*(5-x%5));
            }
        }
        cout << dp[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 4168
#include<iostream>

using namespace std;

int main()
{
  int mat[100][100], vec[100], n, m;
  cin >> n >> m;
  for(int y=0; y<n; y++){
    for(int x=0; x<m; x++){
      cin >> mat[x][y];
    }
  }
  for(int y=0; y<m; y++){
    cin >> vec[y];
  }

  for(int y=0; y<n; y++){
    int buf=0;
    for(int x=0; x<m; x++){
      buf+=mat[x][y]*vec[x];
    }
    cout << buf << endl;
  }
  return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
int const N = 1010;
char g[N][N];
int f[N][N];
queue<pair<int, int> > q;
int const dir[4][2] = { 0,1,0,-1,1,0,-1,0 };
int main() {
  clr(f, 0x3f);
  int n, m; scanf("%d%d", &n, &m);
  rep(i, n) scanf(" %s", g[i]);
  rep(i, n) rep(j, m) if (g[i][j] == '#') {
    f[i][j] = 0; q.push(make_pair(i, j));
  }
  while (!q.empty()) {
    pair<int, int> t = q.front(); q.pop();
    rep(i, 4) {
      int tx = t.first + dir[i][0];
      int ty = t.second + dir[i][1];
      if (tx >= 0 && tx < n && ty >= 0 && ty < m) {
        if (f[t.first][t.second] + 1 < f[tx][ty]) {
          f[tx][ty] = f[t.first][t.second] + 1;
          q.push(make_pair(tx, ty));
        }
      }
    }
  }
  int mx = 0;
  rep(i, n) rep(j, m) mx = max(mx, f[i][j]);
  printf("%d\n", mx);
  return 0;
}



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

int main()
{
	int a,b,c,d,e,f,g,h,i,j,k,l;
	cin >> a >> b >> c >> d >> e >> f;
	g = a;
	h = 5*b;
	i = 10*c;
	j = 50*d;
	k = 100*e;
	l = 500*f;

		if (1000 <= g+h+i+j+k+l)
			cout << "1" << endl;
			else
				cout << "0" << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef int64_t LL;
#define rep(i,N) for(LL i=0;i<(int)N;i++)
constexpr int MOD=1e9+7;
constexpr LL SCORE=1LL<<20,Z=(1LL<<0)|(1LL<<20)|(1LL<<40);
int main()
{
  int N;
  LL A=0,x,y;
  vector<LL> bit(20,0);
  cin>>N;
  while(cin>>x)rep(i,20)bit.at(i)+=x>>i&Z,x>>1;
  rep(i,20){x=bit.at(i);rep(j,3){y=x&SCORE-1;x/=SCORE;A=fmod(A+fmod(y%MOD*(N-y)%MOD*pow(2,i+20*j),MOD),MOD);}}
  return cout<<A<<endl,0;
}

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

#define DEBUG

#ifndef LOCAL
#undef DEBUG
#endif

#ifdef DEBUG
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) ;
#endif

int c[3];
int n;

void fail()
{
	puts("No");
	exit(0);
}

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if (x%2==1) c[0]++;
		else if (x%4==0) c[2]++;
		else c[1]++;
	}
	int pre=0;
	for(int i=1;i<=n;i++)
	{
		if (i==1)
		{
			if (c[0])
			{
				pre=0;
				c[0]--;
			}
			else if (c[1])
			{
				pre=1;
				c[1]--;
			}
			else if (c[2])
			{
				pre=2;
				c[2]--;
			}
			continue;
		}
		if (pre==0)
		{
			if (!c[2])
			{
				fail();
			}
			pre=2;
			c[2]--;
		}
		else if (pre==1)
		{
			if (!c[1])
			{
				if (!c[2])
				{
					fail();
				}
				else
				{
					pre=2;
					c[2]--;
				}
			}
			else
			{
				pre=1;
				c[1]--;
			}
		}
		else
		{
			if (!c[0])
			{
				if (!c[1])
				{
					pre=2;
					c[2]--;
				}
				else
				{
					pre=1;
					c[1]--;
				}
			}
			else
			{
				pre=0;
				c[0]--;
			}
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String args[]) {
      
      Scanner sc = new Scanner(System.in);
      PrintWriter w = new PrintWriter(System.out);
      //Input Part
      int n = sc.nextInt();
      int k = sc.nextInt();
      int height[] = new int[n];
      for(int i = 0; i < n; i++)
      {
          height[i] = sc.nextInt();
      }
      
      //Logic Part
      int dp[] = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(height[1] - height[0]);
      for(int i = 2; i < n; i++)
      {
          dp[i] = dp[i-1] + Math.abs(height[i] - height[i-1]);
          for(int j = 2; j <= k; j++)
          {
              if(j <= i && j < n)
              {
                  dp[i] = Math.min(dp[i], dp[i-j] + Math.abs(height[i] - height[i-j]));
              }
          }
      }
      w.println(dp[n-1]);
      w.close();
    }
}

Measured memory_bytes: 59492
#include<bits/stdc++.h>
#define lli         long long
#define rep(i,a,b)  for(i=a;i<b;i++)
using namespace std;

lli isprime[100005+1],isprime1[100001];

void Precompute()
{
    lli N=100000,i,j,x=sqrt(N);

    for(i=2;i<=x;i++)
    {
        for(j=2*i;j<=N;j+=i)
        {
            isprime[j]=1;
        }
    }

    isprime[1]=1;

    rep(i,1,N+1)
    {
        if(!isprime[i] and !isprime[(i+1)/2])
        {
            isprime1[i]=1;
        }
    }

//    rep(i,1,11)
//    {
//        cout<<isprime1[i]<<' ';
//    }

    rep(i,1,N+1)
    {
        isprime1[i]+=isprime1[i-1];
    }
}

int main()
{
    Precompute();

    lli Q;
    cin>>Q;

    while(Q--)
    {
        lli L,R;
        cin>>L>>R;

        cout<<isprime1[R]-isprime1[L-1]<<'\n';
    }


    return 0;
}


Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        var ss = new string[input[0]];

        for (var i = 0; i < input[0]; i++)
        {
            ss[i] = Console.ReadLine();
        }

        Console.WriteLine(string.Concat(ss.OrderBy(x => x)));
    }
}


Measured memory_bytes: 3416
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const int MAX_N = 210;
int h, w;
char field[MAX_N][MAX_N];
int table[MAX_N][MAX_N];
int princess;
int soldier = INF;
void bfs(int y, int x)
{
    table[y][x] = 0;
    queue<P> que;
    que.push(P(y, x));
    while(!que.empty())
    {
        P p = que.front(); que.pop();
        for(int i = 0; i < 4; i++)
        {
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
            if(table[ny][nx] >= 0 || field[ny][nx] == '#') continue;
            table[ny][nx] = table[p.first][p.second] + 1;
            if(field[ny][nx] == '@') princess = table[ny][nx];
            if(field[ny][nx] == '$') soldier = min(table[ny][nx], soldier);
            que.push(P(ny, nx));
        }
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    int sy, sx;
    memset(table, - 1, sizeof(table));
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++) 
        {
            cin >> field[i][j];
            if(field[i][j] == '%') sy = i, sx = j;
        }
    }
    bfs(sy, sx);
    cout << (princess < soldier ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3440
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int num1 = sc.nextInt();
            int num2 = sc.nextInt();
            if(num1 + num2 < 24){
              System.out.println(num1+num2);
            } else {
              System.out.println(num1+num2-24);
            }
            }
}

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

int main() {
    int k, n, i, maxk = 0;
    cin >> k >> n;
    int lst[n];
    for(i = 0; i < n; i++){
        cin >> lst[i];
        if(i > 0){
            maxk = max(maxk, lst[i]-lst[i-1]);
        }
        if(i == n-1) maxk = max(maxk, k - lst[n-1] + lst[0]);
    }
    cout << k - maxk << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fst first
#define snd second
#define fore(x,a,b) for(int x=(a), qwerty=(b); x<qwerty; x++)
#define pb push_back
#define mset(a,v) memset((a),(v),sizeof(a))
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const int N=2e5+5;
ll f[N],h[N],v[N],n;
void upd(int i, ll v){
	for(;i<N;i+=i&-i)f[i]=max(v,f[i]);
}
ll sum(int i){
	ll r=0; for(;i;i-=i&-i)r=max(f[i],r); return r;
}

int main(){FIN;
	cin>>n;
	fore(x,0,n)cin>>h[x];
	fore(x,0,n)cin>>v[x];
	fore(x,0,n){
		ll ans = sum(h[x]-1)+v[x];
		upd(h[x],ans);
	}
	cout << sum(N-1)<<"\n";
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define mod 1000000007
#define sz(v) v.size()
#define all(x) x.begin(), x.end()
#define prec(x) fixed << setprecision(x)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)
#define speedup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;

int mxn = 1e18;

void solve(){
    ld a, b;
    cin >> a >> b;
    int ans = a*b;
    cout << ans;
}

int32_t main() {
    speedup;

    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }

    // test{
        solve();
    // }

    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;

/*
const ll M = 1000000007;
vector<ll> fac(3001);
vector<ll> ifac(3001);
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
*/


ll lcm(ll a,ll b){
 
  ll r, x, tmp;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

ll gcd(ll a ,ll b){
    if(a==0){return b;}
    else if(b==0){return a;}
    else{
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
    }
}




int main(void){
    const ll INF = 1000000007;
    ll ans = 0;
    string s1,s2;
    cin >> s1;
    cin >> s2;
    if(s1.at(0)==s2.at(0))ans++;
    if(s1.at(1)==s2.at(1))ans++;
    if(s1.at(2)==s2.at(2))ans++;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;
#define ll long long

int main(){
    ll A,P;
    cin >> A >> P;
    cout << ((3*A)+P)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll K, X; cin >> K >> X;
    string ans = "No";
    if (K * 500 >= X) ans = "Yes";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#define _PI (3.141592653589793)
int main()
{
	int A, B, C, K;
	std::cin >> A >> B >> C >> K;
	int remain = K;
	int sum = 0;
	if (A >= remain) {
		sum += remain;
		remain = 0;
	}
	else {
		sum += A;
		remain -= A;
	}
	if (B >= remain) {
		remain = 0;
	}
	else {
		remain -= B;
	}
	sum -= remain;
	std::cout << sum << std::endl;
	return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<math.h>

int main(){
  int i,j,n,a[4];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<3;j++)scanf("%d",&a[j]);
    for(j=0;j<3;j++)
      if(a[j]>a[j+1]){
	a[3]=a[j];
	a[j]=a[j+1];
	a[j+1]=a[3];
      }
    if(sqrt(a[2]*a[2])==sqrt(a[0]*a[0]+a[1]*a[1]))printf("YES\n");
    else printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 580
import sys
import collections

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
A = list(map(int, readline().split()))


def solve():
    acum = [0] * (N + 1)
    acum[0] = 0
    c = collections.Counter()
    c[0] = 1

    ans = 0
    for i in range(N):
        x = (acum[i] + A[i]) % M
        ans += c[x]
        c[x] += 1
        acum[i + 1] = x
    return ans


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 15848
#include <stdio.h>
int main()
{
   int a, b, c;
   scanf( "%d", &a );
   switch( a ){
   case 1:
      printf( "Hello World\n" );
      break;
   case 2:   
      scanf( "%d", &b );
      scanf( "%d", &c );
      printf( "%d\n", b + c );
      break;
   }
   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse
// struct Edge {
//   int to, id;
//   Edge(int a, int b): to(a), id(b) {}
// };

vector<int> g[100010];
ll dp[100010][2];
// bool done[100010];

void dfs(int v,int p=-1) {
	dp[v][0]=dp[v][1]=1;
	for (auto next:g[v]) {
		if (next!=p) {
			dfs(next,v);
			dp[v][0]*=(dp[next][0]+dp[next][1]);
			dp[v][0]%=MOD;
			dp[v][1]*=dp[next][0];
			dp[v][1]%=MOD;
		}
		// dfs(next);
		// dp[v][0]*=(dp[next][0]+dp[next][1]);
		// dp[v][0]%=MOD;
		// dp[v][1]*=dp[next][0];
		// dp[v][1]%=MOD;
	}
	// done[v]=true;
}

int main(int argc, char const *argv[])
{
	int n;cin>>n;

	rep(i,n-1) {
		int x,y;cin>>x>>y;
		x--;y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}

	dfs(0);

	cout<<(dp[0][0]+dp[0][1])%MOD<<endl;
	return 0;
}

Measured memory_bytes: 14208
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef TEST
struct test {
    int ans;
} td[] = {
    {},
};
#endif

int
cmp(const void *a, const void *b)
{
    return *(long *)b - *(long *)a;
}

void
solver(int x, int y, int a, int b, int c, long *p, long *q, long *r)
{
    int i;
    long sum = 0;

    qsort(p, a, sizeof(long), cmp);
    qsort(q, b, sizeof(long), cmp);
    qsort(r, c, sizeof(long), cmp);

    for(i = 0; i < x; i++)
        sum += p[i];

    for(i = 0; i < y; i++)
        sum += q[i];

    x--;
    y--;
    for(i = 0; i < c; i++) {
        if(x == -1 && y == -1)
            break;
        if(y == -1 || p[x] < q[y]) {
            if(r[i] > p[x]) {
                sum -= p[x];
                sum += r[i];
                x--;
            }
        } else if(x == -1 || p[x] >= q[y]) {
            if(r[i] > q[y]) {
                sum -= q[y];
                sum += r[i];
                y--;
            }
        }
    }
    printf("%ld\n", sum);
}

int
main(int argc, char *argv[])
{
#ifdef TEST
    int tt;
    for(tt = 0; tt < sizeof(td) / sizeof(struct test); tt++) {
        solver();
        printf("%d\n", td[tt].ans);
    }
#endif
    int i;
    int X, Y, A, B, C;
    long p[100000], q[100000], r[100000];

    bzero(p, sizeof(p));
    bzero(q, sizeof(q));
    bzero(r, sizeof(r));

    scanf("%d%d%d%d%d", &X, &Y, &A, &B, &C);
    for(i = 0; i < A; i++)
        scanf("%ld", p + i);
    for(i = 0; i < B; i++)
        scanf("%ld", q + i);
    for(i = 0; i < C; i++)
        scanf("%ld ", r + i);

    solver(X, Y, A, B, C, p, q, r);
    return 0;
}

Measured memory_bytes: 3324
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int[] a = new int[N];
        long sum = 0;
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
            sum += a[i];
        }
        if (sum < K) {
            System.out.println(N);
            return;
        }
        Arrays.sort(a);
        boolean[][] L = new boolean[N+2][K+1];
        for (int i = 0; i <= N; i++) {
            Arrays.fill(L[i], false);
        }
        L[0][0] = true;
        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= K; j++) {
                if (!L[i-1][j]) {
                    continue;
                }
                L[i][j] = true;
                if (j+a[i-1] <= K) {
                    L[i][j + a[i - 1]] = true;
                }
            }
        }
        for (int j = 0; j <= K; j++) {
            L[N+1][j] = L[N][j];
        }
        boolean[][] R = new boolean[N+2][K+1];
        for (int i = 0; i <= N; i++) {
            Arrays.fill(R[i], false);
        }
        R[N+1][0] = true;
        for(int i = N; 1 <= i; i--) {
            for(int j = 0; j <= K; j++) {
                if (!R[i+1][j]) {
                    continue;
                }
                R[i][j] = true;
                if (j+a[i-1] <= K) {
                    R[i][j+a[i-1]] = true;
                }
            }
        }
        for (int j = 0; j <= K; j++) {
            R[0][j] = R[1][j];
        }
        int[][] countR = new int[N+2][K+1];
        for(int i = 0; i <= N; i++) {
            countR[i][0] = 1;
            for (int j = 1; j <= K; j++) {
                if (!R[i][j]) {
                    countR[i][j] = countR[i][j-1];
                } else {
                    countR[i][j] = countR[i][j-1]+1;
                }
            }
        }
        for(int j = 0; j <= K; j++) {
            countR[N+1][j] = countR[N][j];
        }
        long need = 0;
        for(int i = 1; i <= N; i++) {
            if (K <= a[i-1]) {
                need += 1;
                continue;
            }
            for(int j = 0; j < K; j++) {
                if(!L[i-1][j]) {
                    continue;
                }
                if (K-j-a[i-1]-1 < 0) {
                    if (0 < countR[i+1][K-j-1]) {
                        need += 1;
                        break;
                    }
                } else if (0 < countR[i+1][K-j-1]-countR[i+1][K-j-a[i-1]-1]) {
                    need += 1;
                    break;
                }
            }
        }
        System.out.println(N-need);
    }
}


Measured memory_bytes: 244932
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int a[4],b[4];
    while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
        int H=0,B=0;
        int blow[10]={};
        rep(i,4) blow[a[i]]++;
        rep(i,4) blow[b[i]]++;
        rep(i,10)if(blow[i]==2)B++;
        
        rep(i,4){
            if(a[i]==b[i])H++;
        }
        cout<<H<< " "<<B-H<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;
 
signed main()
{
    fast;
    int n,k;
    cin>>n>>k;

    vector<int> a(n);

    for ( int i = 0 ; i < a.size() ; i++ )
    {
        cin>>a[i];
    }

    vector<int> dp(n,0);

    dp[1] = abs(a[1]-a[0]);

    for ( int i = 2 ; i < a.size() ; i++ )
    {
        for ( int j = 1 ; j <= min(i,k) ; j++ )
        {
            if ( j == 1 )
            {
                dp[i] = dp[i-1]+abs(a[i]-a[i-1]);
            }
            else
            {
                dp[i] = min(dp[i-j] + abs(a[i]-a[i-j]) , dp[i] );
            }
            
        }
    }

    cout<<dp[a.size()-1]<<endl;
    
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	while(1){
		int n,m,q;
		cin >> n >> m >> q;
		if(n==0) break;
		
		vector<lli> s(q, 0LL);
		vector<string> b(q);
		for(int i=0; i<q; i++){
			string str;
			cin >> str >> b[i];
			for(int j=0; j<n; j++){
				s[i] |= (long long int)(str[j]-'0') << j;
			}
		}
		for(int i=1; i<q; i++){
			s[i] ^= s[i-1];
		}
		
		vector<lli> cand(m, (1LL<<n)-1);
		for(int i=0; i<q; i++){
			for(int j=0; j<m; j++){
				if(b[i][j]=='1'){
					cand[j] &= s[i];
				}else{
					cand[j] &= ~s[i];
				}
			}
		}
		
		for(int i=0; i<m; i++){
			bool unique=false;
			for(int j=0; j<n; j++){
				if(cand[i] == (1LL<<j)){
					if(j>9){
						cout << (char)('A'+j-10);
					}else{
						cout << j;
					}
					unique = true;
				}
			}
			if(!unique){
				cout << '?';
			}
			if(cand[i]==0) cout << "error";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
}
int N=1e5+9,k;
void input_(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
void solve(){
	int k;
    cin>>k;
    for(int i=0;i<k;i++) cout<<"ACL";
}
int main(){
    input_();
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0); 
	int t=1;
	//cin>>t;
	while(t--) 
	    solve();
	return 0; 
}

Measured memory_bytes: 3576
package main

import (
	"fmt"
	"math"
)

var x, a, b, ans int

func main() {
	fmt.Scan(&x, &a, &b)

	if abs(x-a) < abs(x-b) {
		fmt.Println("A")
	} else {
		fmt.Println("B")
	}
}

/*  ----------------------------------------  */

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy []XY

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y > a[j].y
	}
	return a[i].x > a[j].x
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-


def main():
    n, x = map(int, input().split())

    # KeyInsight
    # 再帰的な構造を見抜いて，条件に応じて場合分け
    # See:
    # http://drken1215.hatenablog.com/entry/2019/05/13/114600
    # ◯気がつけた点
    # ・バーガーとパティの量が，レベルが高くなるにつれて規則的に増える
    # ・再帰を使えば良さそう
    # △気がつけなかった点
    # ・規則性のある状態をどう再帰関数として，定式化するか
    def f(n, x):
        # 終了条件
        if n == 0:
            return 1

        # Nレベルバーガーから，N - 1レベルバーガーになるときの枚数の変化
        total_length = 2 ** (n + 1) - 3
        p_count = 2 ** n - 1

        # イメージ
        # B：バン，P：パティ
        # Nレベルバーガー：B(N - 1レベルバーガー)P(N - 1レベルバーガー)B
        if x == 1:
            # Bのみ
            return 0
        elif x <= total_length + 1:
            # B(N - 1レベルバーガー)
            # レベルを一つ減らす．N - 1レベルバーガーの中身を見るため，最下層のBは見なくてもよくなる
            return f(n - 1, x - 1)
        elif x <= total_length + 2:
            # B(N - 1レベルバーガー)P
            # N - 1レベルバーガーのパティ + 1枚
            return p_count + 1
        elif x <= 2 * (total_length + 1):
            # B(N - 1レベルバーガー)P(N - 1レベルバーガー)
            # N - 1レベルバーガーのパティ + 1枚と，上側にある（N - 1レベルバーガーのパティの数）
            return p_count + 1 + f(n - 1, x - total_length - 2)
        else:
            # B(N - 1レベルバーガー)P(N - 1レベルバーガー)B
            return 2 * p_count + 1

    print(f(n, x))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream> 
#include<cmath>
#include<vector>
using namespace std;
int main()
{
int n;
cin>> n;
vector<int> A;
vector<int> B;
vector<int> C;
for(int i =0;i<n;i++)
{
	int a;
	cin>>a;
	A.push_back(a);
}
for(int i =0;i<n;i++)
{
	int a;
	cin>>a;
	B.push_back(a);
}
for(int i =1;i<n;i++)
{
	int a;
	cin>>a;
	C.push_back(a);
}
int sum = 0;
for(int i =0;i<n;i++)
{
	sum+=B[A[i]-1];
	if(i<n-1 && A[i]== A[i+1]-1) sum+=C[A[i]-1];
}

cout<<sum;
return 0;
}


Measured memory_bytes: 256
//そもそも2があるかどうか、
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i=0; i<N ; i++) {
    cin >> vec.at(i);
  }
  
  int count=1;
  int j=0;
  while (true) {
    if (vec.at(j)==2 || count==N)
      break;
    else {
      j=vec.at(j)-1;
      count++;
    }
  }
  if (count==N)
    cout << -1 << endl;
  else 
    cout << count << endl;
        
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 210, T = 0, H = 1;

bool used[MAXN];
bool user[MAXN];

int main()
{
    int n, temp;
    while(cin >> n && n)
    {
        memset(used, false, sizeof(used));
        memset(user, H, sizeof(user));

        REP(n){cin >> temp; user[temp] = T;}
        int rest[2] = {n,n}, now = -1;
        int turn = T, loser;
    
        while( rest[0] != 0 && rest[1] != 0)
        {
            bool sub = true;
            for(int i = 1;i<= n*2; i++)if(!used[i] && user[i] == turn && now < i)
            {
                used[i] = true;
                now = i;
                rest[turn]--;
                turn = !turn;
                sub = false;
                break;
            }

            if(sub)
            {
                now = -1;
                turn = !turn;
            }
        }
        loser = turn;

        int ans = 0;
        //for(int i = 1;i<=2*n;i++)if((user[i] == loser)&& !used[i] )ans+=i;

        REP(2)cout << rest[1-i] << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<29);


void floyd(vector<vector<int> > &d) {
  int N = d[0].size();
  rep(k, N) {
    rep(i, N) {
      if (d[i][k] == INF) continue;
      rep(j, N) {
        if (d[k][j] == INF) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  int H, W; cin >> H >> W;
  int N = H * W;
  vector<vector<int> > math(H, vector<int>(W));
  vector<vector<int> > d(N, vector<int>(N));
  rep(i, H) {
    rep(j, W) {
      char s; cin >> s;
      math[i][j] = (s == '.') ? 0 : 1;
    }
  }

  rep(i, N) {
    rep(j, N) {
      d[i][j] = (i == j) ? 0 : INF;
    }
  }

  rep(i, H) {
    rep(j, W) {
      if (math[i][j] == 1) continue;

      int from = (i * W) + j;
      int to;

      int x = max(0, j-1);
      if (math[i][x] == 0) {
        to = (i * W) + x;
        d[from][to] = min(d[from][to], 1);
        d[to][from] = min(d[to][from], 1);
      }

      x = min(j+1, W-1);
      if (math[i][x] == 0) {
        to = (i * W) + x;
        d[from][to] = min(d[from][to], 1);
        d[to][from] = min(d[to][from], 1);
      }

      x = max(0, i-1);
      if (math[x][j] == 0) {
        to = (x * W) + j;
        d[from][to] = min(d[from][to], 1);
        d[to][from] = min(d[to][from], 1);
      }

      x = min(i+1, H-1);
      if (math[x][j] == 0) {
        to = (x * W) + j;
        d[from][to] = min(d[from][to], 1);
        d[to][from] = min(d[to][from], 1);
      }

    }
  }


  floyd(d);

  int ans = 0;
  rep(i, N) {
    rep(j, N) {
      if (d[i][j] >= INF) continue;
      ans = max(ans, d[i][j]);
    }
  }

  cout << ans << endl;

  return 0;
}


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

int n;

void putstr(int c, string str) {
    if (str.size() == n) {
        cout << str << endl;
        return;
    }
    
    char next;
    for (int i = 0; i < c; i++) {
        next = 'a' + i;
        putstr(c, str + next);
    }
    next = 'a' + c;
    putstr(c+1, str + next);
}

int main() {
    cin >> n;
    putstr(1, "a");
    return 0;
}


Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    string s;
    cin >> s;
    if(s.size() < 4 || s.substr(0, 4) != "YAKI")cout << "No" << endl;
    else cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]
C = Counter(S)
print("AC x " + str(C["AC"]))
print("WA x " + str(C["WA"]))
print("TLE x " + str(C["TLE"]))
print("RE x " + str(C["RE"]))

Measured memory_bytes: 16484
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n; cin >> n;
  if(n == 1){
    cout << "Hello World" << endl;
  }else {
    int a, b; cin >> a >> b;
    cout << a + b << endl;
  }


  return 0;
}



//


Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	if N%2 == 0 {
		fmt.Println(0.5)
	} else {
		half := N / 2
		fmt.Println(float64(half+1) / float64(N))
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

void test();

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	int n = s.length();
	f(i,1,n){
		if(s[i]==s[i-1]){
			cout << "Bad\n";
			return 0;
		}
	}
	cout << "Good\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, d, r;
	double f;
	
	scanf("%d %d", &a, &b);
	
	d = a / b;
	r = a % b;
	f = (double) a / b ;
	printf("%d %d %f\n", d, r, f);
	return(0);
}

Measured memory_bytes: 636
#include<iostream>
#include<string>

using namespace std;
typedef long long ll;

int main(){
    int n;
    string S;
    cin >> n;
    cin >> S;
    if(n<3)
    {
        cout << 0 << endl;
        return 0;
    }
    ll r, g, b;
    r = b = g = 0;
    for (int i = 0; i < n; i++)
    {
        if(S[i]=='R')
        {
            r++;    
        }
        else if (S[i]=='G')
        {
            g++;
        }
        else if (S[i]=='B')
        {
            b++;
        }
    }
    ll all = r * g * b;

    for (int i = 0; i < n - 2; i++)
    {
        for (int j = i+1; j < n - 1; j++)
        {
            if (S[i] != S[j])
            {
                int a = j - i;
                int k = i + 2 * a;
                if (k < n)
                {
                     if (S[j] != S[k] && S[k] != S[i])
                    {
                        all--;
                    }
                }


                
                
            }
        }
        
    }
    cout << all << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) {
    if (a >= b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;   
}

int main() {
    int s,t;
    cin>>s>>t;
    bool flag=true;
    int sum=1;
    int count=0;
    while(flag==true){
        if(sum>=t){
            cout<<count<<endl;
            break;
        }
        else{
            sum+=(s-1);
            count++;
        }
        
    }

}





Measured memory_bytes: 256
import java.math.BigInteger;
	import java.util.Scanner;
	
	public class Main {
		public static void main(String[] args) {
			// TODO 自動生成されたメソッド・スタブ
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			
			int[] nums = new int[n];
			sc.nextLine();
			BigInteger sums = BigInteger.ZERO;
			for (int i = 0; i < n; i++) {
				nums[i] = sc.nextInt();
				sums = sums.add(BigInteger.valueOf(nums[i]));
			}
			
			BigInteger answer = BigInteger.ZERO;
			BigInteger jud = BigInteger.ZERO;
			for (int i = 0; i < n; i++) {
				sums = sums.subtract(BigInteger.valueOf(nums[i]));
				answer = answer.add(BigInteger.valueOf(nums[i]).multiply(sums));
			}
			
//			BigInteger answer = BigInteger.ZERO;
//			for (int i = 0; i < n; i++) {
//				for (int j = i + 1; j < n; j++) {
//					answer = answer.add(BigInteger.valueOf(nums[i]).multiply(BigInteger.valueOf(nums[j])));
//				}
//			}
			BigInteger m = BigInteger.ONE;
			for (int i = 0; i < 9; i++) {
				m = m.multiply(BigInteger.valueOf(10));
			}
			m = m.add(BigInteger.valueOf(7));
			System.out.println(answer.mod(m));
			
	//		BigInteger[] anss = new BigInteger[n];
	//		anss[0] = BigInteger.ONE;
	//		sc.nextLine();
	//		for (int i = 0; i < n; i++) {
	//			// 掛け合わせを保持
	//			anss[i] = anss[i].multiply(BigInteger.valueOf(sc.nextInt()));
	//		}
			
		}
		
	}


Measured memory_bytes: 60528
import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import java.lang.Math.*;

public class Main {

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	public void run() throws Exception {
		FastIO file = new FastIO();
		int n = file.nextInt();
		int w = file.nextInt();
		int[] a = new int[n];
		long[] b = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = file.nextInt();
			b[i] = file.nextLong();
		}
		long[][] dp = new long[n + 1][w + 1];
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= w; j++) {
				if (a[i - 1] > j) {
					dp[i][j] = Math.max(dp[i-1][j-1], Math.max(dp[i-1][j], dp[i][j-1]));
				}
				else {
					dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-a[i-1]] + b[i-1]);
				}
			}
		}
		file.out.println(dp[n][w]);
		file.out.flush();
	}

	public static class FastIO {
		BufferedReader br;
		StringTokenizer st;
		PrintWriter out;

		public FastIO() {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		void print(Object o) {
			out.print(o);
		}

		void println(Object o) {
			out.println(o);
		}

		void printf(String s, Object... o) {
			out.printf(s, o);
		}
	}

	public static long pow(long n, long p, long mod) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n % mod;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2, mod);
			return (temp * temp) % mod;
		} else {
			long temp = pow(n, (p - 1) / 2, mod);
			temp = (temp * temp) % mod;
			return (temp * n) % mod;

		}
	}

	public static long pow(long n, long p) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2);
			return (temp * temp);
		} else {
			long temp = pow(n, (p - 1) / 2);
			temp = (temp * temp);
			return (temp * n);

		}
	}

	public static long gcd(long x, long y) {
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}

	public static boolean isPrime(int 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;
	}
}


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

int main() {
  string c;
  cin >> c;
  
  if (c=="a") {
    cout << "vowel" << endl;
  }
  else  if (c=="i") {
    cout << "vowel" << endl;
  }
  else  if (c=="u") {
    cout << "vowel" << endl;
  }
  else  if (c=="e") {
    cout << "vowel" << endl;
  }
  else  if (c=="o") {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
  
}


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

int main(void){
  int m;
  string s;
  cin >> m;
  for(int i = 0; i < m; i++){
    cin >> s;
    set<string> train;
    train.insert(s);
    for(size_t j = 1; j < s.length(); j++){
      string a = s.substr(0, j);
      string b = s.substr(j);
      train.insert(b + a);
      reverse(a.begin(), a.end());
      train.insert(a + b);
      train.insert(b + a);
      reverse(b.begin(), b.end());
      train.insert(a + b);
      train.insert(b + a);
      reverse(a.begin(), a.end());
      train.insert(a + b);
      train.insert(b + a);
    }
    cout << train.size() << endl;
  }

  return 0;
}

Measured memory_bytes: 3212
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))

t = 1

s = 0

if t not in a:
    s = -1
else:
    for x in a:
        if x == t:
            t += 1
        else:
            s += 1

print(s)


Measured memory_bytes: 100804
#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 998244353;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, k;
	cin >> n >> k;
	vector<int> l(k), r(k);
	for (int i = 0; i < k; i++)
		cin >> l[i] >> r[i];
	vector<long long> dp(2 * n + 100);
	dp[1] = 1;
	dp[2] = -1;
	for (int i = 1; i <= n; i++) {
		dp[i] = (dp[i] % MOD + MOD) % MOD;
		dp[i + 1] += dp[i];
		for (int j = 0; j < k; j++) {
			dp[i + l[j]] += dp[i];
			dp[i + r[j] + 1] -= dp[i];
		}
	}
	// dp[1] = 1;
	// for (int i = 1; i < n; i++) {
	// 	for (int j = 0; j < k; j++) {
	// 		for (int kk = l[j]; kk <= r[j]; kk++) {
	// 			(dp[i + kk] += dp[i]) %= MOD;
	// 		}
	// 	}
	// }
	cout << dp[n] << "\n";
	return 0;
}

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

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end()) << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define PIGRECO 3.141592653589793

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////
#define int long long

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	int n;
	cin >> n;

	vector<int>a(n + 1);

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

	vector<vector<int>>dp(n + 1, vector<int>(n + 1));

	for (int l = n; l > 0; l--) {

		for (int r = l; r <= n; r++) {

			if (l == r) {
				dp[l][r] = a[l];
			}
			else {

				dp[l][r] = max(a[l] - dp[l + 1][r], a[r] - dp[l][r - 1]);


			}

		}
	}

	cout << dp[1][n] << endl;



}

Measured memory_bytes: 73660
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

vector<pair<ll,ll>> p;

// index が条件を満たすかどうか
bool isOK(int index, int key) {
    if (p[index].first > key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
int binary_search(int key) {
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)p.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}


signed main(){
	int h,w; cin>>h>>w;
	string c[h]; rep(i,h) cin>>c[i];
	rep(i,h){
		rep(_,2) cout<<c[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,p,q;
  cin>>a>>b;
  if(a<b)
  {
    p=a;q=b;
  }
  else
  {
    p=b;q=a;
  }
  for(int i=1;i<=q;i++)
    cout<<p;
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256