akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h" 
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9

typedef long long unsigned int ll;

string s;
set<string> st;
int k;

void solve(){
  for(int i = 0; i< s.size(); i++){
    for(int j = 1; j<=5 && s.size(); j++){//k < 5なので文字以上の分割は考えなくていい
      string sub = s.substr(i, j);
      st.insert(sub);
    }
  }
  int cnt = 0;
  for (auto itr = st.begin(); itr != st.end(); ++itr) {
    if(cnt == k-1)
      cout << *itr << endl;
    cnt++;
  }
}

int main(){
  cin >> s;
  cin >> k;
  solve();
}

Measured memory_bytes: 1664
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int read(){
	int ans=0,f=1,c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}
	return ans*f;
}
int n;
int main(){
	n=read();
	if((n/100)==(n%10)) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main(){
    long long h,w;
    cin>>h>>w;
    long long count;
    if(h==1||w==1){
        cout<<1<<endl;
    }
    else{
        if(h%2==0){
        count=(h/2)*w;
        }
        else{
            if(w%2==0){
                count=(h/2+1)*(w/2)+(h/2)*(w/2);
            }
            else{
                count=(h/2+1)*(w/2+1)+(h/2)*(w/2);
            }
        }
        cout<<count<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define maxn 100005
using namespace std;
int dp[maxn][3];
int main() {
	ios::sync_with_stdio(false);
	//   sync_with_YinHsuan(true);
	cin.tie(0);
	int n;
	cin >> n;
	for ( int i=1, a, b, c; i<=n; ++i ) {
		cin >> a >> b >> c;
		dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c;
	}
	cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << '\n';
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int bserch(int A[],int B[],int m,int n){
    int count=0;
    for(int j=0;j<m;j++){
        int left=0;
        int right=n;
        int key=B[j];
        while(left<right){
            int mid=(left+right)/2;
            if(A[mid]==key){
                count++;
                break;
            }
            else if(key<A[mid]){
                right=mid;
            }
            else{
                left=mid+1;
            }
        }
    }
    return count;
}
int main(){
    int A[109000]={};
    int B[100000]={};
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>B[i];
    }
    cout<<bserch(A,B,m,n)<<endl;
    return 0;
}


Measured memory_bytes: 3936
#include<stdio.h>
#define F 1
#define NF -1
#define N 8

void Queen(int i);
void Print(void);

int boad[N][N],R[N],col[N],A[2*N-1],B[2*N-1];

int main()
{
  int i,j,n,m,l;

  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      boad[i][j] = 0;
    }
  }
  for(i=0; i<N; i++){
    R[i] =F;
    col[i]=F;
  }
  for(i=0; i<2*N; i++){
    A[i] = F;
    B[i] =F;
  }
  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%d%d",&m,&l);
    boad[m][l] = 1;
  }
  Queen(0);
  
  return 0;
}

void Queen(int i){
  int j;
    if(i==N){
      Print();
    }
  
  for(j=0; j<N; j++){
    if(col[j] ==NF || B[i+j] == NF || A[i-j+N-1] ==NF)continue;
    R[i]=j;
    col[j] = B[i+j] = A[i-j+N-1] =NF;

    Queen(i+1);

    R[i] = col[j] = B[i+j] =A[i-j+N-1] =F;
  }
}

void Print(){
  int i,j;

  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(boad[i][j] ==1 && R[i]!=j)return;
    }
  }
  
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
  
      if(R[i]==j)printf("Q");

      else printf(".");
    }
    printf("\n");
  }
}







Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
	private: int _num[32],_head;
	public: int SUF; template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'),putchar(SUF);return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; putchar(SUF); return *this;}
	fastout() {_head=0,SUF=' ';}
}fout;
// ----------------------------
// #define int ll
using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1000000007;

int n, flag = 1;
char str[maxn];

int main()
{
    scanf("%s", str + 1);
    n = strlen(str + 1);
    for(int l = 1; l <= n; ++l) if(str[n - l + 1] != str[l]) flag = 0;
    int end = (n - 1) / 2;
    for(int l = 1; l <= end; ++l) if(str[end - l + 1] != str[l]) flag = 0;
    for(int l = (n + 3) / 2; l <= n; ++l) if(str[n - l + 1] != str[l]) flag = 0;
    if(flag) puts("Yes");
    else puts("No"); 
    return 0;
}
// ----------------------------
// by imzzy


Measured memory_bytes: 256
import java.util.*;

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

        int count=0;

        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();

        int k=sc.nextInt();

        if(k<=a){
            count+=k;
            k=0;
        }else{
            count+=a;
            k-=a;
        }
        if(k<=b){
            k=0;
        }
        else{
            k-=b;
        }
        count-=k;
        System.out.println(count);
    }
}


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

main(){

  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];

  ll tx=0;
  rep(i,n){
    if(i&1)tx-=a[i];
    else tx+=a[i];
  }

  vector<ll> ans(n);
  ans[0]=tx;
  for(ll i=1;i<n;++i){
    ll tmp=a[i-1]-(ans[i-1]/2);
    ans[i]=2*tmp;
  }
  rep(i,n)cout<<ans[i]<<" ";
  cout<<endl;

}

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

int main(){
  int i,flag=0;
  string S;
  cin >> S;
  
  for(i=0;i<S.size();i++){
    if(flag == 0 && S.at(i) == 'L'){
      cout << "No"; return 0;
    }
    else if(flag == 1 && S.at(i) == 'R'){
      cout << "No"; return 0;
    }
    if(flag == 0) flag++;
    else flag--;
  }
  cout << "Yes";
  return 0;    
}


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

int binarySearch(vector<int> A, int key, int n)
{
	int left = 0;
	int light = n;
	while ( left < light )
	{
		int mid = (left + light)/2;
		if (A[mid]==key)return mid;
		else if(key < A[mid])light = mid;
		else left = mid + 1;
	}
	return -1;
}

int main()
{
	int n; cin >> n;
	vector<int> S(n);
	rep(i,n)cin>>S[i];
	int q; cin >> q;
	vector<int> T(q);
	rep(i,q)cin >> T[i];
	int count=0;
		rep(j,q)
		{
			int foo = binarySearch(S,T[j],n);
			if(foo!=-1)count++;
		}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3844
import java.util.*;

public class Main{
  
  public static void main (String[] args){
    
    Main main = new Main();
    main.solve();
  }
  
  private void solve(){
    
    Scanner scanner = new Scanner (System.in);
    int number = scanner.nextInt();
    int maximumTime = scanner.nextInt();
    
    int cost=0;
    int time=0;
    int minimumCost=0;
    boolean firstFlag=true;
    
    for (int index=0; index<number; index++){
      
      cost = scanner.nextInt();
      time = scanner.nextInt();
      
      if(time<=maximumTime&&(cost<minimumCost||firstFlag==true)){
        minimumCost=cost;
        firstFlag=false;
      }
    }
    
    if (firstFlag==true){
      System.out.println("TLE");
    } else {
    System.out.println(minimumCost);
    }
  }
}

Measured memory_bytes: 21716
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

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

static size_t A[100000];

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

int main(void) {
	size_t N;
	size_t A[200];

	scanf("%zu\n", &N);
	for (size_t idx = 0; idx < N; idx++) {
		scanf("%zu", &A[idx]);
		if (idx < N - 1) {
			scanf(" ");
		}
	}

	size_t count = 0;

	while (1) {
		for (size_t idx = 0; idx < N; idx++) {
			if (A[idx] % 2 == 0) {
				A[idx] /= 2;
			}
			else {
				goto result;
			}
		}
		count++;
	}

result:
	printf("%zu\n", count);

	return 0;
}


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

constexpr int64_t mod{1'000'000'007};

int main()
{
	int64_t N, K;
	scanf("%lld%lld", &N, &K);
	std::vector<int64_t> spanTable;
	for (int64_t i{1}; i * i <= N; i++)
		spanTable.push_back(i);
	{
		std::vector<int64_t> tmp;
		for (int64_t i{1}; i * i < N; i++)
			tmp.push_back(N / i);
		while (!tmp.empty())
		{
			spanTable.push_back(tmp.back());
			tmp.pop_back();
		}
	}
	for (int i{(int)spanTable.size() - 1}; i > 0; i--)
		spanTable[i] -= spanTable[i - 1];
	using vi = std::vector<int64_t>;
	int size{(int)spanTable.size()};
	std::vector<vi> dp(K + 1, vi(size));
	dp[0][0] = 1;
	for (int k_i{1}; k_i <= K; k_i++)
	{
		for (int from_i{}; from_i < size; from_i++)
			dp[k_i][size - 1 - from_i] = dp[k_i - 1][from_i] * spanTable[from_i] % mod;
		for (int to_i{size - 1}; to_i > 0; to_i--)
			dp[k_i][to_i - 1] = (dp[k_i][to_i - 1] + dp[k_i][to_i]) % mod;
	}
	int64_t sum{};
	for (int i{}; i < size; i++)
		sum = (sum + dp.back()[i] * spanTable[i] % mod) % mod;
	printf("%lld\n", sum);

	return 0;
}

Measured memory_bytes: 51456
#include<bits/stdc++.h>
using namespace std;
 
#define             ll  long long
#define            ull  unsigned long long
#define            P_B  push_back
#define            M_P  make_pair
#define         DBG(x)  printf("%s %d\n", #x, x)
#define       DBGLL(x)  printf("%s %lld\n", #x, x)
#define         SCI(x)  scanf("%d",&x)
#define         SCD(x)  scanf("%lf",&x)
#define         SCS(x)  scanf("%s",x)
#define         CLR(x)  memset(x, 0, sizeof(x))
#define        CLRN(x)  memset(x, -1, sizeof(x))
#define        SCLL(x)  scanf("%lld", &x)
#define      FOR(i, n)  for(int i = 0; i < n; i++)
#define  FORR(i, m, n)  for(int i = m; i < n; i++)
#define     SCI2(m, n)  scanf("%d%d", &m, &n)
#define  SCI3(m, n, o)  scanf("%d%d%d",&m, &n, &o)
#define     SCD2(m, n)  scanf("%lf%lf",&m,&n)
#define  SCD3(m, n, o)  scanf("%lf%lf%lf",&m,&n,&o)
#define    SCLL2(m, n)  scanf("%lld%lld", &m, &n)
#define SCLL3(m, n, o)  scanf("%lld%lld%lld",&m, &n, &o)
#define             vi  vector<int>
#define            vii  vector<pair<int, int> >
#define            vll  vector<pair<ll, ll> >
#define            Mod  998244353
#define            INF  1000000000
 

int a[100005][4];
int n;

int main()
{
	SCI(n);
	FOR(i, n)
		FOR(j, 3)
			SCI(a[i][j]);
	FORR(i, 1, n){
		a[i][0] = a[i][0] + max(a[i-1][1], a[i-1][2]);
		a[i][1] = a[i][1] + max(a[i-1][0], a[i-1][2]);
		a[i][2] = a[i][2] + max(a[i-1][0], a[i-1][1]);
	}
	printf("%d\n", max(a[n-1][0], max(a[n-1][1] , a[n-1][2])));    
}

Measured memory_bytes: 1792
import numpy as np
N,M = map(int, input().split())
As, Bs = [], []
Cs = np.zeros((N,2))
for i in range(N):
    A, B = map(int, input().split())
    Cs[i] = [A,B]

C_sorted = Cs[Cs[:,0].argsort(), :]
value = 0
for a,b in C_sorted:
    M_tmp = M - b
    if M_tmp > 0:
        value += a*b
        M = M_tmp
    else:
        value += a*M
        break

print(int(value))

Measured memory_bytes: 16360
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];

    long ans = 0;

    foreach (i; K..N+2) {
        long mn = 1L * i * (i - 1) / 2;
        long mx = 1L * N * (N + 1) / 2 - 1L * (N - i) * (N - i + 1) / 2;
        ans += (mx - mn + 1) % MOD;
        ans %= MOD;
    }

    ans.writeln;
}

Measured memory_bytes: 3232
#include<iostream>
using namespace std;
int n,cnt;
int a[100008];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    bool can=0,can2=0;
    for(int i=0;i<n-1;i++)
    {
        if(a[i]==a[i+1])continue;
        else if(a[i]<a[i+1])can=1;
        else if(a[i]>a[i+1])can2=1;
        if(can &&can2)
        {
            cnt++;
            can=0;
            can2=0;
        }

    }
    cout<<cnt+1<<endl;

}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 

int main(){
  int X,p=1;
  cin >> X;
  for(int i=1; i<X; i++){
    for(int j=2; j<X; j++){
      if(X>=pow(i,j) && pow(i,j)>p){
        p=pow(i,j);
      }
    }
  }cout << p << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, n, a;
  scanf("%lld", &n);
  ll ans[n];
  for(i = 0; i < n; ++i) ans[i] = 0;
  for(i = 0; i < n - 1; ++i) scanf("%lld", &a), ans[--a]++;
  for(i = 0; i < n; ++i) printf("%lld\n", ans[i]);
  return 0;
}

Measured memory_bytes: 3288
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans=0;
    rep(i,n){
        int cnt=0;
        for(char c='a';c<='z';c++){
            bool left=false,right=false;
            for(int j=0;j<i;j++){
                if(s[j]==c) left=true;
            }
            for(int j=i;j<n;j++){
                if(s[j]==c) right=true;
            }
            if(left&&right) cnt++;
        }
        if(ans<cnt) ans=cnt;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
struct B{long w,s,v;}A[1111];
comp(a,b)struct B*a,*b;{return a->w+a->s-b->w-b->s;}
n,i,j;
long dp[22222],ans;
main(){
	scanf("%d",&n);
	for(;~scanf("%ld%ld%ld",&A[i].w,&A[i].s,&A[i].v);i++);
	qsort(A,n,sizeof(struct B),comp);
	for(i=0;i<n;i++)
	{
		for(j=A[i].s;j>=0;j--)ans=fmax(ans,dp[j+A[i].w]=fmax(dp[j+A[i].w],dp[j]+A[i].v));
	}
	printf("%ld",ans);
}


Measured memory_bytes: 380
#include <iostream>
using namespace std;
 
int main() {
	int A, B, C, D, ans;
cin>>A>>B>>C>>D;
int x=max(A,C) ;
int y=min(B,D) ;
ans=y-x;
if(ans<0 ) {
cout<<0 ;
} else if(ans>=0) {
cout<<ans ;
} 
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
  int n,m,k;
  cin>>n>>m>>k;
  if(k%n==0||k%m==0){
    cout<<"Yes"<<endl;
    return 0;
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(i*j+(n-i)*(m-j)==k){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }

  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <memory.h>
int main(void){
  int n,a[100],f[100],k,ans,l,r,c,i;
  while(1){
    scanf("%d",&n);
    if(!n)
      break;
    for(i=0;i<n;i++)
      scanf("%d",&a[i]);
    scanf("%d",&k);
    memset(f,0,sizeof(f));
    l=0;r=n-1;ans=0;
    while(1){
      c=(l+r)/2;
      if(f[c])
	break;
      ans++;
      if(a[c]==k)
	break;
      else if(a[c]<k){
	l=c+1;
	f[c]=1;
      }
      else{
	r=c-1;
	f[c]=1;
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 600
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y=0;
		for(int i=1;i<=x;i++){
			if(i%3!=0&&i%5!=0){
				y+=i;
			}
				
		}
			System.out.print(y);

		

	}
}

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

int main(){
  int n,s;
  char c;
  cin>>n;
  s=0;
  
  for(int i=0;i<n;i++){
    cin>>c;
    if(c=='Y'){
      s=1;
      break;
    }
  }
  if(s) cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        long mod = (long)1e9 + 7;

        long n = sc.nextLong();

        long total = 1;
        for (int i=0; i<n; i++) {
            total *= 10;
            total %= mod;
        }
        total += mod;

        long none = 1;
        for (int i=0; i<n; i++) {
            none *= 8;
            none %= mod;
        }

        long nine = 1;
        for (int i=0; i<n; i++) {
            nine *= 9;
            nine %= mod;
        }
        long eight = 1;
        for (int i=0; i<n; i++) {
            eight *= 8;
            eight %= mod;
        }

//        System.out.println(total);
//        System.out.println(none);
//        System.out.println(nine);
//        System.out.println(eight);

        total -= (none + (nine - eight) * 2);
        total += mod;

        System.out.print(total % mod);

    }


}



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

long long n;
vector<pair<long long, long long> > adj[100005];
bool vis[100005];
bool colours[100005];

void dfs(long long node, long long dist) {
    vis[node] = true;
    colours[node] = dist % 2;
    for (long long i=0; i<adj[node].size(); i++) {
        if (!vis[adj[node][i].first]) {
            dfs(adj[node][i].first, dist+adj[node][i].second);
        }
    }
}

int main() {

    cin >> n;
    for (long long i=0; i<n-1; i++) {
        long long a, b, q;
        cin >> a >> b >> q;
        a--;
        b--;
        adj[a].push_back(make_pair(b, q));
        adj[b].push_back(make_pair(a, q));
    }
    memset(vis, 0, sizeof vis);
    dfs(0, 0);
    for (long long i=0; i<n; i++) {
        cout << colours[i] << endl;
    }

}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

bool solve(string s)
{
  if ((s[0] == s[1] && s[0] == s[2] && s[1] == s[2]) || (s[1] == s[2] && s[1] == s[3] && s[2] == s[3]))
    return true;
  else
    return false;
}

int main()
{
  string s;
  cin >> s;
  solve(s) ? cout << "Yes\n" : cout << "No\n";
}


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

using namespace std;

using ll = long long;

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

    vector<vector<pair<int, int>>> data(n, vector<pair<int, int>> ());
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        for (int j = 0; j < a; j++) {
            int x, y;
            cin >> x >> y;
            data[i].push_back(make_pair(x, y));
        }
    }

    ll ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        ll cnt = 0;
        bool flag = true;
        for (int i = 0; i < n; i++) {
            if (bit & (1 << i)) {
                cnt++;
                for (int j = 0; j < data[i].size(); j++) {
                    int x, y;
                    tie(x, y) = data[i][j];
                    if (y) {
                        if ((bit & (1 << (x - 1))) < y) {
                            flag = false;
                            break;
                        }
                    }
                    else if ((bit & (1 << (x - 1))) != 0) {
                        flag = false;
                        break;
                    }
                }
            }
        }
        if (flag) ans = max(ans, cnt);
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(int i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(int i=(a);i<(n);i++)cout<<(arr)[i]<<' ';

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

int main(){
	fast;
	string s;
	cin>>s;
	ll a = 0;
	forn(i, 0, s.size()){
		ll x = (ll)(s[i] - '0');
		
		a+=x;
	}

	if(a%9==0){
		cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3744
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(void){
	
	int a,i,min=INT_MAX,max=INT_MIN,n;
	long sum=0;
	
		scanf("%d",&n);
	
	for(i=0;i<n;i++){
		
		scanf("%d",&a);
		
		if(a<=min)min = a;
		
		
		if(a>=max)max = a;
		
		sum += a;
		
		}
	
	printf("%d %d %ld\n",min,max,sum);
	
return 0;}

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

int main()
{
	string s;
	
	cin>>s;
	int n=(int)s.size();
	int an=INT_MAX,c=0;
	for(int i=0;i<n;i++)
	if(i&1 && s[i]=='1')c++;
	else if((i&1) == 0 && s[i]=='0')c++;
	an=c;c=0;
	
	for(int i=0;i<n;i++)
	if(i&1 && s[i]=='0')c++;
	else if((i&1) == 0 && s[i]=='1')c++;
	cout<<min(an,c)<<endl;
	
	

}



Measured memory_bytes: 3728
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	N := readInt()
	a := make([]int, N)
	for i := range a {
		a[i] = readInt() - 1
	}

	var ans int
	for i := range a {
		j := a[i]
		if a[j] == i {
			ans++
		}
	}
	println(ans / 2)
}

// -----------------------------------------------------------------------------


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  for(int i=0;i<n;i++)
    cin >> a[i];
  for(int i=0;i<n;i++)
    cin >> b[i];


  ll p=0, m=0;
  for(int i=0;i<n;i++) {
    if(a[i] > b[i])
      p += a[i]-b[i];
    else if(b[i] > a[i]) {
      if((b[i]-a[i])%2 == 1)
        m += b[i]-a[i]-1;
      else
        m += b[i]-a[i];
    }

  }

  if(2*p > m)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;


}


Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll x; cin>>x;
	ll ans=0,num=100;
	while(num<x){
		num*=1.01;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define maxn 500005
#define ll long long
#define vi vector<int>
#define pb push_back
using namespace std;
int v[maxn];
vi eg[maxn];
struct th {
	int a[2];
	ll ans;
	th() {
		a[0] = a[1] = ans = 0;
	}
	th(int x) {
		a[0] = a[1] = ans = 0;
		a[x] = 1;
	}
	bool operator < (const th &r)const {
		return 1ll * a[1] * r.a[0] < 1ll * a[0] * r.a[1];
	}
};
th u(th x, th y) {
	th fn;
	fn.a[0] = x.a[0] + y.a[0], 
	fn.a[1] = x.a[1] + y.a[1];
	fn.ans = 1ll * x.a[1] * y.a[0] + x.ans + y.ans;
	return fn;
}
#define ST multiset<th>
#define iter ST::iterator
ST r[maxn];
ST *rt[maxn];
ST *u(ST *a, ST *b) {
	if((*a).size() > (*b).size()) swap(a, b);
//	cout <<"U" << a->size() << ' ' << b->size() << endl;
	for (iter u = (*a).begin(); u != (*a).end(); u++)
		(*b).insert(*u);
	return b;
}
void otp(th r) {
	cout << r.a[0] << ' ' << r.a[1] << ' ' << r.ans << endl;
}
void otp(ST* r) {
	for (iter q = r->begin(); q != r->end(); q++) {
		otp(*q);
	}
	cout << endl;
}
int main() {
    int n;
    cin >> n;
    for (int i = 2; i <= n; i++) {
        int p;
        scanf("%d", &p);
        eg[p].pb(i);
    }
    for (int i = 1; i <= n; i++) 
    	scanf("%d", &v[i]);
    for (int i = n; i >= 1; i--) {
		rt[i] = &r[i];
		for (int j = 0; j < eg[i].size(); j++) {
			int v = eg[i][j];
			rt[i] = u(rt[i], rt[v]);
		}
		th fn = th(v[i]);
		while(1) {
			if(rt[i]->empty() || fn < *rt[i]->begin()) {
				rt[i]->insert(fn);
				break;
			}
			iter q = (*rt[i]).begin();
			fn = u(fn, *q);
			(*rt[i]).erase(q);
		}
	}
	while((*rt[1]).size() >= 2) {
		iter r = (*rt[1]).begin(), v = r;
		v++;
		th k = u(*r, *v);
		(*rt[1]).erase(r), 
		(*rt[1]).erase(v);
		(*rt[1]).insert(k);
	}
	iter q = (*rt[1]).begin();
	cout << (*q).ans << endl;
    return 0;
}

Measured memory_bytes: 67840
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    // make io faster https://gist.github.com/rigibun/7905920
	cin.tie(0);
   	ios::sync_with_stdio(false);
    const auto endl = "\n";

    ll a, b, c, x;
    cin >> a >> b >> c >> x;
    ll ans = 0;
    for (ll i = 0; i <= a; ++i) {
        for (ll j = 0; j <= b; ++j) {
            for (ll k = 0; k <= c; ++k) {
                if (x - (500 * i + 100 * j + 50 * k) == 0) {
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
}


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

int N, M, X;
vector<int> C;
vector<vector<int>> A;
const int INF = 1e+9;

void dfs(vector<int> & bit, int & res) {
	if ((int)bit.size() == N) {
		int cost = 0;
		vector<int> know(M);
		for (int i = 0; i < N; i++) {
			if (bit[i]) {
				cost += C[i];
				for (int j = 0; j < M; j++) {
					know[j] += A[i][j];
				}
			}
		}

		bool ok = true;
		for (int i = 0; i < M; i++) {
			if (know[i] < X) {
				ok = false;
				break;
			}
		}
		if (ok) res = min(res, cost);
		return;
	}

	for (int i = 0; i < 2; i++) {
		bit.push_back(i);
		dfs(bit, res);
		bit.pop_back();
	}
}

int main(void) {
	cin >> N >> M >> X;
	C.resize(N);
	A.resize(N, vector<int>(M));
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}

	vector<int> bit;
	int res = INF;
	dfs(bit, res);

	if (res == INF) cout << -1 << endl;
	else cout << res << endl;

	return 0;
}


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


c=k-li[n-1]+li[0]
dis=[c]
i=0
for i in range(n-1):
  a=li[i+1]-li[i]
  dis+=[a]

max_dis=max(dis)
ans=k-max_dis

print(ans)

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  rep(i, M){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  vector<int> diff(M-1);
  rep(i, M-1){
    diff.push_back(abs(A[i+1] - A[i]));
  }

  sort(diff.begin(), diff.end(), greater<int>());
  int ans = 0;
  int k = N - 1;
  for (k; k <= diff.size(); k++){
    ans += diff[k];
  }
  cout << ans << endl;
  
  
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {

  public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  }

  void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  }

  void __solve(Scanner cin) {
	  
	  int N = cin.nextInt();
	  int array[] = new int[N];
	  
	  for( int i = 0; i < N; ++i ) {
		  array[i] = cin.nextInt();
	  }
	  
	  int L = 0;
	  int sum = 0;
	  long ret = 0;
	  
	  for( int R = 0; R < N; ++R ) {
		  while( (sum & array[R]) != 0 ) {
			  sum ^= array[L++];
		  }
		  sum ^= array[R];
		  ret += (R - L + 1);
	  }
	  
	  System.out.println(ret);

  }

}


Measured memory_bytes: 74704
/*
      author  : nishi5451
      created : 14.08.2020 16:40:26
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    rep(i,a+b+1){
        if(i==a){
            if(s[i]!='-'){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if(s[i]>='0' && s[i]<='9')
                continue;
            else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3584
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    s = S()
    print("x" * len(s))
    
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38512
icase=0
if icase==0:
    n=int(input())
    s=input()
elif icase==1:
    n=3
    s="())"
elif icase==2:
    n=6
    s=")))())"
elif icase==3:
    n=8
    s="))))(((("

l=[]
r=[]
sim=s[0]
if sim=="(":
    lidx=0
    l.append(1)
    ridx=-1
elif sim==")":
    lidx=0
    l.append(0)
    ridx=0
    r.append(1)

for i in range(1,len(s)):
    if s[i]=="(" and s[i-1]=="(":
        l[lidx]+=1
    elif s[i]=="(" and s[i-1]==")":
        lidx+=1
        l.append(1)
    elif s[i]==")" and s[i-1]==")":
        r[ridx]+=1
    elif s[i]==")" and s[i-1]=="(":
        ridx+=1
        r.append(1)

ll=sum(l)
rr=sum(r)
ds=ll-rr

if len(l)>len(r):
    r.append(0)
elif len(l)<len(r):
    l.append(0)
xmin=100
x=0
for i in range(len(l)):
    x=x+l[i]-r[i]
    xmin=min(x,xmin)
if xmin>0:
    xmin=0
    
strs="("*(-xmin) + s + ")"*(ds-xmin)
print(strs)
    

Measured memory_bytes: 9212
#include <stdio.h>
int main(void){
	int a,b;
	int d,r;
	double f;
	scanf("%d %d",&a,&b);
	d = a / b;
	r = a % b;
	f = 1.0 * a / b;
	
	printf("%d %d %.8lf\n",d,r,f);
	
	return 0;
}


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

int main() {
	int n,k;
	cin>>n>>k;
	long int ans=1;
	while(n--)
	  {	long int x=ans*2;
		long int t=ans+k;
	  	ans=min(x,t);
	  	//cout<<ans<<" ";
	  }
	 cout<<ans<<'\n'; 
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int len = int.Parse(Reader.ReadLine());

        string inpt = Reader.ReadLine();

        int[] turnRight = new int[len];
        turnRight[0] = 0;
        for (int i = 1; i < len; i++) {
            turnRight[i] = turnRight[i - 1];
            if(inpt[i-1] == 'W') {
                turnRight[i]++;
            }
        }
        int[] turnLeft = new int[len];
        for (int i = len - 2; i >= 0; i--) {
            turnLeft[i] = turnLeft[i + 1];
            if(inpt[i+1] == 'E') {
                turnLeft[i]++;
            }
        }

        int ans = len;
        for (int i = 0; i < inpt.Length; i++) {
            ans = Math.Min(ans, turnLeft[i] + turnRight[i]);
        }
        Console.WriteLine(ans);

    }


	public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



5
WEEWW


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 14432
#include<stdio.h>

int main(void) {
  int n;
  double a, res = 0.0;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%lf", &a);
    res += 1.0 / a;
  }

  printf("%lf", 1.0 / res);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

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

Measured memory_bytes: 3640
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x: String = read();
    let lower_x = x.to_ascii_lowercase();
    if x != lower_x {
        println!("A");
    } else {
        println!("a");
    }
}


Measured memory_bytes: 2100
import math
a, b, h, m = map(int, input().split())

dega = - 30*h - 0.5*m + 90
degb = - 6*m + 90

x_a = a*math.cos(math.radians(dega))
y_a = a*math.sin(math.radians(dega))
x_b = b*math.cos(math.radians(degb))
y_b = b*math.sin(math.radians(degb))
# print(dega, degb)
# print(x_a, x_b, y_a, y_b)
print(((x_a-x_b)**2+(y_a-y_b)**2)**0.5)


Measured memory_bytes: 9568
#include <bits/stdc++.h>
using namespace std;
int64_t a[86];

  int main() {
    int N;
    cin >> N;
    
    a[0] = 2;
    a[1] = 1;
    
    for(int i = 2;i < (N + 1);i++){
      a[i] = a[i-2] + a[i-1] ;
    }
    
    cout << a[N] << endl;
    
        
}

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

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

    int N;
    cin >> N;
    string S,T;
    cin >> S >> T;
    vector<char> ns;
    for(int i=0;i<N;i++){
        ns.push_back(S[i]);
        ns.push_back(T[i]);
    }
    for(int i=0;i<N*2;i++){
        cout << ns.at(i);
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
const int maxn=1e5+10;
ll num[maxn];
ll dp[maxn];
int main()
{
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    for(int i=1; i<=n; i++)
    {
        scanf("%lld",&num[i]);
       // dp[i]=num[i]*a;
    }
    dp[1]=0;//在第一步为0
    for(int i=2; i<=n; i++)
    {
        //每次走一步需要A
        //任意走需要B
        dp[i]=min(dp[i-1]+(num[i]-num[i-1])*a,dp[i-1]+b);
    }
    printf("%lld\n",dp[n]);

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=200050;
const int M=2*N;
int ls[M],rs[M],tsz,root;
ll lzy[M],mx[M];
void Add(int &c, int ss, int se, int qs, int qe, ll f)
{
	if(qs>qe || qs>se || ss>qe) return;
	if(!c) c=++tsz;
	if(qs<=ss && qe>=se){ lzy[c]+=f;mx[c]+=f;return;}
	int mid=ss+se>>1;
	Add(ls[c],ss,mid,qs,qe,f);
	Add(rs[c],mid+1,se,qs,qe,f);
	mx[c]=max(mx[ls[c]],mx[rs[c]])+lzy[c];
}
ll Get(int c, int ss, int se, int qs, int qe)
{
	if(qs<=ss && qe>=se) return mx[c];
	int mid=ss+se>>1;
	if(qe<=mid) return Get(ls[c],ss,mid,qs,qe)+lzy[c];
	if(qs>mid) return Get(rs[c],mid+1,se,qs,qe)+lzy[c];
	return max(Get(ls[c],ss,mid,qs,qe),Get(rs[c],mid+1,se,qs,qe))+lzy[c];
}
vector<pair<int,int>> seg[N];
int main()
{
	int n,m,i,l,r,x;
	scanf("%i %i",&n,&m);
	for(int i=1;i<=m;i++) scanf("%i %i %i",&l,&r,&x),seg[r].pb(mp(l,x));
	for(int i=1;i<=n;i++)
	{
		Add(root,0,n,i,i,Get(root,0,n,0,i-1));
		for(auto p:seg[i]) Add(root,0,n,p.first,i,p.second);
	}
	printf("%lld\n",Get(root,0,n,0,n));
	return 0;
}

Measured memory_bytes: 20608
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    if n == 2 {
        println!("0");
        return;
    }

    let mut sum = 0usize;
    let mut i = 1;
    while i * i < n {
        if n / i > 0 && n % i == 0 {
            let m = n/i - 1;
            if n/m == n%m {
                sum += m;
            }
        }
        i += 1;
    }
    println!("{}", sum);
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

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

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int l, r; std::cin >> l >> r;
    r = min(l+2018, r);
    int ans = inf;
    srep(i, l, r+1) {
        srep(j, i+1, r+1) {
            int tmp = (i%2019)*(j%2019);
            tmp %= 2019;
            chmin(ans, tmp);
        }
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b;
  
  scanf("%d %d", &a, &b);
  
  if(((1<=a)&&(a<=9))&&((1<=b)&&(b<=9))){
    printf("%d", a*b);
  }else{
    printf("%d", -1);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h> 
using namespace std; 
// Binary indexed tree supporting binary search.
 
 
#define x first
#define y second

#define forn(i, n) for(int i = 0; i < int(n); ++i)

typedef pair<int, int> pii;
//#define forn(i, a,b) for (int i = (int) a; i <= (int) b; ++i)
const int MAXN = 101;


int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int tak = 1;
    while(1){
    	C-=B;
    	if(C<=0){
    		tak = 1;
    		break;
		}
		A-=D;
		if(A<=0){
			tak = 0;
			break;
		}
	}
	if(tak){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
		
	

	return 0;	
}

Measured memory_bytes: 3648
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())

def resolve():
    k,=pin()
    if k<10:
        print(k)
        return
    else:
        from collections import deque as D
        que=D((i,i) for i in range(1,10))
        num=10
        while(1):
            x,y=que.popleft()
            temp=x%10
            subq=[j for j in range(temp-1,temp+2) if j>=0 and j<10]
            #print(subq)
            for q in subq:
                que.append((x*10+q,num))
                if num == k:
                    print(x*10+q)
                    return
                num+=1
    
"""         
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じ,るの忘れてるだろ
"""
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """15"""
        output = """23"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """13"""
        output = """21"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """100000"""
        output = """3234566667"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()



Measured memory_bytes: 14648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  VI D(N);
  rep(i,N) cin>>D[i];
  VI X(13);
  rep(i,N) X[D[i]]++;
  rep(i,13){
    if(X[i]>2){
      cout<<0<<endl;
      return 0;
    }
  }
  VI L,R;
  L.pb(0);
  R.pb(0);
  int F=1;
  rep(i,13){
    if(F){
      if(X[i]==2){
        L.pb(i);
        R.pb(i);
      }else if(X[i]==1){
        L.pb(i);
        F=0;
      }
    }else{
      if(X[i]==2){
        L.pb(i);
        R.pb(i);
      }else if(X[i]==1){
        R.pb(i);
        F=1;
      }
    }
  }
  int ans=24-L[L.size()-1]-R[R.size()-1];
  rep(i,L.size()-1) ans=min(ans,L[i+1]-L[i]);
  rep(i,R.size()-1) ans=min(ans,R[i+1]-R[i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 256