akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	cout.tie(NULL);
	int a;	cin >> a;
	long int ans = a*(1+a+a*a);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3644
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]

new = []
wait = []
for i in range(n):
    new.append(i)
    wait.append(a[i][0])

progress = [0] * n
day = 0
finished = []
while len(finished) < n:
    visited = []
    for i in new:
        _wait = wait[i] - 1

        if _wait != float('inf') and wait[_wait] == i + 1 and _wait not in visited and i not in visited:
            progress[i] += 1
            progress[_wait] += 1
            visited.append(i)
            visited.append(_wait)

            if progress[i] != n - 1:
                wait[i] = a[i][progress[i]]
            else:
                wait[i] = float('inf')
                finished.append(i)

            if progress[_wait] != n - 1:
                wait[_wait] = a[_wait][progress[_wait]]
            else:
                wait[_wait] = float('inf')
                finished.append(_wait)

    # print(visited, progress)
    if not visited:
        day = -1
        break

    new = []
    for i in range(len(visited)):
        new.append(visited[i])

    day += 1


print(day)


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

using namespace std;


int main(){
  int e,y;
  cin >> e >> y;

  if(e==0){
    if(1912>y) cout << "M" << y-1867;
    else if(1926>y) cout << "T" << y-1911;
    else if(1989>y) cout << "S" << y-1925;
    else cout << "H" << y-1988;
  }else if(e==1) cout << y+1867;
  else if(e==2) cout << y+1911;
  else if(e==3) cout << y+1925;
  else cout << y+1988;

    cout << endl;

    
  return 0;
}



Measured memory_bytes: 3104
from sys import exit, stdin
N = int(stdin.readline().rstrip())
T = [int(_) for _ in stdin.readline().rstrip().split()]
M = int(stdin.readline().rstrip())
PX = [list(map(int, stdin.readline().rstrip().split())) for _ in range(M)]
for i in range(M):
    drink_i = PX[i][0]-1
    print(PX[i][1]+sum(T[:drink_i]+T[drink_i+1:]))

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


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

  int a[n];
  for (int i=0;i<n;i++){
    cin >> a[i];
  }
  
  long long ans=0,MOD = 1000000007,tmpSum=0,piledSum[n];

  //累積和
  piledSum[n-1] = a[n-1];
  //cout << piledSum[n-1] << endl;
  for (int i=n-2;i>=0;i--){
    piledSum[i] = piledSum[i+1] + a[i];
    //cout << piledSum[i] << endl;
  }

  
  for (int i=0;i<n-1;i++){
    
    //cout << "a[i]: " << a[i]%MOD << ", 累積和: " << piledSum[i+1] << ", ans:" << ans <<endl;
    ans += ((a[i]%MOD)*(piledSum[i+1]%MOD))%MOD;
    ans = ans%MOD;
  }

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

Measured memory_bytes: 5964
import java.util.*;
public class Main {
    public static void main(String args []){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] List = new int[N+1];
        long opt=1;
        int root = 1;
        int max = 0;
        for(int i=0;i<N;i++) {
            int num = sc.nextInt();
            if(i==0) root = num;
            if(max<num) max = num;
            List[num]++;
        }
        if(root==0&&List[0]==1){
            for(int i=1;i<max;i++){
                if(List[i]!=0&&List[i+1]!=0){
                    long num2 = 1;
                    for(int j=0;j<List[i+1];j++)num2= (num2*List[i])%998244353;
                    opt=(opt*num2)%998244353;
                }
                else{
                    opt = 0;
                    break;
                }
            }

        }
        else  opt=0;
        System.out.println(opt);
    }
}

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

int main(){
 int W,H,x,y,r;
 cin >> W >> H >> x >> y >> r;
 
 if((W >= (x+r) && x >= r) &&
  (H >= (y+r) && y >= r)){
  cout << "Yes" << endl;
 } else {
  cout << "No" << endl;
 }

 return 0;
} 

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

int main() {
  int k,s,cnt=0;
  cin >> k >> s;
  for(int i=0; i<=k; i++) {
    for(int j=0; j<=k; j++) {
      if(s-i-j>=0&&s-i-j<=k) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    vector<int> g[n];
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    for (int i = 0; i < n; ++i) {
      cout << g[i].size() << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	vector<ll> a(n);
	vector<ll> h(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];

			h[a[i]]++;
	}

	bool b = true;
	if (n % 2 == 1)
	{
		for (ll i = 0; i < n; i++)
		{
			if (i == 0)
			{
				if (h[i] != 1)
				{
					b = false;
				}
			}
			else if (i % 2 == 0)
			{
				if (h[i] % 2 == 1 || h[i] > 2)
				{
					b = false;
				}
			}
			else
			{
				if (h[i] > 0)
				{
					b = false;
				}
			}
		}

		if (b)
		{
			ull res = 1;
			for (ll i = 0; i < n / 2; i++)
			{
				res = (res * 2) % mod;
			}
			println(res);
		}
		else
		{
			println(0);
		}
	}
	else
	{
		for (ll i = 0; i < n; i++)
		{
			if (i % 2 == 1)
			{
				if (h[i] != 2)
				{
					b = false;
				}
			}
			else
			{
				if (h[i]  > 0)
				{
					b = false;
				}
			}
		}

		if (b)
		{
			ull res = 1;
			for (ll i = 0; i < n / 2; i++)
			{
				res = (res * 2) % mod;
			}
			println(res);
		}
		else
		{
			println(0);
		}
	}
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main(){
	int h,m;
	string all, l, r;
	while (1){
		cin >>all>> m;
		if (all == "-")break;
		for (int i = 0; i < m; i++){
			cin >> h;
			l = all.substr(0, h);
			r = all.substr(h, -1);
			all = r + l;
		}
		cout << all << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <typeinfo>
#include <queue>
#include <math.h>
using namespace std;



int main(){
	string str;
	cin>>str;
	int sum=0;
	int n=str.size();

	for (int i = 0; i < n-1; ++i)
	{
		if (str[i]!=str[i+1])
		{
			sum++;
		}
	}

	cout<<sum<<endl;




return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
    using namespace std;
    #define FOR(i,n) for(int i=0;i<n;i++)
    #define why(n,x) int n;while(cin >>n,n!=x)
    #define iFOR(i,x,n)for(int i=x;i<n;i++)
    #define unless(flg) if ( !(flg) )
    #define read cin<<
    #define echo cout<<
    #define fin <<'\n'
    #define __ <<" "<<
    #define ___ <<" "
    #define bash push_back
    #define ALL(x) x.begin(),x.end()
    #define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
    #define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
    #define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
    #define memmin(x) memset((x),-1,sizeof((x)))
    #define memzer(x) memset((x), 0,sizeof((x)))
    #define meminf(x) memset((x),0x3f,sizeof((x)))
    #define int long long
    typedef long long ll;
    typedef pair < int , int >  pii;
    typedef vector < int > vit;
    typedef map < string , int > mstit;
    typedef vector < pii > vpi ;
    typedef greater < pii > gpi;
    typedef priority_queue < pii , vpi , gpi > dijk ;
    static const signed int INF = 0x3f3f3f3f;
    static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
    static const signed int SMOD = 1000000007;
    static const signed int NMOD = 1000000009;
    static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
    static const signed int dy[]={0,-1,0,1,-1,1,-1,1};
     
    bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
    template<class T>T abs(T &x){return x<0 ? -x : x;}
    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; }
    int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
    int gcd(int a,int b){return b?gcd(b,a%b):a;}
     
     
     
    signed main(){
        int n,m;
        int a[10005]={};
        int x,y;
        cin >> n >> m;
        FOR(i,n){
            cin >> x;
            FOR(i,x){
                cin >> y;
                a[y]++;
            }
        }
        int ans = 0;
        FOR(i,m+1){
            if(a[i]==n) ans++;
        }
        cout << ans fin;
      
      return 0;
    }
     
     
     
    struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;
     
     

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

int getMax( int a, int b );
int getWidth( int n, char m[255][255], int s, int t );
int getHeight( int n, char m[255][255], int s, int t );
int getDiagnal1( int n, char m[255][255], int s, int t );
int getDiagnal2( int n, char m[255][255], int s, int t );

int main()
{
    int n;
    char m[255][255];
    
    while( cin >> n )
    {
        if( n == 0 )
            break;

        for( int i = 0; i < 255; i++ )
            for( int j = 0; j < 255; j++ )
                m[i][j] = 0;

        for( int i = 0; i < n; i++ )
            for( int j = 0; j < n; j++ )
                cin >> m[i][j];
        
        int max = 0;
        for( int i = 0; i < n; i++ )
        {
            max = getMax( max, getHeight( n, m, 0, i ) );
            max = getMax( max, getWidth( n, m, i, 0 ) );
            max = getMax( max, getDiagnal1( n, m, 0, i ) );
            max = getMax( max, getDiagnal2( n, m, 0, i ) );
        }
        for( int i = 1; i < n; i++ )
            max = getMax( max, getDiagnal1( n, m, i, n - 1 ) );
        for( int i = 1; i < n; i++ )
            max = getMax( max, getDiagnal2( n, m, i, 0 ) );

        cout << max << endl;
    }

    return 0;
}

int getMax( int a, int b )
{
    if( a > b )
        return a;
    else
        return b;
}

int getWidth( int n, char m[255][255], int s, int t )
{
    int cnt = 0, max = 0;
    while( t < n )
    {
        if( m[s][t] == '1' )
        {
            cnt++;
            if( cnt > max )
                max = cnt;
        }
        else
            cnt = 0;
        t++;
    }
    return max;
}

int getHeight( int n, char m[255][255], int s, int t )
{
    int cnt = 0, max = 0;
    while( s < n )
    {
        if( m[s][t] == '1' )
        {
            cnt++;
            if( cnt > max )
                max = cnt;
        }
        else
            cnt = 0;
        s++;
    }
    return max;
}

int getDiagnal1( int n, char m[255][255], int s, int t )
{
    int cnt = 0, max = 0;
    while( s < n && t >= 0 )
    {
        if( m[s][t] == '1' )
        {
            cnt++;
            if( cnt > max )
                max = cnt;
        }
        else
            cnt = 0;
        s++;
        t--;
    }
    return max;
}


int getDiagnal2( int n, char m[255][255], int s, int t )
{
    int cnt = 0, max = 0;
    while( s < n && t < n )
    {
        if( m[s][t] == '1' )
        {
            cnt++;
            if( cnt > max )
                max = cnt;
        }
        else
            cnt = 0;
        s++;
        t++;
    }
    return max;
}


Measured memory_bytes: 3140
// Author :mdragneell
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define pi  pair< int,int >
#define pl  pair< ll,ll >
#define f first
#define s second


ll const mod=1e9+7;
ll const N=1e3+5;
ll min(ll x,ll y) { if(x < y) return x; else return y; }
ll max(ll x,ll y) { if(x > y) return x; else return y; }
ll gcd(ll x,ll y) { if(x == 0) return y; else return gcd(y%x,x);}
ll powmod(ll x,ll y){ll res=1;while(y>0){if(y%2==1)res=(res*x)%mod;y>>=1;if(y<=0)break;x=(x*x)%mod;}return res;}



struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);}
};
struct compare {
    bool operator()(const pair<ll, ll>& value,  const ll& key){ return (value.first < key); }
    bool operator()(const ll& key, const pair<ll, ll>& value) { return (key < value.first); }
};

bool compare1(const pair<ll,ll> &a,const pair<ll,ll> &b)
{   if(a.first<b.first) return true ;
    else if(a.first==b.first) return (a.second > b.second);
    else return false;
}

int main()
{

        ios_base::sync_with_stdio(false); cin.tie(NULL);
       
        int tt=1;
        //cin>>tt;

        while(tt--)
        {
               ll n,k;
               cin>>n;
               
                n=log2(n);
                ll ans=pow(2,n+1)-1;
                cout<<ans<<endl;
            
                
        }



}


Measured memory_bytes: 512
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 h: usize = read();
    let w: usize = read();
    let n = h * w;
    let d: usize = read();
    let mut field = vec![vec![0; w]; h];
    let mut rev_field = vec![(0, 0); n];
    for y in 0..h {
        for x in 0..w {
            field[y][x] = read::<usize>() - 1;
            rev_field[field[y][x] as usize] = (y as i32, x as i32);
        }
    }
    let mut sums = vec![vec![0; n / d + 2]; d];
    for i in 0..(n-d) {
        let ni = i + d;
        let dist = (rev_field[i].0 - rev_field[ni].0).abs() + (rev_field[i].1 - rev_field[ni].1).abs();
        let offset = i % d;
        let index = i / d;
        sums[offset][index + 1] = sums[offset][index] + dist;
    }
    let q: usize = read();
    for _ in 0..q {
        let from: usize = read::<usize>() - 1;
        let to: usize = read::<usize>() - 1;
        let offset = from % d;
        let start = from / d;
        let end = to / d;
        println!("{}", sums[offset][end] - sums[offset][start]);
    }
}

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

#define pb push_back
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define beg begin()
#define en end()
#define sz size()
#define mem(a,b) memset(a,b,sizeof a)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;	
	if(n%4==0||n%7==0){
		cout<<"Yes";
	}
	
	else{
		bool hallar=false;
	
	for(int i=4;i<=100;i+=4){
		for(int j=7; j<100;j+=7){
			if(i+j==n){
				hallar=true;
			}
		}
	}
	
	if(hallar==true){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	cout<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
s = [input() for _ in range(h)]
hrz = [[0] * w for _ in range(h)]
vrt = [[0] * w for _ in range(h)]
for i in range(h):
    cnt = 0
    for j in range(w + 1):
        if j < w and s[i][j] == '.':
            if cnt == 0:
                start = j
            cnt += 1
        elif cnt > 0:
            for k in range(start, j):
                hrz[i][k] = cnt
            cnt = 0
for j in range(w):
    cnt = 0
    for i in range(h + 1):
        if i < h and s[i][j] == '.':
            if cnt == 0:
                start = i
            cnt += 1
        elif cnt > 0:
            for k in range(start, i):
                vrt[k][j] = cnt
            cnt = 0
ans = max(hrz[i][j] + vrt[i][j] - 1 for i in range(h) for j in range(w))
print(ans)


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

using namespace std;
typedef long long ll;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
    int h, w; cin>> h >> w;
    int si, sj; cin>> si >> sj;
    int ti, tj; cin>> ti >> tj;
    si--; sj--; ti--; tj--;
    vector<string> s(h);
    forin(s);
    const int INF=1e+9;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    deque<pair<int, int>> q;
    dist[si][sj]=0;
    q.emplace_back(si, sj);
    while(!q.empty()){
        int i = q.front().first;
        int j = q.front().second;
        q.pop_front();
        int d = dist[i][j];
        rep(v, 4){
            int ni = i + di[v], nj = j + dj[v];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if(s[ni][nj] == '#') continue;
            if(dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            q.emplace_front(ni, nj);
        }
        for(int ei = -2; ei <= 2; ei++){
            for(int ej = -2; ej <= 2; ej++){
                int ni = i+ei, nj=j+ej;
                if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if(s[ni][nj] == '#') continue;
                if(dist[ni][nj] <= d+1) continue;
                dist[ni][nj] = d+1;
                q.emplace_back(ni, nj);
            }
        }
    }
    int ans = dist[ti][tj];
    if(ans == INF) ans = -1;
    cout<< ans << endl;
}

Measured memory_bytes: 9484
import java.util.*;

public class Main {

    static int solve(int n, long k, int[] A) {
        int p = 0;
        List<Integer> l = new ArrayList<>();
        Map<Integer, Integer> used = new HashMap<>();
        while (!used.containsKey(p)) {
            used.put(p, l.size());
            l.add(p);
            p = A[p];
        }

        int loop = l.size() - used.get(p);

        if (k < used.get(p)) return l.get((int)k) + 1;
        k -= used.get(p);
        k %= loop;
        return l.get((int)(used.get(p) + k)) + 1;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long k = in.nextLong();
        int[] A = new int[n];
        for (int i=0;i<n;i++) A[i] = in.nextInt() - 1;
        System.out.println(solve(n, k, A));
    }
}


Measured memory_bytes: 67412
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define ld long double
#define mkp make_pair
#define sz(x) (int)x.size()
#define pi pair<long long, long long>
#define watch(x) cout << (#x) << " is " << (x) << endl; cout.flush()
#define endl '\n'
#define _ << ' '
#define FAST_LOG2(x) (sizeof(unsigned long)*8 - 1 - __builtin_clzl((unsigned long)(x)))
#define clog2(x) (((x) - (1 << FAST_LOG2(x))) ? FAST_LOG2(x) + 1 : FAST_LOG2(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e9+1;

ll n, in, cnt[64], ans=0;

int main()
{
    //ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("A.txt", "r", stdin);
    #endif
    cin >> n;
    for(ll i=0; i<n; i++){
        cin >> in;
        for(ll j=0; in; j++){
            if(in&1LL) cnt[j]++;
            in >>= 1LL;
        }
    }
    for(ll i=0; i<=60; i++) ans = (ans + (n-cnt[i]) * cnt[i] % mod * ((1LL<<i) % mod) % mod ) % mod;
    cout << ans << endl;
}


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

namespace ABC098
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b,c;
            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            c = a + b;
            if (c< a - b) c = a-b;
            if (c < a*b) c = a *b;
            Console.WriteLine(c);
            Console.ReadKey();
        }
        
                
    }
}


Measured memory_bytes: 11092
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>


using namespace std;

int main(){
  int k,s;
  cin>>k>>s;
  int sum=0;
  for(int i=0;i<=k;i++){
    int x=i;
    for(int j=0;j<=k;j++){
      int y=j;
      int z=s-x-y;
      if(0<=z&&z<=k)sum++;
    }
  }
  cout<<sum<<endl;


  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a[5],i,c;
	for(i=0;i<5;i++){
		cin>>a[i];
		if(a[i]==0)
		c=i;
	}
	cout<<c+1;
	return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		if(A>=10) {
			System.out.println(-1);
			return;
		}
		if(B>=10) {
			System.out.println(-1);
			return;
		}
		System.out.println(A*B);
	}

}


Measured memory_bytes: 21844
import java.util.Scanner;
class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int tate = sc.nextInt();
		int yoko = sc.nextInt();
		int men;
		int syu;
		men = tate * yoko;
		syu = tate * 2 + yoko * 2;
		System.out.println(men+" "+syu);
		sc.close();
	}
}

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

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

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n; cin >> n;
  vector<lint> l(n); for(int i=0;i<n;i++) { cin >> l[i]; }

  lint ans=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(l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) { continue; }
        lint lmax = max(l[i],max(l[j],l[k])), sum = l[i]+l[j]+l[k];
        if(lmax < sum-lmax) { ans++; }
      }
    }
  }

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


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

using namespace std;
using namespace boost;

main() {
    int32_t n;
    cin >> n;
    unordered_map<int64_t, int32_t> a;
    vector<int64_t> s(n);
    for (auto i : irange(0, n)) {
        int64_t aa;
        cin >> aa;
        ++a[aa];
        s[i] = aa;
    }

    sort(s.begin(), s.end());

    int64_t ans = 0;
    for (int p = 30; p >= 1; --p) {
        auto m = (1L << p);
        for (auto aa : s) {
            if (aa > m / 2) break;

            if (aa * 2 == m) {
                int count = a[aa] / 2;
                ans += count;
                a[aa] -= 2 * count;
            } else {
                int count = min(a[aa], a[m - aa]);
                ans += count;
                a[aa] -= count;
                a[m - aa] -= count;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 30324
#include <bits/stdc++.h>
#define intt long long
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define in(n) scanf("%d",&a);
#define out(n) printf("%d\n",a);
#define SIZE 100001
#define INF INT_MAX
#define F first
#define S second

using namespace std;



int main()
{
    FAST_READ;
    int n;
    intt mx = -1 ,sum = 0;
    cin>>n;
    int a[n];
    for (int i = 0;i<n;i++) {
        cin>>a[i];
        sum += a[i];
    }
    cout<<sum - n<<endl;
    return 0;
}


Measured memory_bytes: 256
function main(_stdin) {
    const stdin = _stdin.split('\n');
    const [user, relation] = stdin.shift().split(' ');
    const relations = stdin.filter((e, i) => i < relation).map(e => e.split(' ').map(e => parseInt(e, 10)));
    const qblock = stdin.slice(relation);
    const qnum = parseInt(qblock.shift(), 10);
    const questions = qblock.filter((e, i) => i < qnum).map(e => e.split(' ').map(e => parseInt(e, 10)));

    const nodes = createNodes(relations);
    const color = [...new Array(parseInt(user, 10)).keys()].fill(null);

    assignColor(nodes, color);


    for(const q of questions){
        if(color[q[0]] && color[q[1]] && color[q[0]] === color[q[1]]) {
            console.log('yes');
        } else {
            console.log('no');
        }
    }
}

function createNodes(relations) {
    const nodes = [];
    for (let i = 0, l = relations.length; i < l; i++) {
        const [from, to] = relations[i];
        if (!nodes[from]) {
            nodes[from] = [from, 1, to];
        } else {
            nodes[from][1]++;
            nodes[from].push(to);
        }
        if (!nodes[to]) {
            nodes[to] = [to, 1, from];
        } else {
            nodes[to][1]++;
            nodes[to].push(from);
        }
    }
    return nodes;
}

function dfs(nodes, color, r, c) {
    const stack = [];
    stack.push(r);
    color[r] = c;

    while (stack.length !== 0) {
        const u = stack.pop();
        const children = nodes[u].slice(2);
        for (let i = 0, l = children.length; i < l; i++) {
            const v = children[i];
            if (color[v] === null) {
                color[v] = c;
                stack.push(v);
            }
        }
    }
}

function assignColor(nodes, color) {
    let id = 1;
    let max = color.length - 1;
    for (let i = 0; i < max; i++) {
        if (color[i] === null && nodes[i] !== undefined) {
            dfs(nodes, color, i, id++);
        }
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 89792
//-- In The Name of God --
#include<bits/stdc++.h>
using namespace std;


#define      mod     1e9+7
#define      pai     acos(-1)
#define      ff      first
#define      ss      second
#define      ll      long long
#define      pb      push_back
#define      mp      make_pair
#define      endl    "\n"
#define      fii     freopen("input.txt","r",stdin);
#define      foo     freopen("output.txt","w",stdout);
#define      fast    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const   ll   mx=1e5+100;

int main()
{
    fast;
    ll i,j,a,b,c,d,n,m,t;
    cin>>n>>m;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll cnt=0;
    ll prv=arr[0];
    for(i=1;i<n;i++)
    {
        if((prv+arr[i])>m)
        {
            ll tem=((prv+arr[i])-m);
            cnt+=tem;
            //cout<<tem<<"==="<<cnt<<"===";
            ll p=0;
            prv=max(arr[i]-tem,p);
            //cout<<prv<<endl;
        }
        else
        {
            prv=arr[i];
        }
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 4412
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for(int i = 0; i < N; ++i){
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    int min = 1e9;
    for(int i = 0; i + K <= N; ++i){
        int l = h[i+K-1] - h[i];
        if(l < min) min = l; 
    }
    cout << min;
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import os
from sys import stdin
import bisect

def solve(tc):
    x, n = map(int, stdin.readline().split())
    if n==0:
        print(x)
        return

    seq = list(map(int, stdin.readline().split()))
    cand = list()
    for i in range(102):
        if i not in seq:
            cand.append(i)

    k = bisect.bisect_left(cand, x)
    ans = cand[k]
    if x-cand[k-1]<=cand[k]-x:
        ans = cand[k-1]
    print(ans)


tcs = 1
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1

Measured memory_bytes: 62152
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 d: i32 = read();
    let mut n: i32 = read();

    if n == 100 {
        n += 1;
    }
    match d {
        0 => println!("{}", n),
        1 => println!("{}", n * 100),
        2 => println!("{}", n * 10000),
        _ => return
    }

}

Measured memory_bytes: 4352
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            # 答えは1つ出力すれば良いので =7 になれば終了
            print(f + "=7")
            exit()

    else:
        dfs(i + 1, f + "-" + s[i + 1], sum - int(s[i + 1]))
        dfs(i + 1, f + "+" + s[i + 1], sum + int(s[i + 1]))

s = list(str(input()))

dfs(0, s[0], int(s[0]))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <unordered_map>
#include <map>

using commands_t = std::unordered_map<char, std::map<size_t, bool>>;

int simulate(int N, int i, int j,
             std::string const& S, commands_t& td) {
  if (i < 0) return -1;
  if (i >= N) return N;

  auto const& cmds = td[S[i]];
  auto it = cmds.lower_bound(j);

  if (it == cmds.end()) return i;

  j = it->first;

  if (it->second)
    return simulate(N, i-1, j+1, S, td);
  else
    return simulate(N, i+1, j+1, S, td);
}

int main() {
  size_t N, Q;
  std::string S;

  std::cin >> N >> Q >> S;

  commands_t td;

  for (size_t i=0; i<Q; i++) {
    char t, d;
    std::cin >> t >> d;

    td[t].emplace(i, d=='L');
  }

  auto ans = N;

  {
    size_t first = 0;
    size_t last = N;

    for (auto len = last-first; len != 0; ) {
      auto half = len / 2;
      auto mid = first + half;
      if (simulate(N, mid, 0, S, td) < 0) {
        len -= half + 1;
        first = mid + 1;
      } else {
        len = half;
      }
    }

    ans -= first;
  }

  {
    size_t first = 0;
    size_t last = N;

    for (auto len = last-first; len != 0; ) {
      auto half = len / 2;
      auto mid = first + half;
      if (simulate(N, mid, 0, S, td) < static_cast<int>(N)) {
        len -= half + 1;
        first = mid + 1;
      } else {
        len = half;
      }
    }

    ans -= N-first;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 12932
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    ll h;
    cin >> h;
    ll ans = 0, pow2 = 1;
    while(h) {
        h /= 2;
        ans += pow2;
        pow2 *= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# %%time
import numpy as np
n, x = list(map(int, input().split()))
s = 0
a = [n-x, x]
s += n
# print(a,s)
while True:
#     if a[0] == a[1]:
#         s += a[0]
#         break
#     else:
    mi = np.min(a)
    ar = np.argmax(a)
    num = a[ar]//mi
    a[ar] -= mi * num
    s += 2 * mi * num
#     print(a, s)
    if np.min(a) == 0:
        s -= mi
        break
            
print(s)

Measured memory_bytes: 18748
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL n,l,id = -1;
LL a[200005];

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> l;
	for(LL i = 1;i <= n;i ++) cin >> a[i];
	for(LL i = 1;i < n;i ++) if(a[i] + a[i + 1] >= l) id = i;
	if(id == -1) cout << "Impossible" << endl;
	else{
		cout << "Possible" << endl;
		for(LL i = 1;i < id;i ++) cout << i << endl;
		for(LL i = n - 1;i > id;i --) cout << i << endl;
		cout << id << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll ab[25000][2500];
int main() {
	cin >> n >> m;
	if (n < m) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <tuple>
#include <utility>
#include <stdlib.h>
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb push_back
#define mp make_pair

int main() {
	LL x, a;
	cin >> x >> a;
	if (x < a) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

l = [0] * N
for i in range(N):
    l[i] = list(map(int, input().split()))

food = [0] * M
for i in l:
    for j in range(i[0]):
        food[i[j + 1] - 1] += 1

print(food.count(N))

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

/*
 AC x 10
 WA x 0
 TLE x 0
 RE x 0
 */

int N;
int C[10];

string verdict[10]={"AC","WA","TLE","RE"};
int main(){
    //cout<<"Hello\n";
    scanf("%d", &N);
    for(int i=0; i<N; i++){
        string a;
        cin>>a;
        for(int j=0; j<4; j++)
            if(a==verdict[j]) {
                C[j]++;
                break;
            }
    }
    for(int i=0; i<4; i++){
        cout<<verdict[i]<<" x "<<C[i]<<endl;
    }
    
    return 0;
}


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

using namespace std;

int main()
{
    int n,r;

    cin>>n;

    r = n%10;

    if(r==3)
    {
        cout<<"bon"<<endl;
    }
    else if(r==0 || r==1 || r==6 || r==8)
    {
        cout<<"pon"<<endl;
    }
    else
    {
        cout<<"hon"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main(void){
  int ret=0;
  int a,b;
  int cases = 0;

  while(cin >> a >> b){

    if((a|b) == 0) break;
    if(cases) cout << endl;
    ret = 0;
    for(int i=a;i<=b;i++){
      if((i%4 == 0 && i%100 != 0) || i%400 == 0){
        ret++;
        cout << i << endl;
      }
    }
    if(!ret) cout << "NA" << endl;
    cases++;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <time.h>
void SelectionSort(int *p,int n);
int main ()
{
    int number,*p,i;
    scanf("%d",&number);
    p = (int *)malloc(number*sizeof(int));
    for(i = 0; i < number ; i++)
    {
        scanf("%d",&p[i]);
    }
    SelectionSort(p,number);
    free(p);
    return 0;
}
void SelectionSort(int *p,int n)
{
    int i,j,k,count = 0,temp;
    for(i = 0;i < n - 1;i++)
    {
        k = i;
        for(j = i+1;j < n;j++)
        {
            if(p[j]<p[k])
                k = j;
        }
        if(k!=i)
        {
            count++;
            temp = p[k];
            p[k] = p[i];
            p[i] = temp;
        }
    }
    for(i = 0;i < n;i++)
    {
        if(i>0)printf(" ");
        printf("%d",p[i]);
    }
    printf("\n%d\n",count);
}



Measured memory_bytes: 2060
fun main(args: Array<String>) {
    var (A, B, C, D) = listOfLong()
    val E = lcm(C , D)
    fun f(x: Long): Long {
        val a = x / C
        val b = x / D
        val c = x / E
        return x - (a + b - c)
    }
    val ans = f(B) - f(A - 1)
    println("${ans}")
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { it.toLong() }
fun gcd(a: Long, b: Long): Long = if (a % b == 0L) b else gcd(b, a % b)
fun lcm(a: Long, b: Long): Long = a * b / gcd(a, b)


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

int main(){
  int N, K, x, d;
  cin >> N >> K;
  d = 0;
  for (int i=0; i<N; i++) {
    cin >> x;
    if (x < K-x) {
      d += 2*x;
    }
    else {
      d += 2*(K-x);
    }
  }
  cout << d << endl;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int ans = A;
  if (A == B)
    ans = C;
  if (A == C)
    ans = B;
  if (B == C)
    ans = A;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
int pa[111111],id[111111],cnt;
bool used[111111];
int n,m,x,y,z;
vector<pair<int,int> > g[1111111];
vector<int> gra[1111111];
void Init(int i)
{
	pa[i]=i;
	used[i]=0;
	id[i]=-1;	
}
int root(int x)
{
	if (pa[x]!=x) pa[x]=root(pa[x]);
	return pa[x];
}
void Union(int x,int y)
{
	int rx=root(x),ry=root(y);
	if (rx==ry) return;
	pa[rx]=ry;
}
queue<int> q;
int dist[1111111];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		g[z].push_back(make_pair(x,y)); 
	}
	cnt=n;
	for (int i=1;i<=1000000;i++)
	{
		for (int j=0;j<g[i].size();j++)
		{
			Init(g[i][j].first);
			Init(g[i][j].second);
		}
		for (int j=0;j<g[i].size();j++)
		{
			Union(g[i][j].first,g[i][j].second);
		}
		for (int j=0;j<g[i].size();j++)
		{
			x=g[i][j].first;y=g[i][j].second;
			if (!used[x])
			{
				int r=root(x);
				if (!~id[r]) id[r]=++cnt;
				used[x]=1;
				gra[x].push_back(id[r]);
				gra[id[r]].push_back(x); 
			}
			if (!used[y])
			{
				int r=root(y);
				if (!~id[r]) id[r]=++cnt;
				used[y]=1;
				gra[y].push_back(id[r]);
				gra[id[r]].push_back(y);  
			}
		}
	}
	memset(dist,-1,sizeof(dist));
	q.push(1);dist[1]=0;
	while(!q.empty())
	{
		x=q.front();q.pop();
		for (int i=0;i<gra[x].size();i++)
		{
			int to=gra[x][i];
			if (!~dist[to])
			{
				dist[to]=dist[x]+1;
				q.push(to); 
			}
		}
	}
	if (!~dist[n]) printf("-1\n");
	else printf("%d\n",dist[n]/2);
	return 0;
}

Measured memory_bytes: 73600
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;


const ll N = 1e9+7;
const ll M = 2*1e5+5;
ll dp[M], invdp[M], inv[M];


ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a/b;
        a -= t * b; swap(a,b);
        u -= t * v; swap(u,v);
    }
    u %= m;
    if(u < 0) u += m;
    return u;

}

void expo(){
    dp[0] = 1;
    invdp[0] = 1;
    inv[0] = 1;
    rep(i,M){
        dp[i+1] = dp[i] * (i + 1) % N;
        inv[i+1] = N - inv[N%(i+1)] * (N/(i+1)) % N;
        invdp[i+1] = modinv(dp[i+1], N);
    }
}


ll conv(ll x, ll y){
    ll ans;
    if(y > 0) ans = dp[x] * (invdp[y] * invdp[x-y] %N) % N;
    else ans = 1;
    // cout << dp[x] << " " << invdp[y] << " " << invdp[x-y] << " " << ans << endl;
    return ans;
}


void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

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

template<typename T>
void print(T &arr){
    ll sz = sizeof(arr)/sizeof(arr[0]);
    for(int i = 0;i < sz-1;i++){cout << arr[i] << ' ';}
    cout << arr[sz-1] << endl;
}


int main(){
    ll n,m; cin >> n >> m;
    map<ll,ll> e;
    ll temp = m;
    rep(i,sqrt(m)+1){
        if(i <= 1)continue;
        while(temp % i == 0){
            e[i]++;
            temp /= i;
        }
    }
    if(temp != 1)e[temp]++;
    // for(auto itr = e.begin(); itr != e.end();itr++){
    //     print((*itr).first, (*itr).second);
    // }

    expo();

    ll ans = 1;
    for(auto itr = e.begin(); itr != e.end();itr++){
        // print((*itr).first, (*itr).second);
        ans = (ans * conv((*itr).second+n-1,(*itr).second)) % MOD;
    }

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

Measured memory_bytes: 4992
#include<iostream>

using namespace std;

int main(){
    int n,time;
    cin >> n >> time;
    int *c = new int[n];
    int *t = new int[n];
    for(int i = 0; i < n; i++){
        cin >> c[i] >> t[i];
    }
    
    int cost = 1001;
    for(int i = 0; i < n; i++){
        if(t[i] <= time){
            if(cost > c[i]){
                cost = c[i];
            }
        }
    }
    if(cost == 1001){
        cout << "TLE" << endl;
    }else{
        cout << cost << endl;
    }


    delete[] c;
    delete[] t;
    return 0;
}

Measured memory_bytes: 3608
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());

		int a[] = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		Arrays.sort(a);

		int max = a[n - 1], m = max / 2, mSmall = 0;

		for (int i = 0; i < n; i++) {
			if (a[i] < m) {
				mSmall = a[i];
			} else if (a[i] == m) {
				System.out.println(max + " " + m);
				break;
			} else if (max - a[i] > mSmall) {
				System.out.println(max + " " + a[i]);
				break;
			} else {
				System.out.println(max + " " + mSmall);
				break;
			}
		}

	}

}

Measured memory_bytes: 50260
#include <bits/stdc++.h>
#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 srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


int main() {
    int m,k;
    cin >> m >> k;

    if(k==0){
        rep(i,pow(2,m)){
            cout << i << ' ';
        }
        drep(i,pow(2,m)){
            cout << i << ' ';
        }
        return 0;
    }


    int ans = 0;

    rep(i,pow(2,m)){
        if(i!=k){
            ans = ans ^ i;
        }
    }

    if(ans != k){
        cout << "-1" << endl;
        return 0;
    }

    cout << k << ' ';
    rep(i,pow(2,m)){
        if(i!=k){
            cout << i << ' ';
        }
    }
    cout << k << ' ';
    drep(i,pow(2,m)){
        if(i!=k){
            cout << i << ' ';
        }
    }

    return 0;
}
 
 


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m;
struct node{int l,r;
}a[300010];
bool cmp(node x,node y){return x.r-x.l<y.r-y.l;}

int tree[100010];
void add(int id,int x){for(;id<=m;id+=id&-id) tree[id]+=x;}
int query(int id){int re=0;for(;id;id-=id&-id) re+=tree[id];return re;}
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++) scanf("%d%d",&a[i].l,&a[i].r);
    sort(a+1,a+n+1,cmp);
    for (int i=1,j=0;i<=m;i++)
    {
        int cnt=0;
        for (int t=i;t<=m;t+=i) cnt+=query(t);
        printf("%d\n",cnt+n-j);
        while (j<n&&a[j+1].r-a[j+1].l<=i)
        {
            add(a[j+1].l,1);
            add(a[j+1].r+1,-1);
            j++;
        }
    }
}


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

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ld long double
#define pb push_back
#define fe first
#define se second
#define nl "\n"
#define pp pair < ll , ll > 
#define sz(x) (ll)x.size()
#define st(x) sort(x.begin(),x.end())
#define rst(x) sort(x.rbegin(), x.rend())
#define all(x) x.begin(),x.end()
long double pi = 3.14159265358979323;
 
const double EPS = 1e-12;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
 
ll dp[N][2]; 
//0 for black
//1 for white

bool vis[N];
vector < ll > v[N];
ll add(ll x ,ll y)
{
    return ((x % mod) + (y % mod)) % mod;
}
ll mul(ll x , ll y)
{
    return ((x % mod)*(y % mod))%mod;
}
void dfs(ll s){
    vis[s] = 1;
    if(s != 1 && v[s].size() == 1){
        dp[s][0] = 1;
        dp[s][1] = 1;
        return;
    }   
    //dp[s][0] = dp[s][1] = 1;
    ll ans0 = 1 , ans1 = 1;
    for(auto it : v[s]){
        if(!vis[it]){
            dfs(it);
            ans0 = mul(ans0 , dp[it][1]);
            ans1 = mul(ans1 , add(dp[it][0] , dp[it][1]));
          
        }
    }
            dp[s][0] = add(dp[s][0] , ans0);
            dp[s][1] = add(dp[s][1] , ans1);
}
 
int main()
{
    fast;
    ll n;
    cin >> n ;
    for(int i = 1 ; i < n ;i++ ){
            ll a , b;
            cin >> a >> b ;
            v[a].pb(b);
            v[b].pb(a);
    }
    if(n == 1){
        cout << 2 << "\n";
        return 0 ;
    }
    //fill(dp , dp + n ,1);
    // memset(dp , 1 , sizeof(dp));
    dfs(1);

    cout << add(dp[1][0] , dp[1][1]);





















    
    return 0;
    
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define N 200000

using namespace std;

int x;
int prime[N], tot;
bool vis[N];

inline void sieve() {
	for(int i = 2; true; ++i) {
		if(!vis[i]) {
			prime[++tot] = i;
			if(i >= x) {
				cout << i << endl;
				exit(0);
			}
		}
		for(int j = 1; j <= tot && i * prime[j] < N; ++j) {
			vis[i * prime[j]] = true;
			if(i % prime[j] == 0) break;
		}
	}
}

int main() {
	cin >> x;
	sieve();
	return 0;
}

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

int ans = 0x3f3f3f3f;

signed main () {

    int n;
    scanf("%d", &n);
    for ( int i = 1; i < n; i++ ) {
        int tmp = 0;
        int I = i;
        while ( I ) {
            tmp += I%10;
            I /= 10;
        }
        I = n-i;
        while ( I ) {
            tmp += I%10;
            I /= 10;
        }
        ans = min ( ans, tmp );
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 256