akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var N = cin.nextInt();
            var T = cin.nextInt();

            var list = new List<Tuple<int,int>>();
            for (int i = 0; i < N; i++)
            {
                var c = cin.nextInt();
                var t = cin.nextInt();
                list.Add(Tuple.Create(c,t));
            }

            var sq = list.Where(i => i.Item2 <= T);
            Console.WriteLine(sq.Count()==0?"TLE":sq.Min(i=>i.Item1).ToString());

        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13524
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define forn(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define ford(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define int long long
#define ii pair<int,int>
#define ar array
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define sz(x) ((int)(x).size())
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
//const int N = 3e5+7 ;
vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
//const int MOD = 998244353; check mod always 
// for c and d i was using this mod 
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
void radd(int &a, int b)
{
	a=add(a,b); 
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
void rmult(int &a, int b)
{
	a=mult(a,b);
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<0||b<0) return 0;
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}


void solve(){
    int s ;
    cin >>s ;
    init(1e5) ;
	int ans = 0 ;    
	int mxK = s/3 ;
	for(int i = 1 ; i <= mxK ; i++){
		int n = s-3*i ;
		radd(ans,choose(n+i-1,i-1)) ;
	}
	cout << ans << endl ;
}


int32_t main(){
    FAST_IO ;
    int t = 1 ;
//    cin >> t ;
    while(t--){
        solve() ;
    }
}


Measured memory_bytes: 6332
#include<bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define fr first
#define sc second
#define ll long long int
#define bit(idx) idx&(-idx)
#define bin(x, a) bitset<a>(x)
#define all(A) A.begin(), A.end()
#define debug(x) cout << #x << " = " << x << endl;
using namespace std;

const int MAXN = 2e5 + 5;

ll mask, BIT[MAXN], ans[MAXN];
vector<ll> G[MAXN], A;
unordered_map<ll, ll> um;
stack<vector<pair<ll, ll>>> changes;

void upd(ll idx, ll val){
	vector<pair<ll, ll>> curr_changes;
	for(ll _idx = idx + 1; _idx < MAXN; _idx += bit(_idx)){
		if(val > BIT[_idx]){
			curr_changes.pb({_idx, BIT[_idx]});
		}
		BIT[_idx] = max(BIT[_idx], val);
	}
	changes.push(curr_changes);
}

ll qry(ll idx){
	ll ret = 0;
	for(int _idx = idx + 1; _idx > 0; _idx -= bit(_idx)){
		ret = max(ret, BIT[_idx]);
	}
	return ret;
}

void roll(){
	vector<pair<ll, ll>> curr = changes.top();
	changes.pop();
	for(auto [_, __] : curr){
		BIT[_] = __;
	}
}

void dfs(int u, int p){
	int curr_ans = qry(A[u] - 1) + 1;
	upd(A[u], curr_ans);
	ans[u] = qry(MAXN);
	for(auto v : G[u]){
		if(v != p){
			dfs(v, u);
		}
	}
	roll();
}

int main(){
	ios_base::sync_with_stdio(NULL); cin.tie(); cout.tie();
	int n; cin >> n;
	A.pb(-1);
	int tmp[MAXN] = {0}, sz = 0;
	for(int i = 1; i <= n; i ++){
		int x; cin >> x;
		A.pb(x);
		tmp[sz ++] = x;
	}
	sort(tmp, tmp + sz);
	sz = unique(tmp, tmp + sz) - tmp;
	for(int i = 1; i <= n; i ++)
		A[i] = lower_bound(tmp, tmp + sz, A[i]) - tmp;
	for(int i = 0; i < n - 1; i ++){
		int u, v; cin >> u >> v;
		G[u].pb(v);
		G[v].pb(u);
	}
	dfs(1, 1);
	for(int i = 1; i <= n; i ++){
		cout << ans[i] << endl;
	}
}
/**
10
1 2 5 3 4 6 7 3 2 4
1 2
2 3
3 4
4 5
3 6
6 7
1 8
8 9
9 10

1
2
3
3
4
4
5
2
2
3

*/

Measured memory_bytes: 44072
#[allow(non_snake_case)]

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let W = iter.next().unwrap().parse::<isize>().unwrap();
    let H = iter.next().unwrap().parse::<isize>().unwrap();
    let X = iter.next().unwrap().parse::<isize>().unwrap();
    let Y = iter.next().unwrap().parse::<isize>().unwrap();
    let R = iter.next().unwrap().parse::<isize>().unwrap();

    println!("{}", if R <= X && R <= Y && X <= W - R && Y <= H - R {"Yes"} else {"No"});
}



Measured memory_bytes: 5032
class UnionFind():

    def __init__(self, n):
        self.parent = [i for i in range(0, n)]
        self.rank= [0] * n

    def root(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.root(self.parent[x])
        return self.parent[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def rootRank(self, x):
        return self.rank[self.root(x)]

N,M=map(int,input().split())

uf = UnionFind(N)

for i in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    uf.union(a,b)

z=0
c=[0]*N
for i in range(N):
    p=uf.root(i)
    c[p]+=1
    if z<c[p]:
        z=c[p]

print(z)


Measured memory_bytes: 83332
import collections

n = int(input())
a = list(map(int, input().split()))

c = collections.Counter(a)

ans = 0

for x in c.values():
    ans += x * (x-1) // 2

for x in a:
    if c[x] == 1:
        print(ans)
    else:
        z = c[x]
        print(ans - z*(z-1)//2 + (z-1)*(z-2)//2)

Measured memory_bytes: 27036
import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
count=0
for i in range(n-2):
  for j in range(i+1,n-1):
    index=bisect.bisect_left(l,l[i]+l[j])
    count+=index-j-1
print(count)

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  string S;
  cin >> S;

  vector<int> cumb(2*N+1, 0), cumc(2*N+1, 0), cumbb(2*N+1, 0);
  for ( int i = 0; i < 2*N+1; i++ ) {
    if ( i ) {
      cumb[i] = cumb[i-1];
      cumc[i] = cumc[i-1];
      cumbb[i] = cumbb[i-1];
    }
    if ( i >= N ) continue;    
    if ( S[i] == 'M' ) {
      cumb[i]++;      
    }
    if ( S[i] == 'C' ) {
      cumc[i]++;
      cumbb[i] += cumb[i];      
    }
  }

  int Q;
  cin >> Q;
  for ( int i = 0; i < Q; i++ ) {
    int k;
    cin >> k;
    int ans = 0;
    for ( int j = 0; j < N; j++ ) {
      if ( S[j] == 'D' ) {
	ans += cumbb[j+k-1] - (cumc[j+k-1]-cumc[j])*cumb[j] - cumbb[j];
	// cout << cumbb[j+k] << endl;
      }
    }

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


Measured memory_bytes: 48284
#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;
#define mp make_pair
#define pb(x) push_back(x)
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1e18
 

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll n;
    cin>>n;
    ll a[n][2];
    ll i,j;
    for(i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1];
    }
    ll aa[n];
    clr(aa);
    for(i=0;i<n;i++)
    {
        if(a[i][0]==a[i][1])
        {
            aa[i]=1;
        }
        else{
            aa[i]=0;
        }
    }
    for(i=0;i<n-2;i++)
    {
        ll f=0;
        for(j=0;j<3;j++)
        {
            if(aa[i+j]!=1)
            {
                f=1;
                break;
            }
        }
        if(!f)
        {
            cout<<"Yes\n";
            return;
        }
    }
    cout<<"No\n";
}


int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());

        int diff = A - B;
        int result = Math.max(C - diff, 0);
        System.out.println(result);
    }
}

Measured memory_bytes: 23764
import math
from collections import Counter
MOD = 10 ** 9 + 7

# 雑な方法
primes = []
for i in range(2, 1001):
    for j in range(2, math.floor(math.sqrt(i))+1):
        if i % j == 0:
            break
    else:
        primes.append(i)

N = int(input())
As = list(map(int, input().split()))

cts = Counter()
for a in As:
    x = a
    ct = Counter()
    for p in primes:
        if p > x:
            break
        while x % p == 0:
            x //= p
            ct[p] += 1
    if x > 1:
        ct[x] += 1
    for k, v in ct.items():
        ctsk = cts[k]
        cts[k] = ctsk if ctsk >= v else v

ans = 1
for k, v in cts.items():
    ans *= pow(k, v, MOD)
    ans %= MOD

total = 0
for a in As:
    total += ans * pow(a, MOD-2, MOD)
    total %= MOD
print(total)

Measured memory_bytes: 48348
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int lli;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++) cin >> a[i];
	
	vector<int> dp(n, 0);
	map<int, int> nums;
	int lis = 0;
	for(int i=0; i<n; i++){
		if(nums.count(a[i]-1) != 0){
			dp[i] = dp[nums[a[i]-1]] + 1;
		}else{
			dp[i] = 1;
		}
		lis = max(lis, dp[i]);
		nums[a[i]] = i;
	}
	cout << n -lis << endl;
	return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
using namespace std;

typedef vector <int> VI;
typedef vector <VI> VVI;

VVI E;

int n, m;
VI D;

int cnt;
VI F;
int answer;

const int inf = 1<<24;

bool check() {
    for ( int i = 0; i < n; i++ ) {
        if ( !F[i] ) {
            bool flag = true;
            for ( int j = 0; j < (int)E[i].size() && flag; j++ ) {
                if ( F[E[i][j]] ) flag = false;
            }
            if ( flag ) return false;
        }
    }
    return true;
}

void solve( int s ) {
    if ( s == n ) {
        if ( cnt < answer && check() ) answer = cnt;
        return;
    }

    F[s] = 1;
    cnt++;
    solve(s+1);
    F[s] = 0;
    cnt--;
    solve(s+1);
}

int main() {
    while ( cin >> n >> m ) {
        if ( n == 0 && m == 0 ) break;

        F = VI(n,0);
        E = VVI(n);

        for ( int i = 0; i < m; i++ ) {
            int a, b;
            cin >> a >> b;
            E[a].push_back(b);
            E[b].push_back(a);
        }

        answer = n;
        cnt = 0;
        solve(0);
        cout << answer << endl;
    }
    return 0;
}

Measured memory_bytes: 912
#include<iostream>
#include<stdio.h>
#include<string>
#include<sstream>

using namespace std;

const int M = 1046527;

string s[M];

int change(char c)
{
	if (c == 'A')return 1;
	else if (c == 'C')return 2;
	else if (c == 'G')return 3;
	else if (c == 'T')return 4;
	else return 0;
}

long long getkey(string str)
{
	long long sum = 0, p = 1;
	int i;
	for (i = 0; i < (int)str.length(); i++)
	{
		sum += p*change(str[i]);
		p *= 5;
	}
	return sum;
}

int h1(long long key) { return key % M; }
int h2(long long key) { return 1 + key % (M - 1); }

int find(string str)
{
	long long key, i = 0;
	int h;
	key = getkey(str);
	for (i = 0; i < M; i++)
	{
		h = (h1(key) + i * h2(key)) % M;
		if (s[h] == str)return 1;
		else if (s[h] == "N")return 0;
	}
	return 0;
}

void insert(string str)
{
	long long key, i;
	int h;
	key = getkey(str);
	for (i = 0; i < M; i++)
	{
		h = (h1(key) + i * h2(key)) % M;
		if (s[h] == str)return;
		else if (s[h] == "N")
		{
			s[h] = str;
			return;
		}
	}
}

int main()
{
	int n, i;
	char str[12], com[6];
	stringstream ans;
	for (i = 0; i < M; i++)s[i] = "N";
	cin >> n;
	for (i = 0; i < n; i++)
	{
		scanf("%s %s",com,str);
		if (com[0] == 'i')insert(str);
		else
		{
			if (find(str))ans << "yes" << endl;
			else ans << "no" << endl;
		}
	}
	cout << ans.str();
    return 0;
}

Measured memory_bytes: 61464
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> P;
long long const mod = 998244353;

struct BIT{
    int size;
    vector<int> bit;
    void init(int n){
        size = n;
        bit.assign(size+1, 0);
    }

    int sum(int x){
        int res = 0;
        while(x > 0){
            res = max(res, bit[x]);
            x -= (x & -x);
        }
        return res;
    }

    void add(int x, int y){
        while(x <= size){
            bit[x] = max(bit[x], y);
            x += (x & -x);
        }
    }
};

int n;
vector<P> rob;
int main(void){
    cin >> n;
    for(int i=0;i<n;i++){
        int x, d;
        cin >> x >> d;
        rob.push_back(P(x, x+d));
    }
    sort(rob.begin(), rob.end());
    BIT bit;
    bit.init(n);
    bit.add(n, n-1);

    vector<long long> a(n, 1), b(n, 1);
    //long long ans = 2;
    for(int i=n-2;i>=0;i--){
        int ok = i, ng = n;
        int e = rob[i].second;
        while(ok+1<ng){
            int mid=(ok+ng)/2;
            if(rob[mid].first < e)ok = mid;
            else ng = mid;
        }
        if(ok == i){
            a[i] = a[i+1] + b[i+1];
        }else{
            int j = max(ok, bit.sum(ok+1));
            //cout << j << endl;
            a[i] = a[j];
            bit.add(i+1, j);
        }
        b[i] = a[i+1] + b[i+1];
        a[i]%=mod;
        b[i]%=mod;

    }
    cout << (a[0]+b[0])%mod << endl;
}


Measured memory_bytes: 5744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

vvll g;
ll dp[110000];
bool check[110000];

void dfs(ll x) {
    if(check[x]) return;

    ll tmp = 0;
    for(auto nx : g[x]) {
        dfs(nx);
        chmax(tmp, dp[nx]+1);
    }
    check[x] = true;
    dp[x] = tmp;
}

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

    ll N, M;
    cin >> N >> M;
    g.resize(N);
    rep(_,M) {
        ll x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
    }

    rep(i,N) dfs(i);
    ll ans = 0;
    rep(i,N) chmax(ans, dp[i]);
    cout << ans << endl;
}


Measured memory_bytes: 12344
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 3000005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 

ll k;
string s;

ll power(ll x, ll y, ll p) { 
    ll res = 1;
    x = x % p;
    while (y > 0) { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll fac[M], invfac[M];

void pre() {
    fac[0] = 1;
    for(ll i=1;i<M;i++) fac[i] = (fac[i-1] * i) % MOD;
    invfac[M-1] = power(fac[M-1], MOD-2, MOD);
    for(ll i=M-2;i>=0;i--) {
        invfac[i] = (invfac[i+1] * (i+1)) % MOD;
    }
}

ll ncr(ll n, ll r, ll p) {
    if(r<0 or r>n) return 0;
    return ((( (fac[n] * invfac[r]) % p) * invfac[n-r]) % p);
}

 
int32_t main() {
    fastio;
    cin>>k;
    cin>>s;
    ll n = s.size();
    pre();
    ll ans = 0;
    for(ll i=0;i<=k;i++) {
        ans += ((((ncr(n+k-i-1, n-1, MOD) * power(25, k-i, MOD)) % MOD )* power(26, i, MOD) % MOD ) % MOD);
        ans %= MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 51264
import heapq
N = int(input())
V = list(map(int, input().split()))
heapq.heapify(V)


while len(V) > 1:
    x, y = heapq.heappop(V), heapq.heappop(V)
    heapq.heappush(V, (x + y) / 2)

print(V[0])


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

int main() {
    int h, m, s, a, b, c;
    while(cin >> h){
        cin >> m >> s;
        a = h*60*60 + m*60 + s;
        cin >> h >> m >> s;
        b = h*60*60 + m*60 + s;
        c = b - a;
        cout << c/3600 << " " << c%3600/60 << " " << c%60 << endl;
    }
    return 0;
}



Measured memory_bytes: 3116
// https://atcoder.jp/contests/dp/tasks/dp_c
#include <bits/stdc++.h>

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

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

int main(int argc, char** argv) {
    int n;
    cin >> n;
    vector<vector<int>> dp(n, vector<int>(3));

    int a, b, c;
    cin >> a >> b >> c;
    dp[0] = {a, b, c};

    for (int i = 1; i < n; i++) {

        cin >> a >> b >> c;
        dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a);
        dp[i][1] = max(dp[i - 1][0] + b, dp[i - 1][2] + b);
        dp[i][2] = max(dp[i - 1][0] + c, dp[i - 1][1] + c);
    }
    vector<int>::iterator it = max_element(dp[n - 1].begin(), dp[n - 1].end());
    cout << *it << endl;

    return 0;
};


Measured memory_bytes: 5760
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a_prev = N+1

ans = 0
for a in A:
    ans += B[a - 1]
    if (a - a_prev) == 1:
        ans += C[a_prev - 1]
    a_prev = a

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   /// https://ideone.com/Fd5s8n
  string a,b;
  cin>>a>>b;
  int f=0;
  if(a.length()+1== b.length()){
    for(int i=0;i<a.length();i++){
        if(a[i]!=b[i])
            f=1;
    }
    if(f)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
  }

  else {
    cout << "No" << endl;
  }

    return 0;

}


Measured memory_bytes: 3660
function Main(input) {

  let arr = input.split(" ").map(Number);
  let sum = 0
  for (let i = 0; i < arr.length; i++) {
    sum += arr[i];
  };
  let msg
  if (sum < 22) {
    msg = 'win';
  } else {
    msg = 'bust';
  }
  console.log(msg);
}

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


Measured memory_bytes: 9420
package main

import "fmt"

func main() {
  var n int
  var count int = 0
  fmt.Scan(&n)

  for i:=1; i<=n; i++ {
    for j:=1; j<=n; j++ {
      for k:=1; k<=n; k++ {
        count++
      }
    }
  }

  fmt.Println(count)

}


Measured memory_bytes: 512
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''


def main():
    n, m = list(map(int, input().split()))
    A = list(map(int, input().split()))
    A = set(A)
    B = list(map(int, input().split()))
    B = set(B)

    intersection = A & B
    union = A | B

    print(len(intersection), len(union))
    for i in sorted(list(intersection)):
        print(i)
    for u in sorted(list(union)):
        print(u)


if __name__ == '__main__':
    main()


Measured memory_bytes: 37864
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right
# import numpy as np

def s_inpl(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))

N = int(input())
s = input()

r_count = s.count("R")
b_count = s.count("B")

if r_count > b_count:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3700
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int N;
int A[101010];

int main()
{
	cin >> N;
	rep(i,0,N) cin >> A[i];
	sort(A, A+N);

	int w = N-1;
	int h = 1;
	while (w-1 >= 0 && A[w-1] >= h+1) {
		w--;
		h++;
	}
	int top = A[w] - h;
	int k = w;
	while (A[k-1] >= h) k--;
	int left = w - k;
	// printf("w=%d h=%d | top=%d left=%d\n",w,h,top,left);
	if (top%2 == 0 && left%2 == 0) cout << "Second" << endl;
	else cout << "First" << endl;

	return 0;
}

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

using namespace std;

int main(){
	int a,b; cin >> a >> b;

	a = (a+11)%13;
	b = (b+11)%13;
	if(a > b) cout << "Alice" << endl;
	else if(a < b) cout << "Bob" << endl;
	else cout << "Draw" << endl;

	return 0;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vf80 xs(n), ys(n);
  rep(i, n) cin >> xs[i] >> ys[i];
  auto rad = [&](f80 x, f80 y) {
    f80 ret = 0;
    rep(i, n) {
      amax(ret, sqrt(pow(x - xs[i], 2) + pow(y - ys[i], 2)));
    }
    return ret;
  };
  auto ysearch = [&](f80 x) {
    f80 yl = -10000, yr = 10000;
    while (abs(yl - yr) >= 0.00000001) {
      auto yl_ = yl + (yr - yl) / 3;
      auto yr_ = yr - (yr - yl) / 3;
      if (rad(x, yl_) <= rad(x, yr_)) {
        yr = yr_;
      } else {
        yl = yl_;
      }
    }
    return yl;
  };
  f80 xl = -10000, xr = 10000;
  while (abs(xl - xr) >= 0.00000001) {
    auto xl_ = xl + (xr - xl) / 3;
    auto xr_ = xr - (xr - xl) / 3;
    if (rad(xl_, ysearch(xl_)) <= rad(xr_, ysearch(xr_))) {
      xr = xr_;
    } else {
      xl = xl_;
    }
  }
  cout << rad(xl, ysearch(xl)) << endl;
}


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

int a[] = {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 main() {
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a;
	vector<int> b;
	for (int i=0; i < n; ++i) {
		int c;
		cin >> c;
		a.push_back(c);
		b.push_back(c);
	}
	sort(b.begin(), b.end(),greater<int>());
	int f = b[0], s = b[1];
	for (int i=0; i < n; ++i) {
		if (a[i] == f) cout << s << endl;
		else cout << f << endl;
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int a,b,c; cin >> a >> b >> c;
	if (a%3 == 0){
		cout << "Possible" << endl;
	}else if (b%3 == 0){
		cout << "Possible" << endl;
	}else if ((a+b)%3 == 0){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int sum=0;
        int[] arr=new int[m];
        for (int i = 0; i <arr.length ; i++) {
            arr[i]=sc.nextInt();
            sum=sum+arr[i];
        }
        if(sum<=n) {
            System.out.println(n - sum);
        }else {
            System.out.println(-1);
        }








    }
}





Measured memory_bytes: 46712
x = long(raw_input())
if x % 11 == 0:
    print long(x / 11 * 2)
elif 0 < x % 11 <= 6:
    print long(x / 11 * 2 + 1)
elif x % 11 >= 7:
    print long(x / 11 * 2 + 2)


Measured memory_bytes: 2568
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")

#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 int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define PI acos(-1)
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

int fact[N], invfact[N];
 
void pre() {
	fact[0] = 1;
	for(int i = 1; i < N; i++) {
		fact[i] = fact[i - 1] * i % mod;
	}
	invfact[N - 1] = modpow(fact[N - 1], mod - 2, mod);
	for(int i = N - 2; i >= 0; i--) {
		invfact[i] = invfact[i + 1] * (i + 1) % mod;
	}
}
 
int ncr(int x, int y) {
	if(y > x)
		return 0;
	int res = fact[x] * invfact[y] % mod * invfact[x - y] % mod;
	return res;
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	#ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	#endif

	pre();
	int n, k;
	cin >> n >> k;
	int a[n + 1], sum[n + 1] = {0};
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	if(k == 1) {
		cout << 0;
		return 0;
	}
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++) {
		a[i] = (a[i] + mod) % mod;
		sum[i] = (sum[i - 1] + a[i]) % mod;
	}
	int ans = 0;
	for(int i = k - 2; i <= n - 2; i++) {
		int t1 = (sum[n] - sum[i + 1] + mod) % mod;
		int t2 = sum[n - (i + 1)];
		int tmp = (t1 - t2 + mod) % mod;
		ans = (ans + ncr(i, k - 2) * tmp % mod) % mod;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

template <class S>
void print(vector<vector<S>> &v) {
  for (ll i = 0; i < (ll)v.size(); i++) {
    for (ll j = 0; j < (ll)v[i].size(); j++) {
      cout << v[i][j] << ' ';
    }
    cout << endl;
  }
}

int main(void) {
  int h,w;
  cin >> h >> w;
  vector<vector<bool>> s(h,vector<bool>(w,false));
  rep(i,h){
      string tmp;
      cin >> tmp;
      rep(j,w){
          s[i][j] = (tmp[j] == '#');
      }
    }
    vector<vector<int>> dp(h,vector<int>(w,0));
    dp[0][0]=s[0][0];
    for(int i=0; i< h; i++){
        for(int j=0; j< w; j++){
            if(i && j){
              dp[i][j] =
                  min(dp[i - 1][j] + (!s[i - 1][j] && s[i][j]),
                      dp[i][j - 1] + (!s[i][j - 1] && s[i][j]));
            }else if (i){
              dp[i][j] = dp[i - 1][j] + (!s[i - 1][j] && s[i][j]);
            }else if(j){
              dp[i][j] = dp[i][j-1] + (!s[i][j-1] && s[i][j]);
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
}


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

int main(){
	int x,y;
	while(1){
	    cin >> x >> y;
	    if ( x == 0 && y == 0 ) break;
	    if ( x < y ){
	    	cout << x << " " << y << endl;
	    }else {
	    	cout << y << " " << x << endl;
	    }
	}
	return 0;
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	
	ll ans = -1;
	rep(i, n){
		ll sm =0;
		rep(j,i+1) sm +=a[j];
		rep2(j,i,n) sm +=b[j];
		ans = max(ans, sm);
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin
# -*- coding="utf-8" -*-
 
n = int(input())
if n >= 64:
  a = 64
elif n >= 32:
  a = 32
elif n >= 16:
  a = 16
elif n >= 8:
  a= 8
elif n >= 4:
  a = 4
elif n >= 2:
  a = 2
else:
  a = 1
print(a)

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

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;

int main() {
  // Happy hacking!
  ll a, b, c;
  cin >> a >> b >> c;
  ll temp = b / a;

  cout << min(temp, c) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;


int main(){
    ll n;
    ll a[101];
    ll sum=0;
    cin>>n;
    REP(i, 0, n){
        cin>>a[i];
        sum+=a[i];
    }

    sort(a, a+n);

    if(sum%2!=0){
        REP(i, 0, n){
            if(a[i]%2!=0){
                sum-=a[i];
                break;
            }
        }
    }
    cout<<sum/2<<endl;
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

signed main() {
    int A,B,C,D,P;
    cin>>A>>B>>C>>D>>P;
    if(C>=P) cout<<min(A*P,B)<<endl;
    else cout<<min(A*P,B+(P-C)*D)<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007


int res = 1000000;

void dfs(int amount,int count){

    if(amount == 0){
        chmin(res,count);
        return;
    }else{
        
        int money = 1;
        int tmp = amount;
        while(tmp >= 6){
            tmp /= 6;
            money*=6;
        }
        if(money> 1){
            dfs(amount-money,count+1);
        }

        money = 1;
        tmp = amount;
        while(tmp >= 9){
            tmp /= 9;
            money *=9;
        }
        if(money > 1){
            dfs(amount - money,count+1);
        }

        dfs(0,count+amount);
    }

}

int main(){

    int n;
    cin >> n;

    dfs(n,0);

    cout << res << endl;

    return 0;
}


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

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

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

  int a, b, c;
  cin >> a >> b >> c;

  if (a <= c && c <= b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

long long Get(long long N,long long d,long long x){
	if(x==0){
		if((N>>d)&1)return (1LL<<60)-1LL;
		return N;
	}
	else{
		if((N>>d)&1)return N;
		return -1;
	}
}

int get(long long Nu,long long Nv,long long d,int f){
	if(d<0){
		if(f==0)return 1;
		else return 0;
	}
	static map<vector<long long>,int> mp;
	vector<long long> args = {Nu,Nv,d,f};
	if(mp.count(args))return mp[args];
	int ret = 0;
	for(int u=0;u<2;u++){
		for(int v=0;v<2;v++){
			long long nu,nv;
			nu = Get(Nu,d,u);
			nv = Get(Nv,d,v);
			if(nu<0||nv<0)continue;
			if(f==0&&u==1&&v==0)continue;
			if(f==1&&u==1&&v==1)continue;
			ret = mod(ret + get(nu,nv,d-1,u^v));
		}
	}
	mp[args] = ret;
	return ret;
}

int main(){
	
	long long N;
	cin>>N;
	
	cout<<get(N,N,60,0)<<endl;
	
	return 0;
}


Measured memory_bytes: 3640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int X, A;
	cin >> X >> A;

	cout << ((X < A) ? 0 : 10) << "\n";

	return 0;
}

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

#define rep(i,n) for((i)=0;(i)<(int)n;(i)++)
#define foreach(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)

int n, x[30], y[30], r[30], c[30], res;
int memo[30];

bool isOverlap(int a, int b) {
  double sub_x = (double)(abs(x[a]-x[b]));
  double sub_y = (double)(abs(y[a]-y[b]));
  double dist = sqrt(sub_x*sub_x + sub_y*sub_y);
  return (dist < r[a] + r[b]) ? 1 : 0 ;
}

void dfs(int S, int sum) {
  //printf("%d %d\n", S, sum);
  res = max(res, sum);
  int i, j;
  rep(i,n) if (!((1<<i)&S) && (S & memo[i]) == memo[i]) {
    rep(j,n) if (!((1<<j)&S) && (S & memo[j]) == memo[j]) {
      if (i == j || c[i] != c[j]) continue;
      dfs(S|(1<<i)|(1<<j), sum + 2);
    }
  }
}

char dp[1<<24+1];

int main() {
  int i, j;
  while (cin>>n, n) {
    res = 0;
    memset(dp, -1, sizeof dp);
    rep(i,n) cin>>x[i]>>y[i]>>r[i]>>c[i];
    rep(i,n) {
      memo[i] = 0;
      rep(j,i) if (isOverlap(i,j)) memo[i] |= (1<<j);
    }
    //dfs(0, 0);
    dp[0] = 0;
    for(int S=0;S<(1<<n);S++) {
      if(dp[S] == -1) continue;
      res = max(res, (int)dp[S]);
      rep(i,n) if (!((1<<i)&S) && (S & memo[i]) == memo[i]) {
        rep(j,n) if (!((1<<j)&S) && (S & memo[j]) == memo[j]) {
          if (i == j || c[i] != c[j]) continue;
          int nS = S|(1<<i)|(1<<j);
          dp[nS] = max((int)dp[nS], dp[S]+2);
        }
      }
    }
    cout<<res<<endl;
  }
  return 0;
}

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

int main(){
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a);
  vector<int> q(b);
  vector<int> r(c);
  rep(i,a){
    int a_y;
    cin >> a_y;
    p[i] = a_y;
  }
  rep(i,b){
    int b_y;
    cin >> b_y;
    q[i] = b_y;
  }
  rep(i,c){
    int c_y;
    cin >> c_y;
    r[i] = c_y;
  }
  sort(p.begin(), p.end(),greater<int>());
  sort(q.begin(), q.end(),greater<int>());
  sort(r.begin(), r.end(),greater<int>());
  vector<int> s(c+x+y);
  rep(i,x) s[i]=p[i];
  rep(i,y) s[x+i]=q[i];
  rep(i,c) s[x+y+i]=r[i];
  sort(s.begin(), s.end(), greater<int>());
  ll ans=0;
  rep(i,x+y) ans += s[i];
  cout<< ans << endl;
  // for_each(p.begin(), p.end(), [](int const& ele){
  //   cout << ele << endl;
  // });
  return 0;
}

Measured memory_bytes: 2560
package main

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

func main() {
	A := nextInt()
	B := nextInt()

	fmt.Println(calc(A-1) ^ calc(B))
}

func calc(n int) int {
	if n%2 == 0 {
		return n ^ n/2%2
	}

	return (n + 1) / 2 % 2
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
from heapq import*
X,Y,Z=map(int,input().split());N=X+Y+Z;A=[];q1=[];q2=[];L=[0];R=[0]
for _ in[0]*N:A.append([int(e)for e in input().split()])
A.sort(key=lambda a:a[0]-a[1])
for i in range(N):
	L.append(L[i]+A[i][1]);heappush(q1,A[i][1]-A[i][2]);R.append(R[i]+A[N-1-i][0]);heappush(q2,A[N-1-i][0]-A[N-1-i][2])
	if i>=Y:L[i+1]-=heappop(q1)
	if i>=X:R[i+1]-=heappop(q2)
print(max(L[i]+R[N-i] for i in range(Y,N-X+1)))

Measured memory_bytes: 39204
s = gets.chomp
n = s.length
k = gets.chomp.to_i


chars = []


s.length.times do |i|
  chars << s[i..n-1]
end

chars.sort!
idx = 0

checked = Hash.new(false)

chars.each do |char|
  char.length.times do |i|
    if checked[char[0..i]] == false
      checked[char[0..i]] = true
      idx += 1
    end

    if idx == k
      puts char[0..i]
      exit
    end
  end
end


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end()))
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define NUM(x,v) (POSU(x,v)-POSL(x,v))
#define REV(x) (reverse(x.begin(),x.end()))
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
//#define out(a) cout<<fixed<<setprecision((a))
#define YesNo(a) cout<<((a)?"Yes":"No")<<endl
#define YESNO(a) cout<<((a)?"YES":"NO")<<endl



int main(){
  int a,b;
  cin >> a >> b;
  cout << max(0,a-2*b);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int a, b;
  cin >> a >> b;
  if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
  return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn


object Main extends App {
  val n  = StdIn.readLine().toInt
  val a  = StdIn.readLine().split(" ").map(_.toInt)

  def solve(a: Array[Int]): Int = {

    val b = a.scanLeft(0) {(acc, x) => gcd(acc, x)}
    val c = a.scanRight(0) {(acc, x) => gcd(acc, x)}

    val d = for (x <- 0 to a.length -1) yield {
      gcd(b(x), c(x + 1))
    }
    d.max
  }

  def gcd(x: Int, y: Int) :Int = {
    if (y == 0 ) x
    else gcd(y, (x % y))
  }

  println(solve(a))

}
  




Measured memory_bytes: 52804
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

const int N = 234567;

int bit[N];

void add(int p, int v) {
  for (int i = p; i < N; i += i & -i)
    bit[i] += v;
}

int sum(int p) {
  int res = 0;
  for (int i = p; i > 0; i -= i & -i)
    res += bit[i];
  return res;
}

LL pre[N];

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector <LL> v;
  for (int i = 1; i <= n; i ++) {
    int a;
    scanf("%d", &a);
    a -= k;
    v.push_back(pre[i] = pre[i - 1] + a);
  }
  v.push_back(0);
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  LL ans = 0;
  int pos = upper_bound(v.begin(), v.end(), 0) - v.begin();
  add(pos, 1);
  for (int i = 1; i <= n; i ++) {
    int a = upper_bound(v.begin(), v.end(), pre[i]) - v.begin();
    ans += sum(a);
    add(a, 1);
  }
  cout << ans << endl;

}

Measured memory_bytes: 4336