akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.BufferedInputStream;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner (new BufferedInputStream(System.in));
    int n = sc.nextInt();
    int k = sc.nextInt();
    int c = sc.nextInt();
    String s = sc.next();
    int[] front = new int[k];
    int[] back = new int[k];
    int step = 0;
    for(int i = -1 - c, j = 0; i < n; ++j) {
        while(j < n && (s.charAt(j) == 'x' || j - i - 1 < c)) ++j;
        i = j;
        step++;
        front[step - 1] = i;
        if(step == k) break;
    }
    step = k;
    for(int i = n + c, j = n - 1; i > -1; --j) {
        while(j > -1 && (s.charAt(j) == 'x' || i - j - 1 < c)) --j;
        i = j;
        step--;
        back[step] = i;
        if(step == 0) break;
    }
    for(int i = 0; i < k; ++i) {
        if(front[i] == back[i]) System.out.println(front[i] + 1);
    }
  }
}

Measured memory_bytes: 52996
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, x=100;
  cin >> N;
  
  for(int i=0; i<N; i++){ //A(i)のCheck
    
    cin >> A;
    
    for(int j=0; j<x; j++){ //2^jかどうかのCheck
      
      if( A%2 == 0 )
        A /= 2;
      else{
        x = j;
        break;
      }      
    }  
  }  
  cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int a,b,k;
        cin >> a >> b >> k;
        if(k<=a){
            cout << a-k << ' ' << b  << '\n';
        }
        else{
            k=k-a;
            cout << 0 << ' ' << max(b-k,(int)0) << '\n';
        }
        

}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int v[100010];

int main()
{
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n,sol=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&v[i]);
    int tip=0;
    for(int i=2;i<=n;i++)
    {
        if(tip==1)
        {
            if(v[i]<v[i-1])
            {
                sol++;
                tip=0;
            }
        }
        else if(tip==2)
        {
            if(v[i]>v[i-1])
            {
                sol++;
                tip=0;
            }
        }
        else if(tip==0)
        {
            if(v[i]>v[i-1]) tip=1;
            else if(v[i]<v[i-1]) tip=2;
        }
    }
    sol++;
    printf("%d",sol);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
// #pragma GCC optimization ("O3,unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
using namespace std;

#define _ << ": " <<
#define watch1(var1) (cerr << (#var1) _ var1 << '\n')
#define watch2(var1, var2) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << '\n';
#define watch3(var1, var2, var3) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << ", " << (#var3) _ var3 << '\n';
#define wloop(size, arr) cerr << (#arr) << ": "; for (int i = 0; i < size; i++) cerr << arr[i] << " \n"[i+1 == size];

template<typename... Args>
void read(Args&... args) { ((cin >> args), ...); }

template<typename... Args>
void show(Args... args) { ((cout << args << " "), ...); }

#define ints(a...) int a; read(a)
#define longs(a...) int64_t a; read(a)

void solve() {
    longs(n);
    array<char, 100000> v;
    int pos = 0;
    while (n) {
        n--;
        v[pos++] = n % 26 + 'a';
        n /= 26;
    }
    for (int i = pos - 1; ~i; i--) cout << v[i];
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1; 
    // cin >> T;
    while (T--) solve();
    return 0;
}

Measured memory_bytes: 3700
#include<iostream>
#include<stdio.h>
#include<vector>
#include <algorithm>
#include<string>

using namespace std;

int main(){
	int a,b,n=0;
	bool yy,mm;
	string ans;
	cin >> n;
	a=n/100;
	b=n%100;
	if(a<=12&&b<=12){
		ans="AMBIGUOUS";
	}
	if (a>12){
		if(b>12||b==0){
			ans="NA";
		}else{
			ans="YYMM";
		}
	}else if(a==0){
		if(b<=12){
			ans="YYMM";
		}
	}
	if (b>12){
		if(a>12||a==0){
			ans="NA";
		}else{
			ans="MMYY";
		}
	}else if(b==0){
		if(a<=12){
			ans="MMYY";
		}
	}
	if(a==0&&b==0){
		ans="NA";
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(num,init,name) vector<int> name((num),(init));



int main(){
    int n;
    ll cnt=0;
    cin>>n;
    vec(n,0,a);
    rep(i,n){
        cin>>a[i];
        while(!(a[i]%2)){
            a[i]/=2;
            cnt++;
        }
    }
    cout<<cnt<<endl;
    
    return 0;


}



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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 2e9;
const int mod = 1e9 + 7;

bool finish(int n, int i, const map<char, int> mp) {
    vi v;
    for (auto p : mp) {
        v.emplace_back(p.second);
    }
    sort(rall(v));
    int rest = n - i - 1;
    if (v[0] > v[1] + rest) {
        for (auto p : mp) {
            if (p.second == v[0]) {
                cout << p.first << " " << i + 1 << endl;
                return true;
            }
        }
    }
    else {
        return false;
    }
}

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

    int n, m;
    cin >> n >> m;
    vi x(m);
    rep(i, m) cin >> x[i];

    vi used(n + 1);
    rrep(i, m) {
        if (!used[x[i]]) {
            cout << x[i] << endl;
            used[x[i]] = true;
        }
    }

    rep2(i, 1, n + 1) {
        if (!used[i]) {
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,k,count=0,i,j;
  	cin>>a>>b>>k;
  	
  	for(i=max({a,b});i>0;i-=1){
		if(a%i==0 && b%i==0){
          count++;
        }
      	if(count==k){	
          break;
        }
    }
  
  	cout<<i<<endl;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> a(n);

    REP(i, n) cin >> a[i];

    if(n == 1) cout << abs(a[0] - w) << endl;
    else cout << max(abs(a[n-1] - w), abs(a[n-2] - a[n-1])) << endl;;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int N,i;
  int a[N];
  int num=0;
  scanf("%d", &N);
  for (i=0; i < N; i++){
    scanf("%d", &a[i]);
  if (a[i]%2==0){
    if (a[i]%3!=0&&a[i]%5!=0){
      num++;
    }
  }
  }
  if (num>0){
    printf("DENIED\n");
  }
  else{
    printf("APPROVED\n");
  }
  return 0;
}

Measured memory_bytes: 1668
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
typedef long long ll;
const ll mod = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i: irange(0, N)) cin >> A[i];
    vector<int> B(N + 1);
    for (int i: irange(1, N + 1)) cin >> B[i];
    vector<int> C(N);
    for (int i: irange(1, N)) cin >> C[i];

    int ans = 0;
    for (int i: irange(0, N)) {
        ans += B[A[i]];
        if (i > 0 && A[i] == A[i - 1] + 1) {
            ans += C[A[i] - 1];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    priority_queue<int> Q;
    string op;
    while(true){
        cin >> op;
        if(op=="insert"){
            int val;
            cin >> val;
            Q.push(val);
        }else if(op=="extract"){
            int val;
            val=Q.top();Q.pop();
            cout << val << endl;
        }else if(op=="end"){
            break;
        }
    }
}



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

char c[19];

int main(){
    for(int i=0;i<19;i++){
        cin>>c[i];
    }
    c[5]=' ';
    c[13]=' ';
    for(int i=0;i<19;i++){
        cout<<c[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int N, K;
	cin >> N >> K;
	if (K <= (N + 1) / 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else if (a + b == c + d) {
		cout << "Balanced" << endl;
	}
	else {
		cout << "Right" << endl;
	}
}

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

int main() {
	int N;
	cin >> N;
	if (N == 2) {
		cout << -1 << endl;
		return 0;
	}
	if (N == 3) {
		cout << "aa.\n..b\n..b\n";
		return 0;
	}
	if (N == 6) {
		cout << "aa....\n..b...\n..b...\n...aa.\n.....b\n.....b\n";
		return 0;
	}
	if (N == 7) {
		cout << "aabbcc.\nddee..h\nffgg..h\n....mki\n....mki\n....nlj\n....nlj\n";
		return 0;
	}
	if (N == 11) {
		cout << "aacd.......\nbbcd.......\nefgg.......\nefhh.......\n....aabbcc.\n....ddee..h\n....ffgg..h\n........mki\n........mki\n........nlj\n........nlj\n";
		return 0;
	}
	vector<vector<char> > V4 = { {'a','a','c','d'},{'b','b','c','d'},{'e','f','g','g'},{'e','f','h','h'} };
	vector<vector<char> > V5 = { {'a','a','b','b','c'},{'h','i','i','.','c'},{'h','.','.','j','d'},{'g','.','.','j','d'},{'g','f','f','e','e'} };
	vector<vector<char> > ANS(N, vector<char>(N, '.'));
	int C4, C5;
	for (int i = 0; ; i++) {
		if ((N - i * 4) % 5 == 0) {
			C4 = i;
			C5 = (N - i * 4) / 5;
			break;
		}
	}
	int NOW = 0;
	for (int i = 0; i < C4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				ANS[NOW + j][NOW + k] = V4[j][k];
			}
		}
		NOW += 4;
	}
	for (int i = 0; i < C5; i++) {
		for (int j = 0; j < 5; j++) {
			for (int k = 0; k < 5; k++) {
				ANS[NOW + j][NOW + k] = V5[j][k];
			}
		}
		NOW += 5;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cout << ANS[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 2176
n = int(input())
t=[0]
x=[0]
y=[0]
for i in range(n):
  t_inp,x_inp,y_inp=(int(x) for x in input().split())
  t.append(t_inp)
  x.append(x_inp)
  y.append(y_inp)
  
flag=True
for i in range(1,n+1):
  dt=t[i]-t[i-1]
  dist=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
  if dt<dist:
    flag=False
    break
  if dt%2 != dist%2:
    flag=False
    break
    
if flag:
  print("Yes")
else:
  print("No")




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

int main() {
	int k;
	cin >> k;
	int i, j;
	int ans = 0;
	for(i = 1; i <= k; i++) {
		if (i % 2 == 0) {
			for (j = 1; j <= k; j++) {
				if (j % 2 == 1) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sd(n)       scanf("%d", &n)
#define sdd(a,b)    scanf("%d %d", &a, &b)
#define sddd(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sld(n)      scanf("%lld", &n)
#define slld(a,b)   scanf("%lld %lld", &a, &b)
#define sllld(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define slu(n)      scanf("%llu", &n)
#define sllu(a,b)   scanf("%llu %llu", &a, &b)
#define slllu(a,b,c) scanf("%llu %llu %llu", &a, &b, &c)
#define ss(a)		scanf("%s", a)
#define all(a) 		a.begin(),a.end()
#define unq(x)      x.erase(unique(all(x)), x.end()
#define mp 			make_pair
#define sz(av) 		int((av).size())					//return size of vec
#define CLR(arr)    memset(arr, 0, sizeof(arr))			//assign 0 to whole arr
#define SET(vec)    memset(arr, -1, sizeof(arr))		//assign -1 to whole arr
#define CLRV(vec)	fill(vec.begin(), vec.end(), 0)		//assign 0 to whole vec
#define SETV(vec,n,a) vec.assign(n, a)	
#define vtd(rowsize,colsize,type,name) 		vector < vector <type> > name(rowsize,vector <type> (colsize)); 	//assign to first n elements value a in vec
#define SETB(a)		memset(a, true, sizeof(a))			//boolean array initialize by true value
#define CLRB(a)		memset(a, false, sizeof(a))			//boolean array initialize by false value
#define vintitr 	vector<int>::iterator
#define vlnlnitr 	vector<long long>::iterator
#define sintitr 	set<int>::iterator
#define slnlnitr 	set<long long>::iterator
#define aa			first
#define bb			second
#define mod 		1000000007
#define PI 			acos(-1.00)
#define psb 		push_back
#define ppb			pop_back
#define ppb			pop_back
#define psf			push_front
#define ppf			pop_front
#define in 			inset
#define rep(i, n) 	for(int i=0; i<n; i++)
#define repi(i,j,n) for(int i=j; i<j; i++)
#define rof(i, n)   for(int i=n-1; i>=0; i--)
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define __lcm(a, b)	a*b / __gcd(a, b)
#define __builtin_zerocount(a)	8*sizeof(a)-__builtin_popcount(a)-__builtin_clz(a)-__builtin_ctz(a)
#define D(t)        cerr << #t " = " <<t  << '\n'
#define DBG         cerr << "Hi!" << '\n'
 
 
typedef long long	 		ll;
typedef unsigned long long	llu;
typedef long double			ld;
typedef pair<int, int> 		pii;

int main()
{
//	freopen("t.in","r",stdin);
//	freopen("t.out","w",stdout);
	IOS;
	int n;
	string s;
	cin >> s;
	n = s.length();
	int longlength = 0, longestlength = 0;
	rep(i, n)
	{
		if(s[i]=='A' || s[i] == 'C' || s[i] =='G' || s[i] == 'T')
			longlength ++;
		else
			longlength = 0;
		longestlength = max(longestlength, longlength);
	}
	cout << longestlength << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::cmp::Ordering;
use std::str::FromStr;

fn get_line() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();
    line
}

fn get_vector() -> Vec<i32> {
    let line = get_line();
    let vec : Vec<i32> = line.split_whitespace().map(|x| i32::from_str(x).unwrap()).collect();
    return vec;
}

fn main() {
    let mut v = get_vector();
    let (a, b) = (v[0], v[1]);
    println!("{} {} {}", a / b, a % b, (a as f64) / (b as f64));
}



Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main(){
  int N  , counter = 0 ;
  cin >> N ;
  int a[N] ;
  rep (i,N) cin >> a[i] ;
  for(int i = 1;i <  N-1 ; i++){
    if( a[i-1] < a[i]  && a[i] < a[i+1] ) counter++;
    if( a[i-1] > a[i]  && a[i] > a[i+1] ) counter++;
  }
  cout << counter <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int H,W,i,j;
    char a[101][101];
    char Hmask[100] = {0};
    char Wmask[100] = {0};
    scanf("%d %d",&H,&W);
    for(i = 0; i < H; i++)
    {
        scanf("%s",&a[i]);
    }
    for(i = 0; i < H; i++)
    {
        for(j = 0; j < W && a[i][j] == '.'; j++);
        if(j == W) Hmask[i] = 1;
    }
    for(j = 0; j < W; j++)
    {
        for(i = 0; i < H && a[i][j] == '.'; i++);
        if(i == H) Wmask[j] = 1;
    }
    for(i = 0; i < H; i++)
    {
        if(Hmask[i] != 1)
        {
            for(j = 0; j < W; j++)
            {
                if(Wmask[j]!=1)
                {
                    printf("%c", a[i][j]);
                }
            }
            printf("\n");
        }
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MAXN 1e6+5;

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
  	long long a,b;
  	cin>>a>>b;

  	if(a>0 && b >0) {
  		cout<<"Positive";
  		return 0;
  	}
  	else if(a<=0 && b >=0) {
  		cout<<"Zero";
  		return 0;
  	}
  	else if(a<0 && b < 0) {
  		if((abs(b-a))&1)
  			cout<<"Positive";
  		else
  			cout<<"Negative";
  	}
	return 0;		
}



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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    L=["hon","pon","bon"]
    N=I()
    N=N%10
    aaa=[0,1,6,8]
    if N==3:
        print(L[-1])
    elif N in aaa:
        print(L[1])
    else:
        print(L[0])


main()


Measured memory_bytes: 61740
#include<bits/stdc++.h>
using namespace std;using int32=int_fast32_t;using uint32=uint_fast32_t;using int64=int_fast64_t;using uint64=uint_fast64_t;using pi=pair<int32,int32>;using pll=pair<int64,int64>;using vi=vector<int32>;using vvi=vector<vector<int32>>;using vll=vector<int64>;using ll=int64;using ull=uint64;
#define all(x) x.begin(),x.end()
inline ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
int32 dp[100][64];
void Main(){
    ll N=read();
    ll mod=1e9+7;
    dp[0][63]=1;
    for(int len=0;len<N;len++){
        for(int last=0;last<64;last++) for(int cur=0;cur<4;cur++){
            if(!dp[len][last]) continue;
            if(cur==0&&last>>2==0B0110) continue;
            if(cur==1&&last>>2==0B0010) continue;
            if(cur==0&&last>>2==0B1001) continue;
            if(cur==0&&last%4==2&&last>>4==1) continue;
            if(cur==0&&last%16==0B0110) continue;
            dp[len+1][(cur<<4)+(last>>2)] += dp[len][last];
            dp[len+1][(cur<<4)+(last>>2)] %= mod;
        }
    }
    ll ans=0;
    for(int last=0;last<64;last++)ans += dp[N][last];
    printf("%d\n",ans%mod);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(2000005);

mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n, k);
    res *= comb.fact[k];
    return res;
}

int main() {
    int n, k;
    cin >> n >> k;
    k = min(k, n - 1);
    mint ans;
//    rep(i, k + 1) ans += comb(n, i) * comb((n - i - 1) + i, i);
    rep(i, k + 1) ans += comb(n, i) * comb(n - 1, n - i - 1);
    cout << ans.x << endl;
}


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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001;
using namespace std;
typedef long long ll;

ll n;

int dfs(ll num){
  int ret;
  ll tmp_num = num;
  if(tmp_num > n)return 0;
  // std::cout << num << '\n';
  bool three_flag = false;
  bool five_flag=false;
  bool seven_flag=false;
  while(tmp_num > 0){
    if(tmp_num%10==3)three_flag=true;
    if(tmp_num%10==5)five_flag=true;
    if(tmp_num%10==7)seven_flag=true;
    tmp_num /= 10;
  }
  if(three_flag && five_flag && seven_flag){
    // std::cout << "/* message */" << '\n';
    ret = 1;
  }

  else ret = 0;
  for(ll i=0; i<3; i++){
    if(i==0)ret += dfs(num*10+3);
    if(i==1)ret += dfs(num*10+5);
    if(i==2)ret += dfs(num*10+7);
  }
  return ret;
}


int main(){
  std::cin >> n;
  std::cout << dfs(0) << '\n';

}


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

vector<ll> num(1010,0); 
vector<bool> prime(1010,true);
void isprime(){
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=1010;i++){
        if(!prime[i]){continue;}
        for(ll j=i*i;j<=1010;j+=i){
            prime[j]=false;
        }
    }
    return;
}

int main(){
    ll n;cin>>n;
    isprime();

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

    for(ll i=2;i<=n;i++){
        ll number=i;
        for(ll j=2;j<=i;j++){
            if(prime[j]==true){
                while(number%j==0){
                    num[j]++;
                    number/=j;
                }
            }
        }
    }

    ll ans=1;
    for(ll i=2;i<=n;i++){
        ans*=(num[i]+1);
        ans%=mod;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll t1,t2,a1,b1,a2,b2;
int main() {
	scanf("%lld%lld%lld%lld%lld%lld",&t1,&t2,&a1,&a2,&b1,&b2);
	if(a1*t1+a2*t2==b1*t1+b2*t2) printf("infinity\n");
	else {
		if(a1>b1) swap(a1,b1),swap(a2,b2);
		if(a1*t1+a2*t2<b1*t1+b2*t2) printf("0\n");
		else {
			ll x=a1*t1+a2*t2-b1*t1-b2*t2,y=b1*t1-a1*t1;
			printf("%lld\n",(y/x)*2+(y%x?1:0));
		}
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc=new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		final long STACK_SIZE=8*1024*1024;
		new Thread(null, new AOJ2022(), "RUN", STACK_SIZE).start();
	}
	
	class AOJ2022 implements Runnable{
		AOJ2022(){}
		@Override public void run(){
			while(sc.hasNext()){
				N=sc.nextInt();
				if(N==0)	break;
				solve();
			}
		}
		
		int N,N2;
		
		void solve(){
			String[] str=new String[N];
			for(int i=0; i<N; ++i)	str[i]=sc.next();
			
			boolean[] eq=new boolean[N];
			for(int i=0; i<N; ++i){
				if(eq[i])	continue;
				for(int j=0; j<N; ++j){
					if(i!=j && !eq[j] && str[i].matches(".*?"+str[j]+".*?"))	eq[j]=true;
				}
			}
			ArrayList<String> str2=new ArrayList<String>();
			for(int i=0; i<N; ++i)if(!eq[i])	str2.add(str[i]);
			N2=str2.size();
			
//			System.out.println(str2);
			
			int[][] len=new int[N2][N2];
			for(int i=0; i<N2; ++i){
				for(int j=0; j<N2; ++j){
					if(i==j)	continue;
					int offset=0, l=str2.get(i).length();
					for( ; offset<l; ++offset){
						if( str2.get(j).startsWith( str2.get(i).substring(offset) ) )	break;
					}
					
					len[i][j]=l-offset;
				}
			}
			
//			for(int j=0; j<N2; ++j){
//				for(int i=0; i<N2; ++i)	System.out.print(len[i][j]+" | ");
//				System.out.println();
//			}
			
			StringBuilder[][] dp=new StringBuilder[1<<N2][N2];
			for(int i=0; i<N2; ++i){
				dp[1<<i][i]=new StringBuilder(str2.get(i));
			}
			for(int i=0; i<(1<<N2); ++i){
				for(int j=0; j<N2; ++j){
					if(dp[i][j]==null)	continue;
					for(int k=0; k<N2; ++k){
						if( (i&(1<<k)) > 0 )	continue;
						StringBuilder next=new StringBuilder(dp[i][j]);
						next.append(str2.get(k).substring(len[j][k]));
						int newIdx=i|(1<<k);
						int len1=dp[newIdx][k]==null? 1<<29 : dp[newIdx][k].length(), len2=next.length();
						if(len1>len2 || ( len1==len2 && dp[newIdx][k].toString().compareTo(next.toString()) > 0 ) ){
							dp[newIdx][k]=next;
						}
					}
				}
			}
			
//			for(int j=0; j<N2; ++j){
//				for(int i=0; i<(1<<N2); ++i)	System.out.print(dp[i][j]+" | ");
//				System.out.println();
//			}
			
			String ans=null;
			int tmp=(1<<N2)-1;
			for(int i=0; i<N2; ++i){
				if(dp[tmp][i]!=null && ( ans==null || ans.length() > dp[tmp][i].length() || ( ans.length()==dp[tmp][i].length() && ans.compareTo(dp[tmp][i].toString()) > 0 ) ) ){
					ans=dp[tmp][i].toString();
				}
			}
			System.out.println(ans);
			
		}
	}
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define int long long
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1e5+5;

ll expo(ll a, ll b){
    if(b == 0) 
		return 1;
    ll x = expo(a, b/2);
    return (b & 1 ? ((x*x)*a) : (x*x) );
}

int32_t main() {
	ll x;
	cin >> x;
	for(ll i = -1500; i <= 1500; i++) 
		for(ll j = -1500; j <= 1500; j++)
			if( (expo(i, 5) - expo(j, 5)) == x) {
				cout << i << " " << j << endl;
				return 0;
			}
	
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main() {
    int n = 0;
    int h[20] = {};

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

    int max = 0;
    int count = 0;
    for(int i = 0; i < n; i++) {
        if(max <= h[i]){
            count++;
            max = h[i];
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 888
package main

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

//FOR I/O : STARTS
var Reader *bufio.Reader = bufio.NewReader(os.Stdin)
var Writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func Printf (f string, a ...interface{}) { fmt.Fprintf(Writer, f, a...) }
func Scanf (f string, a ...interface{}) { fmt.Fscanf(Reader, f, a...) }
func Println (a ...interface{}) { fmt.Fprintln(Writer, a...)}
func Scanln (a ...interface{}) { fmt.Fscanln(Reader, a...)}
//I/O ENDS HERE

func Abs(x int) int {
    if x < 0 {
        return -x
    }
    return x
}

func Min(x, y int) int {
    if x < y {
        return x
    } else {
        return y
    }
}

func Max(x, y int) int {
    if x >= y {
        return x
    } else {
        return y
    }
}

func Ceil(x, y int64) int64 {
    //returns x/y
    if x%y == 0 {
        return x/y
    } else {
        return int64(x/y)+1
    }
}

func main() {
    defer Writer.Flush()

    var s string
    Scanf("%s\n", &s)
    if s == "ABC" {
        Println("ARC")
    } else {
        Println("ABC")
    }
}


Measured memory_bytes: 1828
S = input()
if S == 'RRR':
  print(3)
elif S == 'RRS':
  print(2)
elif S == 'SRR':
  print(2)
elif S == 'RSR':
  print(1)
elif S == 'RSS':
  print(1)
elif S == 'SRS':
  print(1)
elif S == 'SSR':
  print(1)
elif S == 'SSS':
  print(0)

Measured memory_bytes: 61660
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// ouls
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  var(int, N);

  vector<i64> b(N + 10);
  rep(i, N - 1) {
    input(b[i]);
  }

  i64 res = b[0];
  for (int i = 1; i < N - 1; ++i) {
    res += min(b[i], b[i-1]);
  }

  res += b[N-2];
  outl(res);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main () {
    int i,b=0;
    cin>>i;
    int a[i];
    for(int c=0;c<i;c++){
        cin>>a[c];
        a[c]+=-1;
        b+=a[c];
    }
    cout<<b<<endl;
    return 0;
}


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

int main()
{
  int a,b;
  cin >> a >> b;
  int ans = 0;
  int i;
  for(i = a;i <= b;++i){
    if(i/10000 == i%10 && (i/1000)%10 == (i%100)/10){
      ++ans;
    }else{
      continue;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORr(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORr(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

int main(void){
  string s;
  cin >> s;
  REP(i, s.size()){
    s[i] = 'x';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
ans = False
for a in range(N+1):
  for b in range(N+1):
    c = N - a - b
    if (0 <= c <= N) and (10000*a + 5000*b + 1000*c == Y):
      print('{} {} {}'.format(a, b, c))
      exit()
if not ans:
  print('-1 -1 -1')

Measured memory_bytes: 40940
#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(), x.end()
using namespace std;

int f(int x) {
    if (x == 1) return 1;
    return 2 * f(x / 2) + 1;
}

void PUNKS_NOT_DEAD() {
    int h;
    cin >> h;
    cout << f(h);
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    PUNKS_NOT_DEAD();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  int a;
  while (cin >> a) {
    cout << 3 * a * a << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int N;
	int count = 0;
	cin >> N;
	for (int i = 1;i < N;i++) {
		for (int q = 1;q < N;q++) {
			if (i * (q+1) + 1 > N) {
				count += q;
				/*cout <<i<< "!"<<q<<count << "#" << endl;*/
				break;
			}
		}
	}
	cout << count << endl;
}

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

int main(){
    int ans=0;
    int n,a,b;
    cin >> n >> a>>b;
    int data[n];

    //cout <<fixed<<setprecision(16)<< << endl;
    if(n*a>b)cout << b << endl;
    else cout << n*a << '\n';

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);

  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  vector<int> b;
  int prev=a[0];
  int cnt=1;
  for (int i = 1; i < n; i++)
  {
    if(a[i]!=prev){
      prev=a[i];
      b.push_back(cnt);
      cnt=1;
    }
    else cnt++;
  }
  b.push_back(cnt);
  sort(b.begin(),b.end());

  int m=b.size()-k;
  int ans=0;
  for (int i = 0; i < m; i++)
  {
    ans+=b[i];
  }

  cout << ans << endl;
}

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

int main() {
    while (true) {
        char field[3][4];
        for (int i = 0; i < 3; i++) {
            cin >> field[i];
        }
        if (field[0][0] == '0') {
            break;
        }
        if (field[1][1] != '+' &&
            ((field[1][1] == field[0][0] && field[1][1] == field[2][2])
             || (field[1][1] == field[0][1] && field[1][1] == field[2][1])
             || (field[1][1] == field[0][2] && field[1][1] == field[2][0])
             || (field[1][1] == field[1][0] && field[1][1] == field[1][2])
            )) {
            cout << field[1][1] << endl;
        } else if (field[0][0] != '+' &&
                   ((field[0][0] == field[0][1] && field[0][0] == field[0][2])
                    || (field[0][0] == field[1][0] && field[0][0] == field[2][0])
                   )) {
            cout << field[0][0] << endl;
        } else if (field[2][2] != '+' &&
                   ((field[2][2] == field[0][2] && field[2][2] == field[1][2])
                    || (field[2][2] == field[2][0] && field[2][2] == field[2][1])
                   )) {
            cout << field[2][2] << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int a[N];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= n / i; j ++) {
			a[j * i] ++;
		}
	}
	long long ans = 0;
	for (int i = 1; i <= n; i ++) {
		ans += a[n - i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7520
k,x=map(int,input().split())
li=[]
for i in range(-1000000,1000001):
  li.append(i)
for i in range(2*k-1):
  if li[x-1-(k-1)+i]>=-1000000:
    print(li[x+1000000-(k-1)+i],end=" ")

Measured memory_bytes: 116676
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const int N = 1e5 + 100;
int p[N];
bool used[N];

void make_pair(int i) {
    p[i] = i;
}

int find_id(int a) {
    if (p[a] == a)
        return a;
    return p[a] = find_id(p[a]);
}

void union_pair(int a, int b) {
    a = find_id(a);
    b = find_id(b);
    if (a == b)
        return;
    p[b] = a;
}

int main() {
    used[0] = 1;
    for (int i = 0; i < N; ++i)
        make_pair(i);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > f;
    for (int i = 0; i < n; ++i) {
        int t, cost;
        cin >> t >> cost;
        t = m - t + 1;
        if (t < 0)
            continue;
        f.push_back({cost, t});
    }
    sort(f.begin(), f.end());
    reverse(f.begin(), f.end());
    long long ans = 0;
    for (auto x : f) {
        int tmp = find_id(x.second);
        while(tmp != 0 && used[tmp]) {
            union_pair(tmp - 1, tmp);
            tmp = find_id(tmp);
        }
        if (!used[tmp]) {
            ans += x.first;
            union_pair(tmp - 1, tmp);
            used[tmp] = 1;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1784
from collections import deque
from itertools import accumulate
from bisect import bisect_left
H, W = map(int, input().split())
N = int(input())
a = [int(i) for i in input().split()]
m = list(accumulate(a))

grid = []
for i in range(H+2):
    if i == 0 or i == H+1:
        grid.append('#'*(W+2))
    else:
        grid.append('#' + '.'*W + '#')
ans = [[0 for i in range(W+2)] for j in range(H+2)]
st = deque([])
st.append((1,1))
visited = [[0 for i in range(W+2)] for j in range(H+2)]
cur = 0
visited[1][1] = 1
while st:
    x, y = st.pop()
    # 色を塗る操作
    cur += 1
    ans[y][x] = cur
    if grid[y+1][x] == '.'and visited[y+1][x] == 0:
        st.append((x, y+1))
        visited[y+1][x] = 1
    elif grid[y][x+1] == '.'and visited[y][x+1] == 0:
        st.append((x+1, y))
        visited[y][x+1] = 1
    elif grid[y-1][x] == '.'and visited[y-1][x] == 0:
        st.append((x, y-1))
        visited[y-1][x] = 1
    elif grid[y][x-1] == '.'and visited[y][x-1] == 0:
        st.append((x-1, y))
        visited[y][x-1] = 1
cur = 1
a = [[0 for i in range(W)] for j in range(H)]
for i in range(1,H+1):
    ls = []
    for j, x in enumerate(ans[i][1:-1], 0):
        a[i-1][j] = bisect_left(m, x)+1
for i in range(H):
    print(*a[i])

Measured memory_bytes: 75420
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt","r",stdin);
#define mp(x,y) make_pair(x,y)
#define pii pair<int,int>
void read(int &val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int INF = 0x3f3f3f3f;
const int maxn=1e7+7;
const int mod=1e9+7;
typedef long long LL;

int n,m;
bool vis[maxn];

int main(){
    int ans=-1;
    int k;read(k);
    LL nw = 7;
    fo(i,1,maxn-1){
        if(nw%k==0) {
            ans=i;break;
        }
        nw%=k;
        if(vis[nw]) break;
        nw*=10;nw+=7;
    }
    printf("%d\n",ans);


    return 0;
}

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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1000000007;
const double PI = 3.14159;

using namespace std;

bool is_prime(ll n)
{
    if (n == 1)
        return false;
    for (ll i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

vector<int> anss;

int main() {

    int n;

    while (true) {
        cin >> n;
        if (n == 0) break;

        int ans = 0;
        for (int i = n + 1; i <= 2*n; i++) {
            if (is_prime(i)) ans++;
        }

        anss.push_back(ans);
    }

    rep(i, anss.size())
        AA(anss[i]);
}


Measured memory_bytes: 3136
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;

int main() {
    cin >> n;

    V<Pii> v(n);
    REP(i, n) {
        int x, l;
        cin >> x >> l;
        v[i] = {x, l};
    }

    sort(ALL(v), [](const Pii &a, const Pii &b) {
        return a.first - a.second > b.first - b.second;
    });

    int left = 2e9+100;
    int res = 0;
    FOR(i, v) {
        if (i->first + i->second <= left) {
            res++;
            left = i->first - i->second;
        }
    }

    std::cout << res << '\n';

    return 0;
}


Measured memory_bytes: 1024
from collections import Counter
n = int(input())

lst = [int(i) for i in input().split()]

lst_odd = []
lst_eve = []

for i in range(n):
    if i%2 == 0:
        lst_odd.append(lst[i])
    else:
        lst_eve.append(lst[i])

cnt = Counter(lst_odd)
mod = cnt.most_common()
e1 = mod[0][0]
if len(mod) > 1:
    e2 = mod[1][0]
else:
    e2 = 0

cnt = Counter(lst_eve)
mod = cnt.most_common()
o1 = mod[0][0]
if len(mod) > 1:
    o2 = mod[1][0]
else:
    o2 = 0

if e1 != o1:
    ans = n - lst_odd.count(e1) - lst_eve.count(o1)
else:
    ans = n - max((lst_odd.count(e1) + lst_eve.count(o2)),(lst_odd.count(e2) + lst_eve.count(o1)))

print(ans)

Measured memory_bytes: 21024
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

void read(int &x){ scanf("%d",&x); }

const int N=51,M=102,P=1e9+7; 

void update(int &x,int k){ x+=k,x=x>=P?x-P:x; } 

int n,m,a[M],f[N][M][M],ans;

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	read(n); 
	m=(n<<1)-1; 
	rep(i,1,m)read(a[i]); 
	sort(a+1,a+m+1); 
	f[n][0][0]=1;
	dec(i,n,1){
		int l=a[i]!=a[i-1],r=a[m-i+1]!=a[m-i+2],z;
		rep(j,0,m)rep(k,0,m)if(z=f[i][j][k]){
			update(f[i-1][j+l][k+r],z); 
			lop(t,0,j+l)update(f[i-1][t][k+r+1],z); 
			lop(t,0,k+r)update(f[i-1][j+l+1][t],z); 
			if(i==1)update(ans,z); 
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == '?') s[i] = 'D';
    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  int n;
  cin >> n;
  int sho, amari;
  bool flag = false;
  for(int i = 1; i <= 9; ++i){
    sho = n / i;
    amari = n % i;
    if((1 <= sho && sho <= 9) && amari == 0) {
      flag = true;
      break;
    }
  }

  if(flag) cout << "Yes" <<endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    private static final int MAX = 5000+24;
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        while(in.hasNext()) {
            int n=in.nextInt();
            out.println(24+(24-n));
            out.flush();
        }
        in.close();
        out.close();
    }

}


Measured memory_bytes: 21844