akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define uint unsigned int



#if 1
const int MOD = 998244353;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}
#endif

#if 0
int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}
#endif

using namespace std;

struct Data {
    int x, y, z;
};

vector <Data> aux;
bool vis[100];

void bkt(int n, int k, int lvl) {
    if(lvl == n) {
        for(auto it : aux) {
            cout << it.x << " " << it.y << " " << it.z << "\n";
        }
        exit(0);
    }
    else {
        for(int a = k; a <= k + 3 * n - 1; a++) {
            if(vis[a]) continue;
            for(int b = a + 1; b <= k + 3 * n - 1; b++) {
                if(vis[b]) continue;
                for(int c = a + b; c <= k + 3 * n - 1; c++) {
                    if(vis[c]) continue;
                    aux.push_back({a, b, c});
                    vis[a] = vis[b] = vis[c] = 1;
                    bkt(n, k, lvl + 1);
                    vis[a] = vis[b] = vis[c] = 0;
                    aux.pop_back();
                }
            }
        }
    }
}

int main() {
#ifdef HOME
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, n, k;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> k;

    //bkt(n, k, 0);



    set <int> a, b, c;
    for(i = 0; i < n; i++) {
        a.insert(k + i);
        b.insert(k + n + i);
        c.insert(k + 2 * n + i);
    }


    vector <Data> sol;
    bool ok = 1;

    while(c.size()) {
        auto C = *prev(c.end());
        multiset <int> :: iterator A, B;

        if(ok) {
            B = prev(b.end());
            A = a.upper_bound(C - *B);
            if(A == a.begin()) {
                cout << -1;
                return 0;
            }
            A = prev(A);
        }
        else {
            A = prev(a.end());
            B = b.upper_bound(C - *A);
            if(B == b.begin()) {
                cout << -1;
                return 0;
            }
            B = prev(B);
        }
        sol.push_back({*A, *B, C});
        a.erase(*A);
        b.erase(*B);
        c.erase(C);
        ok ^= 1;
    }

    for(auto it : sol) {
        cout << it.x << " " << it.y << " " << it.z << "\n";
    }

    return 0;
}


Measured memory_bytes: 14336
N, K = map(int, input().split())

import math

ans = 0
for i in range(1, N + 1):
    tmp = max(0, math.ceil(math.log2(K) - math.log2(i)))
    # print("#", i, tmp, 0.5 ** tmp)
    ans += 0.5 ** tmp

ans /= N

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
using namespace std;
 
int main(){
	int k,a,b;
	cin >> k >> a >> b;
	
	for(int i =1;i<1001;i++)
	{
		if(i*k<=b && i*k>=a)
		{
			cout << "OK" <<endl;
			return 0;
		}
		
	}
	cout << "NG" << endl;
}

Measured memory_bytes: 3624
/*
AizuOnline A0534
Chain
*/
#include <stdio.h>
#include <string.h>
#define DEBUG 0
#define RELEASE 1
int check_erase_if_1_ball_change(char * str,int len)
{
  int i,j;
  int equals;
  int ret;

  equals = 0;
  
  for(i=0;i<len;i++)
    for(j=i+1;j<len;j++)
      equals += ((i!=j)&&str[i]==str[j])?1:0;
  ret=(equals*2 == (len-1)*(len-2))?(-1):0;

#if DEBUG
  printf("E=%d L=%d R=%d\n",equals,len,ret);
#endif
  return(ret);
}    

int all_erase(char * str,int len,int top)
{ int a,b;
  
#if DEBUG
  int i;
  printf("V=");
  for(i=0;i<len;i++)
    printf("%c",str[i]);
  printf("\n");
#endif
  if(top == 0 && len == 3 && str[0] == str[1] && str[1]==str[2])
    return(-1);
  if(len < 4)
    return(0);

  if(len < 8)
    return(check_erase_if_1_ball_change(str,len));
      
  
  a=((str[0] == str[1])?1:0)+1;
  if(a>1)
    a += ((str[0] == str[2])?1:0);
  b=((str[0] == str[len-1])?1:0);
  if(b)
    b +=((str[0] == str[len-2])?1:0);
  if(b == 2)
    b +=((str[0] == str[len-3] )?1:0);

  
/*printf("%d %d %d\n",len,a,b);*/

  if(a+b > 3)
    return(all_erase(str+a ,len-a-b,0));
  else
    return(0);
}

main()
{
  char str[10001];
  int i,j,len;
#if RELEASE
  while(EOF != scanf("%d",&len) && len > 0)
  {
  for(i=0;i<len;i++)
    scanf(" %c",&(str[i]));
#else
    scanf("%s",str);
    len =strlen(str);
#endif
     for(j=len;j>=4;j--)
       {
         /*printf("j=%d\n",j);*/
         for(i=0;i<len-j+1;i++)
           {
             /*printf("i=%d,j=%d\n",i,j);*/
             if(all_erase(str+i,j,-1))
               {
                 printf("%d\n",len-j);
                 goto END;
               }
           }
       }
  printf("%d\n",len);
END:
  ;
#if RELEASE
}
#endif

return(0);
}

Measured memory_bytes: 0
#include <stdio.h>

int main (void)
{
	int gyoretu[100][100],beku[100];//????????¨???????????????????????????
	int gyo,retu,you;//??\????????????
	int a,b,ko=0;
	int an[100];//??????????????????????????????

	scanf("%d %d",&gyo,&retu);

	for(a=0;a<gyo;a++)//????????????????????????
	{
		for(b=0;b<retu;b++)
		{
			gyoretu[a][b]=0;
		}
	}
	for(a=0;a<retu;a++)//?????????????????????????????????
	{
		beku[a]=0;
	}

	for(a=0;a<gyo;a++)//???????????\???
	{
		for(b=0;b<retu;b++)
		{
			scanf("%d",&gyoretu[a][b]);
		}
		
	}
	
	

	for(a=0;a<retu;a++)//?????????????????\???
	{
		scanf("%d",&beku[a]);
	}

	
	for(a=0;a<gyo;a++)//?????????????????????
	{
		ko=0;
		for(b=0;b<retu;b++)
		{
			ko=(gyoretu[a][b]*beku[b])+ko;
			
		}
		an[a]=ko;
	}

	for(a=0;a<gyo;a++)//?????????????????????
	{
		printf("%d\n",an[a]);
	}

	return 0;
}

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  //
  ll n, h, w;
  cin >> n >> h >> w;
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    ll a, b;
    cin >> a >> b;
    if (a >= h && b >= w) {
      ans++;
    }
  }

  cout << ans << '\n';
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int n,K,a[200005],c[200005];
int main(){
	cin>>n>>K;
//	a[1]=a[n]=1;
//	for(int i=2;i<n;i++)a[i]=0;
	for(int i=1;i<=n;i++){
		//cin>>a[i];
		scanf("%d",&a[i]);
	}
	int w=0;
	for(int i=1;i<=K;i++){
		w++;
		memset(c,0,sizeof(c));
		for(int j=1;j<=n;j++){
			int l=max(j-a[j],1),r=min(j+a[j],n);
			c[l]++,c[r+1]--;
		}
		bool flag=1;
		for(int j=1;j<=n;j++){
			c[j]+=c[j-1],a[j]=c[j];
			if(a[j]!=n)flag=0;
		}
		if(flag)break;
	}
	//cout<<w<<endl;
	for(int i=1;i<=n;i++)cout<<a[i]<<' ';
} 

Measured memory_bytes: 5320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;
  double ans=0;
  for(int i=0;i<n;i++){
    double x;string u;cin>>x>>u;
    if(u=="JPY")ans+=x;
    else ans+=x*380000.0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e5+10;
const int MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
int lvl[MAX];
int vis[MAX];
void dfs(int u ){
	vis[u]=1;
	lvl[u]=1;
	for(auto v:adj[u]){
		if(!vis[v]){
			dfs(v);
		
		}
		lvl[u]=max(lvl[u], lvl[v]+1);
	}
}
int main() 
{ 
	//ios_base::sync_with_stdio(false);
  //  cin.tie(NULL);	
//	#ifndef ONLINE_JUDGE
//	freopen("inp.txt" ,"r", stdin );
////	freopen("out.txt", "w", stdout);
	//#endif
	int n , m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x, y;
		cin>>x>>y;
		adj[x].push_back(y);
	}
	dfs(1);
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			dfs(i);
		}
	}
	for(int i=1;i<=n;i++)
		ans=max(ans, lvl[i]-1);
	cout<<ans;
	
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
using namespace std;
 
 ll mod=1e9 +7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

const ll M=200006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // compute();
    Sieve();
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
      ll x;
      cin>>x;
      while(!prime[x]) x++;
      cout<<x;


    }
    return 0;
   }

Measured memory_bytes: 14136
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 2*1e5+1;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    ///freopen("a.in","r",stdin);
    ///freopen("a.out","w",stdout);
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    rep(i,n){
        string a,b;
        map<char,int>mp;
        int cnt=0;
        a=s.substr(0,i+1);
        b=s.substr(i+1,n-i-1);
        for(char c:a)mp[c]=1;
        for(char c:b)if(mp[c])cnt++,mp[c]=0;
        ans=max(ans,cnt);
    }
    cout<<ans<<enl;

    return 0;
}


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

int main()
{
  double d,ans=0.0;

  cin>>d;

  ans=d*sqrt(2);

  for(int i=1;i<=10;i++){
    if(i<=d){
      double tmp=sqrt(d*d-i*i);
      if(tmp<1.0)ans=max(ans,i+1.0);
      else ans=max(ans,i+tmp);
    }
  }

  printf("%.10f\n",ans);

  return 0;
}

Measured memory_bytes: 1240
import java.util.*;
import java.math.*;
class Main {
    //
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[] ary = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int a = sc.nextInt();
        System.out.println(ary[a-1]);
    }
    
}



Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++)cin>>s[i];

    int dp[h][w];
    dp[h-1][w-1]=1;
    for(int i=h-2;i>=0;i--){
        if(s[i][w-1]=='#')dp[i][w-1]=0;
        else dp[i][w-1]=dp[i+1][w-1];
    }
    for(int i=w-2;i>=0;i--){
        if(s[h-1][i]=='#')dp[h-1][i]=0;
        else dp[h-1][i]=dp[h-1][i+1];
    }
    for(int i=h-2;i>=0;i--){
        for(int j=w-2;j>=0;j--){
            if(s[i][j]=='#'){
                dp[i][j]=0;
            }else{
            dp[i][j]=dp[i+1][j]+dp[i][j+1];
            dp[i][j]-=(dp[i][j]>=MOD)?MOD:0;
            }
        }
    }
    cout<<dp[0][0]<<endl;
}


Measured memory_bytes: 5248
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define nl "\n"
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;
#define mt make_tuple
#define vec vector

#define int long long

const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;

typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

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

	cout << max({a*c, a*d, b*c, b*d}) ;
}

int32_t main() {

#ifndef ONLINE_JUDGE
    freopen("error.txt", "w", stderr);
#endif

    fast;

	// int t; cin >> t; while(t--)
		solve() ;

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}


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

#[fastout]
fn main() {
    input!{
        n: usize,
        m: usize,
        c: i64,
        b: [i64;m],
        a: [[i64; m]; n],
    }

    let mut ans = 0;
    for i in 0..n {
        let mut v = 0;
        for j in 0..m {
            v += a[i][j]*b[j];
        }
        v += c;
        if v > 0 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

int round(int x) {
    int y = x % 1000;
    if (y == 0) return x;
    else return x + 1000 - y;
}

int main() {

    int n;
    cin >> n;
    int debt = 100000;
    for (int i = 0; i < n; ++i) {
        debt *= 1.05;
        debt = round(debt);
    }

    cout << debt << endl;

    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e9
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mod 1000000007
#define pb push_back
#define all(s) s.begin(),s.end()
#define pie 3.14159265358979323846
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=b-1;i>=a;i--)
#define gcd __gcd
#define con continue
#define pii pair<ll,ll>
const ll N=1e5+6;
ll par[N];
void make_par(){
   for(ll i=0;i<N;i++)par[i]=i;
}
ll find_par(ll u){
   if(par[u]==u)return u;
   return par[u]=find_par(par[u]);
}
void union_par(ll a,ll b){
   a=find_par(a);
   b=find_par(b);
   par[a]=b;
   return;
}
signed main(){
    FASTIO;
    ll tt=1;
    //cin>>tt;
    while(tt--){
        ll n,m,a,b;cin>>n>>m;
        make_par();
        for(ll i=0;i<m;i++){
           cin>>a>>b;
           union_par(a,b);
        }
        set<ll>st;
        for(ll i=1;i<=n;i++){
           st.insert(find_par(i));
           //cout<<find_par(i)<<"\n";
        }
        cout<<st.size()-1<<"\n";
    }
}


Measured memory_bytes: 8292
import java.util.*;
import java.io.*;

public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) {
		solve();
		
	}
	
	static void solve()
	{
		int n = in.nextInt();
		int[] arr = new int[n];
		for(int i = 0; i < n; i++)
			arr[i] = in.nextInt();
		
		int count = 0;
		for(int i = 0; i < n; i++)
		{
			for(int j = i + 1; j < n; j++)
			{
				for(int k = j + 1; k < n; k++)
				{
					if(arr[i] == arr[j] || arr[j] == arr[k] || arr[i] == arr[k]) continue;
					int[] a = new int[] {arr[i], arr[j], arr[k]};
					Arrays.sort(a);
					if(a[0] + a[1] > a[2]) count++;
				}
			}
		}
		System.out.println(count);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}





Measured memory_bytes: 38424
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int main(void) {
  ll n;
  cin >> n;
  ll res = 1e18;
  for(ll i = 1; i*i <= n; ++i) {
    if(n % i == 0) {
      res = min(res, (i-1) + (n/i-1));
    }
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
lr = []
for i in range(m):
    lr.append(list(map(int, input().split())))

def ans():
    ans = lr[0]
    for i in range(1, m):
        if ans[0] > lr[i][-1] or ans[-1] < lr[i][0]:
            print(0)
            return
        ans = [max(ans[0], lr[i][0]), min(ans[-1], lr[i][-1])]

    print(ans[-1]- ans[0] + 1)
    return

ans()


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

const int MOD = (int)1e9+7;

int main(){
	int N;
	long long X;
	cin >> N >> X;

	vector<pair<long long,long long>> size_Psize(N+1);
	size_Psize.at(0)=make_pair(1,1);
	for(int i=1;i<=N;i++){
		size_Psize.at(i).first=(size_Psize.at(i-1).first)*2 +3;
		size_Psize.at(i).second=(size_Psize.at(i-1).second)*2 +1;
	}
	long long ans=0;
	int now=N;
	while(X>0){
		if(X>=size_Psize.at(now).first){
			ans+=size_Psize.at(now).second;
			X-=size_Psize.at(now).first;

			if(X>0){
				ans++;
				X--;
			}
		}
		else{
			X--;
			now--;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long out = 0;
        for(int i = 1; i <= n; i++){
            if(i % 3 != 0 && i % 5 != 0) out += i;
        }
        System.out.println(out);
        scan.close();
    }
    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 27176
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define rep(i,a,n) for( int i = a ; i < n ; i++ )
#define prep( i, a , n ) for ( int i = a ; i>= n ; i--)
#define   pr pair<int,int>
const int N = 1e5 + 5 , M=N,inf=(int)1e9;
const int mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
ll ans ;
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
vector < int > h[N];
void solve(){
    int n ;
    cin >> n ;
    vector < vector < int > > a(n , vector < int > (3)) ;
    for( int i = 0 ; i < n ; i++){
        for( int j = 0 ; j < 3 ; j++){
            cin >> a[i][j] ;
        }
    }
    vector < int > dp1(n,0) , dp2(n,0) , dp3(n,0) ;
    dp1[0] = a[0][0] , dp2[0] = a[0][1] , dp3[0] = a[0][2] ;
    for ( int i = 1 ; i < n ; i++){
        dp1[i] = max(dp2[i-1]+a[i][0],dp3[i-1]+a[i][0]);
        dp2[i] = max(dp1[i-1]+a[i][1],dp3[i-1]+a[i][1]);
        dp3[i] = max(dp2[i-1]+a[i][2],dp1[i-1]+a[i][2]);
    }
    cout << max( dp1[n-1],max(dp2[n-1],dp3[n-1])) ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
   //cin >> q;
    while(q--)
        solve();
}
/*
    ---------------- lemmas-----------------------------------
   1)
   2)
   3)

*/


Measured memory_bytes: 9216
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#include<stack>
#include<queue>
using namespace std;

 
int main(){
    int r;
    cin >> r;
    cout << r*r << endl;
}

Measured memory_bytes: 256
class Stack<T> {
    val values = emptyList<T>().toMutableList()

    fun push(value: T) = values.add(value)

    fun pop() = values.removeAt(values.size - 1)

    override fun toString() = values.toString()
}
class Queue<T> {
    val values = emptyList<T>().toMutableList()

    fun enqueue(value: T) = values.add(value)

    fun dequeue() = values.removeAt(0)

    override fun toString() = values.toString()
}

fun <T> List<T>.get1Origin(index: Int) = this[index - 1]
fun <T> List<T>.subList1Origin(fromIndex: Int, toIndex: Int) = this.subList(fromIndex - 1, toIndex - 1)
fun <T> MutableList<T>.set1Origin(index: Int, element: T) = this.set(index - 1, element)
fun <T> MutableList<T>.removeAt1Origin(index: Int) = this.removeAt(index - 1)

fun String.splitToString() = this.split(" ")
fun String.splitToInt() = this.split(" ").map { it.toInt() }
fun String.splitToLong() = this.split(" ").map { it.toLong() }

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val P = readLine()!!.splitToInt()
    var count = 0
    var min = Int.MAX_VALUE
    for (Pj in P) {
        if (min >= Pj) {
            min = Pj
            count++
        }
    }
    println(count)
}

Measured memory_bytes: 82440
#include <bits/stdc++.h>
#define ll long long
#define MN 100000
using namespace std;
inline ll read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9')if(ch=='-')f=-1,ch=getchar();
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int main()
{
    int n=read();
    if(n==1)puts("Hello World");
    else{int x=read(),y=read();printf("%d\n",x+y);}    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }
class ModInt {
  static int MOD;
  long long x;

 public:
  static void mod(int m) { MOD = m; }

  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

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

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.x; }

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }

  long long val() { return x; }
};
int ModInt::MOD = 1000000007;
template <typename T>
class Combination {
  vector<T> fact, ifact;

 public:
  Combination(int nMax) : fact(nMax + 1), ifact(nMax + 1) {
    fact[0] = 1;
    for (int i = 0; i < nMax; ++i) fact[i + 1] = fact[i] * (i + 1);
    for (int i = 0; i < nMax + 1; ++i) ifact[i] = fact[i].inverse();
  }

  T factorial(int n) const { return fact[n]; }
  T inverseFactorial(int n) const { return ifact[n]; }

  T P(int n, int k) const {
    if (n < 0 || k < 0 || n < k) return 0;
    return factorial(n) * inverseFactorial(n - k);
  }

  T C(int n, int k) const {
    if (n < 0 || k < 0 || n < k) return 0;
    return factorial(n) * inverseFactorial(n - k) * inverseFactorial(k);
  }

  T H(int n, int k) const {
    if (n < 0 || k < 0) return 0;
    return k == 0 ? 1 : C(n + k - 1, k);
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  Combination<ModInt> comb(n);

  ModInt ans = 0;
  for (int i = 0; i <= min(k, n - 1); ++i) {
    ans += comb.C(n, i) * comb.C(n - 1, i);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>

int main(int argc, char const* argv[])
{
	int h,w;
	std::cin >> h >> w;
	while (!(h==0&&h==w)) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if ((i+j)%2) {
					std::cout << "." ;
				} else {
					std::cout << "#" ;
				}
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
		std::cin >> h >> w;
	}

	return 0;
}

Measured memory_bytes: 1152
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  const int k = getInt();


  if(k > ((n - 1) * (n - 2)) / 2){
    printf("%d\n", -1);
  }else{
    const int nn = ((n - 1) * (n - 2)) / 2;
    const int m = (n - 1) + (nn - k);

    printf("%d\n", m);
    for(int i = 2; i <= n; i++)
      printf("%d %d\n", 1, i);

    int cnt = nn - k;
    if(cnt){
      for(int i = 2; i <= n; i++){
	for(int j = i + 1; j <= n; j++){
	  printf("%d %d\n", i, j);
	  if(--cnt == 0) break;
	}
	if(cnt == 0) break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 128
n = gets
how = n.to_i
until how == 0
    member = Hash.new
    how.times do
        x = gets
        y = x.split(" ")
        id = y[0].to_i
        howmuch = y[1].to_i
        howmany = y[2].to_i
        sell = howmany * howmuch
        if member.key?(id)
            member[id] += sell
        else
            member.store(id,sell)
        end
    end
    seller = member.select{|k,v| v >= 1000000}
    if seller.empty?
        puts "NA"
    else
    seller.each do |k,v|
        puts "#{k}"
    end
    end
    n = gets
    how = n.to_i
end


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

int main(){
	int n;
	cin >> n;
	vector<pair<pair<string, int>, int> > A(n);
	string s;
	int p;
	for(int i=0; i<n; i++){
		cin >> s;
		cin >> p;
		A[i] = {{s,100-p}, i+1};
	}
	sort(A.begin(),A.end());
	for(int i=0; i<n; ++i){
		cout << A[i].second << endl;
	}
	
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int h,w;
int c[10][10];
int a[201][201];

int main(void){
	scanf("%d%d",&h,&w);
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			scanf("%d",&c[i][j]);
		}
	}
	for(int k=0;k<10;k++){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
			}
		}
	}
	int ans=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			scanf("%d",&a[i][j]);
			if(a[i][j]!=-1){
				ans+=c[a[i][j]][1];
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int n,dp[200005],now,a[200005],bf[200005];
int pos=1, mod=1000000007;

int main() {
	scanf("%d",&n);
	int T=n;
  	while(T--) {
    	scanf("%d",&a[pos]);
      	if(a[pos]!=now) {
        	now = a[pos];
          	bf[pos]=dp[a[pos]];
          	dp[a[pos]] = pos;
          	pos++;
        }
        else n--;
    }
  	dp[0]=1;
  	for(int i=1;i<=n;i++) 
  		if(bf[i]) dp[i] = (dp[i-1] + dp[bf[i]])%mod;
  		else dp[i] = dp[i-1];
    printf("%d\n",dp[n]);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    int now = i;
    int s = 0;
    while (now) {
      s += now % 10;
      now /= 10;
    }
    if (a <= s && s <= b) {
      ans += i;
    }
  }
  cout << ans << endl;
}


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/
  

  int t;

  int n;

  int s,f;

  while(cin>>t,t){
    cin>>n;


    int ans=0;

    for(int i=0;i<n;i++){ 
      cin>>s>>f;					      
      ans+=f-s;

    }

    if(ans>=t){
      cout<<"OK"<<endl;
    }else{
      cout<<t-ans<<endl;
    }
  }

    
  return 0;

}



Measured memory_bytes: 3116
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a,b,sum,count;

    a = sc.nextInt();
    b = sc.nextInt();
    if(b == 1){
      System.out.println(0);
    }else{
      sum = a;
      count = 1;
      while(sum < b){
        sum += (a - 1);
        count++;
      }

      System.out.println(count);
    }
  }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> A(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> A.at(i);
  }
  std::vector<int> B;
  std::vector<int> C;
  for (int i = 0; i < n; i++) {
    int b, c;
    b = A.at(i) + i;
    c = i - A.at(i);
    B.push_back(b);
    C.push_back(c);
  }
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  long long ans = 0;
  for (auto b : B) {
    int count =
        upper_bound(C.begin(), C.end(), b) - lower_bound(C.begin(), C.end(), b);
    ans += count;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5836
from math import ceil, log2

N = int(input())

K = ceil(log2(N))

nodes = [i for i in range(1 << K)]

for i in range(N-1):
    out = []
    for j in range(i+1, N):
        res = nodes[i] ^ nodes[j]
        for k in range(N):
            if (res >> k) & 1:
                out.append(k+1)
                break
    print(*out)

Measured memory_bytes: 3952
//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (ll i=a;i<b;++i)
#define Ford(i,a,b) for (ll i=a;i>=b;--i)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(15) << x; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=1e5+5,LG=20,SM=1000,inf=1e9+5;
ll mod=1e9+7;
ll pw(ll a,ll n) { return (n==0?1:pw(a*a%mod,n/2)*(n%2?a:1)%mod); }
#define MOK(x) if (x>mod) x-=mod;

ll s(ll x){
  if (x<10) return x;
  return s(x/10)+x%10;
}

vll v,v2;

int main(){
  ios::sync_with_stdio(0);
  ll k;
  cin >> k;
  For(i,1,1000){
    ll x=i;
    For(j,0,15){
      v.PB(x);
      x*=10;
      x+=9;
    }
  }
  sort(ALL(v));
  v.resize(unique(ALL(v))-v.begin());
  ld bst=1e20;
  reverse(ALL(v));
  for(ll x:v){
    if (bst<(ld)x/(ld)s(x)) continue;
    bst=(ld)x/(ld)s(x);
    v2.PB(x);
  }
  reverse(ALL(v2));
  For(i,0,k) cout << v2[i] << '\n';
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
#define dis distance
#define so sort
#define rev reverse
#define pub push_back
#define sec second
#define fir first


typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int EPS = 1e-9;
const int MOD = 1e9+7;

llu gcm(llu x, llu y){
  llu r = 0;
  if(x<y) swap(x,y);

  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}
llu lcm(llu x, llu y){
  return  x * (y / gcm(x, y));
}



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  llu nt;
  cin >> nt;
  REP(i,n-1){
    llu t;
    cin >> t;
    nt = lcm(nt,t);
    DUMP(t);
    DUMP(gcm(nt,t));
    DUMP(nt);
  }
  cout << nt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);



void solve() {
	int n; int k;
	string s;
	cin >> n >> k >> s;
	int cnt = 0;
	rep(i, n) {
		if (s[i] == 'L') {
			if (i > 0 && s[i - 1] == 'L')cnt++;
		}
		else {
			if (i + 1 < n&&s[i + 1] == 'R')cnt++;
		}
	}
	int ans = cnt + 2 * k;
	ans = min(ans, n - 1);
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(50);
	//init();
	solve();

	//cout << "finish" << endl;
	//stop
		return 0;
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
void solve()
{
 string s; cin>>s; 
 int c=0; for(int i=0;i<=2;i++) { if(s[i]=='R') c++; } if(c==0||c==1||c==3){ cout<<c<<"\n"; return; }
 if((s[0]=='R' and s[1]=='R')||(s[2]=='R' and s[1]=='R')) { cout<<2<<"\n"; } else cout<<1<<"\n"; return;  
}
int main()
{
/*  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/
  ios_base::sync_with_stdio(false); 
  cin.tie(nullptr); 
  int t=1; 
  while(t--)
  {
    solve(); 
  }
  return 0; 
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=1000010;
const int inf=2147483647;
int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*f;
}
int L,n=1,m=0,a[22],l=0;
struct Edge{int x,y,d;}e[70];
int main()
{
    L=read();
    int t=L-1;
    for(int i=0;(1<<i)<=t;i++)
    {
        n++;
        t-=(1<<i);
        e[++m].x=n-1,e[m].y=n,e[m].d=0;
        e[++m].x=n-1,e[m].y=n,e[m].d=(1<<i);
    }
    t=L;
    while(t)a[++l]=(t&1),t>>=1;
    int tot=(1<<(l-1));
    for(int i=l-1;i;i--)
    if(a[i])
    {
        e[++m].x=i,e[m].y=n,e[m].d=tot;
        tot+=(1<<(i-1));
    }
    printf("%d %d\n",n,m);
    for(int i=1;i<=m;i++)printf("%d %d %d\n",e[i].x,e[i].y,e[i].d);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, i;
	int ary[101] = {};

	ary[4] = 1;
	ary[7] = 1;
	for (i = 8; i < 101; i++) {
		if (ary[i - 4]) ary[i] = 1;
		if (ary[i - 7]) ary[i] = 1;
	}

/*
	for (i = 0; i < 101; i++) {
		printf("%d ", i);
		printf("%d\n", ary[i]);
	}
*/

	scanf("%d", &n);
	printf(ary[n] ? "Yes\n" : "No\n");
	return 0;
}



/*
#include <stdio.h>
 
int main(void) {
	int n, i;
	int dp[101] = {0};
	
	dp[4] = 1;
	dp[7] = 1;
	for (i = 8; i <= 100; i++) {
		if (dp[i - 4]) dp[i] = 1;
		if (dp[i - 7]) dp[i] = 1;
	}
	for (i = 0; i <= 100; i++) {
		printf("%d  ", i);
		printf("%d\n", dp[i]);
	}
	
	scanf("%d", &n);
	printf(dp[n] ? "Yes\n" : "No\n");
	
	return 0;
}
*/

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

using namespace std;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define bas(x) #x << ": " << x << " "
#define prarr(x, n) cout << #x << ": "; for (int qsd = 0; qsd < n; qsd++) cout << x[qsd] << " "; cout << endl;
#define prarrv(x) cout << #x << ": "; for (int qsd = 0; qsd < (int)x.size(); qsd++) cout << x[qsd] << " "; cout << endl;
#define inside sl<=l&&r<=sr
#define outside sr<l||r<sl

typedef long long ll;

int main(){
	ll s;
	cin >> s;
	ll x1, y1, x2, y2;
	x1 = 1000000000;
	y2 = ceil((double)s/(double)x1);
	x2 = 1;
	y1 = x1*y2-s;
	assert(x1*y2 - x2*y1  == s);
	cout << "0 0 " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);

		String s1 = scan.next();
		String s2 = scan.next();
		
		int n1 = scan.nextInt();
		int n2 = scan.nextInt();
		
		if(scan.next().equals(s1))n1--;
		else n2--;
		
		System.out.println(n1 + " " + n2);
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vector<string> s(500);
  rep(i,n)
    cin>>s[i];
  int tmp=0;
  rep(i,n)rep(j,n)
    if(s[i][j]=='#')tmp++;
  if(tmp==0){
    cout<<-1<<endl;
    return 0;
  }
  tmp=0;
  rep(j,n){
    rep(i,n)
      if(s[i][j]=='.')break;
    if(i<n)tmp++;
  }
  int ans=tmp;
  tmp=INF;
  rep(i,n){
    int t=0;
    rep(j,n)if(s[i][j]=='.')t++;//i行目の白の数                  
    rep(j,n)if(s[j][i]=='#')break;
    if(j==n)t++;
    tmp=min(tmp,t);
  }
  cout<<ans+tmp<<endl;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        if(N < 10) {
            System.out.println(N);
        } else if (N < 100) {
            System.out.println(9);
        } else if (N < 1000) {
            System.out.println(9 + N - 99);
        } else if (N < 10000) {
            System.out.println(9 + (999 - 100 + 1));
        } else if (N < 100000) {
            System.out.println(9 + (999 - 100 + 1) + N - 9999);
        } else {
            System.out.println(9 + (999 - 100 + 1) + (99999 - 10000  +1));
        }
    }
}

Measured memory_bytes: 22100
N = int(input())
S = [int(input()) for _ in range(N)]

S.sort()
ans = sum(S)
if ans % 10 != 0:
    print(ans)
    exit()

for i in range(N):
    if (ans - S[i]) % 10 != 0:
        print(ans - S[i])
        exit()
print(0)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const int MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main() {
    int n;
    cin >> n;
    // 入力
    string S;
    cin >> S;


    vector <int> cnt(26,0);
    REP(i,n)
    {
        ++cnt[S[i] - 'a'];
    }

    ll res = 1;
    REP(i,26)
    {
        res *= (cnt[i] + 1);
        res %= MOD;
    }
    cout << res - 1  << endl;
}

Measured memory_bytes: 512
def main():
    N, A, B = map(int, input().split())
    answer = 0

    for i in range(1, N+1):
        n = 0
        for j in str(i):
            n += int(j)
            if n > B:
                break
        if n >= A and n <= B:
            answer += i

    print(answer)


if __name__ == '__main__':
    main()


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	double a, b;
	cin >> a >> b;

	double c = a + b;
	c = c / 2.0;
	cout << ceil(c) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * The Third Permutation
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int n = parseInt(br.readLine());
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = parseInt(br.readLine());
		}

		Arrays.sort(a);

		List<Integer> list = new ArrayList<>();

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a.length; j++) {
				if (i != j) {
					list.add(a[i] * (int) (Math.pow(10, (int) Math.log10(a[j]) + 1)) + a[j]);
				}
				if (list.size() > 1000) {
					break;
				}
			}
		}

		Collections.sort(list);

		System.out.println(list.get(2));

	}
}

Measured memory_bytes: 28996
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< string, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
int D;
int ans;

int main(){
    
    cin>>N>>D;
    
    ans = N/(2*D+1);
    if( N % (2*D+1) ) ans++;
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int n, a; cin >> n >> a;
	n %= 500;
	if (n <= a)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main()
{
    long long int n,k,min,d;
    cin >> n >> k;
    min=1000000000000000000;
    n=n%k;
    while(1)
    {
        d=abs(n-k);
        if(min>d)
        {
            min=d;
            n=d;
        }
        else
        {
            break;
        }
    }
    cout << min << endl;

    return 0;
}


Measured memory_bytes: 256