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

using namespace std;
constexpr int NMAX = 2010;

char snukes[3][NMAX];
int slen[3];

char potAns[NMAX * 3], potAns2[NMAX * 3];

char merge(char a, char b) {
	if (a == '?' && b == '?') return '?';
	else if (a != '?' && b != '?') {
		if (a == b) return a;
		else return 'X';
	} else if (a == '?') return b;
	else return a;
}

vector<int> attemptMinMerge(char *a, char *b, char *res) {
	int n = strlen(a), m = strlen(b);
	vector<int> ans;
	for (int stb = 0; stb <= n; ++stb) {
//		printf("att stb %d\n", stb);
		bool success = true;
		for (int i = 0; i < n; ++i) res[i] = a[i];
		for (int i = 0; i < m; ++i) {
			if (res[i + stb]) {
				char cmres = merge(res[i + stb], b[i]);
				if (cmres == 'X') {
//					printf("break b %d %c %c\n", i, res[i + stb], b[i]);
//					printf("%s\n", res);
					success = false;
					break;
				}
				res[i + stb] = cmres;
			} else {
				res[i + stb] = b[i];
			}
		}
		if (success) {
			ans.push_back(stb);
		}
		memset(res, 0, sizeof potAns);
	}
	return ans;
}

bool merges[3][3][NMAX];

int main() {
	for (int i = 0; i < 3; ++i) scanf("%s", snukes[i]);
	for (int i = 0; i < 3; ++i) slen[i] = strlen(snukes[i]);
	int ans = 1000000000;
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			if (i != j) {
				vector<int> possibles = attemptMinMerge(snukes[i], snukes[j], potAns);
				memset(potAns, 0, sizeof potAns);
				for (int x : possibles) merges[i][j][x] = true;
//				for (int x : possibles) printf("%d %d can merge at %d\n", i, j, x);
			}
		}
	}
	vector<int> stOrder{0, 1, 2};
	do {
//		printf("match order %d %d %d\n", stOrder[0], stOrder[1], stOrder[2]);
		for (int stb = 0; stb <= slen[stOrder[0]]; ++stb) {
			for (int stc = 0; stc <= stb + slen[stOrder[1]]; ++stc) {
				if (!merges[stOrder[0]][stOrder[1]][stb]) continue;
				if (stb <= stc && stc <= stb + slen[stOrder[1]] && !merges[stOrder[1]][stOrder[2]][stc - stb]) continue;
				if (stc <= stb && stb <= stc + slen[stOrder[2]] && !merges[stOrder[2]][stOrder[1]][stb - stc]) continue;
				if (stc <= slen[stOrder[0]] && !merges[stOrder[0]][stOrder[2]][stc]) continue;
//				printf("pos %d %d possible \n", stb, stc);
				ans = min(ans, max(max(slen[stOrder[0]], stb + slen[stOrder[1]]), stc + slen[stOrder[2]]));
			}
		}
	} while (next_permutation(begin(stOrder), end(stOrder)));
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i=0; i<n; i++) a[i] = sc.nextInt();
		sc.close();
		
		int res = 0;
		int dif;
		for(int i=0; i<n-1; i++) {
			for(int j=i+1; j<n; j++) {
				dif = Math.abs(a[i]-a[j]);
				if(dif > res) res = dif;
			}
		}
		System.out.println(res);
	}
}

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

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

    int bn = b-a;
    int ans = 0;
    for (int i = 1; i <= bn; i++) {
        ans += i;
    }
    ans -= b;
    cout << ans << endl;
}

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

int main(){
    long long n;
    cin >> n;
    vector<long long> a(3*n,0);

    for(int i=0;i<3*n;i++){
        cin >> a[i];
    }

    sort(a.begin(),a.end());

    long long ans=0;

    int cnt=0;
    int pos = 3*n-2;
    while(cnt<n){
        ans += a[pos];
        //cout << a[pos] << endl;
        cnt++;
        pos-=2;
    }

    cout << ans << endl;
}



Measured memory_bytes: 5568
import math
n = int(input())
a = list(map(int, input().split()))


def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for _ in range(2,tmp):
        while n % 2 == 0:
            n //= 2
            factor.append(2)
    if not factor:
        return [n]
    else:
        factor.append(n)
        return factor


count = 0
for i in a:
    temp = trial_division(i)
    count += temp.count(2)

print(count)

Measured memory_bytes: 42860
#include<stdio.h>
int bas(int a){
	int s;
	if(a<0){
		s=-(a);
		return s; 
	}
	else return a;
}
int main(){
	int x,a,b;
	int ans1,ans2;
	scanf("%d%d%d",&x,&a,&b);
	ans1=bas(a-x),ans2=bas(b-x);
	if(ans1>ans2)  printf("B\n");
	else printf("A\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll h,w,n;
cin >> h>>w>>n;
ll t[n] = {};
rep(i, n)
{
    cin >> t[i];
}
ll gr[h][w];
ll co=0;
rep(i,n)rep(j,t[i]){
    gr[co/w][co%w]=i;
    co++;
}
rep(i,h){rep(j,w){
    if(i%2){cout << gr[i][j]+1 <<' ';}
    else{cout << gr[i][w-j-1]+1 <<' ';}
}
cout  << endl;
}

return 0;
}

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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}


int ask(ll x) {
    cout << "? " << x << "\n";
    cout.flush();
    string s;
    cin >> s;
    if (s == "Y")
        return 1;
    return 0;
    /*
    cout << "? " << x << "\n";
    ll n = 12345;
    if (x <= n && to_string(x) <= to_string(n)) {
        cout << "Y\n";
        return 1;
    }
    if (x > n && to_string(x) > to_string(n)) {
        cout << "Y\n";
        return 1;
    }
    cout << "N\n";
    return 0;*/
}

int check(ll x) {
    while (x < 1e12)
        x = x * 10 + 9;
    if (ask(x))
        return 1;
    return 0;
}

int main() {
    ll x = 0;
    while (true) {
        int l = -1;
        int r = 9;
        if (x == 0)
            l = 0;
        while (r - l > 1) {
            int mid = (l + r) >> 1;
            if (check(x * 10 + mid))
                r = mid;
            else
                l = mid;
        }
        x = x * 10 + r;
        if (r != 9) {
            if (ask(x + 1)) {
                cout << "! " << x << "\n";
                cout.flush();
                return 0;
            }
        }
        else {
            if (!ask((x - 1) * 10)) {
                cout << "! " << x << "\n";
                cout.flush();
                return 0;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 596
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    i32 a, b, c;
    std::cin >> a >> b >> c;
    std::cout << (a <= c && c <= b ? "Yes" : "No") << '\n';
}


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

using namespace std;
using ll = long long;

int main() {
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    for(int i = 0;i < h;++i) {
        cin>>s[i];
    }
    const vector<int> vx={1,0};
    const vector<int> vy={0,1};
    vector<vector<int>> visited(h,vector<int>(w,10000));
    priority_queue<pair<int,pair<int,int>>> q;
    q.push(make_pair(-(s[0][0]=='#'?1:0),make_pair(0,0)));
    while(!q.empty()){
        auto t=q.top();
        int y=t.second.first;
        int x=t.second.second;
        int cost=-t.first;
//cerr<<y<<" "<<x<<" "<<cost<<endl;
        q.pop();
        for(int v = 0;v < 2;++v) {
            int ny=y+vy[v];
            int nx=x+vx[v];
            if(ny<0||nx<0||ny>=h||nx>=w)continue;
            int nc=cost;
            if(s[y][x]!=s[ny][nx]&&s[ny][nx]=='#')++nc;
//cerr<<"a:"<<ny<<" "<<nx<<" "<<nc<<endl;
            if(visited[ny][nx]<=nc)continue;
            visited[ny][nx]=nc;
            q.push(make_pair(-nc,make_pair(ny,nx)));
        }
    }
    cout<<visited[h-1][w-1]<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define tr(a) ((a)/M_PI*180)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  double a,b,x; cin >>a >>b >>x;
  double s=2*x/a;
  if(s<a*b){
    printf("%.10lf",90-tr(atan(s/b/b)));
  }
  else{
    s=2*a*b-s;
    printf("%.10lf",90-tr(atan(a*a/s)));
  }
}

/// confirm df==0 ///


Measured memory_bytes: 384
#include <cstdio>

using namespace std;

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int ans=0;
	for(int i=1;i<=10000000;i++)
	{
		if((a&1)||(b&1)||(c&1))break; 
		ans++;
		int t1=b/2+c/2,t2=a/2+c/2,t3=a/2+b/2;
		a=t1,b=t2,c=t3;
	}
	if(ans==1e7)printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<pair<int,int>,int> memo;

int dfs(int i,int j,vector<vector<int>>& gra){
    if(i==gra.size()-1 && j==gra[0].size()-1) {return 1;}
    //if(memo[make_pair(i,j)]) return memo[make_pair(i,j)];
    int count=0;
    if(i+1<gra.size() && gra[i+1][j]==1) count= (count%1000000007 + dfs(i+1,j,gra)%1000000007)%1000000007;
    if(j+1<gra[0].size() && gra[i][j+1]==1) count = (count%1000000007 +dfs(i,j+1,gra)%1000000007)%1000000007;
    memo[make_pair(i,j)] = count%1000000007;
    return count%1000000007;
}

int main() {
	int h,w; cin>>h>>w;
	vector<vector<int>> gra;
	for(int i=0;i<h;i++){
	    vector<int> t;
	    for(int j=0;j<w;j++){
	        char c;cin>>c;
	        if(c=='.')t.push_back(1);
	        else t.push_back(0);
	    }
	    gra.push_back(t);
	}
	vector<vector<int>> dp(h,vector<int>(w,0));
	dp[0][0] = 1;
	for(int i=0;i<h;i++){
	    for(int j=0;j<w;j++){
	        if(gra[i][j]==0)dp[i][j] = 0;
	        else if(i-1>=0 && j-1>=0){
	            dp[i][j] = (dp[i-1][j]%1000000007+dp[i][j-1]%1000000007)%1000000007;
	        }else if(i-1>=0){
	            dp[i][j] = dp[i-1][j]%1000000007;
	        }else if(j-1>=0){
	            dp[i][j] = dp[i][j-1]%1000000007;
	        }else{
	            dp[i][j] =1;
	        }
	    }
	}
	cout<<dp[h-1][w-1];
}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++){
		cin >> d[i];
	}

	int ans;
	int size=d.size()/2;
	sort(d.begin(),d.end());
	ans=d[size]-d[size-1];

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

Measured memory_bytes: 640
#include <iostream>
#include <stack>

using namespace std;

static const int N = 100;
static const int WHITE = 0;
static const int GRAY  = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

// u に隣接する v を番号順に取得
int next(int u)
{
    for (int v = nt[u]; v < n; v++) {
        nt[u] = v + 1;
        if (M[u][v]) return v;
    }

    return -1;
}

// スタックを用いた深さ優先探索
void dfs_visit(int r)
{
    int i;
    stack<int> S;

    for (i = 0; i < n; i++) nt[i] = 0;

    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;

    while (!S.empty()) {
        int u = S.top();
        int v = next(u);

        if (v != -1) {
            if (color[v] == WHITE) {
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        } else {
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}

void dfs()
{
    int i, u;

    // 初期化
    for (i = 0; i < n; i++) {
        color[i] = WHITE;
    }
    tt = 0;

    // 未訪問の u を始点として深さ優先探索
    for (u = 0; u < n; u++) {
        if (color[u] == WHITE) dfs_visit(u);
    }
    for (i = 0; i < n; i++) {
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main()
{
    int u, k, v;
    int i, j;

    cin >> n;
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < n; j++) M[i][j] = 0;
    }

    for (i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    dfs();

    return 0;
}


Measured memory_bytes: 3140
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int n;
vector<vector<int>> a;
ll memo[3][110];
ll dp(int i, int j){
    if(i == 0 && j == 0) return a[0][0];
    if(memo[i][j] != -1) return memo[i][j];

    ll res = 0;
    if(i - 1 >= 0){
        res = max(res, dp(i - 1, j) + a[i][j]);
    }
    if(j - 1 >= 0){
        res = max(res, dp(i, j - 1) + a[i][j]);
    }

    return memo[i][j] = res;
}

int main(void){
    cin >> n;
    a.resize(2);
    for(int i = 0; i < 2; i++){
        a[i].resize(n);
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < 3; i++){
        for(int j = 0; j <= n; j++){
            memo[i][j] = -1;
        }
    }

    cout << dp(1, n - 1) << endl;

}

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

long long ans;

/*void solve(int a,int b,int c)
{
	long long s=a*b,v1,v2;
	for(int i=1;i<=c/2;++i)
	{
		v1=s*i;
		v2=s*(c-i);
		if(ans>abs(v2-v1))
			ans=abs(v2-v1);
	}
}*/

int main()
{
	long long a[3];
	while(cin>>a[0]>>a[1]>>a[2]){
	/*ans=a*b*c;
	solve(a,b,c);
	solve(a,c,b);
	solve(b,c,a);*/
	if(a[0]%2==0||a[1]%2==0||a[2]%2==0)
		ans=0;
	else
	{
		sort(a,a+3);
		ans=a[0]*a[1];
	}
	cout<<ans<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a==b)printf("a == b\n");
	else if(a>b)printf("a > b\n");
	else printf("a < b\n");
	
	return 0;
}

Measured memory_bytes: 580
import java.util.*;

class Main{
    public static long min(long a,long b){
        return (a<b)?a:b;
    }
    
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        long B=sc.nextLong();
        long N=sc.nextLong();
        
        long ans=min(B-1,N);
        
        double xdivB=(double)(ans)/(double)(B);
        
        while(xdivB>1){
            xdivB/=10;
        }
        
        xdivB*=A;
        
        System.out.println((int)(xdivB));
    }
}

Measured memory_bytes: 35844
#include <bits/stdc++.h>
#define $ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define endl "\n"
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    $
    int n,m,sum = 0;
    cin >> n >> m;
    int arr[m];
    for (int i = 0 ; i<m ; i++) {
        cin >> arr[i];
        sum += arr[i];
    }
    if (sum > n) {
        cout << -1 << endl;
        return 0;
    }
    else {
        cout << n - sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3708
import java.util.*;

class Main{
 public static void main(String[] args){
  int x,i=0;

  Scanner scan = new Scanner(System.in);  

  while(true){
   i++;
   x=scan.nextInt();
   if(x==0){break;}
   
   System.out.println("Case "+i+": "+x);
  }
 }
}

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

#define ll long long 
#define ld long double 
#define pii pair<ll,ll>

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
ll M = 1e9+7;
ll n;
ll a[100005];

int main()
{
    fastio;
    ll ans=0,a,b,c;
    cin>>a>>b>>c;
    ans = b + min(b+a+1,c) ;
    cout << ans << "\n"; 
    return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

void run (void) {
  char s[16];
  scanf ("%s", s);
  i32 k = strlen (s);
  i32 cnt = 15 - k;
  for (i32 i = 0; i < k; ++i) {
    if (s[i] == 'o') cnt++;
  }
  puts (cnt >= 8 ? "YES" : "NO");
}

int main (void) {
  run();
  return 0;
}


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

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;


int n, M[MAX][MAX];

void dijkstra() {
    int minv;
    int d[MAX], color[MAX];

    for( int i = 0; i < n; i++ ) {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = GRAY;

    while(1) {
        minv = INFTY;
        int u = -1;
        for (int i = 0; i < n; i++) {
            if (minv  > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1 ) {
            break;
        }
        color[u] = BLACK;
        for (int v = 0; v < n; v++) {
            if (d[v] > d[u] +M[u][v]) {
                d[v] = d[u] + M[u][v];
                color[v] = GRAY;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << i << " " << ( d[i] == INFTY ? -1 : d[i] ) << endl;
    }
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = INFTY;
        }
    }

    int k, c, u, v;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            M[u][v] = c;
        }
    }

    dijkstra();
    return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

using P1 = array<int, 26>;
using P2 = array<int, 365>;

struct state{
    array<int, 26> prv;
    array<int, 365> ans;
    int val;
    bool operator<(const state &a) const { return val > a.val; }
    state(P1 a, P2 b, int x) : prv(a), ans(b), val(x) {};
};


int main() {
    int d;
    cin >> d;
    array<int, 26> A{};
    for (auto &&k : A) cin >> k;
    vector<array<int, 26>> v(d);
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < 26; ++j) {
            scanf("%d", &v[i][j]);
        }
    }
    vector<int> ans(d);
    int W = 10;
    vector<state> a;
    a.emplace_back(P1{}, P2{}, 0);
    fill(a[0].prv.begin(),a[0].prv.end(), -1);
    for (int i = 0; i < d; ++i) {
        priority_queue<state> Q;
        for (auto &&s : a){
            for (int k = 0; k < 26; ++k) {
                state ss(s);
                ss.ans[i] = k;
                ss.val += v[i][k];
                ss.prv[k] = i;
                for (int l = 0; l < 26; ++l) {
                    ss.val -= (i-ss.prv[l])*A[l];
                }
                Q.emplace(ss);
                if(Q.size() > W) Q.pop();
            }
        }
        a.clear();
        while(!Q.empty()) a.emplace_back(Q.top()), Q.pop();
    }
    for (auto &&m : a.back().ans) {
        printf("%d\n", m+1);
    }
    return 0;
}

Measured memory_bytes: 3896
#include <bits/stdc++.h> // imports every library in c++
using namespace std; // ; is essential | says that you are USING the libraries

int A, B, C;

int main() {
    cin >> A;
    cin >> B;
    cin >> C;
    int d = A - B;
    int e = C - d;
    if(e < 0){
        cout << 0;
    } else {
        cout << e;
    }
    return 0;
}

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

using namespace std;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int a, b;
    cin >> a >> b;
    string s, t;
    cin >> s >> t;
    int top = 1;
    int bottom = h;
    int left = 1;
    int right = w;
    bool fail = false;
    for (int i = n - 1; i >= 0; --i) {
        if (t[i] == 'U') {
            bottom = min(h, bottom + 1);
        } else if (t[i] == 'D') {
            top = max(1, top - 1);
        } else if (t[i] == 'L') {
            right = min(w, right + 1);
        } else {
            left = max(1, left - 1);
        }
        if (s[i] == 'U') {
            top = max(2, top + 1);
        } else if (s[i] == 'D') {
            bottom = min(h - 1, bottom - 1);
        } else if (s[i] == 'L') {
            left = max(2, left + 1);
        } else {
            right = min(w - 1, right - 1);
        }
        if (top > bottom || left > right) {
            fail = true;
            break;
        }
       // cout << top << " " << bottom << " " << left << " " << right << "\n";
    }
    if (fail || b < left || b > right || a < top || a > bottom) {
        cout << "NO\n";
    } else {
        cout << "YES\n";
    }
    return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;
#define INF 1LL<<60
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
ll lcm(ll a, ll b) {
    if (a == INF) return INF;
    if (b == INF) return INF;
    a /= gcd(a, b);

    ld aa = log10l(a);
    ld bb = log10l(b);

    if (log10l(INF) <= aa + bb) return INF;

    return a * b;
}
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/




typedef long double ld;
#define INF 1LL<<60
int N; ll M; ll A[20]; ld P[20];
ll f[1 << 20];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) {
        int x; cin >> x;
        P[i] = x / 100.0;
    }

    // f[mask] := ??¨?????????mask??¨?????§????????????????????°
    rep(mask, 1, 1 << N) {
        ll lc = 1;
        rep(i, 0, N) if(mask & (1 << i)) lc = lcm(lc, A[i]);
        f[mask] = M / lc;
    }

    // ????????????????????????????????\??????????????????????????????
    // f[mask] := ??¨?????????mask?????????????????§????????????????????°
    rep(i, 0, N) rep(j, 0, 1 << N) if (j & (1 << i)) f[j] -= f[j ^ (1 << i)];

    ld ans = 0;
    rep(mask, 0, 1 << N) {
        ld p = 1;
        rep(i, 0, N) {
            if (mask & (1 << i)) p *= P[i];
            else p *= 1 - P[i];
        }

        ans += (ld)abs(f[mask]) * p;
    }
    printf("%.10llf\n", ans);
}

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

int main() {
  int i=6,ans=0;
  char x;
  for(i=1;i<=6;i++) {

    cin >> x;
    if(x == '1') ans+=1;
  }
  cout << ans << endl;
  return 0;
}     
    

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

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

    int c4 = 0,c2 = 0, c = 0;

    for (int i = 0; i < N; ++i) {
        int cur;
        cin >> cur;
        if (cur % 4 == 0) c4++;
        else if (cur % 2 == 0) c2++;
        else c++;
    }
    if (c4 + 1 >= c && c2 == 0) {
        cout << "Yes" << endl;
    } else if (c4 >= c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }



    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::vector<int> a(N);

  int max_v1 = -1, max_v2 = -1;
  for (int i = 0; i < N; ++i) {
    std::cin >> a[i];
    if (max_v1 <= a[i]) {
      max_v2 = max_v1;
      max_v1 = a[i];
    } else if (max_v2 < a[i]) {
      max_v2 = a[i];
    }
  }

  for (int i = 0; i < N; ++i) {
    if (a[i] == max_v1) std::cout << max_v2 << std::endl;
    else std::cout << max_v1 << std::endl;
  }
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;using std::queue;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;using std::swap;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::vector<int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}

namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
template<class T> void rsort(T &v){std::sort(v.rbegin(),v.rend());}
}

int main(){
  int a,b,n;cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
  return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if((a+b) % 2 == 1){
    cout << "IMPOSSIBLE" << endl;
  }
  else{
    if(a > b){
      cout << a + (b-a)/2 << endl;
    }
    else{
      cout << b + (a-b)/2 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false

signed main(void){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    while(1){
        C-=B;
        if(C<=0){
            cout << "Yes" << endl;
            return 0;
        }
        
        A-=D;
        if(A<=0){
            cout << "No" << endl;
            return 0;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3624
#include <cstdio>
using namespace std;
int main(void){
    // Here your code !
    int a;
    int b;
    scanf("%d %d", &a, &b);
    if (a > b){
        printf("a > b\n");
    }
    else if (a < b){
        printf("a < b\n");
    }
    else{
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 2532
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx")

#include <bits/stdc++.h>

using namespace std;

#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

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

    for (int i = 1; i <= 5; i++) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i << '\n';
            return 0;
        }
    }

    return 0;
}

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

using namespace std;

int p[25], a[4];

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> p[i];
    for (int i = 2; i < n; ++i) {
        for (int j = i - 1; j <= i + 1; ++j) a[j - i + 2] = p[j];
        sort(a + 1, a + 4);
        if (a[2] == p[i]) ans++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def f(S):
    worst = 0
    res = 0
    for s in S:
        if(s=='('):
            res += 1
        else:
            res -= 1
        worst = min(worst, res)
    return worst, res
def main():
    N=I()
    S=[ST() for _ in range(N)]
    
    AB_nega=[]
    AB_nonnega=[]
    for i in range(N):
        a,b = f(S[i])
        if b<0:
            AB_nega.append((a,b))
        else:
            AB_nonnega.append((a,b))
    
    AB_nega.sort(key=lambda x:-x[0]+x[1], reverse =True)
    AB_nonnega.sort(reverse = True)

    # print(AB_nega)
    # print(AB_nonnega)

    now = 0
    for a,b in AB_nonnega:
        if(now+a < 0):
            print("No")
            return
        now += b
        # print(now,"#######")
    
    
    for a,b in AB_nega:
        if(now+a<0):
            print("No")
            return
        now += b
        # print(now,"#########")
    if now == 0:
        print('Yes')
    else:
        print("No")


    
if __name__ == '__main__':
    main()

Measured memory_bytes: 210168
N = int(input())
a = [s for s in map(int, input().split())]
a.append(-1)
c = 0
result = 0
for i in range(1, N + 1):
	if a[i] == a[i - 1]:
		c += 1
	else:
		if c == 0:
			continue
		else:
			c += 1
			if c % 2 == 1:
				result += (c - 1) / 2
				c = 0
			else:
				result += c / 2
				c = 0
print(int(result))


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws Exception {
        BufferedReader br = 
                new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int num = Integer.parseInt(line);
        int sec = num % 60;
        int min = num / 60 % 60;
        int hour = num / (60 * 60) % 60;

        System.out.println(String.format("%d:%d:%d", hour, min, sec));
    }
}

Measured memory_bytes: 24736
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;
    string rs = s;
    reverse(rs.begin(), rs.end());
    if (s != rs) {
        cout << "No" << endl;
        return 0;
    }
    string s1 = s.substr(0, (s.size() - 1) / 2);
    string rs1 = s1;
    reverse(rs1.begin(), rs1.end());
    if (s1 != rs1) {
        cout << "No" << endl;
        return 0;
    }
    string s2 = s.substr(0, (s.size() - 1) / 2);
    string rs2 = s2;
    reverse(rs2.begin(), rs2.end());
    if (s2 != rs2) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int A,B,C,D;

	scanf("%d %d %d %d",&A,&B,&C,&D);

	printf("%d\n",min(A,B)+min(C,D));

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    double l; cin >> l;
    l /= 3.0;
    cout << fixed << setprecision(15);
    cout << l*l*l << endl;
}

Measured memory_bytes: 256
import sys
n=input()
pair=[]
sort=[]
for i in range(n):
	a, b=map(int, raw_input().split())
	pair.append([[a, 0], [b, 0]])
	sort.append((a, i, 0))
	sort.append((b, i, 1))
sum=0
sort.sort()
for i in range(n):
	assert pair[sort[i][1]][sort[i][2]][0]==sort[i][0]
	pair[sort[i][1]][sort[i][2]][1]=1
	sum+=sort[i][0]
cnt=[[0, 0], [0, 0]]
for i in range(n):
	cnt[pair[i][0][1]][pair[i][1][1]]+=1
assert cnt[0][0]==cnt[1][1]
if cnt[0][0]>0 or cnt[0][1]==n or cnt[1][0]==n:
	print sum
else:
	min_value=1000000000000000000
	max_value=-1
	for i in range(n):
		if pair[i][0][1]:
			assert pair[i][1][1]==0
			min_value=min(min_value, pair[i][1][0])
			max_value=max(max_value, pair[i][0][0])
		else:
			assert pair[i][1][1]==1
			min_value=min(min_value, pair[i][0][0])
			max_value=max(max_value, pair[i][1][0])
	min_id=-1
	max_id=-1
	for i in range(n):
		if pair[i][0][1]:
			assert pair[i][1][1]==0
			if min_value==pair[i][1][0]:
				min_id=i
			if max_value==pair[i][0][0]:
				max_id=i
		else:
			assert pair[i][1][1]==1
			if min_value==pair[i][0][0]:
				min_id=i
			if max_value==pair[i][1][0]:
				max_id=i
	assert min_value>=max_value
	if min_id!=max_id:
		print sum-max_value+min_value
	else:
		new_min_value=1000000000000000000
		new_max_value=-1
		for i in range(n):
			if i==min_id:
				continue
			if pair[i][0][1]:
				new_min_value=min(new_min_value, pair[i][1][0])
				new_max_value=max(new_max_value, pair[i][0][0])
			else:
				assert pair[i][1][1]==1
				new_min_value=min(new_min_value, pair[i][0][0])
				new_max_value=max(new_max_value, pair[i][1][0])
		print min(sum-max_value+new_min_value, sum-new_max_value+min_value)
		print>>sys.stderr, "\n\n\n"


Measured memory_bytes: 64164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        String s = "" + n;
        String a = "";
        for (int i = s.length() - 1; i >= 0; i--) {
            a += s.charAt(i);
        }
        if (s.equals(a)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,m; cin >> n >> m;
  cout << (n-1)*(m-1) << endl;
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int N; string S;
	cin >> N >> S;
	int ans = 0;
	rep(i, 1000) {
		int x = i;
		int r = x % 10;
		x /= 10;
		int q = x % 10;
		x /= 10;
		int p = x;

		V<int> vd{p,q,r};
		int now = 0;

		rep(j, S.size()) {
			if (now < 3 && S[j] == '0' + vd[now]) {
				now++;
			}
		}
		if (now == 3) {
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n,t;
  cin >> n >> t;
  ll a[n],b[n];
  vector<vector<ll>> v;
  for(ll i=0;i<n;i++){
    ll c,d;
    cin >> c >> d;
    v.push_back({c,d});
  }
  sort(v.begin(),v.end());
  for(ll i=0;i<n;i++){
    a[i]=v[i][0];
    b[i]=v[i][1];
  }

  vector<vector<ll>> dp(n+1,vector<ll>(t+1,0));
  //i番目までの料理から選んで、時刻jまでに完食した場合の最大満足度

  for(ll i=0;i<n;i++){
    for(ll j=1;j<=t;j++){
      if(j>=a[i])dp[i+1][j]=max(dp[i][j],dp[i][j-a[i]]+b[i]);
      else dp[i+1][j]=dp[i][j];
    }
  }

  ll s=0;
  for(ll i=1;i<n;i++){
    s=max(dp[i][t-1]+b[i],s);
  }

  cout << s << endl;

}

Measured memory_bytes: 73900
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9;
ll const inf = 2e5+1;

void solve()
{   

    string n; cin >> n;
    ll k; cin >> k; set<ll> unlike;
    f(i,0,k)
    {
        ll x; cin >> x;
        unlike.insert(x);
    }
    ll add;
    f(i,0,10)
        if(unlike.count(i)==0)
        {
            add = i;
            break;
        }

    n = '0'+n;
   
    
    bool f = 0; ll ind=n.size();
    for(ll i=n.size()-1; i>=0; i--)
    {
        ll curr = (ll)(n[i]-'0');
        if( (i>0 && unlike.count( curr )) || f )
        {
            bool g = 1;
            f(j, curr+1, 10 )
            {
                if( unlike.count( j )==0 ){
                    n[i]= (char)(j+48);
                    f=0,g=0;
                    ind = i+1;
                    break;
                }
            }
            if(g)
                f=1;
        }
    }
    
    f(i,ind,n.size())
        n[i]=(char)(add+48);

    if(n[0]=='0')
        cout << n.substr(1,n.size()-1);
    else
        cout << n << endl;
}

int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/


        
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        f(testcases,0,t){
            solve();
        }
 
 
 
 
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main{ // Main
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int r = scanner.nextInt();
		int g = scanner.nextInt();
		int b = scanner.nextInt();
		
		if((g*10+b) % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
				
		scanner.close();
	}
}

Measured memory_bytes: 21972
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  string s,t;
  cin >> n >> s >> t;
  string ans = "";
  rep(i,n){
    ans += s.substr(i,1) + t.substr(i,1);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
int main ()
{
    int m,n,ans;
    cin>>m>>n;

    if(m>=13)
    {
        ans=n;
    }
    else if(m==6)
    {
        ans=n/2;
    }
    else if(m==12)
    {
        ans=n/2;
    }
    else if (m<=5)
    {
        ans=0;
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int a[5],n=0,m=0;
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    for(int i=0;i<3;i++){
        if(a[i]==5) n++;
        else if(a[i]==7) m++;
    }
    if(n==2&&m==1) printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
class Main{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
while(s.hasNext()){
int c=0;
for(int i=s.nextInt();i>0;--i){
BigInteger b=new BigInteger(s.next());
if(b.isProbablePrime(5))++c;
}
System.out.printf("%d\n",c);
}
}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int N; cin >> N;
  vector<int> T(N),A(N);
  rep(i,N) cin >> T[i] >> A[i];
  
  ll ansT,ansA;
  ansT = ansA = 1;
  rep(i,N) {
    ll t = (ansT + T[i] - 1) / T[i];
    ll a = (ansA + A[i] - 1) / A[i];

    ansT = max(t,a) * T[i];
    ansA = max(t,a) * A[i];
  }

  cout << ansT + ansA << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) {
        cin >> A[i];
        B[i] = A[i] - i - 1;
    }

    sort(all(B));

    vector<int> b;
    int half = N / 2;
    b.push_back(B[half]);
    if (half - 1 >= 0) b.push_back(B[half - 1]);
    if (half + 1 < N) b.push_back(B[half + 1]);

    ll ans = INF;
    rep(i, b.size()) {
        ll tmp = 0;
        rep(j, N) {
            tmp += abs(A[j] - (b[i] + j + 1));
        }
        // cout << b[i] << " " << tmp << endl;
        chmin(ans, tmp);
    }

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

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <stack>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;



void printarray(int n, int a[])
{
    for (int i = 0; i < n; i++)
    {
        cout << a[i];
        if (i != n - 1)
            cout << " ";
    }
    cout << endl;
}

void printpairaraay(int n, pair<int, int> a[])
{
    int x, y;
    for (int i = 0; i < n; i++)
    {
        x = a[i].first;
        y = a[i].second;
        cout << x << " " << y << "\n";
    }
    cout << endl;
}



void swaprange(int b, int t, int e, int a[])
{
    for (int i = 0; i < e - b; i++)
    {
        swap(a[b + i], a[i + t]);
    }
}

int main()
{
    int n, q, x;
  cin >> n;
    int a[n];
  	
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    cin >> q;

    for (int i = 0; i < q; i++)
    {   
      cin >> x;


      if (distance(lower_bound(a,a+n,x), upper_bound(a,a+n,x)) == 0) 
        cout << 0 << endl;
      else cout << 1 << endl;
    }
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 3496