akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define MOD 1000000007
#define int long long
int MAX(int C,int D){
  if(C>D) swap(C,D);
  while(1){if(D%C==0){return C; break;} //前提
           int X=C;
           C=D%C;
           D=X;
  }
}
int MIN(int C,int D){
  return C*D/MAX(C,D);
}
//Librury
signed main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  double ans=A*B/2.0;
  int ans2=0;
  if(C*2==A&&D*2==B) ans2=1;
  cout<<ans<<" "<<ans2<<endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

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

    ll v,e;
    cin>>v>>e;
    VEC2(g,v,0);
    vector<ll> deg(v);
    FOR(i,0,e){
      ll in1,in2;
      cin>>in1>>in2;
      g[in1].push_back(in2);
      deg[in2]++;
    }
    deque<ll> q;
    FOR(i,0,v){
      if(deg[i] == 0) q.push_back(i);
    }
    vector<ll> ans;
    while(!q.empty()){
      ll x = q.front();
      ans.push_back(x);
      q.pop_front();
      FOR(i,0,g[x].size()){
        deg[g[x][i]]--;
        if(deg[g[x][i]] == 0) q.push_back(g[x][i]);
      }
    }

    FOR(i,0,v){
      cout<<ans[i]<<endl;
    }
}



Measured memory_bytes: 4188
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  size_t n;
  cin >> n;
  map<int,int> mp;
  for(int i=0;i<n;++i){
    cin >> x;
    mp[x]++;
  }
  if(mp.size()==n){ 
    cout << n <<endl;
    return 0;
  }
  int ans=0;
  for(auto i=mp.begin();i!=mp.end();i++){
    ans+=i->second-1;
  }
  if(ans%2==0) cout << (int)n-ans <<endl;
  else cout << (int)n-ans-1 <<endl;
  return 0;
}

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

using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; i++){
        if (i * 2 + (x - i) * 4 == y){
            puts("Yes");
            return 0;
        }
    }

    puts("No");
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

string inttos(int num)
{
    return to_string(num);
}

int stoint(string sss)
{
    return stoi(sss);
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T = 1;
	while(T--)
	{
		int x,y,z;
		cin >> x >> y >> z;
		cout << z << " " << x << " " << y << endl;
	}
}


Measured memory_bytes: 256
M, D = map(int, input().split())
my_list = []
for i in range(1, D + 1): 
    new = []
    number = list(str(i))
    for t in range(0, len(number)):
        new.append(int(number[t]))
    if len(new) == 1:
        continue
    else:
        if new[0] >= 2 and new[1] >= 2:
            for k in range(1, M + 1): 
                if k == (new[0] * new[1]):
                    my_list.append(k)
                    my_list.append(i)
                else:
                    continue
        else:
            continue
print(int(len(my_list) / 2)) 

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)998244353, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, s, i, j, a[3003];
    ll dp[3003][3003] = {};

    scanf("%d%d", &n, &s);
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    dp[0][0] = 1;
    for (i = 0; i < n; i++) for (j = 0; j <= s; j++) {
        dp[i + 1][j] = dp[i][j] * 2 % mod;
        if (j >= a[i]) dp[i + 1][j] = (dp[i + 1][j] + dp[i][j - a[i]]) % mod;
    }

    printf("%lld\n", dp[n][s]);

    return 0;
}

Measured memory_bytes: 74228
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

S = [str(i) for i in input().split()]
ans = ""
for i in range(3):
    ans += S[i][0]
print(ans)


Measured memory_bytes: 5524
#include<iostream>
#define m 1000000
using namespace std;

bool ba[m] = { true };
int cp(int x) {
	if (x < 2)return 0;
	if (x == 2)return 1;

	int co = 0;
	for (int i = 0; i < m; i++) {
		ba[i] = { true };
	}
	for (int i = 2; i*i <= x; i++) {
		if (ba[i]) {
			for (int j = i*i; j <= x; j += i) {
				ba[j] = { false };
			}
		}
	}
	for (int i = 2; i <= x; i++) {
		if (ba[i]) {
			++co;
		}
	}
	return co;
}

int main() {
	int x;
	while (cin >> x) {
		cout << cp(x) << endl;
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    int k, s;
    cin >> k >> s;

    int ans = 0;
    for (int i = 0; i <= k; ++i) {
        for(int j = 0; j <= k; j++){
            int x = i, y = j;
            if(s - (x + y) <= k && s - (x + y) >= 0){
                ans++;
            }            
        }
    }


    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000007
//A=65,a=97

int main() {
    ll n,k;cin >> n >> k;
    ll sum = 0;
    for(ll i = k; i <= n+1; i++) {
        ll x=(0 + i-1)*i/2;
        ll y=(n-i+1 + n)*i/2;
        sum += y-x+1;
        sum %= INF;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3600
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
maxX = max(x)
minY = min(y)
for i in range(X+1,Y,1):
  z = i
  if maxX < z and minY >= z:
    print('No War')
    exit()
print('War')

Measured memory_bytes: 3064
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    string a,b,c;
    cin>>a>>b>>c;
    cout<<(char)(a[0]+'A'-'a')<<(char)(b[0]+'A'-'a')<<(char)(c[0]+'A'-'a')<<endl;

    
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Max(x, y) (((x) > (y)) ? (x) : (y))
#define Min(x, y) (((x) < (y)) ? (x) : (y))
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 1e3 + 10;
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
int sx, sy, tx, ty;
signed main()
{
    sx = read(), sy = read(), tx = read(), ty = read();
    for (ri i = 1; i <= ty - sy; ++i) {
        putchar('U');
    }
    for (ri i = 1; i <= tx - sx; ++i) {
        putchar('R');
    }
    for (ri i = 1; i <= ty - sy; ++i) {
        putchar('D');
    }
    for (ri i = 1; i <= tx - sx; ++i) {
        putchar('L');
    }
    putchar('L');
    for (ri i = 1; i <= ty - sy + 1; ++i) {
        putchar('U');
    }
    for (ri i = 1; i <= tx - sx + 1; ++i) {
        putchar('R');
    }
    putchar('D'), putchar('R');
    for (ri i = 1; i <= ty - sy + 1; ++i) {
        putchar('D');
    }
    for (ri i = 1; i <= tx - sx + 1; ++i) {
        putchar('L');
    }
    putchar('U');
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        if (n < 600){
            System.out.println(8);
        } else if (n < 800){
            System.out.println(7);
        }else if (n < 1000){
            System.out.println(6);
        }else if (n < 1200){
            System.out.println(5);
        }else if (n < 1400){
            System.out.println(4);
        }else if (n < 1600){
            System.out.println(3);
        }else if (n < 1800){
            System.out.println(2);
        }else if (n < 2000){
            System.out.println(1);
        }

        sc.close();

    }

}

Measured memory_bytes: 35800
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	const mod = 1000000007

	n, k := nextInt(), nextInt()

	min, max := 0, 0
	for i := 1; i < k; i++ {
		min += i
		max += n - i + 1
	}

	ans := 0
	for i := k; i <= n+1; i++ {
		ans += max - min + 1
		ans %= mod
		min += i - 1
		max += n - i + 1
	}

	puts(ans)
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
int main(){
	while(true){
		int n,k,s;
		scanf("%d%d%d",&n,&k,&s);
		if(n+k+s==0)break;
		int ans = 0;
		REP(msk,1<<n)if(__builtin_popcount(msk)==k){
			int x = 0;
			REP(i,n)if(msk>>i&1)x += (i+1);
			if(x==s)ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define fast() ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lp(i, n) for(int i = 0; i < n; i++)
#define rlp(i, n) for(int i = n-1; i >= 0; i--)
#define loop(i, a, b) for(int i = a; i <= b; i++)
#define rloop(i, a, b) for(int i = a; i >= b; i--)
#define mem(a, val) memset(a, val, sizeof a);
#define test int t; cin>> t; while(t--)
#define all(v) v.begin(),v.end()
#define ll long long
#define ld long double
#define mp_ make_pair
#define pb push_back
#define sz(s) (int)s.size()
const int MAX = 1e5 + 5;
const int inf = 1e9+1;
const ll OO = 1e18;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
int n, a[MAX][3], dp[MAX][3];
int solve(int i = 0, int lst = -1){
    if(i == n) return 0;

    if(lst != -1 && dp[i][lst] != -1)
        return dp[i][lst];

    int mx = 0;
    lp(j, 3){
        if(j == lst) continue;
        mx = max(mx, solve(i + 1, j) + a[i][j]);
    }
    return dp[i][lst] = mx;
}
int main()
{
    cin>> n;
    lp(i, n){
        lp(j, 3) cin>> a[i][j];
    }
    mem(dp, -1);
    cout<< solve() <<"\n";

    return 0;
}

Measured memory_bytes: 12112
s=input()
scnt,ncnt,wcnt,ecnt=0,0,0,0
for i in range(len(s)):
    if(s[i]=='S'):
        scnt+=1
    elif(s[i]=='N'):
        ncnt+=1
    elif(s[i]=='E'):
        ecnt+=1
    elif(s[i]=='W'):
        wcnt+=1
if((scnt!=0 and ncnt==0) or (scnt==0 and ncnt!=0) or (wcnt>0 and ecnt==0) or (wcnt==0 and ecnt>0)):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 38384
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<ll> arr(n);
    F0R(i,n)
        cin >> arr[i];
    int sw=-1;
    ll tot = arr[0];
    FOR(i,1,n)
    {
        tot+=(sw*arr[i]);
        sw*=-1;
        // cout << tot << endl;
    }
    cout << tot << " ";
    ll prev=tot/2;
    FOR(i,0,n-1)
    {
        cout << 2*(arr[i]-prev) << " ";
        prev=arr[i]-prev;
    }

    return 0;
}


Measured memory_bytes: 2176
// 解き直し.
// https://img.atcoder.jp/abc169/editorial.pdf
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 998244353;
LL dp[3030][3030], a[3030], memo[3030], mPow2[3030];

int main(){
    
    // 1. 入力情報.
    int N, S;
    scanf("%d %d", &N, &S);
    rep(i, N) scanf("%lld", &a[i]);
    
    // 2. 2 の べき乗 を 保存.
    mPow2[0] = 1;
    repx(i, 1, 3030) mPow2[i] = mPow2[i - 1] * 2, mPow2[i] %= MOD;
    
    // 3. dp更新.
    repx(i, 1, N + 1){
        repr(j, S, 0){
            int d = j - (int)a[i - 1];
            if(d > 0 && memo[d]) dp[i][j] += dp[i - 1][d], dp[i][j] %= MOD, memo[j]++;
            if(d == 0)           dp[i][j] += mPow2[i - 1], memo[j]++;
            dp[i][j] += dp[i - 1][j] * 2;
            dp[i][j] %= MOD;
        }
    }
    
    // 4. 出力.
    printf("%lld\n", dp[N][S]);
    return 0;
    
}

Measured memory_bytes: 74760
#include <bits/stdc++.h>
using namespace std;
  
#define fo(i, n) for (long long i = 0; i < n; i++)
#define sc(x) cin >> x
#define pr(x) cout << x << endl;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define br cout << endl
typedef long long int lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
lli max(lli a, lli b){ return (a>b)?a:b; }
lli min(lli a, lli b){ return (a<b)?a:b; }

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

int main()
{
    // Fast Input/Output
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    // Test Cases
    int t = 1;
//    cin >> t;

    while (t--) {
        lli n; sc(n);
        vlli h(n);
        fo(i, n)
        {
            sc(h[i]);
        }
        vlli dp(n);
        dp[0] = 0;
        dp[1] = abs(h[1]-h[0]);
        for(int i=2; i<n; i++)
        {
            dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
        }
        pr(dp[n-1]);
    }
    return 0;
}







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

int main(){
	bool flag = false;
	char s[80];
	int hit[4];
	int i, j, n;

	while(1){
		n = 0;
		for (i = 0; i < 8; i++) {
			if(scanf("%s", s) == EOF){
				flag = true;
				break;
			}
			for (j = 0; j < 8; j++) {
				if(s[j] == '1'){
					hit[n++] = i*8+j;
				}
			}
		}
		if(flag){
			break;
		}
		switch(hit[3] - hit[0]){
			case 9:
				cout << "A" << endl;
				break;
			case 24:
				cout << "B" << endl;
				break;
			case 3:
				cout << "C" << endl;
				break;
			case 15:
				cout << "D" << endl;
				break;
			case 10:
				cout << "E" << endl;
				break;
			case 17:
				cout << "F" << endl;
				break;
			case 8:
				cout << "G" << endl;
				break;
			default:
				cout << "ERROR:" << hit[4] - hit[0] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
const int SIZEN = 200010;
const LL mod = 1e9+7;
struct Link{
    int to,next;
}link[SIZEN << 1];
int head[SIZEN],tot = 0;
int sz[SIZEN] = {0};
LL pw[SIZEN] = {0};
void add(int from,int to){
    link[++tot].to = to;
    link[tot].next = head[from];
    head[from] = tot;
}
int N;
LL ans = 0;
LL qpow(LL x,LL len){
    LL ret = 1;
    for(;len;len>>=1){
        if(len & 1)ret = ret * x % mod;
        x = x * x % mod;
    }
    return ret;
}
void dfs(int x,int fa){
    sz[x] = 1;
    for(int i = head[x];i;i=link[i].next){
        int p = link[i].to;
        if(p == fa)continue;
        dfs(p,x);
        sz[x] += sz[p];
    }
    int tmp = N - sz[x];
    for(int i = head[x];i;i=link[i].next){
        int p = link[i].to;
        if(p == fa)continue;
        ans = (ans + (pw[tmp] - 1)*(pw[sz[p]] - 1)%mod)%mod;
        //printf("%lld,tmp = %d\n",ans,tmp);
        tmp += sz[p];
    }   
}
int main(){
    scanf("%d",&N);
    pw[0] = 1;
    for(int i = 1;i <= N;i++)pw[i] = pw[i-1] * 2 % mod;
    for(int i = 1;i < N;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        add(x,y);add(y,x);
    }
    ans = 0;
    dfs(1,0);
    ans = ans * qpow(pw[N],mod-2) % mod;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 19016
#include<stdio.h>

char a[1300];

int main(void){
    int i;

    fgets(a,1300,stdin);

    i = 0;
    while(a[i] != '\0'){
        if(a[i] >= 'A' && a[i] <= 'Z')
            printf("%c",a[i] + 0x20);
        else if(a[i] >= 'a' && a[i] <= 'z')
            printf("%c",a[i] - 0x20);
        else
            printf("%c",a[i]);
        i++;
    }
    return 0;
}

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

int main(){
    long long A, B, N;
    cin >> A >> B >> N;

    if(B == 1){//B = 1の時は計算しない
        cout << 0 << endl;
        return 0;
    }

    //xはBの倍数-1だけ試す
    long long x = B - 1;
    int i=1;
    int ans = 0;

    if(B > N){
        ans = (A * N) / B - A * (x / B);

        cout << ans << endl;

        return 0;
    }

    while(x <= N){

        int TRY;

        TRY = (A * x) / B - A * (x / B);

        ans = max(ans, TRY);

        i++;

        x = B * i - 1;

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
// In the name of Allah
// #isart
// age daste man bood ...
#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define pii pair<int, int>
#define MP make_pair
#define int long long

using namespace std;

const int MAXN = 2000 + 10, MAXM = 6e6 + 10, mod = 1e9 + 7;
ll dp[MAXN][MAXN]; 
ll fact[MAXM], fact1[MAXM];

ll power(int x, int y){
	if(y == 0) return 1;
	ll mid = power(x, y / 2);
	if(y & 1) return 1ll * mid * mid % mod * x % mod;
	else return mid * mid % mod; 
}

ll choose(int x, int y){
	if(x == y) return 1;
	return fact[x] * fact1[y] % mod * fact1[x - y] % mod;
}

main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int n, k;
	cin >> n >> k; k --;
	if(k == 0) return cout << 1, 0;
	fact[0] = 1;
	for(int i = 1; i < MAXM; i ++) fact[i] = 1ll * fact[i - 1] * i % mod;
	fact1[MAXM - 1] = power(fact[MAXM - 1], mod - 2);
	for(int i = MAXM - 2; i > -1; i --) fact1[i] = 1ll * fact1[i + 1] * (i + 1) % mod;	
	dp[0][0] = 1;
	for(int i = 0; i <= n; i ++){
		for(int j = 0; j <= n; j ++){
			if(i == 0 and j == 0) continue;
			if(i > j) continue;
			if(i <= j - 1)
				dp[i][j] = (dp[i][j] + 1ll * j * choose(i + k * (j - 1) + k - 1, k - 1) % mod * dp[i][j - 1] % mod) % mod;
			if(i > 0) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
		}
	}
	cout << dp[n][n];
}


Measured memory_bytes: 116608
N = int(input())
def calc(n):
    return (n*(n+1))//2
max_n = 0
for i in range(1, N+1):
    if calc(i) >= N:
        max_n = i
        break
for i in range(1, max_n+1):
    if calc(max_n) - N == i:
        continue
    else:
        print(i)

Measured memory_bytes: 3316
N = int(input())
Mod = 10**9 + 7
ans = 1  # パワー

for i in range(1, N + 1):
    ans = (ans * i) % Mod  # 途中計算ごとに%をとってよい
    # ans *= i % (10**9 + 7) としてはいけない
print(ans)

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
  
typedef struct Edge{
    int from;
    int to;
    int num;
}Edge;

int main(void) {
    int n,i,j,k,from,to,num,swi, next = 0;
    int dis[10000];
    Edge *edges,*p;
	
    scanf("%d", &n);
    edges = malloc(sizeof(Edge)*500000);
    for (i=0;i<n; i++) {
        scanf("%d %d", &from, &k);
        for(j=0;j<k;j++){
            scanf("%d %d", &to, &num);
            p = &edges[next++];
            p->from = from;
            p->to = to;
            p->num = num;
        }
        dis[i] = INT_MAX;
    }
    dis[0] = 0;
  
    swi = 1;
    while(swi==1) {
        swi = 0;
        for (i=0;i<next;i++) {
            from = edges[i].from;
            to = edges[i].to;
            num = edges[i].num;
            if (dis[from] < INT_MAX && dis[to] > num+dis[from]) {
                dis[to] = num + dis[from];
                swi = 1;
            }
        }
    }
    for (i=0;i<n;i++) {
        printf("%d %d\n", i, dis[i]);
    }
    return 0;
}


Measured memory_bytes: 7612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<pii>>;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;
    vector<bool> isx(N);
    for (int i = 0; i < N; ++i) {
        char c;
        cin >> c;
        isx[i] = (c == 'x');
    }

    vector<bool> issheep(N);
    for (int i = 0; i < 4; ++i) {
        issheep[0] = i & 1, issheep[1] = i & 2;
        for (int j = 1; j < N - 1; ++j)
            issheep[j + 1] = issheep[j - 1] ^ isx[j] ^ !issheep[j];
        if (issheep[0] != issheep[N - 2] ^ isx[N - 1] ^ !issheep[N - 1])
            continue;
        if (issheep[1] != issheep[N - 1] ^ isx[0] ^ !issheep[0])
            continue;
        for (int j = 0; j < N; ++j)
            cout << (issheep[j] ? 'S' : 'W');
        cout << endl;
        return 0;
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define DS       pair<ll, ll>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5+5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll a[N];

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    ll h, n, sum = 0;
    cin >> h >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    puts(h <= sum ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
        int a,b,d,r;
        double f;

        scanf("%d %d",&a,&b);

        d = a / b;
        r = a % b;
        f = (double)a / b;

        printf("%d %d %f\n",d,r,f);

        return 0;
}

Measured memory_bytes: 636
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll maxi=0,f=0,mini=INF,sum=0;
    string str1,str2;
    ll h,w;
    ll n;
    cin>>n;
    while(1){
        if(n==0) break;
        n=n/2;
        sum++;
    }
    f=1;
    rep(i,sum) f=f*2;
    cout<<f-1<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  string a, b;

  cin>>a>>b;

  if(a=="H"){
    if(b=="H"){
      cout<<"H"<<endl;
    }else if(b=="D"){
      cout<<"D"<<endl;
    }
  }else if(a=="D"){
    if(b=="H"){
      cout<<"D"<<endl;
    }else if(b=="D"){
      cout<<"H"<<endl;
    }
  }

}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int n;
int x[101], y[101], h[101];

int main() {
    cin >> n;
    rep(i, n) cin >> x[i] >> y[i] >> h[i];
    rep(cx, 101) rep(cy, 101) {
        set<int> st;
        bool mins = false;
        rep(i, n) {
            if (h[i] > 0) {
                int a = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
                st.insert(a);
            }
            else {
                mins = true;
            }
        }

        int H = 0;
        bool ok = true;
        if (st.size() == 1) {
            for (auto s : st) H = s;
            if (mins) {
                rep(i, n) {
                    if (h[i] == 0) {
                        if (H - abs(cx - x[i]) - abs(cy - y[i]) > 0) ok = false;
                    }
                }
            }
        }

        if (ok and st.size() == 1) {
            cout << cx << ' ' << cy << ' ' << H << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(void){
  int K;
  cin >> K;
  int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << a[K-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
template <class T>
T powmod(T a, ll b, ll m){
	T res = 1;
	while(b){
		if(b % 2){
			res *= a;
			res %= m;
		}
		a = (a * a) % m;
		b /= 2;
	}
	return res;
}

int cnt[101];
int C(int n, int r){
	if(n < r){
		return 0;
	}
	int res = 1;
	int v1 = n - r, v2 = r;
	if(v1 < v2)
		swap(v1, v2);
	for(int i = v1 + 1; i <= n; i++){
		res *= i;
	}
	for(int i = 1; i <= v2; i++){
		res /= i;
	}
	return res;
}

int mod = 1e9 + 7;
int32_t main(){
	cnt[0] = 0;
	string s;
	cin >> s;
	int n = s.size();
	int k;
	cin >> k;
	int ans = 0;
	if(k == 1){
		ans = s[0] - '0';
		ans += 9 * (n - 1);
	}else if(k == 2){
		bool x = false;
		for(int i = 1; i < n; i++){
			if(x){
				ans += 9;
			}else{
				ans += s[i] - '0';
			}
			if(s[i] != '0'){
				x = true;
			}
		}
		ans += C(n - 1, 2) * 9 * 9;
		ans += C(n - 1, 1) * (s[0] - 1 - '0') * 9;
	}else{
		bool x = false;
		for(int i = 1; i < n; i++){
			bool y = x;
			for(int j = i + 1; j < n; j++){
				if(x){
					ans += 9 * 9;
				}else if(y){
					ans += (s[i] - '0') * 9;
				}else{
					if(s[i] != '0')
						ans += (s[i] - '0' - 1) * 9 + s[j] - '0';
				}
				if(s[j] != '0'){
					y = true;
				}
			}
			if(s[i] != '0'){
				x = true;
			}
		}
		ans += C(n - 1, 3) * 9 * 9 * 9;
		ans += C(n - 1, 2) * (s[0] - 1 - '0') * 9 * 9;	
	}
	cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    int x = 0, ans = 0;
    for (char &c : S) {
        if (c == 'I') x++;
        else x--;
        ans = max(ans, x);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
w_arr = Array.new(10) { |i| i=0 }
k_arr = Array.new(10) { |i| i=0 }

10.times do |i|
  w_arr[i] = gets.to_i
end

10.times do |i|
  k_arr[i] = gets.to_i
end

 w = w_arr.sort! {|a, b| b <=> a }
 k = k_arr.sort! {|a, b| b <=> a }
 puts "#{w[0]+w[1]+w[2]} #{k[0]+k[1]+k[2]}"

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

using namespace std;

int main()
{
    int n , k;

    cin >> n >> k;

    int arr[n];

    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }

    sort(arr, arr + n);

    int sum = 0;

    for(int i = 0; i < k; i++)
    {
        sum += arr[i];
    }

    cout << sum << endl;

    return 0;
}


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

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

	int i = 0;
	while (i <  K) {
		if(A >= B){
			B *= 2;
			i++;
		}
		else if(B >= C){
			C *= 2;
			i++;
		}
		else {
			break;
		}
	}

	if(A < B){
		if(B < C){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
     Scanner scan = new Scanner(System.in);
     for(int i = 1;i <= 10000;i++){
         int x = scan.nextInt();
         if(x == 0){
             i = 10001;
         }else{
             System.out.println("Case " + i + ": " + x);
         }
     }
    }
}


Measured memory_bytes: 41792
#include <iostream>

using namespace std;

int max (int a, int b) {return (a>b)?a:b;}

int main () {

	long long a, b;
	long long x, y;

	long long n;

	cin >> n;

	cin >> x >> y;

	//	cout << "after " << 1 << " trials, the values are " << x << " " << y << endl;


	for (long long i=1; i<n; i++) {
		cin >> a >> b;



		long long t = max((x-1)/a + 1, (y-1)/b + 1);

		a *= t;
		b *= t;

		x = a;
		y = b;

	//	cout << "after " << i + 1 << " trials, the values are " << x << " " << y << endl;

	}

	cout << x + y << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();
 		Integer Size[] = new Integer[N];
 		for (int i = 0; i < N; i++) {
 			Size[i] = scanner.nextInt();
 		}
 		Arrays.sort(Size, Collections.reverseOrder());
 		for (int j = 0; j < N; j++) {
 			if (Size[j] < K) {
 				System.out.println(j);
 				break;
 			}
 		}
 		if (Size[N - 1] >= K) {
				System.out.println(N);
		}
	}
}

Measured memory_bytes: 60164
#include <iostream>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  int i,j;
  for(i=0;i<=x;i++){
    if(i*2+(x-i)*4==y){
      cout << "Yes" << "\n";
      return 0;
    }
  }
  cout << "No" << "\n";
  return 0;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    if(n%k == 0) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl                endl

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int x, int y) {                                                             //return x^y in order(log(y))
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
struct trio {
  T first{};
  T second{};
  T third{};
};
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class AStudyScheduling {
public:
  static void solve(istream &cin, ostream &cout) {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int time = 60 * (H2 - H1) + (M2 - M1);
    cout << time - K << endl;
  }
};


signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  AStudyScheduling solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3696
mod = 998244353

def comb(n, r):
    if 2 * r > n: return comb(n, n-r)
    return fac[n] * inv[r] * inv[n-r] % mod

n, a, b, k = map(int, input().split())

fac = [1] * (n+2)
inv = [1] * (n+2)
for i in range(2, n+1):
    fac[i] = fac[i-1] * i % mod
inv[n] = pow(fac[n], mod - 2, mod)
for i in range(n-1, 1, -1):
    inv[i] = inv[i + 1] * (i + 1) % mod

ans = 0
for i in range(n+1):
    Num = (k-a*i)
    if (0 <= Num//b) and (Num//b <= n) and (Num%b == 0):
      j = Num//b 
      ans += comb(n, i) * comb(n, j) 
print(ans%mod)

Measured memory_bytes: 49892
def cmb(n, r, MOD):
    r = min(r, n - r)
    n1 = n + 1
    numerator = denominator = 1
    for i in range(1, r + 1):
        numerator = (numerator * (n1 - i)) % MOD
        denominator = (denominator * i) % MOD
    return (numerator * pow(denominator, MOD - 2, MOD)) % MOD


n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
print((pow(2, n, MOD) - cmb(n, a, MOD) - cmb(n, b, MOD) - 1) % MOD)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>

using namespace std;

int main(void)
{
	int N, M, C;
	int B[20];
	int A[20][20];

	cin >> N >> M >> C;

	for (int i = 0; i < M; i++) cin >> B[i];

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			cin >> A[i][j];
		}
	}

	int total =0;
	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		total = 0;

		for (int j = 0; j < M; j++)
		{
			total += A[i][j] * B[j];
		}

		if (total + C > 0)
		{
			ans++;
		}
	}

	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};



int main() {
    double a,b,x;
    cin >>a>>b>>x;
    double ans ;
    if(a*a*b<2*x){
        ans = atan(2.0*(a*a*b-x)/(a*a*a))*180/M_PI;
    }else{
        ans = atan(a*b*b/(x*2.0))*180/M_PI;
    }


    cout << fixed << setprecision(15) << ans << endl;
    return 0;
    

}


Measured memory_bytes: 4068
S = str(input())

if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
elif S == 'SAT':
    print(1)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int h,w;  cin >> h >> w;
  vector<vi> a(h,vi(w));  rep(i,h) rep(j,w) cin >> a[i][j];
  int ans = 0;
  vector<pair<int,int>> now,next;
  rep(i,h) rep(j,w){
    if(a[i][j]%2){
      if(j+1 < w){
        ans++;
        now.push_back({i+1,j+1});
        next.push_back({i+1,j+2});
        a[i][j+1] += a[i][j];
      }else{
        if(i+1 < h){
          ans++;
          now.push_back({i+1,j+1});
          next.push_back({i+2,j+1});
          a[i+1][j] += a[i][j];
        }
      }
    }
  }
  cout << ans << endl;
  rep(i,ans) cout << now[i].first <<" "<< now[i].second <<" " << next[i].first <<" "<< next[i].second << endl;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 6300
#include <bits/stdc++.h>
using namespace std;
#define NIL -1
#define MAX 25

struct node
{
	int parent, left, right;
	node() {
		parent = left = right = NIL;
	}
} T[MAX];

int D[MAX], H[MAX];

int getSibling(int i)
{
	int p = T[i].parent;
	if (p != NIL)
	{
		if (T[p].left == i)
			return T[p].right;
		else
			return T[p].left;
	}
	else
	{
		return NIL;
	}
}

int getDegree(int i) 
{
	int cnt = 0;
	if (T[i].left != NIL)
		cnt++;
	if (T[i].right != NIL)
		cnt++;
	return cnt;
}

void setDepth(int i, int d)
{
	D[i] = d;
	if (T[i].left != NIL) 
		setDepth(T[i].left, d + 1);
	if (T[i].right != NIL) 
		setDepth(T[i].right, d + 1);
}

int setHeight(int i) 
{
	int h1 = 0, h2 = 0;
	if (T[i].left != NIL)
		h1 = setHeight(T[i].left) + 1;
	if (T[i].right != NIL)
		h2 = setHeight(T[i].right) + 1;
	return H[i] = (h1 > h2 ? h1 : h2 );
}

void print(int i) 
{
	cout << "node " << i << ": parent = " << T[i].parent;
	cout << ", sibling = " << getSibling(i) << ", degree = ";
	cout << getDegree(i) << ", depth = " << D[i] << ", height = ";
	cout << H[i] << ", ";
	if (T[i].parent == NIL) 
		cout << "root\n";
	else if (T[i].left != NIL || T[i].right != NIL)
		cout << "internal node\n";
	else
		cout << "leaf\n";
}

int main(void) 
{
	int n, id, l, r, i;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> id >> l >> r;
		if (l != NIL)
		{
			T[id].left = l;
			T[l].parent = id;
		}
		if (r != NIL) 
		{
			T[id].right = r;
			T[r].parent = id;
		}
	}

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

	setHeight(i);
	setDepth(i, 0);

	for (i = 0; i < n; i++) {
		print(i);
	}
}


Measured memory_bytes: 3096
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] count = new int[n + 10];
        long res = 1;
        for (int i = 1; i <= n; i++)
        {
            var factor = factors(i);
            foreach (var item in factor)
            {
                count[item]++;
            }
        }
        foreach (var item in count)
        {
            res *= (item + 1);
            res %= 1000000007;
        }
        Console.WriteLine(res);
    }

    static int[] factors(int n)
    {
        int i = 2;
        List<int> res = new List<int>();
        while (i * i <= n)
        {
            if (n % i == 0)
            {
                res.Add(i);
                n /= i;
            }
            else
            {
                i++;
            }
        }
        if (n != 1) res.Add(n);
        return res.ToArray();
    }
}

Measured memory_bytes: 11092
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
using namespace std;
using ll = long long;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;
const ll mod=1e9+7;

ll frac[200001];

void modcalc(){
      frac[0]=1;
      for(int i=1;i<=200000;i++){
            frac[i]=(frac[i-1]*i)%mod;
      }
}

int main(){
      modcalc();
      int n;
      cin>>n;
      string s;
      cin>>s;
      string t;
      for(int i=0;i<s.size();i++){
            if(i%2==0){
                  if(s[i]=='B'){
                        t.push_back('L');
                  }
                  else t.push_back('R');
            }
            else{
                  if(s[i]=='B'){
                        t.push_back('R');
                  }
                  else t.push_back('L');
            }
      }
      ll countl=0;
      ll countpair=0;
      ll ans=1;
      for(int i=0;i<t.size();i++){
            if(t[i]=='L'){
                  countl++;
            }
            else{
                  ans=(ans*countl)%mod;
                  countpair++;
                  countl--;
                  //cout<<ans<<endl;
            }
      }
      //cout<<t<<endl;
      if(countl==0){
            cout<<(ans*frac[countpair])%mod<<endl;
      }
      else{
            cout<<0<<endl;
      }
      return 0;
}

Measured memory_bytes: 2436
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai 3.14159265358979323846264338327950288;
#define keta(n) cout << fixed << setprecision((n));
using ll = long long;
int main(){
  string s;
  cin>>s;
  int ans = s.size();
  cout<<s[0]<<ans-2<<s[ans-1];

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int a1 = scanner.nextInt();
        final int a2 = scanner.nextInt();
        final int a3 = scanner.nextInt();
        System.out.println(a1 + a2 + a3 >= 22 ? "bust" : "win");
    }
}


Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
template<class T>
struct Sum2D{
  vector<vector<T>> d;
  Sum2D(int h, int w, const vector<vector<T>> &input):d(h, vector<T>(w, 0)){
    for(int i = 0; i < h; ++i)
      for(int j = 0; j < w; ++j){
        d[i][j] = input[i][j];
        if(i) d[i][j] += d[i-1][j];
        if(j) d[i][j] += d[i][j-1];
        if(i && j) d[i][j] -= d[i-1][j-1]; // 2重に数え上げたやつを引いている
      }
  }
  inline T getSum(int ph, int pw){ // 0,0 - ph,pw 閉区間
    if(ph < 0 || pw < 0)  return 0;
    //長方形のはみだしを許容するならコメントアウトした方が早い
    //if(ph >= h || pw >= w) return 0;
    return d[ph][pw];
  }
  inline T getSum(int p1h, int p1w, int p2h, int p2w){ // p2の方が外側にあること！！
    //cerr << getSum(p2h,p2w) <<" "<< getSum(p2h, p1w-1) <<" "<< getSum(p1h-1, p2w) <<" "<< getSum(p1h-1, p1w - 1) << endl;;
    return getSum(p2h,p2w) - getSum(p2h, p1w-1) - getSum(p1h-1, p2w) + getSum(p1h - 1, p1w - 1);
  }
};

int main(){
  int n,k; cin >> n >> k;
  vt<vt<ll>> a(k+1,vt<ll>(k+1,0));
  vt<vt<ll>> b(k+1,vt<ll>(k+1,0));
  rep(i,n){
    // 黒で0,0 k-1,k-1領域にある同値な条件にいいかえておく
    int x,y; char c; cin >> x >> y >> c;
    if((x/k + y/k) % 2 == 0 && c == 'B'){
      a[x%k][y%k]++;
    }else if((x/k + y/k) % 2 == 1 && c == 'W'){
      a[x%k][y%k]++;
    }else{
      b[x%k][y%k]++;
    }
  }
  Sum2D<ll> s(k+1,k+1,a);
  Sum2D<ll> s2(k+1,k+1,b);
  int ans = max(s.getSum(0,0,k,k), n - s.getSum(0,0,k,k));
  rep(i,k)rep(j,k){
    int tans = s.getSum(0,0,i,j) + s.getSum(i+1,j+1,k,k) + s2.getSum(0,j+1,i,k) + s2.getSum(i+1,0,k,j);
    tans = max(tans, n - tans);
    ans = max(ans, tans);
  }
  cout << ans << endl;
}


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


#define int         long long
#define fast        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
int mod = 1000000007;
int mod2 = 998244353;
/*
//int arr[100000]={};
int binarysearch(int a[],int n,int s)
{
    int l=0,h=n-1,mid,ans = -1;
    while(l<=h)
    {
        mid = l + (h-l)/2;
        if(a[mid]<=s)
        {
            ans = mid;
            l = mid + 1;
        }
        else h = mid - 1;
    }
    //ans = max(ans,k);
    return ans;
}
/*
bool isprime(int n)
{
    int x = sqrt(n),f=0;
    for(int i=2;i<=x;i++)
    {
        if(n%i==0)
        {
            f=1;
            break;
        }
    }
    if(f)
    return false;
    else return true;
}

int find1(int n)
{
    int mn = 9;
    int x = n,s;
    while(x>=1)
    {
        s = x%10;
        mn = min(mn,s);
        x /= 10;
    }
    return mn;
}

int find2(int n)
{
    int mn = 0;
    int x = n,s;
    while(x>=1)
    {
        s = x%10;
        mn = max(mn,s);
        x /= 10;
    }
    return mn;
}
int recurs(int n,int k)
{
    if(k==1)
        return n;
    if(find1(n)==0)
        return n;
    return recurs(n + (find1(n)*find2(n)) , --k);
}*/
signed main()
{
    fast;
    int t = 1;

    //cin>>t;

    while(t--)
    {
        int n=0,m=0,k=0,r=0,f=0,cnt=0,x=0,l=0,y=0,z=0,mx=0,sum=0,mini=INT_MAX,mn=INT_MAX;
        string s,str;
        cin>>n>>s;
        if(s.length()<=n)    cout<<s;

        else {
            for(int i=0;i<n;i++)
                cout<<s[i];
        
        cout<<"...";}
    }
	cerr << "\nTime elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
}


Measured memory_bytes: 3864
N = int(input())
a = list(map(int, input().split()))

a_hash = {}
for i in range(N):
    if a[i] in a_hash:
        a_hash[a[i]] += 1
    else:
        a_hash[a[i]] = 1

a_sort = sorted(a_hash.items(), key = lambda x: x[0])
a_sort = list(a_sort)
ans_list = [0] * N

if len(a) == 1:
    print(1)
    exit()
if len(a_sort) == 1:
    print(a_sort[0][1])
    exit()

for i in range(len(a_sort)):
    if i == 0:
        if a_sort[0][0] == a_sort[1][0] - 1:
            ans_list[0] += a_sort[0][1] + a_sort[1][1]
    elif i == len(a_sort) -1:
        if a_sort[i][0] == a_sort[i-1][0] + 1:
            ans_list[i] += a_sort[i][1] + a_sort[i-1][1]
        else:
            ans_list[i] = a_sort[i][1]
    else:
        if a_sort[i][0] == a_sort[i-1][0] + 1:
            ans_list[i] += a_sort[i][1] + a_sort[i-1][1]
        if a_sort[i][0] == a_sort[i+1][0] - 1:
            ans_list[i] += a_sort[i+1][1]


print(max(ans_list))

Measured memory_bytes: 15968