akhauriyash/Code-Regression huggingface dataset:
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }



int main() {
	fastio;

	ll N;
	cin >> N;
	ll ans = 0, con = 0;
	rep(i, N) {
		ll tmp; cin >> tmp;
		if (tmp == i + 1) {
			++con;
		}
		else {
			if (con != 0) ans += (con + 1) / 2;
			con = 0;
		}
	}
	if (con != 0) ans += (con + 1) / 2;
	cout << ans << endl;
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(), (x).end()

using ll = long long; using vll = vector<ll>;

static const long long mo = 1e9+7;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, t; cin >> n >> t;
    vll a(n); rep(i, a.size()) cin >> a[i];
    sort(all(a));
    
    ll ret = 1;
    rep(i, n) 
        (ret *= i + 1 - (ll)(lower_bound(a.begin(), a.begin() + i + 1, a[i] - t) - a.begin())) %= mo;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3632
function MainC(input){
    const arr = input.split(' ');
    const num1 = BigInt(arr[0]);
    const num2 = BigInt((arr[1].split('.').join('')));
    console.log(String(num1*num2/100n).replace('n',''))
}
MainC(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 29560
function reverse(s) {
  return s.split('').reverse().join('');
}
 
function r_search(input){
  const words = ['dreamer', 'dream', 'eraser', 'erase'];
  const reversed_words = words.map(x => reverse(x));
  var current_input = reverse(input);

  length_check_loop: while(true){
    if(current_input==""){return true;}
    for(word of reversed_words){
      
      if(current_input.startsWith(word)){
        current_input = current_input.substring(word.length)
        continue length_check_loop;
      }
    }
    return false;
  }
  return true;
}
 
function main(input) {
  if(r_search(input.split('\n')[0])){
    console.log('YES');
  }else{
    console.log('NO');
  }
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

ll x[MAXN];
ll y[MAXN];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	FOR(i,1,n+1){
		cin >> x[i];
	}
	FOR(i,1,m+1){
		cin >> y[i];
	}
	n--;
	m--;
	ll s1 = 0;
	for (ll i= 1; i<=n; i++){	
		s1+=(((i*(n-i+1))%MOD)*(x[i+1]-x[i]))%MOD;
		s1%=MOD;
	}
	ll s2 = 0;
	for (ll i= 1; i<=m; i++){
		s2+=(((i*(m-i+1))%MOD)*(y[i+1]-y[i]))%MOD;
		s2%=MOD;
	}
	
	cout << ((s1*s2)%MOD) << "\n";

}


Measured memory_bytes: 5224
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        double A = cin.nextint;
        double B = cin.nextint;
        if (A < B)
        {
            WriteLine((4 * B * B * B * Math.PI / 3).ToString("F7"));
        }
        else
        {
            double c = B * (A * A - B * B) / (A * A + B * B);
            double sita = 2 * Math.PI * (A * A * c * c * c / 3 / B / B - A * A * c * c / B + A * A * c);
            double ue = 4 * B * B * B * Math.PI / 3 - 2 * Math.PI * (B * B * c - c * c * c / 3);
            WriteLine((sita + ue).ToString("f7"));
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}


Measured memory_bytes: 18000
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  cout << (s == "abc" ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,d;
	cin>>n>>d;
	ll cnt=0;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d)cnt++;
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

	int n;
	P x[112345];

	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x[i].first>>x[i].second;
		int l=x[i].second;
		x[i].second=x[i].first+l;
		x[i].first-=l;
		swap(x[i].first,x[i].second);
	}
	sort(x,x+n);

	int res=0;
	int i=0;
	while(i<n)
	{
		res++;
		int j=i;
		while(i<n)
		{	
			if(x[j].first<=x[i].second)
				break;
			i++;
		}
	}

	cout<<res<<endl;

}

Measured memory_bytes: 2048
n = int(input())
s = []
d = {}
for i in range(n):
	x = input()
	l = list(x)
	list.sort(l)
	ll = "".join(l)
	if ll in d:
		d[ll] += 1
	else:
		d[ll] = 1

ans = 0
for i in d:
	ss = d[i]
	if d[i] >= 2:
		ans += ss*(ss-1)/2
print (int(ans))

Measured memory_bytes: 17892
# 2019-11-17 20:44:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    a, b = [int(x) for x in sys.stdin.readline().split()]
    extend = a - 1
    
    total_sockets = 1
    strips_count = 0
    if b >= 2:
        more_needed = True
    else:
        more_needed = False
    
    while more_needed:
        strips_count += 1
        total_sockets += extend
        if total_sockets >= b:
            more_needed = False
    
    print(strips_count)


if __name__ == "__main__":
    main()


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

using namespace std;

#define endl "\n"

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

    int t;
    cin >> t;
    vector<int> arr(t);
    for (int &i : arr) {
        cin >> i;
    }

    int dp[2][t];
    memset(dp, INT_MAX, sizeof dp);
    dp[0][0] = dp[1][0] = 0;
    for (int i = 1; i < t; i++) {
        dp[0][i] = abs(arr[i] - arr[i - 1]);
    }

    for (int i = 1; i < t; i++) {
        if (i - 2 >= 0) {
            dp[1][i] = min(abs(arr[i - 2] - arr[i]) + dp[1][i - 2], dp[0][i] + dp[1][i - 1]);
        } else {
            dp[1][i] = dp[0][i];
        }
    }

    // for (int i = 0; i < t; i++) {
    //     cout << dp[0][i] << " ";
    // }
    // cout << endl;
    // for (int i = 0; i < t; i++) {
    //     cout << dp[1][i] << " ";
    // }

    // cout << endl;

    cout << dp[1][t - 1] << endl;

    return 0;
}

Measured memory_bytes: 4492
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, T; cin >> N >> T;
	vector<int>v(T + 1, 0);
	rep(i, 0, N) {
		int l, r; cin >> l >> r;
		v[l]++; v[r]--;
	}
	rep(i, 1, T + 1)v[i] += v[i - 1];
	cout << *max_element(all(v)) << endl;
	return 0;
}

Measured memory_bytes: 3344
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(auto x:v) cout<<" "<<x; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int T=1;
	//cin>>T;
	while(T--){
		ll x,k,d;
		cin>>x>>k>>d;
		x=abs(x);
		d=abs(d);
		k=abs(k);
		ll n=x/d;
		if(k<n){
			cout<<x-k*d<<endl;
		}
		else{
			ll ans;
			ans=x-n*d;
			k-=n;
			if(k%2)
				cout<<abs(ans-d)<<endl;
			
			else
				cout<<ans<<endl;
		}
	}
}


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

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

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    vector<ll> v;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            v.push_back(i);
            v.push_back(n/i);
        }
    }
    for(int i = 0; i < v.size(); i++){
        if(v[i] == 1) continue;
        ll tmp = v[i] - 1;
        if(n / tmp == n % tmp) ans += tmp;
    }
    cout<< ans;
}

Measured memory_bytes: 384
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            FastScanner fs = new FastScanner();

            final int N = fs.nextInt();
            final int A = fs.nextInt();

            System.out.println(N * N - A);
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21076
N, M, C = map(int, input().split())
b = [int(i) for i in input().split()]
a = []
for i in range(N):
    tmp = [int(i) for i in input().split()]
    a.append(tmp)

count = 0
for i in range(N):
    tmp_sum = C
    for j in range(len(a[i])):
        tmp_sum += a[i][j] * b[j]

    if tmp_sum > 0:
        count+= 1
    else:
        tmp_sum = 0

print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////


void solve() {
	string str; ll N;
	cin >> str >> N; N--;
	rep(i, 0, sz(str)) {
		if(str[i] != '1') {
			cout << str[i] << "\n";
			break;
		}
		else if(i == N) {
			cout << 1 << "\n";
			break;
		}
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) cout << (x) << endl;
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;

ll result = 0;
string S;

void search(ll current, int index,ll sum) {
  if (index == S.size() - 1) {
    current = current * 10 + S[index] - '0';
    sum += current;
    result += sum;
    return;
  }

  current = current * 10 + S[index] - '0';
  search(current, index + 1, sum);
  search(0, index + 1, sum + current);
}
 
int main() {
  cin >> S;
  search(0, 0, 0);
  out(result);
  return 0;
}

Measured memory_bytes: 256
<?php
$money=(int)trim(fgets(STDIN));
$coin = [25,10,5,1];
echo GetRequiredNumber($money,$coin).PHP_EOL;

function GetRequiredNumber($money,$coin){
    $count = 0;
    for($i=0; $i<4; ++$i){
        $quotient = floor($money/$coin[$i]);
        $count += $quotient;
        if($money%$coin[$i]==0){
            return $count;
        }
        $money -= $quotient*$coin[$i];
    }
}
?>


Measured memory_bytes: 9284
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;

int main(){
	int a,b,n;
	while(cin>>a>>b,a){
		cin>>n;
		
		int data[32][32]={0},out[32][32]={0};
		for(int i=0,x,y;i<n;i++){
			cin>>x>>y;
			out[x][y]=1;
		}
		data[1][0]=1;
		for(int i=2;i<=(a+b);i++){
			for(int j=i-1,x,y;j>0;j--){
				x=j;
				y=i-j;
				data[x][y]=data[x-1][y]+data[x][y-1];
				if(out[x][y])data[x][y]=0;
			}
		}
		cout<<data[a][b]<<endl;
	}
	
	return 0;
}


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

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long
#define li long int
#define ld long double
#define lld long long double

#define pb push_back
#define mk make_pair
#define F first
#define S second

#define all(v) (v).begin(),(v).end()
#define fill(a) memset(a, 0, sizeof(a))

const int MX = 1e6;
const int MI = -1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;

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

const int mod=1e9+7;
inline int add(int x,int y)
{
  x+=y;
  if (x>=mod)
    return x-mod;
  return x;
}
inline int sub(int x,int y)
{
  x-=y;
  if (x<0)
    return x+mod;
  return x;
}
inline int mul(int x,int y)
{
  return (x*1ll*y)%mod;
}
inline int power(int x,int y)
{
  int ans=1;
  while(y)
    {
      if (y&1) ans=mul(ans,x);
      x=mul(x,x);
      y>>=1;
    }
  return ans;
}
inline int inv(int x)
{
  return power(x,mod-2);
}
inline int gcd(int x, int y)
{
  return(y!=0)?gcd(y, x%y):x;
}

/*------------CODE-----------*/

int main()
{
  IOS;
  int n;
  cin >> n;
  int ans=0;
  vector<string> arr;
  for (int i=0; i<n; i++)
    {
      string s;
      cin >> s;
      arr.pb(s);
    }
  sort (arr.begin(), arr.end());
  for (int i=0; i<arr.size()-1; i++)
    {
      if (arr[i]!=arr[i+1])
	ans++;
    }
  cout << ans+1 << endl;
  return 0;
}


Measured memory_bytes: 11596
import sys

n, g = map(int, input().split())
cards = [[int(x) for x in sys.stdin.readline().rstrip().split()] for _ in range(g)]

cards.sort(key=lambda x: x[0])
lmx = cards[g - 1][0]
cards.sort(key=lambda x: x[1])
rmn = min(cards[0][1], n)

print(max(0, rmn - lmx + 1))

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

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout << "YES"<<endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};



//#define int ll
signed main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(n*a<b)cout<<n*a<<endl;
    else cout<<b<<endl;
}

Measured memory_bytes: 764
#include <stdio.h>

int main ()
{
	int i, x;
	i = 1;
	while(1) {
		scanf ("%d", &x);
		if( x == 0 ) break;
		else {
			printf ("Case %d: %d\n", i, x );
			i++;
		}
	}
	
	return 0;
}


Measured memory_bytes: 1896
n = int(input())
ws = [list(input()) for _ in range(n)]

def sort_l(l):
    l.sort()
    return l
ws = list(map(sort_l, ws))
ws.sort()

i = 0
j = 0
r = 0
ans = 0
while(i<n-1):
    i += 1
    if ws[i] == ws[j]:
        r += 1
    else:
        ans += r * (r+1) // 2
        r = 0
        j = i
ans += r * (r+1) // 2

print(ans)


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

int main(void) {
    int x,a,b;
    cin >> x >> a >> b;
    if (abs(x-a) < abs(x-b)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            if (n == 1)
            {
                WriteLine("Hello World");
            }
            else
            {
                var a = ReadInt();
                var b = ReadInt();
                WriteLine(a + b);
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <atcoder/all>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

int op(int x, int y)
{
    return max(x, y);
}

int e()
{
    return 0;
}

using seg_tree = atcoder::segtree<int, op, e>;

int main()
{
    int n, k;
    cin >> n >> k;
    seg_tree seg(330000);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        int l = max(0, a - k);
        int r = min(330000, a + k + 1);
        int longest = seg.prod(l, r);
        seg.set(a, longest + 1);
        ans = max(ans, longest + 1);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int64_t A, B, C, D;
  cin >> A >> B >> C >> D;
  int64_t LCM, Cc = C, Dc = D, r = Dc;
  while (Cc % Dc != 0) {
    r = Cc % Dc;
    Cc = Dc;
    Dc = r;
  }
  LCM = C*D/r;
  
  int64_t ans_1 = B/C + B/D - B/LCM;
  int64_t ans_2 = (A - 1)/C + (A - 1)/D - (A - 1)/LCM;
  cout << (B - A + 1) - (ans_1 - ans_2) << endl;
}

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


void solve(long long L){
    double maximum = L/3.0 *L/3.0*L/3.0;
    printf("%f",maximum);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long L;
    scanf("%lld",&L);
    solve(L);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
const ll INF = 1e18L+5;
int main(){
	ll n,w;
	cin>>n>>w;
	vector<ll> weight(n),value(n);
	for(ll i=0;i<n;i++){
		
		cin>>weight[i]>>value[i];
		
	}
	vector<ll> dp(w+1);
	for(ll i=1;i<=n;i++){
		for(ll j=w;j>=0;j--){
			if(weight[i-1]<=j){
				dp[j] = max(dp[j],dp[j-weight[i-1]]+value[i-1]);
			}
		}
	}
	ll ans = 0;
	for(ll i=0;i<=w;i++){
		ans = max(ans,dp[i]);
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 1024
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Long,Integer> map = new HashMap<>();
        for(int i=0; i<n; i++) {
            long key = sc.nextLong();
            if(map.containsKey(key)) {
                map.put(key, map.get(key) + 1);
            }else {
                map.put(key, 1);
            }
        }
        int ans = 0;
        for(Entry<Long, Integer> entry : map.entrySet()) {
            if(entry.getValue() % 2 != 0) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 64364
#include <bits/stdc++.h>
#include<vector>
#include<set>
#define ll long long
using namespace std;
 

ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; 
}
int main() {
	
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll t,a,b,c,d,n,m,k,sum,i,j;
       string str;
     cin>>t;
      ll ans=1LL;
     while(t--)
     {
     	cin>>n;
     	ans=lcm(ans,n);
	 }
     cout<<ans<<endl;
     
     
     
  return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
using namespace std;
int points[1000];
int allp;
int main() {
	int N = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> points[i];
		allp += points[i];
	}
	if (allp % 10 != 0) {
		cout << allp << endl;
		return 0;
	}
	sort(points, points + N);
	int cop = allp;
	for (int i = 0; i < N; i++) {
		allp -= points[i];
		if (points[i] % 10 != 0) {
			cout << allp<<endl;
			return 0;
		}
		else { allp = cop; }
	}
	cout << '0' << endl;
	return 0;
}

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

using namespace std;

int main(){
  int n,k,i;
  cin >> n >> k;
  long long h[n] = {};
  long long sum = 0;
  for(i = 0; i < n; i++){
    cin >> h[i];
  }
  sort(h, h + n ,greater<long long>());
  for(i = k; i < n; i++){
    sum += h[i];
  }
  cout << sum;
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
)

type Observatory struct {
	Id   int
	Conn []int
	Flg  bool
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	var h []int
	var a []int
	var b []int

	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		h = append(h, tmp)
	}

	for i := 0; i < m; i++ {
		var tmp int
		fmt.Scan(&tmp)
		a = append(a, tmp)
		fmt.Scan(&tmp)
		b = append(b, tmp)
	}

	res := make([]bool, n)

	for i := 0; i < n; i++ {
		res[i] = true
	}

	for i := 0; i < m; i++ {
		if h[a[i]-1] == h[b[i]-1] {
			res[a[i]-1] = false
			res[b[i]-1] = false
		} else if h[a[i]-1] < h[b[i]-1] {
			res[a[i]-1] = false
		} else if h[a[i]-1] > h[b[i]-1] {
			res[b[i]-1] = false
		}

	}

	cnt := 0
	for i := 0; i < n; i++ {
		if res[i] {
			cnt++
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 9948
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int n, v[55];
long long s;
int main() {
    DAU
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> v[i];
        for (int j = 1; j < i; ++j)
            s += v[i] * v[j];
    }
    cout << s;
    PLEC
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
	int cheng,add,sub;
	int a,b;
	cin >> a >> b;
	cheng = a*b;
	add = a+b;
	sub = a-b;
	int ans;
	ans = max(max(cheng,add),sub);
	cout << ans;
	
	return 0;
} 

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

int main() {
  int N, M, X, A, B = 0, C = 0;
  cin >> N >> M >> X;

  for (int i = 0; i < M; i++) {
    cin >> A;
    if (A < X) B++;
    else C++;
  }

  cout << min(B, C) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
//参考郑伟杰 
int main(){
	string S;
	int N,K,h=0,count=0;
	cin>>N>>K>>S;
	int i=0,j=1;
	while(j<N)
	{ 
		if(S[i]==S[j])
		{ 
		    j++;
		    h++;} 
		else 
		{
		  i=j;
		  j++;
		}
	}
	for(int t=K;t>0;t--)	
        h+=2;
    if(h>=N-1)
        h=N-1;
    cout<<h;
    return 0;
}

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

int main() {

    int n,m,q;

    scanf("%d %d %d",&n,&m,&q);

    list<int> l;

    for(int i=0;i<n;i++){
        l.push_back(i);
    }

    list<int>::iterator itr = l.begin();

    while(m--){

        int a;

        scanf(" %d",&a);

        if(a%2 == 0){
            while(a!=0){
                itr++;
                if(itr == l.end()){
                    itr = l.begin();
                }
                a--;
            }
        }
        else{
            while(a!=0){
                if(itr == l.begin()){
                    itr = l.end();
                }
                itr--;
                a--;
            }
        }

        list<int>::iterator itrtmp = itr;
        itr++;
        if(itr == l.end()){
            itr = l.begin();
        }
        l.erase(itrtmp);

    }
    
    while(q--){

        int que;
        scanf(" %d",&que);

        int ans = 0;

        for(list<int>::iterator i=l.begin();i != l.end(); i++){
            if(*i == que){
                ans = 1;
                break;
            }
        }

        cout << ans << endl;

    }



    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void)
{
  int n, m;
  string u[300], t;
  cin >> n;
  REP(i, n) cin >> u[i];
  cin >> m;
  bool key = true;
  REP(i, m) {
    cin >> t;
    bool f = false;
    REP(j, n) {
      if(t == u[j]) f = true;
    }
    if(f) {
      if(key) {
        cout << "Opened by " << t << endl;
        key = false;
      } else {
        cout << "Closed by " << t << endl;
        key = true;
      }
    }
    else {
      cout << "Unknown " << t << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3156
#include <stdio.h>
#include <stdlib.h>

int binsearch(int S[], int n, int key)
{
    int left = 0;
    int right = n;
    int mid;
    
    while (left < right) {
        mid = (left + right)/2;
        if (S[mid] == key) 
            return 1;
        else if (S[mid] < key)
            left = mid + 1;
        else
            right = mid;
    }
    return 0;
}

int main()
{
    int n, q;
    int *S, T;
    int i, j = 0;
    int *A;
    
    scanf("%d", &n);
    S = (int*)malloc(sizeof(int) * n);
    for (i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }
    
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &T);
        if (binsearch(S, n, T)) {
            j++;
        }
    }
    
    printf("%d\n", j);
    
    return 0;
}

Measured memory_bytes: 992
#include <stdio.h>
main(){
   int no1,no2,no3,mid,hi,lo;
   scanf("%d %d %d",&no1,&no2,&no3);
   if (no1>no2) {
      mid=no1;
      lo=no2;
   } else {
      mid=no2;
      lo=no1;
   }
   if (mid>no3) {
      hi=mid;
      if(lo>no3){
         mid=lo;
         lo=no3;
      }else {
         mid=no3;
      }
   }else hi=no3;

   printf("%d %d %d\n",lo,mid,hi);
   return 0;
}



Measured memory_bytes: 2028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABH = ReadInts();
            var ans = 0;
            for (int i = ABH[1]; i <= ABH[2]; i++)
            {
                if (ABH[0] % i == 0)
                {
                    ans++;
                }
            }
            WriteLine(ans);

        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



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



int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    rep(i,n) {
        int a;
        cin >> a;
        q.push(a);
    }
    rep(i,m) {
        int a = q.top(); q.pop();
        q.push(a/2);
    }
    ll ans = 0;
    rep(i,n) {
        ans += q.top(); q.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3924
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e2+5;

int n;
int m;
int ar[N][N];

int main(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            char x;
            cin >> x;
            if(x == '#')
                ar[i][j] = 1;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(ar[i][j] == 1){
                cout << "#";
            } else {
                int sm = 0;
                for(int a = i-1; a <= i+1; a++){
                    for(int b = j-1; b <= j+1; b++){
                        sm += ar[a][b];
                    }
                }
                cout << sm;
            }
        }
            cout << endl;
    }
}


Measured memory_bytes: 256
import itertools
N,M = list(map(int,input().split()))
N_list = [i for i in range(N)]
N_result = list(itertools.combinations(N_list, 2))
M_list = [i for i in range(M)]
M_result = list(itertools.combinations(M_list, 2))
print(len(N_result + M_result))

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

int main()
{
    int H, W;
    cin >> H >> W;
    int color;
    int dp[H + 1][W + 1];
    int max_width = 0;
    for(int i = 0; i <= W; i++)
        dp[0][i] = 0;
    for(int i = 1; i <= H; i++)
        dp[i][0] = 0;

    for(int i = 1; i <= H; i++)
    {
        for(int j = 1; j <= W; j++)
        {
            cin >> color;
            if (color == 1)
                dp[i][j] = 0;
            else
            {
                dp[i][j] = min(min(dp[i - 1][j], dp[i - 1][j - 1]), dp[i][j - 1]) + 1;
                max_width = max(max_width, dp[i][j]);
            }
        }
    }

    cout << max_width * max_width << endl;
}


Measured memory_bytes: 10704
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

I dp[100001][2];

int main(){
  REP(i,100001){
    dp[i][0] = MIN;
    dp[i][1] = MAX;
  }
  I n;
  cin >> n;
  V v(3*n);
  VIN(v);
  priority_queue<I, V, greater<I>> fst;
  priority_queue<I> snd;
  I fstT,sndT;
  REP(i,2*n){
    fstT += v.at(i);
    fst.push(v.at(i));
    if (fst.size () > n){
      I fstI = fst.top();fst.pop();
      fstT -= fstI;
    }
    if (fst.size() == n){
      dp[i-(n-1)][0] = fstT;
    }
  }
  for(I i=3*n-1;i>=n;i--){
    sndT += v.at(i);
    snd.push(v.at(i));
    if (snd.size () > n){
      I sndI = snd.top();snd.pop();
      sndT -= sndI;
    }
    if (snd.size() == n){
      dp[i-n][1] = sndT;
    }
  }
  I t=MIN;
  REP(i,n+1){
    t = max(t,dp[i][0] - dp[i][1]);
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 6516
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstdlib>

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

using namespace std;

vector<string> split(const string &str, char delim){
  vector<string> res;
  size_t current = 0, found;
  while((found = str.find_first_of(delim, current)) != string::npos){
    res.push_back(string(str, current, found - current));
    current = found + 1;
  }
  res.push_back(string(str, current, str.size() - current));
  return res;
}

int main()
{
	int sum = 0;
	vector<int> num;

	string s;
	while(cin >> s)
	{
		vector<string> _s = split(s,',');
		int temp = atoi(_s[0].c_str());
		int temp2 = atoi(_s[1].c_str());
		sum += temp*temp2;
		num.pb(temp2);
	}

	double num_sum = 0;
	rep(i,num.size())
	{
		num_sum += num[i];
	}
	cout << sum << endl;
	cout << (int)(num_sum/num.size() + 0.5) << endl;

	return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
#define M 100000
#define NIL -1

int dep(int,int);
void hyoji(int);

typedef struct{
  int p;
  int l;
  int r;
}Node;
  
Node T[M];
int n,D[M];

int main(){
  int i,j,d,v,c,l,r;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].p = T[i].l = T[i].r = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d",&v,&d);
    for(j = 0; j < d; j++){
      scanf("%d",&c);
      if(j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }

  for(i = 0; i <n; i++){
    if(T[i].p == NIL) r = i;
  }

  dep(r,0);

  for(i = 0; i < n; i++) hyoji(i);

  return 0;
}

int dep(int u, int p){
  D[u] = p;
  if(T[u].r != NIL) dep(T[u].r,p);
  if(T[u].l != NIL) dep(T[u].l,p+1);
}

void hyoji(int u){
  int i,c;

  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p == NIL) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}



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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

ll LCM(int a, int b){
    return a*b/gcd(a,b);
}
int main(void){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    int mi=0,i;
    rep(i,0,n){
        cin>>a[i];
    }
    sort(a.begin(),a.end());

    int ans=1;
    for(int i=k;i<n;i+=k-1)ans++;

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 640
using System.Collections.Generic;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var height = ToInt32(input[0]);
        var width = ToInt32(input[1]);
        var whiteH = new HashSet<int>();
        var whiteW = new HashSet<int>();
        var w = "";
        for(var i = 0; i < width; i++)
        {
            w += ".";
        }
        var strs = new string[height];
        for(var i = 0; i < height; i++)
        {
            strs[i] = ReadLine();
            if (strs[i] == w) whiteH.Add(i);
        }
        for(var i = 0; i < width; i++)
        {
            var isWhite = true;
            for(var j = 0; j < height; j++)
            {
                if (strs[j].Substring(i, 1) == "#") isWhite = false;
            }
            if (isWhite) whiteW.Add(i);
        }
        for(var i = 0; i < height; i++)
        {
            if (whiteH.Contains(i)) continue;
            for(var j = 0; j < width; j++)
            {
                if (whiteW.Contains(j)) continue;
                Write(strs[i].Substring(j, 1));
            }
            WriteLine();
        }
        
    }
}



Measured memory_bytes: 11348
S = input()
l=0
m=0
hoge=0
ho=1

for i in S:
        hoge = (hoge+1)%2
        ho = (ho+1)%2
        if i=="1":
                l+=hoge
                m+=ho
        if i=="0":
                l+=ho
                m+=hoge

print(min(l,m))

Measured memory_bytes: 39664
#include <stdio.h>
int main (){
  long long int a,b,c;
  scanf("%lld %lld %lld", &a,&b,&c);

  long long int d=c-a-b;
  if( ( d>0 ) && ( (4*a*b) < d*d ) )
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}


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

void fst()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
int nxt()
{
    int x;
    cin >> x;
    return x;
}
int nex_l()
{
    long long x;
    cin >> x;
    return x;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define binary(n) cout << bitset<31>(n) << "\n";
#define FOR(i, n) for (int i = 0; i < n; i++)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define input_arr(a, n)         \
    for (int i = 0; i < n; i++) \
        cin >> a[i];
#define print_arr(a, n)         \
    for (int i = 0; i < n; i++) \
        cout << a[i] << " ";
#define deb(n) cerr << #n << "=" << n << "\n";

const int MS = 2e6 + 5, mod = 1e9 + 7;

ll fact[MS];
void cal_fact()
{
    fact[0] = 1;
    for (int i = 1; i < MS; i++)
    {
        fact[i] = i * fact[i - 1];
        fact[i] %= mod;
    }
}
ll binpow(ll val, ll deg, ll mod)
{
    if (!deg)
        return 1 % mod;
    if (deg & 1)
        return binpow(val, deg - 1, mod) * val % mod;
    ll res = binpow(val, deg >> 1, mod);
    return (res * res) % mod;
}

ll cal_c(ll n, ll i)
{
    ll res = fact[n];
    ll div = fact[n - i] * fact[i];
    div %= mod;
    // using fermat little theorum
    div = binpow(div, mod - 2, mod);
    return (res * div) % mod;
}

int main()
{
    cal_fact();
    ll n, k;
    cin >> k;
    string s;
    cin >> s;
    n = s.size();

    ll ans = 0;
    for (int i = n; i <= n + k; i++)
    {
        ans+=cal_c(n+k,i)*binpow(25,n+k-i,mod);
        ans%=mod;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 20916
#include <vector>
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

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


int main(void)
{
	int n;
	cin >> n;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = list(input())

cnt = 0

i = 1
while i < len(s):
    if cnt == k:
        break

    if s[i] != s[i-1]:
        cnt += 1
        start = i
        target = s[i]

        while  i < len(s) and target == s[i]:
            if s[i] == 'R': s[i] = 'L'
            else: s[i] = 'R'

            i += 1   

        continue    

    i += 1

ans = 0
for i in range(1, len(s)):
    if s[i] == s[i-1]:
        ans += 1

print(ans)



Measured memory_bytes: 4084