akhauriyash/Code-Regression huggingface dataset:
H, W, h, w = map(int, input().split())
a = [[0] * W for i in range(H)]
INF = 10**9

for i in range(H):
	for j in range(W):
		if i % h == h - 1 and j % w == w - 1:
			a[i][j] = -INF
		elif i % h == 0 and j % w == 0:
			a[i][j] = INF - 1
if sum([sum(line) for line in a]) > 0:
	print("Yes")
	for i in range(H):
		print(*a[i])
else:
	print("No")

Measured memory_bytes: 51420
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    string S,T;
    cin >> S >> T;
    int res = 0;
    rep(i,3){
        if(S[i]==T[i])res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
while 1:
  x, y = map(int, raw_input().split())
  if x == y == 0:
     break


  if x < y:
     print '%d %d' %(x, y)
  elif x > y :
     print '%d %d' %(y, x)
  elif x == y:
     print '%d %d' %(x, y)

 

Measured memory_bytes: 6280
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
using namespace std;

int sqrtN = 710;
struct SqrtDecomposition{
    int N, K;
    vector <long long> data;
    vector <long long> bucketSum;
    
    SqrtDecomposition(){

    }

    SqrtDecomposition(int n){
        N = n;
        K = (N + sqrtN - 1) / sqrtN;
        data.assign(N, 0);
        bucketSum.assign(K, 0);
    }

    void add(int x, int y){
        data[x] += y;
        bucketSum[x / sqrtN] += y;
    }

    long long getSum(int x, int y){
        long long ans = 0;
        if(y - x < sqrtN){
            for(int i = x; i < y; i++){
                ans += data[i];
            }
            return ans;
        }
        for(int i = x / sqrtN + 1; i < y / sqrtN; i++){
            ans += bucketSum[i];
        }

        for(int i = x; i < (x / sqrtN + 1) * sqrtN; i++){
            ans += data[i];
        }
        for(int i = y / sqrtN * sqrtN; i < y; i++){
            ans += data[i];
        }
        return ans;
    }
    
};

SqrtDecomposition sqs[26];
int main(void){
    int N;
    cin >> N;
    string S;
    cin >> S;
    for(int i = 0; i < 26; i++){
        SqrtDecomposition tmp(N);
        sqs[i] = tmp;
    }
    for(int i = 0; i < N; i++){
        sqs[S[i] - 'a'].add(i, 1);
    }

    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int type;
        cin >> type;
        if(type == 1){
            int iq;
            char cq;
            cin >> iq >> cq;
            sqs[S[iq - 1] - 'a'].add(iq - 1, -1);
            sqs[cq - 'a'].add(iq - 1, 1);
            S[iq - 1] = cq;
        } else {
            int l;
            int r;
            cin >> l >> r;
            int ans = 0;
            for(int j = 0; j < 26; j++){
                if(sqs[j].getSum(l - 1, r) > 0){
                    ans ++;
                }
            }
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 106432
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define mp make_pair

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

int n;
vvi F; // n 頂点 m 辺のグラフ: 友達関係
vvi B; // n 頂点 k 辺のグラフ: ブロック関係
vi color; // グラフ F について同じ連結成分にいる頂点には同じ色をあてる
// vector<bool> seen;

void dfs(int v, int c){
	color[v] = c;
  	for (auto u : F[v]){
    	if(color[u]!=-1) continue;
      	dfs(u,c);
    }
}

void Main()
{
	int m, k;
  	cin >> n >> m >> k;
  	if(m==0){
      	rep(i,n) cout << 0 << " "; 
    	return;
    }  
  	F.resize(n);
  	color.resize(n,-1);
  	// seen.resize(n, false);
  
  	rep(i,m){
      	int a, b;
		cin >> a >> b;
      	a--, b--;
      	F[a].push_back(b);
      	F[b].push_back(a);      	
    }

  	// vi ans(n);
  	int c = 1;
  	rep(i,n){
		if(color[i]!=-1) continue;
      	dfs(i, c);
      	c++;
    }
  
  	/*
  	rep(i,n) {
      	cout << color[i] << " ";
    }
    //*/
  
  	vi cnt(c,0); // cnt[0] は使わない
  	rep(i,n){
    	cnt[color[i]]++;
    }
 
  	/*
  	rep(i,c){
    	cout << cnt[i] << " ";
    }
  	//*/
  	
    /*
  	rep(i,n){
    	cout << cnt[color[i]] << " ";
    }
  	//*/

  	B.resize(n);

  	rep(i,k){
      	int a, b;
		cin >> a >> b;
      	a--, b--;
      	if(color[a]==color[b]) {
          	B[a].push_back(b);
      		B[b].push_back(a);
        }
    }
  	
  	/*
  	rep(i,n){
    	// for(auto u:B[i]) cout << i << " " << u << endl;
      	cout << B[i].size() << endl;
	}
    */
  	
  	rep(i,n){
    	cout << cnt[color[i]]-1-F[i].size()-B[i].size() << " ";
    }
  	cout << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

int main() {
  int N;
  string S,T;
  cin>>N>>S>>T;
  vector<char>ans(2*N);
  for(int i=0;i<2*N;i+=2){
    ans[i]=S[i/2];
    ans[i+1]=T[i/2];
  }
  for(int i=0;i<2*N;i++){
    cout<<ans[i];
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 

using namespace std;

//#Rohitpratap311
//#Keep Calm And Stay Happy

typedef long long ll;
typedef long double ld;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n][3];
    for(ll i=0;i<n;i++)
    {
    	cin>>arr[i][0]>>arr[i][1]>>arr[i][2];	
    }
    ll dp[n][3];
    for(ll i=0;i<n;i++)
    {
    	for(ll j=0;j<3;j++)
    	{
    		if(i==0) { dp[i][j]=arr[i][j]; }
    		else
    		{
    			if(j==0) { dp[i][j]=arr[i][j]+max(dp[i-1][1],dp[i-1][2]); }
    			if(j==1) { dp[i][j]=arr[i][j]+max(dp[i-1][0],dp[i-1][2]); }
    			if(j==2) { dp[i][j]=arr[i][j]+max(dp[i-1][0],dp[i-1][1]); }
    		}
    	}
    }
 	cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
	return 0;
}

Measured memory_bytes: 8328
#include<bits/stdc++.h>
#define int1 long long
using namespace std;
int1 sum(int1 a[],int1 i,int1 j)
{
    int1 s=0;
    for(int1 g=i;g<=j;g++)
        s+=a[g];
    return s;
}
int main()
{
    int1 n;
    cin>>n;
    int1 a[n];
    for(int1 i=0;i<n;i++)
        cin>>a[i];
    int1 dp[n][n];
    for(int1 i=0;i<n;i++)
        for(int1 j=0;j<n;j++)
        dp[i][j]=0;

    for(int1 siz=1;siz<n;siz++)
    {
        int1 i=0;
        int1 j=i+siz;
        while(j<n)
        {
            dp[i][j]=LLONG_MAX;
            for(int1 k=i;k<j;k++)
            {
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+sum(a,i,k)+sum(a,k+1,j));
            }
            i++;
            j=i+siz;
        }
    }

    cout<<dp[0][n-1];
    return 0;
}


Measured memory_bytes: 1536
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {s: String};
    let s: String = s;

    let mut count = 0;
    let mut a_index = 20_000_000;
    let mut z_index = 0;

    for s_i in s.chars() {
        if s_i == 'A' && a_index == 20_000_000 {
            a_index = count;
        }

        if s_i == 'Z' {
            z_index = count;
        }

        count += 1;
    }

    println!("{}", z_index - a_index + 1)
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
using namespace std;

void reverse(string &str)
{
	int N = str.size();
	for (int i = 0; i < N/2; ++i)
		swap(str[i], str[N - 1 - i]);
}

int main() {
	int M;
	string s;
	string half1,half2,temp;
	int count,R1,R2,equal;
	vector<string> train;


	cin >> M;

	for (int i=0;i<M;i++) {
		train.clear();
		cin >> s;
		count = 0;

		for(int j=1;j<s.length();j++) { //??????????????????????±????
			half1 = "";
			half2 = "";
			for (int t=0;t<j;t++) {
				half1 += s[t]; //???????????????????????????	
			}
			for(int k=0;k<s.length()-j;k++) {
				half2 += s[j+k]; //??????????????????????????????
			}
			for (int p=0; p<2; p++) {
				if (p == 1) {
					temp = half1;
					half1 = half2;
					half2 = temp;
				}

				for(int t=0;t<4;t++) {
					equal = 0;

					if(t > 0) {
						reverse(half1);
					}
					if(t == 2) {
						reverse(half2);
					}	

					for(int l=0; l<train.size(); l++) {
						if (train[l] == half1+half2) {
							equal = 1;
						}
					}
					if (equal == 0) {
					train.push_back(half1+half2);
					}
					//cout << half1+half2 << endl;
				}

			}
			
			
			
		}
		cout << train.size() << endl;
	}
}

/*
???????????????1???????????????
*/

Measured memory_bytes: 3060
#include<cstdio>
int n,i,j,b[3],a=1,P=998244353;
char c;
int main(){
	scanf("%d\n",&n);
	for(i=1;i<=n;++i)a=1ll*a*i%P;
	for(i=1;i<=3*n;++i){
		c=getchar();
		int &t=b[(c>'B')+(c>'G')],m=1e7;
		for(j=0;j<3;++j)if(b[j]>t&&b[j]-t<m)m=b[j]-t;
		if(m<=n)a=1ll*a*m%P;
		++t;
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include<iomanip>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<long> vc;
    long num;
    for (int i = 0; i < N; i++)
    {
        cin >> num;
        vc.push_back(num);
    }
    long max=vc[0];
    int flag = 0;
    for (int i = 0; i < N; i++)
    {
        if (max<=vc[i])
        {
            max = vc[i];
        }
        else if (vc[i]<max-1)
        {
            cout << "No"<< endl;
            flag = 1;
            break;
        }
        
    }
    if (flag == 0)
    {
        cout << "Yes" << endl;
    }
    
}

Measured memory_bytes: 1400
#include <cstdio>
#include <algorithm>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

const int N = 200010;

struct edge{int to, next;} e[N];
int du[N], head[N], a[N], f[N];
int n, x, y, cnt, tot, ans1, ans2, rt;
bool fl;

void ins(int x, int y)
{
    e[++cnt].to = y; e[cnt].next = head[x]; head[x] = cnt; ++du[x];
}

bool check2(int mid, int len)
{
    int i = 1, j = tot;
    if (i == mid) ++i;
    if (j == mid) --j;

    for(; i < j;)
    {
        if (a[i] + a[j] > len) return 0;
        ++i, --j;
        if (i == mid) ++i;
        if (j == mid) --j;
    }
    return 1;
}

void dfs(int x, int y, int len)
{
    for(int i = head[x]; i; i = e[i].next)
        if (e[i].to != y) dfs(e[i].to, x, len);
    tot = 0;
    for(int i = head[x]; i; i = e[i].next)
        if (e[i].to != y) a[++tot] = f[e[i].to];
    if (!tot) {f[x] = 1; return;}

    if (!(tot & 1)) a[++tot] = 0;
    sort(a + 1, a + tot + 1);

    int l = 1, r = tot, U = n + 1;
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        if (check2(mid, len)) U = a[mid], r = mid - 1; else l = mid + 1;
    }
    if (U == n + 1) fl = 1;
    f[x] = U + 1;
}

bool check(int len)
{
    bool fl = 0; dfs(rt, 0, len);
    return !fl && f[rt] <= len + 1;
}

int main()
{
    scanf("%d", &n);
    FOR(i, 2, n)
    {
        scanf("%d%d", &x, &y);
        ins(x, y); ins(y, x);
    }
    FOR(i, 1, n) if (du[i] & 1) rt = i, ++ans1;
    ans1 >>= 1;
    int l = 1, r = n;
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        if (check(mid)) r = mid - 1, ans2 = mid; else l = mid + 1;
    }
    printf("%d %d\n", ans1, ans2);
    return 0;
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long

void solve() {
	int n, w;
	cin >> n >> w;
	vector<ll> values(w+1);
	for(int i=0; i<n; i++){
		int wi, vi;
		cin >> wi >> vi;
		for(int j=w-wi; j>=0; j--){
			values[j+wi] = max(values[j+wi], vi + values[j]);
		}
	}
	// for(auto x: values) cout << x << ' ';
	// cout << '\n';
	cout << *max_element(values.begin(), values.end());
}

using namespace std;
int main(){
	FAST(); 
	int t = 1; 
	// cin >> t; 
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

    int ans = b;

    if( a+b >= c ) {
        ans += c;
    } else {
        ans += a+b + 1;
    }

    cout << ans << endl;
}


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

int dp[1<<12];
int maxhp,hp;


int main() {
    while(cin>>hp>>maxhp, hp|maxhp) {
        int r,c,t,s,p,d,n;
        string str;
        cin>>r>>c;
        vector<string> mp(r);
        for(int i=0; i<r; ++i) cin>>mp[i];

        map<string,int> trap;
        cin>>t;
        for(int i=0; i<t; ++i) {
            cin>>str>>d;
            trap[str] = d;
        }

        cin>>s;
        string move;
        for(int i=0; i<s; ++i) {
            cin>>str>>n;
            move += string(n, str[0]);
        }

        cin>>p;
        vector<int> pot(p);
        for(int i=0; i<p; ++i) cin>>pot[i];

        int x = 0,y = 0;
        vector<int> dam;
        dam.push_back(0);
        for(int i=0; i<move.length(); ++i) {
            if(move[i] == 'U') y--;
            else if(move[i] == 'D') y++;
            else if(move[i] == 'R') x++;
            else if(move[i] == 'L') x--;
            dam.push_back(trap[string(1,mp[y][x])]);
        }

        memset(dp, -1, sizeof(dp));
        dp[0] = hp;

        for(int i=0; i<dam.size(); ++i) {
            for(int j=0; j<(1<<p); ++j)
                if(dp[j] > 0)
                    for(int k=0; k<p; ++k)
                        if((j & (1<<k)) == 0) {
                            dp[j|(1<<k)] = max(dp[j|(1<<k)],
                                               min(maxhp, dp[j] + pot[k]));
                        }
            for(int j=0; j<(1<<p); ++j) dp[j] -= dam[i];
        }
                 

        bool ok = false;
        for(int j=0; j<(1<<p); ++j) if(dp[j] > 0) ok = true;
        if(ok) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

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

using namespace std;
int main(){
	int a,b,c,d;
	int flag;
	cin>>a>>b>>c>>d;
    while(a>0||c>0){
    	c=c-b;
    	if(c<=0){
		
    	flag=0; break;
		}
	    a=a-d;
    	if(a<=0){
		flag=1;
		break;
    }
	}
	
	if(flag==1)
	cout<<"No"<<endl;
	else
	cout<<"Yes"<<endl;
return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>

int e[101]={0};
int N;
//
int num(int n){
	int c = 0;
	for(int i=2;i<=N;i++){
		if(e[i]>=n-1)c++;
	}
	return c;
}

int main(void){
	int i,j,ans;
	scanf("%d",&N);
	for(i=2;i<=N;i++){
		int kazu = i;
		for(j=2;j<=i;j++){
			while(kazu%j==0){
				e[j]++;
				kazu /= j;
			}
		}
	}
	ans = num(75) + num(25)*(num(3)-1) + num(15)*(num(5)-1) + num(5)*(num(5)-1)*(num(3)-2)/2;
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <sstream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
ll sum(int x){
	ll p10=10,ret=0;
	int i=1;
	for(;x>=p10-1;i++){
		ret+=i*(p10/10*9);
		p10*=10;
	}
	ret+=i*(x-p10/10+1);
	return ret;
}
string To_string(ll a){
	ostringstream os;
	os << a;
	return os.str();
}
int main(){
	while(true){
		int n,k;
		cin>>n>>k;
		if(n==0) break;
		int ub=1e9,lb=0;
		while(ub-lb>1){
			int m=(ub+lb)/2;
			if(n<=sum(m)) ub=m;
			else lb=m;
		}
		n-=sum(lb);
		string s;
		while(s.size()<100) s+=To_string(ub++);
		cout << s.substr(n-1,k) <<endl;
	}
}

Measured memory_bytes: 1220
class TRAMP:
    def __init__(self,arg_mark,arg_number,arg_input_index):
        self.mark = arg_mark
        self.number = arg_number
        self.input_index = arg_input_index

N = int(input())
table = []
for input_index in range(N):
    mark,number = map(str,input().split())
    table.append(TRAMP(mark,int(number),input_index))

def Partition(left,right):
    global table
    i = left-1
    pivot = table[right].number
    for start in range(left,right):
        if table[start].number <= pivot:
            i += 1
            table[i],table[start] = table[start],table[i]
    table[i+1],table[right] = table[right],table[i+1]
    return i+1

def quickSort(left,right):
        if left < right:
            q = Partition(left,right)
            quickSort(left,q-1)
            quickSort(q+1,right)

quickSort(0,N-1)
stable_FLG = True

for i in range(1,N):
    if table[i].number == table[i-1].number and table[i].input_index < table[i-1].input_index:
        stable_FLG=False
        break

if stable_FLG:
    print("Stable")
else:
    print("Not stable")

for i in range(N):
    print("%s %d"%(table[i].mark,table[i].number))
    


Measured memory_bytes: 29652
import java.util.Scanner;

public class Main{
  public static void main(String[] args){

    //String a = Scanner(System.in).nextLine();
    //String[] array = a.split(" ");
    //int[] intArray = new int[arrat.length];
    //for(int i=0; i<array.length; i++){
    //  intArray[i]=Integer.parseInt(array[i]);
    //}

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();

    if ((A%3==0) || (B%3==0) || ((A+B)%3==0)) {
        System.out.println("Possible");
    }else{
        System.out.println("Impossible");
    }
  }
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 x,n; cin >> x >> n;
    set<i32> p;
    rep(i,n) {
        i32 tmp;
        cin >> tmp;
        p.insert(tmp);
    }


    i32 ans,  min_diff = inf;
    for(i32 i = -1; i<105; ++i) {
        if(p.find(i) == p.end()) {
            if(abs(x-i) < min_diff) {
                ans = i;
                min_diff = abs(x-ans);
            }
            else if(abs(x-i) == min_diff) {
                chmin(ans, i);
                min_diff = abs(x-ans);
            }
        }
    }

    cout << ans << '\n';


    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(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 gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  string S;
  cin >> S;
  //int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
  rep(s,1<<3){//スイッチのオンオフ全探索
    //cout << "all:" << bitset<3>(s) << endl;
    int t=0;
    int res=S[0]-'0';
    rep(i,3){//一桁ずつチェック
      if(s>>i & 1) res+=S[i+1]-'0';
      else res-=S[i+1]-'0';
    }
    //cout << bitset<3>(t) << endl;
    if(res==7){
      cout << S[0];
      rep(i,3){//一桁ずつチェック
        if(s>>i & 1) cout << '+';
        else cout << '-';
        cout << S[i+1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


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

int x, a, b;

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

    if (x >= a && a + b >= x) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		while(sc.hasNext()) {
			int n = sc.nextInt();
			findCombie(n);
		}

	}

	private static void findCombie(int n) {
		int cnt = 0;

		for (int a = 0; a < 10; a++) {
			for (int b = 0; b < 10; b++) {
				for (int c = 0; c < 10; c++) {
					for (int d = 0; d < 10; d++) {
						if (a + b + c + d == n) {
							cnt++;
						}
					}
				}
			}
		}

		System.out.println(cnt);

	}

}


Measured memory_bytes: 26296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    string s;cin>>s;
    int a = 0;
    int b = 0;
    rep(i,3){
        if(s[i] == 'A' )a++;
        if(s[i] == 'B' )b++;
    }
    if(a==3 || b == 3)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;


    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,k; cin >> n >> k;
    VI h(n); REP(i,n) cin >> h[i]; SORT(h);
    int ans = INF;
    REP(i,n-k+1) chmin(ans,h[i+k-1]-h[i]);
    out(ans);

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

const int SIZE = 300000;

pair<int, vector<int>> get_cnt_and_indices(int c[SIZE]) {
    vector<pii> pc;
    REP(i, SIZE) pc.push_back({c[i], i});
    sort(ALL(pc), greater<pii>());
    int cnt = pc[0].first;

    vector<int> indices;
    REP(i, SIZE) {
        indices.push_back(pc[i].second);
        if (i == SIZE - 1 || pc[i].first != pc[i + 1].first) break;
    }
    sort(ALL(indices));
    return {cnt, indices};
}

int main() {
    int H, W, M;
    cin >> H >> W >> M;

    int hc[SIZE] = {}, wc[SIZE] = {};
    pii hw[SIZE] = {};
    REP(i, M) {
        int h, w;
        cin >> h >> w; h--; w--;
        hc[h]++;
        wc[w]++;
        hw[i] = {h, w};
    }
    int hcnt, wcnt;
    vector<int> ht, wt;
    pair<int, vector<int>> tmp = get_cnt_and_indices(hc);
    hcnt = tmp.first; ht = tmp.second;
    tmp = get_cnt_and_indices(wc);
    wcnt = tmp.first; wt = tmp.second;

    int cnt = 0;
    REP(i, M) {
        int h, w;
        h = hw[i].first; w = hw[i].second;
        if (binary_search(ALL(ht), h) && binary_search(ALL(wt), w)) cnt++;
    }

    ll ans = hcnt + wcnt;
    if (cnt == ht.size() * wt.size()) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 17048
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

dead = 0
yuusya_zan = 0
for i, yuusya in enumerate(b):
    monster = a[i]

    if yuusya_zan >= monster:
        dead += monster
        monster = 0
    else:
        dead += yuusya_zan
        monster -= yuusya_zan

    if yuusya >= monster:
        yuusya -= monster
        dead += monster
        yuusya_zan = yuusya
    else:
        dead += yuusya
        yuusya_zan = 0

monster = a[n]
if yuusya_zan >= monster:
    dead += monster
    monster = 0
else:
    dead += yuusya_zan
    monster -= yuusya_zan

print(dead)


Measured memory_bytes: 18476
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cstring>
#include<cmath>
using namespace std;
int cnt;
int n;
bool func(int num)
{
    if(num==2)return true;
    else if(num%2==0)return false;
    else if(num==1)return false;
    else
    {
        for(int i=3;i<=sqrt(num);i+=2)
        {
            if(num%i==0)return false;
        }
    }
    return true;
}
int main()
{
    int a,d,n;
    int cnt;
    while(cin>>a>>d>>n,a)
    {
        cnt=0;
        for(int i=a;i<=1000000;i+=d)
        {
            if(func(i))cnt++;
            if(cnt==n)
            {
                cout<<i<<endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int H,W;
		
		Scanner scan = new Scanner(System.in);
		while(true)
		{
			H=scan.nextInt();
			W=scan.nextInt();
			if(H==0&&W==0)
				break;
			for(int i=0;i<H;i++) {
				for(int j=0;j<W;j++) {
					System.out.printf("#");
				}
				System.out.printf("\n");
				
			}
			System.out.printf("\n");
			
		}

	}

}

Measured memory_bytes: 63236
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using l = long;
using vi = vector<int>;
using vl = vector<l>;
using vll = vector<ll>;
using vvl = vector<vector<l>>;
using vvll = vector<vector<ll>>;
using pll = pair<ll, ll>;
using un = unsigned;

int main()
{
	int k;
	string s;
	cin >> k >> s;
	if (s.length() <= k) cout << s;
	else {
		for (int i = 0; i < k; i++) cout << s[i];
		cout << "...";
	}
	return 0;
}


Measured memory_bytes: 3632
N = int(input().rstrip())
a = []
for n in range(N):
    a.append(int(input().rstrip()))

button = [1]
for _ in range(N-1):
    button.append(a[button[-1] - 1])
    if button[-1] == 2:
        print(len(button) - 1)
        exit()
    if button[-1] == button[-2]:
        break
    
print(-1)

Measured memory_bytes: 7856
n=int(input())
s=input()

alpha="abcdefghijklmnopqrstuvwxyz"

count=0
max=0

for i in range(1,n):
    x=s[:i]
    y=s[i:]
    for j in range(len(alpha)):
        if alpha[j] in x and alpha[j] in y:
            count+=1
    if count>max:
        max=count
    count=0

print(max)


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

int main(){
    string S;
    cin>>S;
    int cnt=0;
    rep(i,3){
        if(S[i]=='R')cnt++;
    }
    if(cnt==1||cnt==0)cout<<cnt<<endl;
    else if(cnt==3)cout<<3<<endl;
    else if(S[1]=='S')cout<<1<<endl;
    else cout<<2<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>

#include <stdio.h>

using namespace std;

int main(){

   vector<double> ans;
   int n;

   cin >> n;

   for(;n;){
      double m = 0;
      vector<int> s;
   
      for(int i = 0; i < n; i++){
         int p;
         cin >> p;

         s.push_back(p);
         m += p;
      }

      m /= n;

      double a = 0;

      for(int i = 0; i < s.size(); i++){
         a += (s[i] - m) * (s[i] - m) / n;
      }

      ans.push_back(sqrt(a));

      cin >> n;
   }

   for(int i = 0; i < ans.size(); i++){
      printf("%.8lf\n", ans[i]);
   }

   return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin>>n>>m;
  vector<vector<ll>>ed(3*n);
  rep(i,m){
    ll s,t;cin>>s>>t;
    s--;t--;
      ed[s*3].push_back(t*3+1);
      ed[s*3+1].push_back(t*3+2);
      ed[s*3+2].push_back(t*3);

  }
  queue<ll>que;
  ll s,t;cin>>s>>t;

  s--;t--;
  que.push(s*3);
  vector<ll>dist(3*n,1e9+7);
  dist[s*3]=0;
  while(!que.empty()){
    ll no=que.front();que.pop();
    for(auto nn:ed[no]){
      if(nn==3*t){
        //cout<<no<<" "<<nn<<endl;
        cout<<(dist[no]+1)/3<<endl;
        return 0;
      }
      if(dist[nn]==1e9+7){
        que.push(nn);
        dist[nn]=dist[no]+1;
      }
    }
  }
  cout<<-1<<endl;

  return 0;

}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int dp[100100][3];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n;
  cin>>n;
  vector<vi> a(n,vi(3));
  rep(i,n) rep(j,3) cin>>a[i][j];
  
  rep(i,n){
    rep(j,3){
      rep(k,3){
        if(j==k) continue;
        dp[i+1][j]=max(dp[i+1][j], dp[i][k]+a[i][j]);
      }
    }
  }
  int ans=0;
  rep(i,3) chmax(ans, dp[n][i]);
  cout<<ans<<endl;
}

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

int main(){
  int N;
  cin>>N;
  int cand[7]={64,32,16,8,4,2,1};
  for(int i=0;i<7;i++){
    if(N>=cand[i]){
      cout<<cand[i]<<endl;
      break;
    }
  }
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
    string t = Console.ReadLine();
    int ss = s.Length;
    int tt = t.Length;
    long[,] dp = new long[ss+1, tt+1];

    for(int i = 1; i <= ss; i++)
    {
      for(int j = 1; j <= tt; j++)
      {
        dp[i,j] = Math.Max(dp[i,j-1], dp[i-1,j]);
        if(s[i-1] == t[j-1]) dp[i,j] = Math.Max(dp[i,j], dp[i-1,j-1]+1);
      }
    }

    int memoA = ss;
    int memoB = tt;
    char[] answers = new char[dp[ss,tt]];
    char[] answerMemos = new char[dp[ss,tt]];
    int countMemo = 0;
    while(true)
    {
      if(dp[memoA, memoB] == 0) break;

      if(dp[memoA-1,memoB] == dp[memoA,memoB]) memoA--;
      else if(dp[memoA,memoB-1] == dp[memoA,memoB]) memoB--;
      else
      {
        answerMemos[countMemo] = s[memoA-1];
        memoA--;
        memoB--;
        countMemo++;
      }
    }

    for(int i = 0; i < answerMemos.Length; i++)
    {
      answers[i] = answerMemos[answerMemos.Length-1-i];
    }

    if(answers.Length > 0) Console.WriteLine(string.Join("", answers));
    else Console.WriteLine();
	}
}


Measured memory_bytes: 82912
import kotlin.math.abs
import kotlin.math.min

fun main(){
    val (x, k, d) = readLine()!!.split(" ").map { it.toLong() }
    if (x >= 0){
        val saitan = x / d
        if (k <= saitan){

            println(abs(x - k * d))

        } else {
            if ((k - saitan) % 2 == 0L){
                println(abs(x % d))
            } else {
                println(abs(x % d - d))
            }
        }
    } else {
        val useX = x * -1
        val saitan = useX / d
        if (k <= saitan){

            println(abs(x + (k * d )))

        } else {
            if ((k - saitan) % 2 == 0L){
                println(abs(x % d))
            } else {
                if (x % d > 0){
                    println(abs(x % d -d))
                } else {
                    println(abs(x % d + d))
                }
            }
        }
    }
}

Measured memory_bytes: 36496
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a<40)a=40;
	if(b<40)b=40;
	if(c<40)c=40;
	if(d<40)d=40;
	if(e<40)e=40;
	cout<<(a+b+c+d+e)/5<<endl;
	return 0;
	}



Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int num_e[N] = {};
    int num_w[N] = {};

    if (S[0] == 'E') num_e[0] = 1;
    else num_w[0] = 1;
    for (int i = 1; i < N; ++i) {
        if (S[i] == 'E') num_e[i] = num_e[i-1] + 1, num_w[i] = num_w[i-1];
        else num_w[i] = num_w[i-1] + 1, num_e[i] = num_e[i-1];
    }

    int res = num_e[N-1];
    for (int i = 1; i < N; ++i) {
        res = min(res, num_w[i-1] + (num_e[N-1] - num_e[i]));
    }
    cout << res << endl;

}


Measured memory_bytes: 3076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Math.abs;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final long n = scanner.nextInt();
        final long a = scanner.nextInt();
        final long b = scanner.nextInt();
        final long c = scanner.nextInt();
        final long d = scanner.nextInt();

        for (long i = 2; i < n; i++) {
            final long formerLower = c * (i - 1);
            final long latterLower = c * (n - i);
            final long formerUpper = d * (i - 1);
            final long latterUpper = d * (n - i);
            if (!(a + formerLower > b + latterUpper || a + formerUpper < b + latterLower)) {
                System.out.println("YES");
                return;
            }
        }

        System.out.println("NO");
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

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

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

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


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

int N, mod;
int dp[5009][5009];
int val[5009][5009];
long long t1[5009][5009];
long long t2[5009][5009];

void calc(int num) {
	int maxN = (N / 2);
	for (int i = 0; i <= maxN - 1; i++) {
		int cl = 0, cr = N - num;
		cr = min(cr, N - (maxN - i) * num);
		for (int j = cl; j <= cr; j++) {
			dp[i + 1][j + num] += dp[i][j];
			if (dp[i + 1][j + num] >= mod) dp[i + 1][j + num] -= mod;
		}
		for (int j = cr + num; j >= 0; j--) {
			val[i + 1][j] = val[i + 1][j + 1] + dp[i + 1][j];
			if (val[i + 1][j] >= mod) val[i + 1][j] -= mod;
		}
	}
}

int main() {
	cin >> N >> mod;
	dp[0][0] = 1; val[0][0] = 1;
	for (int i = 0; i <= N; i++) {
		calc(i);
		for (int j = 0; j <= N; j++) t1[i][j] = (val[N / 2][0] - val[N / 2][j + 1] + mod) % mod;
		for (int j = 0; j <= N; j++) t2[i][j] = dp[(N - 1) / 2][j];
	}

	long long ret = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= i; j++) {
			ret += t1[i - 1][j - 1] * t2[N - i][i - j];
			ret %= mod;
		}
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 492740
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <bits/stdc++.h>
using namespace std;
inline int read()
{
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
inline void write(int x)
{
    if(x<0)
	{
    	putchar('-');
		x=-x;
	}
    if(x>9)
		write(x/10);
    putchar(x%10+'0');
}
bool p(int a,int b,int c,int d)
{
	int s;
	s=a+b;
	s=s+c;
	s=s/d;
	s=s%2;
	return s;
}
bool q(int a,int b,int c,int d)
{
	int s;
	s=a-b;
	s=s+c;
	s=s/d;
	s=s%2;
	return s;
}
int main()
{
	ios::sync_with_stdio(false);
	int n,m,l,c;
	bool a,b;
	n=read();
	m=read();
	l=read();
    for(register int i=1;i<=n;i++)
    {
        for(register int j=1;j<=m;j++)
		{
			a=p(i,j,m,l);
			b=q(i,j,m,l);
			if(a==0)
			{
				if(b==0) cout<<'R';
				else cout<<'Y';
			}else{
				if(b==0) cout<<'G';
				else cout<<'B';
			}
        }
        cout<<endl;
	}
    return 0;
}

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

int main(){
    vector<vector<int>> a(3,vector<int>(3));
    
    rep(i,3){
        rep(j,3)
            cin>>a[i][j];
    }
    
    int n;
    cin>>n;
    
    
    rep(h,n){
        int b;
        cin>>b;
        rep(i,3){
            rep(j,3){
                if(a[i][j]==b){
                    a[i][j]=0;
                }
            }
        }
    }
   
    rep(i,3){
        int f1=a[i][0]+a[i][1]+a[i][2];
        int f2=a[0][i]+a[1][i]+a[2][i];
        if(f1==0){
            cout<<"Yes"<<endl;
            return 0;
        }
        if(f2==0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    
    int f3=a[0][0]+a[1][1]+a[2][2];
    if(f3==0){  
            cout<<"Yes"<<endl;
            return 0;
    }
    int f4=a[2][0]+a[1][1]+a[0][2];
    if(f4==0){
            cout<<"Yes"<<endl;
            return 0;
    }
    
    cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3632
<?php
fscanf(STDIN, "%d", $h);
fscanf(STDIN, "%d", $w);
fscanf(STDIN, "%d", $n);

$array = [$h, $w];
$max = max($array);
$ans = ceil($n / $max);
if($ans > 0){
    echo $ans;
}else{
    echo 1;
}

?>

Measured memory_bytes: 4856
#include<iostream>

using namespace std;

int ans;
int ans_max;
int map[10][10];
int x,y,s;

///////////////////////serch1////////////////////
void serch1(int xx,int yy)
{
	map[xx][yy]=-1;
	ans++;
	
	int dx[4]={1,0,-1,0};
	int dy[4]={0,1,0,-1};
/*
	getchar();
	
	system("cls");
	
	for(int i=0;i<10;i++)
	{
		for(int j=0;j<10;j++)
		{
			cout << map[j][i] << " " ;
		}
		cout << endl;
	}
	cout << ans << endl;
//*/
	if(map[xx+1][yy]!=0 && map[xx][yy+1]!=0 && map[xx-1][yy]!=0 && map[xx][yy-1]!=0)
	{
		return ;
	}
	
	
	for(int i=0;i<4;i++)
	{
		if(xx+dx[i]>=0 && yy+dy[i]>=0 && xx+dx[i]<10 && yy+dy[i]<10)
		{
			if(map[xx+dx[i]][yy+dy[i]]==0)
			{
				serch1(xx+dx[i],yy+dy[i]);
			}
		}
	}
}
///////////////////////serch2////////////////////
void serch2(int xx2,int yy2,int way)
{
	if(way==99)
		return ;
	if(ans_max<map[xx2][yy2])
		ans_max=map[xx2][yy2];
	
	map[xx2][yy2]=-2;
	
	int dx[4]={1,0,-1,0};
	int dy[4]={0,1,0,-1};
	
	for(int i=0;i<4;i++)
	{
		if(xx2+dx[i]>=0 && yy2+dy[i]>=0 && xx2+dx[i]<10 && yy2+dy[i]<10)
		{
			if(map[xx2+dx[i]][yy2+dy[i]]!=-2)
			{
				serch2(xx2+dx[i],yy2+dy[i],way+1);
			}
		}
	}
}
///////////////////////s_s////////////////////
void s_s(int s_x,int s_y)
{
	map[s_x][s_y]++;
	
	int dx[4]={1,0,-1,0};
	int dy[4]={0,1,0,-1};
	
	for(int i=0;i<4;i++)
	{
		if(s_x+dx[i]>=0 && s_y+dy[i]>=0 && s_x+dx[i]<10 && s_y+dy[i]<10)
			map[s_x+dx[i]][s_y+dy[i]]++;
	}
	
	return ;
}
///////////////////////s_m////////////////////
void s_m(int m_x,int m_y)
{
	map[m_x][m_y]++;
	int dx[8]={1,0,-1,0,-1,1,1,-1};
	int dy[8]={0,1,0,-1,-1,1,-1,1};
	
	for(int i=0;i<8;i++)
	{
		if(m_x+dx[i]>=0 && m_y+dy[i]>=0 && m_x+dx[i]<10 && m_y+dy[i]<10)
			map[m_x+dx[i]][m_y+dy[i]]++;
	}
	return ;
}
///////////////////////s_l////////////////////
void s_l(int l_x,int l_y)
{
	map[l_x][l_y]++;
	int dx[12]={1,0,-1,0,1,-1,-1,1,2,0,-2,0};
	int dy[12]={0,1,0,-1,-1,1,-1,1,0,2,0,-2};
	
	for(int i=0;i<12;i++)
	{
		if(l_x+dx[i]>=0 && l_y+dy[i]>=0 && l_x+dx[i]<10 && l_y+dy[i]<10)
			map[l_x+dx[i]][l_y+dy[i]]++;
	}
	return ;
}


int main()
{
	int i,j;
	char a;
	
	for(i=0;i<10;i++)
		for(j=0;j<10;j++)
			map[i][j]=0;
	
	for(;cin >> x ;)
	{
		cin >> a >> y >> a >> s ;
		if(s==1)
		{
			s_s(x,y);
		}
		else if(s==2)
		{
			s_m(x,y);
		}
		else if(s==3)
		{
			s_l(x,y);
		}
	}
	
	ans=0;
	ans_max=0;
	
	for(i=0;i<10;i++)
	{
		for(j=0;j<10;j++)
		{
			if(map[i][j]==0)
			{
				serch1(i,j);
			}
		}
	}
	
	serch2(0,0,0);
	
	cout << ans << "\n" << ans_max << endl;
}

Measured memory_bytes: 0