akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string s; cin>>s;
    string t; cin>>t;
    bool come=false;
    int index=0;
    for(int i=0;i<s.size();i++){
        bool flag=true;
        int temp=i;
        for(int j=0;j<t.size();j++){
            if(temp+j>(int)s.size()-1){flag=false;break;}
            if(s[temp+j]=='?')continue;
            else if(s[temp+j]==t[j])continue;
            else flag=false;
        }
        
        if(!flag)continue;
        cmax(index,i);
        come=true;
    }
    if(come){
        for(int j=0;j<s.size();j++){
            if(j==index){
                cout<<t;
                rep(i,(int)t.size()-1)j++;
            }else if(s[j]=='?')cout<<"a";
            else
                cout<<s[j];
        }
        cout<<endl;
        return 0;
    }
    cout<<"UNRESTORABLE"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 998244353;

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main(){
	ios_base::sync_with_stdio(false);
	ll n, s;
	cin >> n >> s;
	vector <ll> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z];
	}
	vector <ll> pow2(n+1);
	pow2[0] = 1;
	ll inv = binpow(2,mod-2,mod);
	for (int z=1;z<n;z++){
		pow2[z] = pow2[z-1]*2;
		pow2[z] %= mod;
	}
	vector <vector<ll>> dp(n,vector<ll>(s+1,0));
	for (int z=0;z<n;z++){
		if (arr[z] <= s){
			dp[z][arr[z]] += pow2[n-1];
			dp[z][arr[z]] %= mod;
		}
		for (int x=0;x<=s;x++){
			if (z > 0){
				dp[z][x] += dp[z-1][x];
				dp[z][x] %= mod;
			}
			if (x-arr[z] >= 0 && z > 0){
				dp[z][x] += dp[z-1][x-arr[z]]*inv;
				dp[z][x] %= mod;
			}
			
		}
	}
	cout << dp[n-1][s] << endl;
}

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

typedef std::pair<unsigned long long, unsigned long long> P;

bool pairCompare(const P& first, const P& second)
{
    return first.first < second.first;
}

int main()
{
    unsigned long long N, M;
    std::cin >> N >> M;
    std::vector<P> X;
    X.resize(N);
    for (auto& it : X) {std::cin >> it.first >> it.second;}
    
    std::sort(X.begin(), X.end(), pairCompare);

    unsigned long long count = 0;
    unsigned long long sum = 0;
    unsigned long long X_count = 0;
    while(count < M)
    {
        if (0 < X[X_count].second)
        {
            ++count;
            sum += X[X_count].first;
            --X[X_count].second;
        }
        else
        {
            ++X_count;
        }
    }
    std::cout << sum << std::endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
int a;
  scanf("%d",&a);
  if(a<=111){printf("111");}
  else if(112<=a&&a<=222){printf("222");}
    else  if(223<=a&&a<=333){printf("333");}
    else  if(334<=a&&a<=444){printf("444");}
    else  if(445<=a&&a<=555){printf("555");}
    else  if(556<=a&&a<=666){printf("666");}
    else  if(667<=a&&a<=777){printf("777");}
    else  if(778<=a&&a<=888){printf("888");}
    else  if(889<=a&&a<=999){printf("999");}
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
 public static void main(String[] args){
   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();
   }
   Arrays.sort(a);
   int ans1=a[N-1];
   int ans2=a[0];
   int tmp=0;
   if(ans1%2==0)
   {
     for(int i=1;i<N-1;i++)
     {
       if(ans1/2<=a[i]) 
       {
         tmp = i;
         break;
       }
     }
     if(tmp!=0)
     {
       if(Math.abs(a[tmp-1]-ans1/2)>=Math.abs(a[tmp]-ans1/2)) ans2=a[tmp];
       else ans2=a[tmp-1];
     }
   }
   else
   {
          for(int i=1;i<N-1;i++)
     {
       if(ans1/2 +1<=a[i]) 
       {
         tmp = i;
         break;
       }
     }
     if(tmp!=0)
     {
       if(Math.abs(a[tmp-1]-ans1/2)>=Math.abs(a[tmp]-(ans1/2 +1))) ans2=a[tmp];
       else ans2=a[tmp-1];
     }
   }
   System.out.println(ans1+" "+ans2);  
 }
}

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

int main()
{
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x,y;
    x = x2-x1;
    y = y2-y1;
    cout << x2-y << " " << y2+x << " " << x1-y << " " << y1+x << endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)
//#define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

//using namespace __gnu_pbds;

using namespace std;

//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n;
string s;
int ans, no;
int main()
{
	cin >> n >> s;
	FOR (i, 0, n-1) {
		if (s[i]=='I') no++;
		else
		no--;
		ans = max(ans, no);
	}
	cout << ans;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define unmap unordered_map
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int bignumlen = 2200;
const int Blen = 8;
const ll base = 100000000;
const int baseHash = 31;
const ld PI = acos(-1);

//Remember limit for IT, etc...
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;

ll k, n;
ll a[limit];
ll s = 0;

void solveProblem() {
    a[0] = a[n] - k;
    ll ans = minN;
    ll res = 0, res1 = 0;

    REP(i, 1, n) {
        ans = max(ans, a[i] - a[i - 1]);
        s += a[i] - a[i - 1];
    }

    cout << s - ans << endl;
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> k >> n;
    REP(i, 1, n) cin >> a[i];
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}



Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
using namespace std;
int main(){
long n,i,m,p,h,w;
double b;
while(cin>>n){
if(n==0)break;
cin>>m>>h>>w;
b=fabs(10000.*w/h/h-22);p=m;
for(i=1;i<n;i++){
cin>>m>>h>>w;
if(b>fabs(10000.*w/h/h-22)||
b==fabs(10000.*w/h/h-22)&&p>m){b=fabs(10000.*w/h/h-22);p=m;}
}
cout<<p<<endl;
}
return 0;
}

Measured memory_bytes: 1160
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long[] A) {
    return A.enumerate
        .map!(t => tuple(t[1], t[0]))
        .array
        .sort()
        .map!(t => (t[1] + 1).to!string)
        .join(" ");
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        A[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, A);
    else
        solve(N, A).writeln;
}


Measured memory_bytes: 10172
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    int n,m;cin >> n >> m;
    int t = n + m;
    int ans = t * (t - 1) / 2;
    ans -= n * m;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ctime>
#include<deque>
using namespace std;

#define fr                first
#define se                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pii               pair<int,int>
#define vi                vector<int>
#define mi                map<int,int>
#define pq                priority_queue<int>
#define set_bits(x)       __builtin_popcountll(x)
#define mod               1000000007
#define inf               1e18                        //Defining infinity the overflow of int
#define ps(x,y)           fixed<<setprecision(y)<<x   //for defining the precision of the decimal upto y places.
#define zrosetbits(x)     __builtin_ctzll(x)         //it will give no of 0's before the first 1 from the right.
#define mk(a,n,type)      type *a=new type[n];
#define test(t)           int t; cin>>t; while(t--)
#define no                cout<<"No\n";
#define yes               cout<<"Yes\n";
#define NO                cout<<"NO\n";
#define YES               cout<<"YES\n";
// #define for(i,n)          for(int i=0;i<n;i++)
// #define for(j,n)          for(int j=0;j<n;j++)
// #define forn(i,n)               for(int i=0;i<n;i--)



//**********************************************************************************************************
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

#define safemap               unordered_map<int,int,custom_hash>

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

void io()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin.tie(0);

}


int helper(int si, int a[], int n, vi &dp)
{
//BASE CASE
  if (si == n - 1)
    return 0;

  if (dp[si] != -1)
    return dp[si];

//RECURSIVE CASE
  int res = INT_MAX;

  for (int i = 1; i <= 2; i++)
  {
    if (si + i < n)
      res = min(abs(a[si + i] - a[si]) + helper(si + i, a, n, dp), res);
  }
  dp[si] = res;
  
  return res;
}


int32_t main()
{

  io();


  // test(t)
  // {

  int n;
  cin >> n;

  int a[n] = {0};

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

  vi dp(n + 1, -1);

  int ans = helper(0, a, n, dp);

  cout << dp[0] << "\n";



// cout << "Case #" << te << ": " << res << "\n";
//te++;
// double c_time = (double) (clock() - begin) / CLOCKS_PER_SEC;
// cout << ps(c_time, 4) << " seconds\n";
  //}

  return 0;
}







Measured memory_bytes: 11060
moji = str(input())
A,B,C,D = int(moji[0]),int(moji[1]),int(moji[2]),int(moji[3])

mojiretsu = str(A-B) + str(B-C) + str(C-D)
if ("00" in mojiretsu ):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
using System;
//using System.Collections.Generic;
//using System.Collections;
using System.Linq;

namespace solution
{
  class Class1
  {
    static void Main()
    {
      int N = int.Parse(Console.ReadLine());
      int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();

      bubbleSort(A, N);
    }

    static void bubbleSort(int[] A, int N)
    {
      int flag = 1;
      int count = 0;
      int i = 0;
      int temp = 0;
      while (flag == 1)
      {
        flag = 0;
        for (int j = N - 1; j >= i + 1; j--)
        {
          if (A[j] < A[j - 1])
          {
            temp = A[j];
            A[j] = A[j - 1];
            A[j - 1] = temp;
            count++;
            flag = 1;
          }
        }
        i++;
      }
      var As = A.Select(x => x.ToString()).ToArray();
      Console.WriteLine(String.Join(" ", As));
      Console.WriteLine(count);
    }
  }
}








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

using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    int n, a = 0;
    n = S.size();
    for(int i = 0; i < n; i++){
        char s, t;
        s = S[i];
        t = T[i];
        if(s != t){
            a += 1;
        }
    }
    cout << a;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
    {
        LL x,n;
        cin>>x>>n;
        LL a[n];
        map<LL,LL> mp;
        for (LL i = 0; i < n; i++) {
          cin >> a[i];
          mp[a[i]]++;
        }
        sort(a,a+n);
        LL mm=a[0];
        LL mx=a[n-1];
        LL i=x;
        LL j=x;
        while(mp[i]!=0 && mx>=x){
            i++;
        }
        while(mp[j]!=0 && mm<=x){
            j--;
        }
        if((x-j)<(i-x)) cout<<j<<endl;
        else if((x-j)>(i-x))  cout<<i<<endl;
        else cout<<j<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
  int n,a=0,b=0,c=0;
  char s[100005];
  scanf("%s",s);
  n=strlen(s);
  for(int i=0;i<n;i++){
    if(s[i]=='a') a++;
    if(s[i]=='b') b++;
    if(s[i]=='c') c++;
  }
  if(fabs(a-b)<=1&&fabs(a-c)<=1&&fabs(c-b)<=1){
    printf("YES");                                                               
  }else{
    printf("NO");                                                                       }
  return 0;
}                                                                                     

Measured memory_bytes: 1816
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,t,x,y,flag=1;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&t,&x,&y);
		if(!(t-(x+y)>=0&&(t-(x+y))%2==0))
		{
			flag=0;
		}
	}
	if(flag)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
		boolean[] number=new boolean[1000000];
		number[0]=false;
		number[1]=false;
		for(int i=2;i<1000000;i++){
			number[i]=true;
		}
		String s;
		while((s = r.readLine()) != null){
			int n=Integer.parseInt(s);
			int count=0;
			for(int j=0;j<=n;j++){
				if(number[j]==true){
					count++;
					for(int k=j;k<=n;k+=j){
						number[k]=false;
					}
				}
			}
			System.out.println(count);
			for(int l=2;l<1000000;l++){
				number[l]=true;
			}
		}
	}
}

Measured memory_bytes: 22260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<int> dp(n,0),h(n);rep(i,n)cin>>h[i];
    dp[1]=abs(h[1]-h[0]);
    rep2(i,2,n){
        dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputs;
		inputs = br.readLine().split(" ");
		int n = Integer.parseInt(inputs[0]), m = Integer.parseInt(inputs[1]);

		N[] nodes = new N[n];
		for ( int i = 0; i < n; i++ ) {
			nodes[i] = new N();
		}

		for ( int i = 0; i < m; i++ ) {
			inputs = br.readLine().split(" ");
			int x = Integer.parseInt(inputs[0]) - 1, y = Integer.parseInt(inputs[1]) - 1;
			nodes[x].chldList.add(nodes[y]);
			nodes[y].prntCnt++;
		}

		ArrayDeque<N> toCheck = new ArrayDeque<>();
		for ( N node : nodes ) {
			if ( node.prntCnt == 0 ) toCheck.add(node);
		}

		int lenMax = 0;
		while ( toCheck.size() > 0 ) {
			N node = toCheck.pollFirst();
			for ( N chld : node.chldList ) {
				chld.prntCnt--;
				chld.len = Math.max(node.len + 1, chld.len);
				lenMax = Math.max(lenMax, chld.len);
				if(chld.prntCnt == 0) {
					toCheck.add(chld);
				}
			}			
		}
		System.out.println(lenMax);
	}
}

class N implements Comparable<N> {
	int				len			= 0;
	int				prntCnt		= 0;
	ArrayList<N>	chldList	= new ArrayList<>();
	
	public N() {
	}

	@Override
	public int compareTo(N o) {
		return this.prntCnt - o.prntCnt;
	}
}


Measured memory_bytes: 55036
#include <bits/stdc++.h>
#define int long long
using namespace std;

int w[100005] , c[105];
int dp[105][100005];


main()
{
	int n , S;
	cin >> n >> S;
	
	for(int i = 1	; i <= n; i++){
		cin >> w[i] >> c[i];
	}
	
	for(int k = 1; k <= n; k++)
	{
		for(int s = 1; s <= S; s++)
		{
			if( s >= w[k] )
			{
				dp[k][s] = max( dp[k - 1][s - w[k]] + c[k] , dp[k - 1][s] );
			}
			else
				dp[k][s] = dp[k - 1][s]; 
		}
	}
	
	
	
	//for(int i = 1; i <= n; i++)
	//{ 
		//#
		//for(int j = 1; j <= S; j++)
		//{
			//cout << dp[i][j] << " ";
		//}
		//cout << endl;
	//}
	
	
	cout << dp[n][S] << endl;
}


Measured memory_bytes: 79360
N, M = gets.split.map(&:to_i)
A = Hash.new {false}
M.times do
  A[gets.to_i] = true
end

MOD = 10 ** 9 + 7

dp = Array.new(N + 1) {0}
dp[0] = 1

for i in 0..N
  next_stair_1 = i + 1
  next if next_stair_1 > N

  if A[next_stair_1] == false
    dp[next_stair_1] += dp[i]
    dp[next_stair_1] %= MOD
  end

  next_stair_2 = i + 2
  next if next_stair_2 > N

  if A[next_stair_2] == false
    dp[next_stair_2] += dp[i]
    dp[next_stair_2] %= MOD
  end
end

puts dp[-1]


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll sum = 0;
  rep(i, n - 1) {
    if (a[i] > a[i + 1]) {
      ll k = a[i] - a[i + 1];
      a[i + 1] += k;
      sum += k;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4040
#include <stdio.h>

int main(){
  int n,i;
  long a[100001],b;
  long result=0;
  
  scanf("%d",&n);
  for(i=0;i<n+1;i++){
    scanf("%ld",&a[i]);
  }
  
  for(i=0;i<n;i++){
    scanf("%ld",&b);
    
    if(a[i]>=b){
      result+=b;
    } else {
      result+=a[i];
      b-=a[i];
      if(a[i+1]>=b){
        result+=b;
        a[i+1]-=b;
      } else {
        result+=a[i+1];
        a[i+1]=0;
      }
    }
    
    //printf("%5d,%5d,%5d : %d\n",i,a[i],a[i+1],result);
  }
  
  printf("%ld",result);
}

Measured memory_bytes: 896
// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var tmp = line[0].split(" ");
	var left = Number(tmp[0]) + Number(tmp[1]);
	var right = Number(tmp[2]) + Number(tmp[3]);

	if(left > right) console.log("Left");
	else if(left === right) console.log("Balanced");
	else console.log("Right");
	return false;

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
def xo(a):
    if a % 4 == 1:
        return 1
    elif a % 4 == 3:
        return 0
    elif a % 4 == 2:
        return a + 1
    else:
        return a


a, b = map(int, input().split())
# 0~(a-1),0~b xor -> xor
if a == b:
    print(a)
elif a == 0:
    print(xo(b))
else:
    print(xo(a-1) ^ xo(b))


Measured memory_bytes: 3060
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(map(str, input().split()))
def pl(a): print(" ".join(list(map(str, a))))
def ma():return map(int,input().split())
def nli(x):return [input for _ in range(x)]
def hukusuu(): 
  listA=[] #appendのために宣言が必要
  while True:
    try:listA.append(list(map(int,input().split())))
    except:break #または、quit(),os.exit()をして止める。
  return listA
from itertools import accumulate as acc 
import operator as op
import copy as cp
import math
from bisect import bisect_left as bisl
from bisect import bisect_right as bisr
def ifif(s):
  if s:print("Yes")
  else:print("No")

n=ri()  
a=rli()
b=[0]*n
for k in range(len(a)):
  b[a[k]-1]=str(k+1)

print(" ".join(b))


Measured memory_bytes: 16100
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long lint;

int main()
{
	int n;
	scanf("%d", &n);

	lint arr[200001];
	for (int i = 0; i < n; ++i)
	{
		scanf("%lld", arr + i);
		if (i) arr[i] += arr[i - 1];
	}

	sort(arr, arr + n);

	lint ans = arr[0] == 0;
	int cnt = 1;

	for (int i = 1; i < n; ++i)
	{
		ans += !arr[i];

		if (arr[i] == arr[i - 1]) ++cnt;
		else ans += (lint)cnt * (cnt - 1) / 2, cnt = 1;
	}

	printf("%lld", ans + (lint)cnt * (cnt - 1) / 2);

	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 2005;
 
int a[N * 3], f[N][N], g[N], gt[N], now, ans;
void update(int x, int y, int t) {
    f[x][y] = max(f[x][y], t);
    now = max(now, t);
    gt[x] = max(gt[x], t);
    gt[y] = max(gt[y], t);
}
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= 3 * n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++) f[i][j] = -INF;
    for (int i = 1; i <= n; i++) gt[i] = -INF;
    update(a[1], a[2], 0);
    for (int j = 1; j <= n; j++) g[j] = gt[j];
    ans = now;
    int cnt = 0;
    for (int i = 1; i < n; i++) {
        int x = a[i * 3], y = a[i * 3 + 1], z = a[i * 3 + 2];
        if (x == y && x == z) {
            cnt++;
            continue;
        }
        if (x == y || x == z || y == z) {
            if (x == z) swap(y, z);
            if (y == z) swap(x, z);
            int t = f[z][z];
            int sb = f[x][z]; // 可能会被改掉
            for (int j = 1; j <= n; j++) {
                update(j, z, max(f[j][x], j == z ? sb : f[x][j]) + 1);
            }
            update(x, y, t + 1);
        } else {
            update(x, y, f[z][z] + 1);
            update(x, z, f[y][y] + 1);
            update(y, z, f[x][x] + 1);
        }
        for (int j = 1; j <= n; j++) {
            update(j, x, g[j]);
            update(j, y, g[j]);
            update(j, z, g[j]);
        }
        update(x, y, ans);
        update(x, z, ans);
        update(y, z, ans);
        for (int j = 1; j <= n; j++) g[j] = gt[j];
        ans = now;
    }
    ans = max(ans, f[a[n * 3]][a[n * 3]] + 1);
    printf("%d\n", ans + cnt);
    return 0;
}

Measured memory_bytes: 19528
#include<stdio.h>

int main(){
    while (1){
        int x, y;
        scanf("%d %d", &x, &y);
        if ((x == 0) && (y == 0)){
            break;
        }
        
        else{
            if (x > y){
                int tmp;
                tmp = x;
                x = y;
                y =tmp;
            }
            
            printf("%d %d\n", x ,y);
        }
        
    }
    return 0;
}


Measured memory_bytes: 2028
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <utility>
using namespace std;
typedef pair<double,double> pdd;
#define mp make_pair
#define fst first
#define scn second
const double eps=1e-11;
pdd findPoint(pdd a,pdd b,pdd c,pdd d){
	//(a.fst-b.fst)*(y-a.scn)=(a.scn-b.scn)*(x-a.fst)
	//(b.scn-a.scn)x+(a.fst-b.fst)y=a.scn(a.fst-b.fst)-a.fst(a.scn-b.scn)
	//(d.scn-c.scn)x+(c.fst-d.fst)y=c.scn(c.fst-d.fst)-c.fst(c.scn-d.scn)
	//ax+by=c
	//dx+ey=f
	//(ae-bd)x=ce-bf	x=(ce-bf)/(ae-bd)
	//(bd-ae)y=cd-af	y=(cd-af)/(bd-ae)
	double A=b.scn-a.scn,B=a.fst-b.fst;
	double C=a.scn*B+a.fst*A;
	double D=d.scn-c.scn,E=c.fst-d.fst;
	double F=c.scn*E+c.fst*D;
	if(A*E==B*D)	return mp(-1000,-1000);
	return mp((C*E-B*F)/(A*E-B*D),(C*D-A*F)/(B*D-A*E));
}
int main(){
	while(true){
		int n;	cin>>n;
		if(n==0)	break;
		vector<pdd> a(n),b(n);
		for(int i=0;i<n;i++)	cin>>a[i].fst>>a[i].scn>>b[i].fst>>b[i].scn;
		int ret=1;
		for(int i=0;i<n;i++){
			set<pdd> plist;
			for(int j=i-1;j>=0;j--){
				pdd newP=findPoint(a[i],b[i],a[j],b[j]);
				if(fabs(newP.fst)>=100.0||fabs(newP.scn)>=100.0)	continue;
				plist.insert(newP);
			}
			ret+=1+plist.size();
		}
		cout<<ret<<endl;
	}
	return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    for (int i = 0; i< s.size();i++){
        s = s[s.size()-1]+s.substr(0,s.size()-1);
        if (s==t){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)
typedef long long ll;

using namespace std;

int main(void){

int n;
string s;

	while(cin >> n){
		if(cin.eof()) break;
		rep(i,n){
			cin >> s;
			int dt;
			string ans="";
			rep(j,s.size()){
				if(s[j] >= 'a' && s[j] <= 'z' ){
					if(ans=="") ans = s[j];
					bool fn=true;
					rep(k, ans.size()) if(s[j]==ans[k]) fn=false;
					if(fn && dt<0 ) ans = s[j] + ans;
					if(fn && dt>0 ) ans = ans  + s[j];

				}
				if(s[j] >= '<') dt=-1;
				if(s[j] >= '>') dt= 1;

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

Measured memory_bytes: 1216
#include<cstdio>
#include<cstring> 
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,tmp[12],ans,s[12][12],p[12];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,x,k;i<=m;i++) {
		scanf("%d",&k);
		for(int j=1;j<=k;j++) scanf("%d",&x),s[x][++s[x][0]]=i;
	}
	for(int i=1;i<=m;i++) scanf("%d",&p[i]);
	for(int i=0;i<(1<<n);i++){memset(tmp,0,sizeof tmp);
		for(int j=0;j<n;j++)
		if((i&(1<<j))==(1<<j)){//printf("ww1");
			for(int q=1;q<=s[j+1][0];q++) tmp[s[j+1][q]]++;
		}int f=1;
		// printf("\n%d %d\n",p[1],p[2]);
		for(int j=1;j<=m;j++) if((p[j]%2)!=(tmp[j]%2)) f=0;
		ans+=f;
		//if(f) printf("s%d ",i); 
	}
	printf("%d",ans);
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;
struct edge{int to, cost;};

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

int N;
vector<vector<edge>> adj;
vi color;

void dfs(int v=0, int c=0){
    color[v]=c;
    for(auto e : adj[v]){
        if(color[e.to] != -1) continue;
        if(e.cost%2 == 0) dfs(e.to, c);
        else dfs(e.to, c^1);
    }
    return;
}

int main(){
    cin >> N;
    adj.resize(N, vector<edge>(0));
    color.assign(N, -1);
    for(int i=0; i<N-1; i++){
        int u, v, w; cin >> u >> v >> w;
        u--, v--;
        adj[u].push_back((struct edge){v, w});
        adj[v].push_back((struct edge){u, w});
    }
    dfs();
    for(auto c : color){
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 11056
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, k;
int cnt[100];

signed main() {
	int i;
	
	cin >> n >> k;
	rep(i, k) {
		int d;
		cin >> d;
		int j;
		rep(j, d) {
			int a;
			cin >> a;
			cnt[a - 1]++;
		}
	}
	
	int ans = 0;
	rep(i, n) if (cnt[i] == 0) ans++;
	cout << ans << endl;
	return 0;
}

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

int h, n, a, total = 0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> h >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        total += a;
    }
    cout << (total >= h ? "Yes" : "No");
}

Measured memory_bytes: 256
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

K = int(input())

l = []
cnt = 0
q = deque()

for i in range(1, 10):
    q.append((str(i), i))

while len(q) > 0:
    (n, prev) = q.popleft()
    l.append(int(n))
    cnt += 1
    if cnt > 100000:
        break
    if prev == 0:
        q.append((n + "0", 0))
        q.append((n + "1", 1))
    elif 1 <= prev <= 8:
        q.append((n + str(prev - 1), prev-1))
        q.append((n + str(prev), prev))
        q.append((n + str(prev + 1), prev+1))
    else:
        q.append((n + "8", 8))
        q.append((n + "9", 9))

l.sort()
print(l[K-1])


Measured memory_bytes: 112088
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define ll long long
#define ld long double
using namespace std;
ll read(){ll x;scanf("%lld",&x);return x;}
const int MAXN=2000005;
ll sz[MAXN][2];
void insert(ll x){
	int a[50],cnt=0;
	memset(a,0,sizeof(a));
	while(x) a[cnt++]=x%2,x/=2;
	for(int i=45;i>=0;i--){sz[i][a[i]]++;} 
}
int main(){
	int n=read();;
	ll k=read();
	for(int i=1;i<=n;i++) insert(read());
	ll res=0;
	for(int i=45;i>=0;i--){
		if(k>=(1ll<<i)&&sz[i][0]>sz[i][1]){
			res=res+(1ll<<i)*sz[i][0];
			k-=(1ll<<i);
		}
		else res=res+(1ll<<i)*sz[i][1];
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
using namespace std;
int test[213456];
signed main() {
	int n, m; cin >> n >> m; // m <= 1000
	vector<vector<long long>>aa(m, vector<long long>(2));
	for (int h = 0; h < m; h++) {
		cin >> aa[h][0] >> aa[h][1];
	}
	//sort(aa.begin(), aa.end());
	for (int h = 1; h < 213456; h++) {
		test[h] = 1000000000;
	}
	for (int h = 0; h <= n; h++) {
		for (int i = 0; i < m; i++) {
			test[h] = min(test[h], aa[i][1] + test[max((long long)0, h - aa[i][0])]);
		}
		//cout << test[h] << endl;
	}
	cout << test[n] << endl;
}

Measured memory_bytes: 1920
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int a, b, c;
int m;

int memo[100][100][100];

int rec(int x, int y, int z)
{
    if(memo[x][y][z] != -1) return memo[x][y][z];
    if(x == y && x == z) return 0;
    if(max(x, max(y, z)) > m+2) return INF;
    int ret = rec(x, y+1, z+1) + 1;
    ret = min(ret, rec(x+1, y, z+1) + 1);
    ret = min(ret, rec(x+1, y+1, z) + 1);
    ret = min(ret, rec(x+2, y, z) + 1);
    ret = min(ret, rec(x, y+2, z) + 1);
    ret = min(ret, rec(x, y, z+2) + 1);
    return memo[x][y][z] = ret;
}

void init()
{
}

void solve()
{
    m = max(a, max(b, c));
    REP(i, 100) REP(j, 100) REP(k, 100) memo[i][j][k] = -1;
    cout << rec(a, b, c) << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 4224
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {

	int a,b;
	scanf("%d %d", &a, &b);

	if(a > 9 || b > 9) {
		printf("-1\n");
	} else {
		printf("%d\n",a*b );
	}

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();

        int area = a * b;
        int cir = (a + b) * 2;

        System.out.println(area + " " + cir);
    }
}

Measured memory_bytes: 26060
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int N, M, A, B, C, D, S, G, V, P;
int K[32][32];
const int Inf = 1000000100;

int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++)
      K[i][j] = Inf;
  }
  for (int i=0; i<M; ++i) {
    scanf("%d,%d,%d,%d", &A, &B, &C, &D);
    K[A][B] = C;
    K[B][A] = D;
  }
  scanf("%d,%d,%d,%d", &S, &G, &V, &P);
  for (int k = 1; k <= N; k++) {
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++)
        K[i][j] = min(K[i][j],K[i][k] + K[k][j]);
    }
  }
  printf("%d\n", (V-P-K[S][G]-K[G][S]));
}



Measured memory_bytes: 3168
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { //Prime FACTORIZE!
//1e18 = 5^18*2^18 (Simply consider 5s since all factors are even anyway)
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		long N = input.nextLong();
		if (N%2==1) System.out.println(0);
		else {
			long cnt = 0;
			long div = 5;
			cnt+=N/div/2;
			long pow = 1;
			while (div<N) {
				div*=5;
				pow++;
				cnt+=(N/div)/2;
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 21844
N = gets.to_i
L = gets.split.map(&:to_i)
sorted = L.sort

ans = 0
(0...(N - 1)).each do |ai|
  ((ai + 1)...N).each do |bi|
    a = sorted[ai]
    b = sorted[bi]
    n = a + b
    i = sorted.bsearch_index { |m| m >= n } || N
    ans += i - 1 - bi
  end
end
puts ans


Measured memory_bytes: 1912
n = int(input())
li = list(map(int,input().split()))

for i in range(n):
    li[i] -= i

import statistics
import math
a = math.floor(statistics.median(li))
b = math.ceil(statistics.median(li))

num_a,num_b = 0,0
for i in range(n):
    num_a += abs(li[i]-(a))
    num_b += abs(li[i]-(b))
print(min(num_a,num_b))

Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
map<string,int>sad;
int main()
{
    _SAD()
    string s,k;
    cin>>s;
    for(int i=0;i<SZ(s);i++)
    {
        if(i%2==0)
        {
            k+=s[i];
        }
    }
    cout<<k<<NL;
    return 0;
}


Measured memory_bytes: 592
n, k = list(map(int, input().split()))
Gem = list(map(int, input().split()))
gem = []
Max = Gem[0]
r = min(n,k)
for i in range(r + 1):
    gem = []
    for j in range(r - i + 1):
        gem = Gem[0:i]
        gem += Gem[n - j:n]
        dif = k - (i + j)
        for s in range(dif):
            if len(gem) == 0:
                break
            M = gem.index(min(gem))
            if gem[M] < 0:
                del gem[M]
            else:
                break
        if len(gem) == 0:
            Max = max(Max,0)
        elif Max < sum(gem):
            Max = sum(gem)
print(Max)


Measured memory_bytes: 3064
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn,now,ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos and *pos <= '9') n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos and *pos <= '9') a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos and *pos <= '9') pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos and *pos <= '9') b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7828
/**
 *   author: r1933
**/
#include "bits/stdc++.h"

using namespace std;

#define all(x) x.begin(), x.end()
using i64 = long long;

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  cout << (s.substr(0, 4) == "YAKI" ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    string row="";
    int west=0;
    int east=0;
    for(int i=0;i<n;i++){
        char a;
        cin>>a;
        row+=a;
        if(a=='E')east++;
        if(a=='W')west++;
    }
    int ans = west;
    int max_l=INT_MAX;
    int west2=0;
    for(int i=0;i<n;i++){
        if(row[i]=='W'){
            if(west2+east<max_l){
              max_l=west2+east;
            }
            west--;
            west2++;
        }else{
            if(west2+east-1<max_l){
              max_l=west2+east-1;
            }
            east--;
        }
    }

    cout<<max_l<<endl;
	return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S , x;
  cin >> N;
  // ここにプログラムを追記
  
    for (int i = 0; i < N; i++) {
      cin >> S;
    if (S == "P" || "W" || "G") {
      x = "Three";
  }
     if (S == "Y") {
      x = "Four";
       break;
  }
}
  cout << x << endl;
}

Measured memory_bytes: 256
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

s=input()
N=len(s)
t=''.join(list(s.replace('x',''))[::-1])
if s.replace('x','')!=t:
    print(-1)
    exit()
ans=0
i=0
j=N-1
while i<j:
    if s[i]==s[j]:
        i+=1
        j-=1
    elif s[i]=='x':
        ans+=1
        i+=1
    else:
        ans+=1
        j-=1
print(ans)

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

int prime(int);

int main(){
  int sum=0,num;
  
  while(scanf("%d",&num)!=EOF){
  sum+=prime(num);
  }
  printf("%d\n",sum);
  return 0;
}

int prime(int num){
  int i;
  
  if(num<2) return 0;
  if(num==2) return 1;
  if(num%2==0) return 0;
  if(num==3) return 1;
  for(i=3;i<=sqrt(num);i+=2){
    if(num%i==0) return 0;
  }
  return 1;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    int N,K;
    cin >> N >> K;

    ll ans = 0;
    for (ll i=K; i<=N+1; i++) {
      ll minumum = (i*(i-1))/2;
      ll maximum = minumum + i * (N-i+1);
      ans +=(maximum-minumum+1);
      ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  string s,t;
  while(true){

    getline(cin,s);
    if(cin.eof())break;

    for(int i = 0 ; i < 26 ; i++ ){
      t = "";
      for(int j = 0 ; j < (int)s.size() ; j++ ){
	if('a'<= s[j] && s[j]<= 'z'){
	  if((s[j] + i) > 'z')t+=(char)(s[j] + i - 26);
	  else t+=(char)(s[j]+i);
	}
	else t += s[j];
      }
      if(t.find("the") != string::npos ||
	 t.find("this") != string::npos ||
	 t.find("that") != string::npos ){
	cout << t << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>
int main(void){
 // Your code here!
 int H,W;

 while(1){
   
 scanf("%d%d", &H, &W);

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


 int i;
 for(i=0; i < H; i++)
 {
  int j;
 for(j=0; j < W; j++)
 {
 if((i+j) % 2 == 0)
 putchar('#');
 else
 putchar('.');
 }

 if(i < H-1) putchar('\n');
 else{
 putchar('\n');
 putchar('\n');
  }
  }
  }
 return 0;

}


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

#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    fast_io;
    int d,t,s;
    cin >> d >> t >> s;
    int dist = t * s;
    if(dist >= d)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }

}


Measured memory_bytes: 3632
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint X,Y,Z,i,j,n,ans;cin>>X>>Y>>Z>>n;
	ans=(X*Y+Y*Z+Z*X)*2+n*6;
	vector<int>x(n),y(n),z(n);
	for(i=0;i<n;i++){cin>>x[i]>>y[i]>>z[i];}
	for(i=0;i<n;i++){
		if(x[i]==0){ans-=2;}
		if(x[i]==X-1){ans-=2;}
		if(y[i]==0){ans-=2;}
		if(y[i]==Y-1){ans-=2;}
		if(z[i]==0){ans-=2;}
		if(z[i]==Z-1){ans-=2;}
		for(j=0;j<i;j++){
			if(abs(x[i]-x[j])+abs(y[i]-y[j])+abs(z[i]-z[j])==1){ans-=2;}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3124