akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
int n, k, sum;
int main(void){
    cin >> n >> k;
    vector<int> vec(n);
    rep(i, n) {
        cin >> vec[i];
    }
    sort(vec.rbegin(), vec.rend());
    rep(i, k) sum += vec[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3628
g,p,win,lose=0,0,0,0
gets.chomp.chars.each do |c|
    case c
    when 'g'
        if(g > p)
            p += 1
            win += 1
        else
            g += 1
        end
    when 'p'
        if(g > p)
            p += 1
        else
            g += 1
            lose += 1
        end
    end
end
p (win - lose)

Measured memory_bytes: 6908
from collections import deque

H, W = map(int, input().split())
maze = [input() for i in range(H)]
ans = 0
move = [(1, 0), (0, 1), (-1, 0), (0, -1)]
for h in range(H):
    for w in range(W):
        if maze[h][w] == '#':
            continue
        queue = deque()
        depth = [[-1] * W for i in range(H)]
        depth[h][w] = 0
        queue.append((h, w))
        while queue:
            i, j = queue.popleft()
            for di, dj in move:
                ni, nj = i+di, j+dj
                if 0 <= ni < H and 0 <= nj < W and maze[ni][nj] == '.' and depth[ni][nj] == -1:
                    queue.append((ni, nj))
                    depth[ni][nj] = depth[i][j] + 1
        ans = max(ans, max(max(d) for d in depth))
print(ans)


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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
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; }
const ll inf = 1ll << 60;

ll n, m, k;
vector<ll> rem(201010); /// rem.at(i)はiの階乗i!をmodで割った余り
vector<ll> rinv(201010); /// rinv.at(i)は1/i!,つまり「i!にかけたら1になる数」をmodで割った余り
vector<ll> inv(201010); /// inv.at(i)は1/iをmodで割った余り

int gcc(int n, int m) {
    int a = max({n, m});
    int b = min({n, m});
    if(b == 0) return a;
    int c;
    while(a % b != 0){
        c = a % b;
        a = b;
        b = c;
    }
    return b;
}

///前処理
void prev(){
    rem.at(1) = 1ll;
    rem.at(0) = 1ll;
    inv.at(1) = 1ll;
    inv.at(0) = 0ll;
    rinv.at(0) = 1ll;
    rinv.at(1) = 1ll;
    rp(i, 2, n*m+6){
        rem.at(i) = rem.at(i-1) * i % mod;
        inv.at(i) = mod - (inv.at(mod % i) * (mod / i)) % mod;
        rinv.at(i) = (rinv.at(i-1) * inv.at(i)) % mod;
    }
}

int main() {
    scanf("%lld%lld%lld", &n, &m, &k);
    prev();
    ll cmb = (rem.at(n * m - 2) * rinv.at(k - 2)%mod * rinv.at(n * m - k)%mod) % mod;
    printf("%lld\n", (((m*m%mod*m%mod - m)*n*n%mod + (n*n%mod*n%mod - n)*m*m%mod) * inv.at(6)%mod * cmb%mod));
    return 0;
    
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

inline int read(){
	int x = 0, ch = getchar(), f = 1;
	while (!isdigit(ch)){if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}

int n, a[100005];
int main(){
	n = read();
	REP(i, 1, n) a[i] = read();
	n = unique(a + 1, a + n + 1) - a - 1;
	int ans = 0;
	for (int i = 1, j; i <= n; i = j + 1, ++ans){
		if (i == n){
			++ans; break;
		}
		j = i;
		if (i == 7){
			++i, --i;
		}
		if (a[j + 1] < a[j]){
			while (j + 1 <= n && a[j + 1] < a[j]) ++j;
		}
		else{
			while (j + 1 <= n && a[j + 1] > a[j]) ++j;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

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

	if (a > 8 || b > 8)
	{
		cout << ":(" << endl;
	}
	else
	{
		cout << "Yay!" << endl;
	}
}

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<char> A(H*W);
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> A.at(i * W + j); 
        }
    }
    for(int i = 0; i < H + 2; i++){
        for(int j = 0; j < W + 2; j++){
            if(i == 0 || j == 0 || j == W + 1 || i == H + 1){
                cout << "#";
                if(j == W + 1) cout << endl;
            }else{
                cout << A.at( ((i-1) * W) + (j-1) ) ;
            }
        }
    }
}


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

const int N = 1e5 + 10 , M = 5e5+10 ,  MOD = 1e9+7;
const int OO = 0x3f3f3f3f;
const double EPS = 1e-3;

#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 


int n ;




int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	
    

    cin >> n;
    vi v(n);
    for(auto &x : v)
        cin >> x;
    int mx = OO , cnt = 0;
    loop(i, n){
        if(v[i] < mx){
            cnt++;
            mx = v[i];    
        }    
    }
    cout << cnt << "\n";



    
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n / 2; ++i) {
        ans += (s[i] != s[n - 1 - i]);
    }
    cout << ans << endl;
    return 0;
}

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

xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]

x_c = [x + y for (x, y) in zip(x, y)]
y_c = [x - y for (x, y) in zip(x, y)]

ans = max(x_c) - min(x_c)

ans_1 = max(y_c) - min(y_c)

if ans < ans_1:
    ans = ans_1

print(ans)

Measured memory_bytes: 129340
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 3010
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
#define INF 1000000000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
   int n,k;
   cin>>n>>k;
   int cnt=0;
   REP(i,n){
       int h;
       cin>>h;
       if(h>=k) cnt++;
   }
   OUT(cnt);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 4e5 + 7;
const ll mod = 998244353;

ll f[maxn], n, m, k;
ll my_pow(ll x, ll y){
    ll ans = 1;
    while(y > 0){
        if(y & 1)ans = ans * x % mod;
        y >>= 1;
        x = x * x % mod;
    }
    return ans;
}
ll C(int x, int y)
{
    if(y == 0 || y == x)return 1;
    return f[x] * my_pow(f[x - y], mod - 2) % mod * my_pow(f[y], mod - 2) % mod;
}
int main() 
{
    cin >> n >> m >> k;
    f[0] = 1;
    for(int i = 1; i < maxn; ++i)f[i] = f[i - 1] * i % mod;
    ll ans = 0;
    for(int i = 0; i <= k; i++){
        ll tmp = 1LL * m * C(n - 1, i) % mod * my_pow(m - 1, n - i - 1) % mod;
        //cout << m << ' ' << C(n - 1, i) << ' ' << my_pow(m - 1, n - i - 1) << '\n';
        //cout << i << ' ' << tmp << '\n';
        ans = (ans + tmp) % mod;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 6764
# https://atcoder.jp/contests/abc094/tasks/arc095_a
# C - Many Medians
import copy

n = int(input().split()[0])
x_list = list(map(int, input().split()))
sorted_x_list = sorted(x_list)
mean_index = int((n + 1)/ 2) - 1
mean_list = []

a = sorted_x_list[mean_index]
b = sorted_x_list[mean_index + 1]
for x in x_list:
    if x <= a:
        mean_list.append(str(b))
    else:
        mean_list.append(str(a))

ans = '\n'.join(mean_list)
print(ans)

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

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin); freopen("output1.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	int arr[n][3];
	for (int i = 0; i < n; i++) {
		cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
	}
	int dp[n][3] = {};
	dp[0][0] = arr[0][0];
	dp[0][1] = arr[0][1];
	dp[0][2] = arr[0][2];
	for (int i = 1; i < n; i++) {
		dp[i][0] = arr[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = arr[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = arr[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));


}

Measured memory_bytes: 5936
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " = " << x << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAX=1e5+5;
vector<int> G[MAX];
int mem[MAX];
int n,m;
int f(int u){
    int &ans=mem[u];
    if(ans!=-1)return ans;
    ans=0;
    for(auto x:G[u]){
        ans=max(ans,f(x)+1);
    }
    return ans;
}
int main() {
#ifdef LOCAL
  // freopen("h.txt", "r", stdin);
  // freopen("main.out", "w", stdout);
#else
  ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
#endif

  cin>>n>>m;
  memset(mem,-1,sizeof mem);
  forn(i,m){
      int x,y;
      cin>>x>>y;
      G[x].pb(y);
  }
  forn(i,n){
      G[0].pb(i+1);
  }
  cout<<f(0)-1<<endl;
  return 0;
}

Measured memory_bytes: 8056
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,s=0;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n-1;i++)
    {
        s+=a[i];
    }
    s+=(a[n-1]/2);
    cout<<s<<endl;
}
return 0;
}

Measured memory_bytes: 256
use std::io::BufRead;

fn main() {
    let (left_mat, right_mat) = read_two_mat();
    let mut mat = Vec::new();
    for (i, vl) in left_mat.iter().enumerate() {
        mat.push(Vec::new());
        for vr in right_mat.iter() {
            let mut sum: isize = 
                vl.iter().zip(vr.iter()).map(|(a, b)| a * b).sum();
            mat[i].push(sum);
        }
    }
    for vec in mat {
        let mut s = String::new();
        for i in vec {
            s.push_str(&format!("{} ",i));
        }
        s.pop();
        println!("{}", s);
    }
}

fn read_two_mat() -> (Vec<Vec<isize>>, Vec<Vec<isize>>) {
    let handle = std::io::stdin();
    let mut n_m_l = String::new();
    handle.lock().read_line(&mut n_m_l).ok();
    let mut n_m_l_iter = n_m_l.trim().split_whitespace()
        .map(|a| a.parse().unwrap());
    let n = n_m_l_iter.next().unwrap();
    let m = n_m_l_iter.next().unwrap();
    let l = n_m_l_iter.next().unwrap();
    let mut left_mat = Vec::new();
    let mut right_mat = Vec::new();
    
    for line in handle.lock().lines().take(n).map(|a| a.unwrap()) {
        let vec = line.trim().split_whitespace()
        .map(|a| a.parse().unwrap()).collect();
        left_mat.push(vec);
    }
    for _ in 0..l {
        right_mat.push(Vec::new());
    }
    for line in handle.lock().lines().take(m).map(|a| a.unwrap()) {
        for (i, n) in line.trim().split_whitespace()
                .map(|a| a.parse().unwrap()).enumerate() {
            right_mat[i].push(n);
        }
    }
    (left_mat, right_mat)
}


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


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

    vector<string> W(N);
    for (int i = 0; i < N; ++i) cin >> W[i];

    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (W[i] == W[j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    for (int i = 0; i < N-1; ++i) {
        if (W[i][W[i].size()-1] != W[i+1][0]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int cnt=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++) {
        if(s[i]=='1') cnt++;
        else cnt--;
    }
    if(cnt<0) cnt = cnt*(-1);
    cout<<s.size()-cnt<<endl;
}


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

vector<vector<int>> G;
int dp[100005];

int dfs(int i){
    if(dp[i] != -1) return dp[i];
    int ans = 0;
    for(auto e:G[i]){
        ans = max(ans,dfs(e) + 1);
    }
    dp[i] = ans;
    return ans;
}

int main() {
    int N, M;
    cin >> N >> M;
    G.resize(N);
    rep(i,M){
        int x,y;
        cin >> x >> y;
        x--;y--;
        G[x].push_back(y);
    }

    rep(i,N) dp[i] = -1;
    int ans = 0;
    rep(i,N) ans = max(ans,dfs(i));
    cout << ans << endl;
}

Measured memory_bytes: 8192
#include <stdio.h>

int main(void)
{
	int a=0,b=0,c=0;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b&&b<c)
	{
		printf("Yes\n");
	}
	
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int a,b,t;
    cin>>a>>b>>t;
    cout<<((t/a)*b)<<endl;
}

Measured memory_bytes: 256
def main():
    s = input()
    K = int(input())
    lst = sorted(list(set(s)))
    ans = []

    def dfs(sub):
        if len(ans) < K:
            ans.append(sub)
            for c in lst:
                if sub + c in s:
                    return dfs(sub + c)
        return

    for c in lst:
        dfs(c)
    print(ans[-1])
    return


main()


Measured memory_bytes: 3060
n = int(input())
t = list(map(int, input().split()))
m = int(input())
time = [0] * m
for i in range(m) :
    p, x = map(int, input().split())
    tmp = t[p-1]
    t[p-1] = x
    print(sum(t))
    t[p-1] = tmp


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

P = [input().split() for i in range(N)]
last = input()

sleep_num = 0
sum_time = 0
for i,j in enumerate(P):
  if j[0] == last:
    sleep_num = i
  sum_time += int(j[1])
    


awake = 0
for i,j in enumerate(P):
  awake += int(j[1])
  if i == sleep_num:
    break

k = sum_time - awake

print(k)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int n=s.length();
    vector<int>a(n+1);
    rep(i,n+1){
        a[i]=0;
    }
    rep(i,n){
        if(s[i]=='<'){
            a[i+1]=max(a[i+1],a[i]+1);
        }
    }
    for(int i=n-1; i>=0; --i){
        if(s[i]=='>'){
            a[i]=max(a[i],a[i+1]+1);
        }
    }
    ll sum=0;
    rep(i,n+1){
        sum+=a[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 2820
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
	int n,T,c[100],t[100];
	cin>>n>>T;
	for(int i=0;i<n;i++) cin>>c[i]>>t[i];
	
	int minv=10000;
	for(int i=0;i<n;i++){
		if(t[i]<=T&&c[i]<minv){
			minv=c[i];
		}
	}
	
	if(minv==10000) cout<<"TLE"<<endl;
	else cout<<minv<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,L;
  scanf("%d %d",&N,&L);
  int sum = 0;
  if(L+N-1 <= 0){
    for(int i=0;i<N-1;i++){
      sum += L + i;
    }
  }else{
    if(L <= 0){
      for(int i=0;i<N;i++){
        sum += L + i;
      }
    }else{
      for(int i=1;i<N;i++){
        sum += L + i;
      }
    }
  }
  printf("%d\n",sum);
  return 0;
}

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

int main(){
  string s; cin >> s;
  int i = 0;
  while (i < s.size()){
    if (i % 2 == 0){
      if (s.at(i) == 'L'){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if (s.at(i) == 'R'){
        cout << "No" << endl;
        return 0;
      }
    }
    i++;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

pii dfs(vv<int> &g,int v,int p){
  pii re(0,v);
  for(int w:g[v])if(w!=p) MX(re,dfs(g,w,v));
  if(g[v].size()==2) ++re.X;
  return re;
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  vv<int> g(n);
  rep(i,n-1){
    int x,y;
    cin>>x>>y; --x; --y;
    g[x].pb(y);
    g[y].pb(x);
  }
  int lf=0;
  rep(i,n)if(g[i].size()==1) ++lf;
  pii p=dfs(g,0,-1);
  pii q=dfs(g,p.Y,-1);
  //out(p,q,lf,1);
  cout<<q.X+lf<<endl;
  return 0;
}


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

int main(){

  long double a, b, h, m;

  cin >> a >> b >> h >> m;

  h = 30*h + 0.5*m;
  m = 6*m;
  long double hoge = abs(h-m);
  //cout << hoge << endl;
  hoge = min(hoge, 360-hoge);
  //cout << hoge << " " << cos(hoge*M_PI/180) << " " << cosh(hoge) << endl;

  cout << setprecision(13) << sqrt(a*a+b*b-(2*a*b*cos(hoge*M_PI/180))) << endl;

}


Measured memory_bytes: 4156
# coding: utf-8
# Your code here!
A,B,C,K=map(int,input().split())

all=A+B+C
"""
if K>=2:
    A+=all*4**(K//2-1)
    B+=all*4**(K//2-1)
    C+=all*4**(K//2-1)
"""
if K%2==1:
    A,B,C=B+C,C+A,A+B

ans=A-B
if abs(ans)>10**18:
    print("Unfair")
else:
    print(ans)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N;
  vector<pii> a;

  cin >> N;
  for (int i = 0; i < N; ++i) {
    int x, y;cin >> x >> y;
    a.emplace_back(x, y);
  }

  sort(ALL(a));

  const auto b = a.back();

  int ans = b.first + b.second;

  cout << ans << endl;


  return 0;
}



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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> H(N);
    REP(i, N) cin >> H[i];

    ll start = 0;
    ll ans = 0;
    for (int i = 1; i < N; ++i)
    {
        if (H[i] > H[i - 1])
        {
            ans = max(ans, i - start - 1);
            start = i;
        }
        if (i == N - 1) ans = max(ans, i - start);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;
const int MAX_N = 200100;
int n;
ll h[MAX_N];

ll L[MAX_N],R[MAX_N];
ll st[MAX_N];

void solve(){
  
  int t = 0; 
  for(int i = 0; i < n; i++){
    while( t > 0 && h[st[t-1]] >= h[i]){ t--;}
    L[i] = t == 0 ? 0 : (st[t-1]+1);
    st[t++] = i;
  }
  
  t = 0;
  for(int i = n-1; i >= 0; i--){
    while(t > 0 && h[st[t-1]] >= h[i]){ t--;}
    R[i] = t == 0 ? n : st[t-1];
    st[t++] = i;
  }
  
  ll ans = 0;
  for(int i = 0; i < n; i++){//ここを改変する
   
   ll res = (i-L[i]+1)*(R[i]-i);
    ans += res*h[i];
  }
  
  cout << ans << endl;
}

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

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;


ll N;
ll sum, mx;
int main() {
    cin>>N;
    REP(i,0,N){
        ll a;
        cin>>a;
        sum += a;
        mx = max(mx, a);
    }
    p(sum-mx/2);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

vector<ll> A;
vector<vector<int>> G;

ll countPairs(const vector<ll> &g) {
  ll sum = accumulate(g.begin(), g.end(), 0ll);
  ll mx = *max_element(g.begin(), g.end());
  return sum - mx;
}

ll dfs(int v, int p) {
  ll a = A[v];
  vector<ll> children;
  for (int u : G[v]) {
    if (u != p) {
      ll c = dfs(u, v);
      if (c < 0) {
        return -1;
      }
      children.push_back(c);
    }
  }
  if (children.empty()) {
    return a;
  }
  ll sum = accumulate(children.begin(), children.end(), 0ll);
  ll y = sum - a;
  ll x = a - y;
  if (x < 0 || y < 0 || countPairs(children) < y) {
    return -1;
  }
  return x;
}

int main() {
  int N;
  cin >> N;
  A.resize(N);
  G.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  ll v = dfs(0, -1);
  bool res = (G[0].size() > 1 ? v == 0 : v >= 0);
  cout << (res ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 14464
N = int(input())
A = list(map(int, input().split()))

B = [0] * N
n = [i+1 for i in range(N)]
for i in range(N)[::-1]:
  if sum(B[i::i+1]) % 2 != A[i]:
    B[i] = 1

print(sum(B))
print(*[i+1 for i, b in enumerate(B) if b==1])

Measured memory_bytes: 20280
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
    map<ll,ll>mp;
    ll n,ans=0; cin>>n;
    for(ll i=0;i<n;i++) 
    {
        ll a; cin>>a; mp[a]++;
    }
    for(auto i:mp) 
    {
        if(i.second>=i.first) ans+=(i.second-i.first);
        else ans+=i.second;
    }
    cout<<ans;
}

Measured memory_bytes: 9544
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
	int n;
	cin >> n;
	vector<int> a, b;
	for (int i = 0;i < n;++i) {
		int c;
		cin >> c;
		a.push_back(c);
	}
	int now = 0;
	REP(i, n) {
		int c;
		cin >> c;
		now += c;
		b.push_back(c);
	}
	now += a[0];
	int ans = 0;
	ans = max(ans, now);
	for (int i = 0;i < n - 1;++i){
		now -= b[i];
		now += a[i + 1];
		ans = max(ans, now);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;

    ll n = s.size();

    auto sa = atcoder::suffix_array(s);

    auto lcp = atcoder::lcp_array(s, sa);

    ll ans = n * (n + 1) / 2;

    for (auto x : lcp) {
        ans -= x;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15552
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) {
    cin >> vec.at(i);
  }
  int max=0;
  int num=1;
  rep(i,n){
    if (i==0) {
      max = vec.at(i);
      continue;
    }
    if (vec.at(i)>=max){
      max=vec.at(i);
      num++;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s="";
		while((s=br.readLine())!=null){
			BigInteger bi=new BigInteger(s);
			int x=bi.intValue();
			for (int i = x-1; i>0; i--) {
				bi=bi.multiply(BigInteger.valueOf(i));
			}
			
			System.out.println(bi);
		}
	}
}

Measured memory_bytes: 16904
N,M,V,P=map(int,input().split())
B = sorted(list(map(int, input().split())))[::-1]
count=P
dif=0
for i in range(P,N):
    dif+=B[i-1]
    if V<=(P-1)+(N-i) and B[P-1]<=B[i]+M:
        count+=1
    elif dif-B[i]*(i-P+1)<=M*(N-V) and B[P-1]<=B[i]+M:
        count+=1
print(count)

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	int n, k;cin >> n >> k;
	if(k > (n - 1) * (n - 2) / 2){
		cout << -1 << endl;
		return 0;
	}

	vector<P> ans;
	REP(i, n - 1)ans.EB(i, n-1);
	REP(i, n - 1){
		REP(j, i){
			if(k == 0)ans.EB(i, j);
			else k--;
		}
	}

	cout << ans.size() << endl;
	REP(i, ans.size())cout << ans[i].FI + 1 << " " << ans[i].SE + 1 << endl;

	return 0;
}


Measured memory_bytes: 512
solve n k
  | k `mod` 2 == 0 = p*p*p + q*q*q
  | otherwise      = p*p*p
  where
    p = n `div` k
    q = (n + (k `div` 2)) `div` k

main = do
  cont <- getContents
  let [n,k] = map read $ words cont
      a = solve n k
  putStrLn $ show a


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
    int a,b,n;cin>>n;
    map<string,int>m;
    m["AC"]=0;m["WA"]=0;m["TLE"]=0;m["RE"]=0;
    rep(i,n){
        string s;cin>>s;
        m[s]++;
    }
    cout<<"AC"<<' '<<'x'<<' '<<m["AC"]<<endl;
    cout<<"WA"<<' '<<'x'<<' '<<m["WA"]<<endl;
    cout<<"TLE"<<' '<<'x'<<' '<<m["TLE"]<<endl;
    cout<<"RE"<<' '<<'x'<<' '<<m["RE"]<<endl;
}

Measured memory_bytes: 3628
#![allow(bare_trait_objects)]
#![allow(unused_imports)]
#![allow(dead_code)]

use std::fmt::Debug;
use std::io::BufRead;
use std::io::Stdin;
use std::io::StdinLock;
use std::str::FromStr;

pub struct Scanner<'a> {
    // stdin: Stdin,
    buf_read: Box<BufRead + 'a>,
    tokens: Vec<String>,
}

impl<'a> Scanner<'a> {
    pub fn new(buf_read: StdinLock<'a>) -> Self {
        Scanner {
            buf_read: Box::new(buf_read),
            tokens: Vec::new(),
        }
    }

    // pub fn from_stdin() -> Self {
    //     let stdin = Box::leak(Box::new(std::io::stdin()));
    //     Self {
    //         buf_read: Box::new(stdin.lock()),
    //         tokens: Vec::new(),
    //     }
    // }

    pub fn next(&mut self) -> String {
        while self.tokens.is_empty() {
            let mut s = String::new();
            if self.buf_read.read_line(&mut s).is_err() {
                panic!()
            }
            self.tokens = s
                .split_whitespace()
                .filter(|s| !s.is_empty())
                .rev()
                .map(str::to_string)
                .collect();
        }
        self.tokens.pop().unwrap()
    }

    pub fn next_g<T: FromStr>(&mut self) -> T
    where
        T::Err: Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn next_vec_g<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: Debug,
    {
        (0..n).map(|_| self.next_g()).collect()
    }

    pub fn usize(&mut self) -> usize {
        self.next_g()
    }

    pub fn i64(&mut self) -> i64 {
        self.next_g()
    }

    pub fn vec_i64(&mut self, n: usize) -> Vec<i64> {
        self.next_vec_g(n)
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let h = sc.i64();
    let w = sc.i64();

    let mut ans = 0;
    if w == 1 || h == 1 {
        ans = 1
    } else {
        ans += (w + 1) / 2 * ((h + 1) / 2);
        ans += w / 2 * (h / 2);
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int mod;
vector<vector<int> > edges;
vector<long long> sub, ans;

long long solve1(int curr, int prev)
{
    sub[curr] = 1;
    for(int next : edges[curr]){
        if(next == prev)
            continue;
        sub[curr] *= solve1(next, curr) + 1;
        sub[curr] %= mod;
    }
    return sub[curr];
}

void solve2(int curr, int prev, long long cnt)
{
    int n = edges[curr].size();
    vector<long long> v(n);
    for(int i=0; i<n; ++i){
        int next = edges[curr][i];
        if(next == prev)
            v[i] = cnt + 1;
        else
            v[i] = sub[next] + 1;
    }

    vector<long long> v1(n+1, 1), v2(n+1, 1);
    for(int i=0; i<n; ++i){
        v1[i+1] = v1[i] * v[i] % mod;
        v2[i+1] = v2[i] * v[n-1-i] % mod;
    }
    ans[curr] = v1[n];

    for(int i=0; i<n; ++i){
        int next = edges[curr][i];
        if(next == prev)
            continue;
        solve2(next, curr, v1[i] * v2[n-1-i] % mod);
    }
}

int main()
{
    int n;
    cin >> n >> mod;
    edges.assign(n, vector<int>());
    for(int i=0; i<n-1; ++i){
        int x, y;
        cin >> x >> y;
        -- x;
        -- y;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }

    sub.resize(n);
    solve1(0, -1);
    ans.resize(n);
    solve2(0, -1, 0);

    for(int i=0; i<n; ++i)
        cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 22016
#include <iostream>
#define P 1000000007
using namespace std;
bool p[1000];
long long int seki[2000];
long long int n;
bool is_prime(long long int a){
	if (a==1) return false;
	if (a==2) return true;
	for(long long int i=2;i<a;i++){
		if(a%i==0)return false;
	}return true;
}
long long int jo(long long int i,long long int n){
	if(i<=n)return jo(i,n/i)+n/i;
	else return 0;
}
long long int kake(long long int a,long long int b){
	return (a*b)%P;
}
void solve(void){
	for(long long int i=1;i<n+1;i++){
		p[i]=is_prime(i);
	}
	for(long long int i=1;i<n+1;i++){
		if(p[i])seki[i]=jo(i,n)+1;
		else seki[i]=1;
	}
	long long int ans=1;
	for(long long int i=1;i<n+1;i++){
		ans=kake(ans,seki[i]);
	}
	cout<<ans<<endl;
}
int main() {
	cin>>n;
	solve();
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  int key;
  struct node *r;
  struct node *l;
  struct node *p;
};
typedef struct node *Node;
Node root;

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;
  z=malloc(sizeof(struct node));
  z->key=k;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->l;
    }else {
      x=x->r;
    }
  }
  z->p=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key<y->key){
      y->l=z;
    }else{
      y->r=z;
    }
  }
}

void inoder(Node u){
  if(u==NIL)return;
  inoder(u->l);
  printf(" %d",u->key);
  inoder(u->r);
}
void preoder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preoder(u->l);
  preoder(u->r);
}

Node find(Node u,int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->l;
    else u=u->r;
  }
  return u;
}

int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if(com[0]=='p'){
      inoder(root);
      printf("\n");
      preoder(root);
      printf("\n");
    }else if(com[0]=='f'){
      scanf("%d",&x);
      Node t=find(root,x);
      if(t!=NIL)printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}



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

int main() {
    int N,Y;
    cin >> N >> Y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for (int a=0; a<= N; ++a){
        for (int b=0; b<=N; ++b){
            int c = N-a-b;
            int total = 10000*a + 5000*b + 1000*c;
            if (total == Y && c>=0) {
                res10000 = a;
                res5000 = b;
                res1000 = c;
            }
        }
    }
    
    cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
  string s;
  int k;
  cin >> s >> k;
  int len = s.size();
  int i = 0;
  if(k == 1){
    cout << s[0] << endl;
    return 0;
  }
  while(s[i] == '1'){
    if(i+1==k){
      cout << s[i] << endl;
      return 0;
    }
    i++;
  }
  cout << s[i] << endl;
  return 0;
}


Measured memory_bytes: 256
A, B, K = map(int, input().split())

items = []
if A == 1 or B == 1:
    items.append(1)
else:
    for i in range(1, max(A, B)+1):
        if A % i == 0 and B % i == 0:
            items.append(i)

print(items[-K] if len(items) >= K else items[0])


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

int main(){
    int n,d;
    cin>>n>>d;
    int count = 0;
    for(int i = 0; i < n; i++){
        double x,y;
        cin>>x>>y;
        double dist = sqrt(x*x + y*y);
        if(dist <= d){
            count++;
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 2e5;
int h, a;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> a;
  cout << (h+a-1)/a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<set>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int N=200200;
int n,L,a[N],pr[N],nx[N],l[N],r[N];
int vi[N],tl[N],tr[N],p[N];
ll ans;
struct cmp{
	bool operator()(int x,int y)
		{return a[x]!=a[y]?a[x]<a[y]:x<y;}
};
set<int,cmp>q;
ll calc(int m){
	ll ret=0,S=0;
	FOR(i,1,m){
		if(i>=L) S+=l[p[i-L+1]];
		ret+=1ll*S*r[p[i]];
	}
	return ret;
}
int main(){
	scanf("%d%d",&n,&L);ans=n;
	FOR(i,1,n) scanf("%d",&a[i]);
	FOR(i,1,n){
		pr[i]=i-1,nx[i]=i==n?0:i+1;
		l[i]=r[i]=1;q.insert(i);
	}
	while(q.size()){
		int u=*q.begin(),v,m,t,w=a[u];
		for(m=0,v=u;v && a[v]==w;v=nx[v]) 
			q.erase(v),p[++m]=v;
		//FOR(i,1,m) cout<<p[i]<<' ';cout<<'\n';
		// FOR(i,1,m) cout<<a[p[i]]<<' ';cout<<'\n';
		p[0]=pr[p[1]],p[m+1]=nx[p[m]];
		ans+=calc(m);t=m/L;//cout<<"ans="<<ans<<'\n';
		FOR(i,1,t) tl[i]=tr[i]=0;
		FOR(i,1,m) tr[i/L]+=r[p[i]],tl[t-(m-i+1)/L+1]+=l[p[i]];
		FOR(i,1,t) p[i]=v=p[(i-1)*L+1],l[v]=tl[i],r[v]=tr[i],a[v]=w+1,q.insert(v);
		p[t+1]=p[m+1];
		//FOR(i,1,t) cout<<l[p[i]]<<'-'<<r[p[i]]<<' ';cout<<'\n';
		FOR(i,0,t) pr[p[i+1]]=p[i],nx[p[i]]=p[i+1];
		pr[0]=nx[0]=0;
		if(!t) nx[p[0]]=pr[p[1]]=0;
		ans-=calc(t);//cout<<"ans="<<ans<<'\n';
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 15232
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();

    int cnt = 0;
    for (int pin = 0; pin <= 999; pin++) {
      int pos = 100;
      for (int i = 0; i < s.length(); i++) {
        char c = (char) ((pin / pos) % 10 + '0');
        if (s.charAt(i) == c)
          pos /= 10;
        if (pos == 0) break;
      }
      if (pos == 0) ++cnt;
    }
    System.out.println(cnt);
  }
}


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

const int MAX = 6e3 + 5;
const int INF = (int) 1e9;
char A[MAX], B[MAX];
int n;

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

	cin >> A;
	cin >> B;

	n = strlen(A);
	bool equal = true, only_zeros = true;
	fori(i, 0, n) {
		if(A[i] != B[i]) {
			equal = false;
		}
		if(B[i] == '1') {
			only_zeros = false;
		}
	}

	if(equal) {
		puts("0");
		return 0;
	}
	else if(only_zeros) {
		puts("-1");
		return 0;
	}

	fori(i, 0, n) {
		B[i + n] = B[i + 2 * n] = B[i];
	}
	vector<int> ones;
	fori(i, 0, 3 * n) {
		if(B[i] == '1') {
			ones.push_back(i);
		}
	}

	int ans = INF;
	fori(D, 0, 2 * n + 1) {
		vector<ii> constraints;
		int flipped = 0;
		int L = min(D, n);
		int R = max(D, n);
		fori(i, n, 2 * n) {
			if(B[i + (D - n)] != A[i - n]) {
				flipped++;
				int left = min(i + (D - n), i);
				int right = max(i + (D - n), i);
				auto it = lower_bound(ones.begin(), ones.end(), left);	
				if(it == ones.end() || *it > right) {
					auto R_it = upper_bound(ones.begin(), ones.end(), right);
					auto L_it = lower_bound(ones.begin(), ones.end(), left);
					if(R_it == ones.end()) {
						int L_val = -1;
						if(left == i + (D - n)) {
							L_val = D - (left - *prev(L_it));
						}
						else {
							L_val = D - (right - *prev(L_it));
						}
						L = min(L, L_val);
					}
					else if(L_it == ones.begin()) {
						int R_val = -1;
						if(right == i + (D - n)) {
							R_val = D + (*R_it - right);
						}
						else {
							R_val = D + *R_it - left;
						}
						R = max(R, R_val);
					}
					else {
						int L_val = -1, R_val = -1;
						if(right == i + (D - n)) {
							R_val = D + (*R_it - right);
						}
						else {
							R_val = D + *R_it - left;
						}
						if(left == i + (D - n)) {
							L_val = D - (left - *prev(L_it));
						}
						else {
							L_val = D - (right - *prev(L_it));
						}
						constraints.emplace_back(L_val, R_val);
					}
				}
			}
		}
		sort(constraints.begin(), constraints.end());
		int max_R = R, best_L = L, best_R = R, best_diff = INF;
		for(const auto &each : constraints) {
			if(best_diff > max_R - each.first) {
				best_diff = max_R - each.first;
				best_L = each.first;
				best_R = max_R;
			}
			max_R = max(max_R, each.second);
		}
		if(best_diff > max_R - L) {
			best_diff = max_R - L;
			best_L = L;
			best_R = max_R;
		}
		L = min(best_L, L);
		R = max(best_R, R);
		/*
		debug(L);
		debug(R);
		debug(D);
		debug(2 * (R - L) - abs(n - abs(D)));
		debug(flipped);
		cout << endl;
		*/
		ans = min(ans, 2 * (R - L) - abs(n - abs(D)) + flipped);
	}
	cout << ans << '\n';

	return 0;
}



Measured memory_bytes: 384
n = int(input())
S, P = [], []
Sdic = {}
line = [list(input().split()) for _ in range(n)]
for i in range(n):
    S.append(line[i][0])
    P.append(int(line[i][1]))
    if line[i][0] not in Sdic:
        Sdic[line[i][0]] = 1
Sdic2 = sorted(Sdic.items())
Sa = []
for i in range(len(Sdic2)):
    Sa.append(Sdic2[i][0])
for s in Sa:
    data = []
    for j in range(n):
        if S[j] == s:
            data.append(j)
    Pd = [[k, P[k]] for k in data]
    Pd = sorted(Pd, reverse=True, key=lambda x: x[1])
    for j in range(len(Pd)):
        print(Pd[j][0] + 1)

Measured memory_bytes: 3064