akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.algorithm;
import std.conv;
import std.numeric;
import std.math;
import std.string;

void main()
{
	auto n = to!int(chomp(readln()));
	int[] v;
	foreach (token; split(chomp(readln())))
	{
		v ~= to!int(token);
	}
	int[int] cnt0, cnt1;
	foreach (i, e; v)
	{
		if (i % 2 == 0)
		{
			++cnt0[e];
		}
		else
		{
			++cnt1[e];
		}
	}
	int sum0, sum1;
	int[2][] arr0, arr1;
	foreach (key; cnt0.keys)
	{
		arr0 ~= [key, cnt0[key]];
	}
	arr0.sort!"a[1] > b[1]"();
	foreach (key; cnt1.keys)
	{
		arr1 ~= [key, cnt1[key]];
	}
	arr1.sort!"a[1] > b[1]"();

	int i, j;
	while (arr0[i][0] == arr1[j][0])
	{
		int d0 = arr0[i][1] - arr0[i+1][1];
		int d1 = arr1[j][1] - arr1[j+1][1];
		if (d0 < d1 && i < arr0.length - 1) ++i;
		else if (j < arr1.length - 1) ++j;
		else
		{
			i = j = -1;
			break;
		}
	}
	int result;
	if (i == -1) result = arr1[0][1];
	else
	{
		foreach (ai, e; arr0)
		{
			if (ai == i) continue;
			result += e[1];
		}
		foreach (ai, e; arr1)
		{
			if (ai == j) continue;
			result += e[1];
		}
	}

	writeln(result);
	stdout.flush();
}

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

using namespace std;

typedef long long lol;
const int mod = 998244353;
inline int pls( int a , int b ) { a += b - mod; return a + ( a >> 31 & mod ); }
inline int mns( int a , int b ) { a -= b; return a + ( a >> 31 & mod ); }
inline void inc( int & a , int b ) { a += b - mod; a += a >> 31 & mod; }
inline void dec( int & a , int b ) { a -= b; a += a >> 31 & mod; }
inline int fpow( int base , int k ) {
  int res = 1;
  while( k ) {
    if( k & 1 ) res = (lol)res * base % mod;
    base = (lol)base * base % mod; k >>= 1;
  }
  return res;
} int _w;

const int N = 3e2 + 5;

int f[N][N][N] , n , k , sum[N] , m , ss[N];
char str[N];

int main( void ) {
  _w = scanf("%s%d",str+1,&k);
  n = strlen( str + 1 );
  str[n + 1] = '0';
  for( int i = 0 , r ; i <= n ; i = r ) {
    r = i + 1;
    while( r <= n && str[r] != '0' ) ++r;
    sum[++m] = r - i - 1;
  }
  for( int i = m ; i ; --i ) ss[i] = ss[i + 1] + sum[i];
  k = min( k , ss[1] );
  f[0][0][0] = 1;
  for( int i = 1 , s = 0 ; i <= m ; s += sum[i] , ++i ) 
    for( int j = s ; j <= ss[1] ; ++j )
      for( int l = 0 ; l <= k ; ++l ) if( f[i - 1][j][l] ) 
        for( int p = 0 ; p + j <= ss[1] && l + p - sum[i] <= k ; ++p ) {
          inc( f[i][j + p][l + max( p - sum[i] , 0 )] , f[i - 1][j][l] );
        }
  int ans = 0;
  for( int i = 0 ; i <= k ; ++i )
    inc( ans , f[m][ss[1]][i] );
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 17988
#include <stdio.h>

#define MAX 15

int guchoku(const int *start, const int *goal, int num) {
	int status[MAX];
	int i, j;
	int count = 0;
	for (i = 0; i < num; i++) {
		status[i] = start[i];
	}
	for (i = 0; i < num; i++) {
		if (status[i] != goal[i]) {
			for (j = i + 1; j < num; j++) {
				if (status[j] == goal[i]) break;
			}
			if (j >= num) return MAX * MAX + 10;
			for (; j > i; j--) {
				int temp = status[j];
				status[j] = status[j - 1];
				status[j - 1] = temp;
				count++;
			}
		}
	}
	return count;
}

int main(void) {
	int N, M;
	int b[MAX];
	int p[MAX];
	int target[MAX];
	int start, current, phase, left;
	int i;
	int answer = -1, candidate;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &b[i]) != 1) return 1;
	}
	for (i = 0; i < M; i++) {
		if (scanf("%d", &p[i]) != 1) return 1;
	}
	for (start = 0; start <= 1; start++) {
		current = start;
		phase = 0;
		left = p[0];
		for (i = 0; i < N; i++) {
			target[i] = current;
			left--;
			if (left <= 0) {
				current = 1 - current;
				phase++;
				left = p[phase];
			}
		}
		candidate = guchoku(b, target, N);
		if (answer < 0 || candidate < answer) answer = candidate;
	}
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 600
//https://atcoder.jp/contests/abc144/tasks/abc144_a
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a;
	cin>>a;
	ll b;
	cin>>b;
	if((a>9)||(b>9))
	{
		cout<<"-1"<<"\n";
	}
	else
	{
		cout<<a*b<<"\n";
	}
	return 0;
	
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define ITR(i,x) for(auto i=(x).begin();i!=(x).end();++i)
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int mod = 1000000007;

bool square(ll a){ll n=(ll)sqrt(a);return a==n*n;}
int digitsum(ll N,int a);//a進数におけるNの各桁の和、計算量はloga(N)
ll mpow(ll x, ll n);
ll inv_mod(ll a){return mpow(a,mod-2);}
int gcd(int x,int y){return y ? gcd(y,x%y) : x;};//xとyの最大公約数
int lcm(int x,int y){return x*y/gcd(x,y);}//xとyの最小公倍数

int main(){
    int N,K;
    cin>>N>>K;
    vector<ll> h(N);
    REP(i, N) cin >> h[i];
    vector<ll> dp(N);
    dp[0]=0;
    rep(i,1,N){ 
        dp[i]=LLONG_MAX;
        REP(j,K+1){
            if(i-j>=0){ 
                ll r=dp[i-j]+llabs(h[i-j]-h[i]);
                dp[i]=min(dp[i],r);
            }
            
        }
        // cout<<dp[i]<<endl;
    }
    cout<<dp[N-1]<<endl;
}

int digitsum(ll N,int a){
    if(N==0) return 0;
    int ret=0;
    ret+=digitsum(N/a,a)+N%a;
    return ret;
}
ll mpow(ll x, ll n){ //x^n(mod division) ←普通にpow(x,n)では溢れてしまうため，随時mod計算 2分累乗法だから早い
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}
/*
class Factorial{//階乗とその逆元を求めて計算に利用するクラス
private:
    vector<ll> fac;
public:
    
    Factorial(ll N){
        fac.push_back(1);
        for(int i=0;i<N;i++) fac.push_back(fac[i]*(i+1)%mod);
    }

    ll fact(ll a){return fac[a];}
    ll ifact(ll a){return inv_mod(fac[a]);}

    ll cmb(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0) return 0;
        ll tmp =ifact(a-b)*ifact(b)%mod;
        return tmp*fac[a]%mod;
    }
};
*/

/*
class UnionFind{//UnionFind木
 private:
    vector<int> Parent;
 public:
    UnionFind(int N){
        for(int i=0;i<N;i++) Parent.push_back(-1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A]=root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]-=Parent[B];
        Parent[B]=A;
    }
};
*/

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}

public class Main {
  private static int solve(int n, int c, int k, int[] t) {
    Arrays.sort(t);
    
    int numBus = 0;
    int numPeople = 0;
    int minT = 0;
    for (int ti : t) {
      if (numPeople == 0 || minT + k < ti) {
        numPeople = 1;
        minT = ti;
        numBus++;
      } else {
        numPeople++;
      }
      if (numPeople >= c) {
        numPeople = 0;
      }
    }
    return numBus;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int c = reader.nextInt();
    int k = reader.nextInt();
    int[] t = reader.nextIntArray(n);
    out.println(solve(n, c, k, t));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}



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

using namespace std;

#define FOR(var, start, end) for (int var = start; var < end; var++)
#define REP(var, cnt) FOR(var, 0, cnt)

int A[110][2];
vector<int> edges[110];

int matched[110];

int dfs(int v, vector<int> &visited) {
  for (int u : edges[v]) {
    if (find(visited.begin(), visited.end(), u) != visited.end()) {
      continue;
    }

    visited.push_back(u);

    if (matched[u] == -1 || dfs(matched[u], visited)) {
      matched[u] = v;
      return 1;
    }
  }
  return 0;
}

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

  REP(i, N) {
    int x, y;
    cin >> x >> y;
    A[i][0] = x;
    A[i][1] = y;

    matched[i] = -1;
  }

  REP(i, N) {
    int x, y;
    cin >> x >> y;

    REP(j, N) {
      if (A[j][0] < x && A[j][1] < y) {
        edges[i].push_back(j);
      }
    }
  }

  int ret = 0;
  REP(i, N) {
    vector<int> aa;
    ret += dfs(i, aa);
  }

  cout << ret << endl;
}


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

int main(){
    int x,n;
    cin >> x >> n;
    set<int> p;
    rep(i,n){
        int a;
        cin >> a;
        p.insert(a);
    }
    int ans = 0;
    int minii = 10000;
    //sort(p.begin(),p.end());
    for(int i=200; i>=-200; i--){
        if(p.count(i)){continue;} 
        //cout << abs
        else if(abs(x-i) <=minii){
            minii = abs(x-i);
            ans = i;
            //cout << i << endl;
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3632
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=MOD;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=200005;
int f[N+1],inf[N+1];
int C(int n,int r)
{
    if(r>n)
        return 0;
    int ans=(f[n]*inf[r])%hell;
    return (ans*inf[n-r])%hell;
}
void pre()
{
    f[0]=1;
    for(int i=1;i<=N;i++)
        f[i]=(f[i-1]*i)%hell;
    inf[N]=power(f[N],hell-2,hell);
    for(int i=N-1;i>=0;i--)
        inf[i]=(inf[i+1]*(i+1))%hell;
}

void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    int ans=0,z;
    for(int i=0;i<=k;i++)
    {
        int z=C(n-1,i);
        z=(z*power(m-1,n-1-i,hell))%hell;
        ans=(ans+z)%hell;
    }
    ans=(ans*m)%hell;
    cout<<ans<<endl;
    
    
    
}

int32_t main()
{
    IOS;
    pre();
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

const long long INF = (1LL << 60);

int main(){

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

    long long ans = INF;
    long long leftSum = 0;
    long long rightSum = 0;
    for(long long temp: A){
        rightSum += temp;
    }

    ans = min(ans, rightSum);
    for(long long temp: A){
        leftSum += temp;
        rightSum -= temp;
        ans = min(ans, abs(leftSum - rightSum));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    char S[N];
    string num = "Three";
    for(int i=0;i<N;i++){
        cin >> S[i] ;
        if(S[i] == 'Y'){
            num = "Four";
        }
    }
    cout << num <<endl;
}

Measured memory_bytes: 3636
# coding: utf-8
# ABC051 C - Back and Forth
"""
0 0 1 2
UURDDLLUUURRDRDDDLLU
"""

sx, sy, tx, ty = map(int, input().split())

# YU1
[print("U", end="") for y in range(ty - sy)]

# XR1
[print("R", end="") for x in range(tx - sx)]

# YD1
[print("D", end="") for y in range(ty - sy)]

# XL1
[print("L", end="") for x in range(tx - sx)]

# XL2
print("L", end="")

# YU2
[print("U", end="") for y in range(ty - sy + 1)]

# XR2
[print("R", end="") for x in range(tx - sx + 1)]

# YD2
print("D", end="")

# XR2
print("R", end="")

# YD3
[print("D", end="") for y in range(ty - sy + 1)]

# XL3
[print("L", end="") for x in range(tx - sx + 1)]

# YU3
print("U", end="")

print()


Measured memory_bytes: 4468
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var bf = Console.ReadLine();
            var af = "";
            var dict = new Dictionary<string, int>();
            dict[bf] = 0;

            for (var i = 1; i < N; i++)
            {
                af = Console.ReadLine();
                if (bf[bf.Length-1] != af[0] || dict.ContainsKey(af))
                {
                    Console.WriteLine("No");
                    return;
                }

                dict[af] = 0;
                bf = af;
            }

            Console.WriteLine("Yes"); 
        }
    }
}


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

const int MAXN = 3e2 + 10;
long long a[MAXN];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
    }
    long long s = 0;
    for (int i = 3; i <= n; i++) {
        s ^= a[i];
    }
    if ((s ^ a[1] ^ a[2]) == 0) {
        puts("0");
        return 0;
    }

    // x, a[1] + a[2] - x = y
    // max(x)
    // x ^ y = s;
    // x + y = a[1] + a[2];
    // a[1] + a[2] = s + 2 * (x & y)
    // x & y = w = (a[1] + a[2] - s) / 2
    // ^ = 0, & = 0, (0, 0)
    // ^ = 0, & = 1, (1, 1)
    // ^ = 1, & = 0, (1, 0) || (0, 1)
    // ^ = 1, & = 1, imposible
    if ((a[1] + a[2]) % 2 != s % 2) {
        puts("-1");
        return 0;
    }
    if (a[1] + a[2] < s) {
        puts("-1");
        return 0;
    }
    long long w = (a[1] + a[2] - s) / 2;

    long long x = 0, y = 0;
    for (int i = 60; i >= 0; i--) {
        long long u = (s >> i) & 1LL;
        long long v = (w >> i) & 1LL;
        if (u == 0 && v == 0) {
            
        } else if (u == 0 && v == 1) {
            x |= (1LL << i);
            y |= (1LL << i);
        } else if (u == 1 && v == 1) {
            puts("-1");
            return 0;
        }
    }
    //cout << s << " " << w << endl;
    //cout << x << " " << y << endl;
    for (int i = 60; i >= 0; i--) {
        long long u = (s >> i) & 1LL;
        long long v = (w >> i) & 1LL;
        if (u == 1 && v == 0) {
            long long cur = x | (1LL << i);
            if (cur <= a[1]) {
                x |= (1LL << i);
            }
            cur = y | (1LL << i);
            if (cur <= a[1]) {
                y |= (1LL << i);
            }
        }
    }
    if (max(x, y) > a[1]) {
        puts("-1");
        return 0;
    }
    if (max(x, y) == 0) {
        puts("-1");
        return 0;
    }

    //cout << x << " " << y << endl;
    printf("%lld", a[1] - max(x, y));
    return 0;
}


Measured memory_bytes: 3828
#include<stdio.h>
char a[2000000],b[2000000];
void str(void){
  int c,i,sw=0,j;
  char cp;
  j=0;
  sw=0;
  // printf("point1\n");
  for(i=0;a[i]!='\0';i++){
    if(sw==0){
      cp=a[i];
      c=1;
      sw=1;
      continue;
    }
    else{
      // printf("point2\n");
      if(cp==a[i]){
	c++;
      }
      else{
	if(c>=100){
	  b[j]=c/100+'0';
	  c%=100;
	  j++;
	}
	if(c>=10){
	  b[j]=c/10+'0';
	  c%=10;
	  j++;
	}
	b[j]=c+'0';
	j++;
	b[j]=cp;
	j++;
	sw=0;
	i--;
	//	printf("point3 %c%c%c\n",b[0],b[1],b[2]);//
      }
    }
  }
  if(sw==1){
    // printf("point4\n");

    if(c>=100){
      b[j]=c/100+'0';
      c%=100;
      j++;
    }
    if(c>=10){
      b[j]=c/10+'0';
      c%=10;
      j++;
    }
    b[j]=c+'0';
    j++;
    b[j]=cp;
    j++;
    sw=0;
    i--;
    //   printf("point3 %c%c%c\n",b[0],b[1],b[2]);//
  }
  b[j]='\0';
  return;
}

int main(){
  int i,n,j;
 
  while(1){
    for(i=0;i<2000000;i++){
      a[i]=b[i]=0;
    }
  
    scanf("%d",&n);
    if(n==0)break;
    scanf("%s",a);
    for(i=0;i<n;i++){
      str();
      // printf("%c%c%c\n",b[0],b[1],b[2]);//
      for(j=0;b[j]!='\0';j++){
	a[j]=b[j];
      }
      a[j]='\0';
    }
    for(i=0;a[i]!='\0';i++){
      printf("%c",a[i]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 4904
#include <cstdio>
#define MAX 10000
#define NIL -1

struct Node {
  int parent,left,right;
};

Node T[MAX];
int n,D[MAX],H[MAX];

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

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

int getsibling(int u){
  if (T[u].parent == NIL) return NIL;
  if (T[T[u].parent].left != u && T[T[u].parent].left != NIL)
  return T[T[u].parent].left;
  if (T[T[u].parent].right != u && T[T[u].parent].right != NIL)
  return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getsibling(u));
  int deg = 0;
  if(T[u].left != NIL)deg++;
  if(T[u].right != NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }else printf("internal node\n");
}

int main() {
  int v,l,r,root = 0;
  scanf("%d",&n);
  for(int i=0; i < n ; i++)T[i].parent = NIL;

  for (int i = 0; i < n; i++) {
    scanf("%d %d %d",&v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL)T[l].parent = v;
    if(r != NIL)T[r].parent = v;
  }

  for(int i=0; i < n; i++) if(T[i].parent == NIL) root = i;

  setDepth(root,0);
  setHeight(root);

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



Measured memory_bytes: 2768
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ll A[N]; F0R(i, N) cin >> A[i];
    F0R(i, N) {
        if (A[i] == 0) {
            cout << 0 << nl; return 0;
        }
    }
    ld L = 0;
    F0R(i, N) {
        L += log10(A[i]);
    }
    if (L > 18.1) {
        cout << -1 << nl; return 0;
    }
    ll ans = 1; F0R(i, N) ans *= A[i];
    if (ans > 1000000000000000000) {
        cout << -1 << nl; return 0;
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 4684
import java.util.*;
public class Main {
    public static void main(String args []){
        Scanner sc  = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int [][] List = new int[H][W];
        for(int i=0;i<H;i++){
            String s = sc.next();
            for(int j=0;j<W;j++){
                if(s.charAt(j)=='.') List[i][j]=1;
                else List[i][j]=0;
            }
        }
        int max = 0;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                int Dis[][] = new int[H][W];
                int Check[][] = new int[H][W];
                for(int k=0;k<H;k++) {
                    for (int l=0;l<W;l++){
                        if(List[k][l]==1) Dis[k][l]=999999999;
                        else Dis[k][l]=-1;
                        Check[k][l]=0;
                    }
                }
                if(List[i][j]==1){
                    Dis[i][j]=0;
                    Dis = Dijkstra(H,W,List,Dis,j,i);
                }
                for(int k=0;k<H;k++){
                    for(int l=0;l<W;l++){
                        if(max<Dis[k][l]&&Dis[k][l]!=999999999) max = Dis[k][l];
                    }
                }
            }
        }
        System.out.println(max);
    }
    public static int[][] Dijkstra(int H, int W,int [][] List,int [][] Dis,int r,int c){
        if(r+1!=W){
            if(List[c][r+1]==1){
                if(Dis[c][r]+1<Dis[c][r+1]) {
                    Dis[c][r + 1] = Dis[c][r] + 1;
                    Dis = Dijkstra(H, W, List, Dis, r+1, c);
                }
            }
        }
        if(r-1!=-1){
            if(List[c][r-1]==1){
                if(Dis[c][r]+1<Dis[c][r-1]) {
                    Dis[c][r -1] = Dis[c][r] + 1;
                    Dis = Dijkstra(H, W, List, Dis, r-1, c);
                }
            }
        }
        if(c+1!=H){
            if(List[c+1][r]==1){
                if(Dis[c][r]+1<Dis[c+1][r]) {
                    Dis[c+1][r] = Dis[c][r] + 1;
                    Dis = Dijkstra(H, W, List, Dis, r, c+1);
                }
            }
        }
        if(c-1!=-1){
            if(List[c-1][r]==1){
                if(Dis[c][r]+1<Dis[c-1][r]) {
                    Dis[c-1][r] = Dis[c][r] + 1;
                    Dis = Dijkstra(H, W, List, Dis, r, c-1);
                }
            }
        }
        return Dis;
    }
}

Measured memory_bytes: 30144
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n;
	static int count = 0;
	static Pair pair;
	static int num[][]=new int[100][10];

	public static void main(String[] args) {
		read();
		pair = new Pair(0, 0);
		for (int i = 0; i < n; i++) {
			// System.out.println("dfs is " + i + "??????");
			dfs(i,0);
		}

	}
	public static void read(){
		n = sc.nextInt();
		for(int i = 0;i<n;i++){
			for(int j=0;j<10;j++){
				num[i][j]=sc.nextInt();
			}
		}
	}
	public static void dfs(int i,int j) {
		if (count >= 10) {
			System.out.println("YES");
			init();
			return;
		}
		count++;

		int nextNum = num[i][j];
		//?????£?????????????????????
		if (nextNum < pair.left && nextNum < pair.right) {
			System.out.println("NO");
			init();
			return;
		}
		
		//?????£????????\???
		if (nextNum > pair.left && nextNum > pair.right) {
			// ?????£????????\??????
			// ?????????????°???????
			if (nextNum - pair.left <= nextNum - pair.right) {
				pair.left = nextNum;
				// System.out.println(pair.left + " " + pair.right + "count:" +
				// count);
				dfs(i,++j);
				return;
			} else {
				// ????????????????????°????????£??????
				pair.right = nextNum;
				// System.out.println(pair.left + " " + pair.right + "count:" +
				// count);
				dfs(i,++j);
				return;
			}
		}
		// ?????£??????????????\?????????
		if (nextNum < pair.left || nextNum < pair.right) {
			if (nextNum > pair.left) {
				pair.left = nextNum;
				// System.out.println(pair.left + " " + pair.right + "count:" +
				// count);
				dfs(i,++j);
				return;
			} else {
				pair.right = nextNum;
				// System.out.println(pair.left + " " + pair.right + "count:" +
				// count);
				dfs(i,++j);
				return;
			}
		}

	}

	public static void init() {
		count = 0;
		pair.left = 0;
		pair.right = 0;
	}

}

class Pair {
	int left;
	int right;

	Pair(int a, int b) {
		left = a;
		right = b;
	}

}

Measured memory_bytes: 18632
N, M, X = map(int, input().split())
book = [list(map(int, input().split())) for i in range(N)]
out = 10**12
for i in range(0, 2**N):
    list = [0] * (M+1)
    st = format(int(i), "b").zfill(N)
    for j in range(N):
        if int(st[j]) == 1:
            for a in range(M+1):
                list[a] +=  book[j][a]
            
    if all([b >= X for b in list[1:]]) == True:
        out = min(out, list[0])

if out == 10**12:
    print(-1)

else:
    print(out)

Measured memory_bytes: 9224
#include <stdio.h>

int main()
{
    int N;
    int d[50];
    int i, j;
    int sum = 0;
    scanf("%d", &N);
    for (i = 0; i < N; i++)
    {
        scanf("%d", &d[i]);
    }

    for (i = 0; i < N; i++)
    {
        for (j = i + 1; j < N; j++)
        {
            sum += d[i] * d[j];
        }
    }

    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
b = len([a for a in A if a % 4 == 0])
c = len([a for a in A if a % 2])
d = len([a for a in A if a % 2 == 0 and a % 4])
print("YNeos"[not(b>=c if d else b >= c-1)::2])

Measured memory_bytes: 14252
n = int(input())
answer = [0 for _ in range(n)]

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            if i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i <= n:
                answer[i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i - 1] = answer[i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i - 1] + 1
for i in range(n):
    print(answer[i])


Measured memory_bytes: 9188
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int n, m;
string s;
vector<int> vec;


int main() {
	cin >> n >> m;
	int ans = 0;
	if (n>m)
	{
		ans += n;
		n--;
	}
	else {
		ans += m;
		m--;
	}
	if (n > m)
	{
		ans += n;
		n--;
	}
	else {
		ans += m;
		m--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <assert.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;


#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <bitset>
const int maxn = 1e5 + 20;
LL perfixSum[maxn], absSum[maxn];
vector<int>pos;
void cut(LL &val, int pos1, int pos2) {
    if (pos1 > pos2) return;
    val -= absSum[pos2] - absSum[pos1 - 1];
}
void work() {
    int n;
    scanf("%d", &n);
    int val;
    scanf("%d", &val);
    perfixSum[1] = val;
    absSum[1] = val;
    for (int i = 2; i <= n; ++i) {
        int val;
        char op;
        cin >> op;
        scanf("%d", &val);
        if (op == '+') {
            perfixSum[i] = perfixSum[i - 1] + val;
        } else {
            perfixSum[i] = perfixSum[i - 1] - val;
            pos.push_back(i);
        }
        absSum[i] = absSum[i - 1] + val;
    }
    LL ans = perfixSum[n];
    for (int i = 0; i <= (int)pos.size() - 2; ++i) {
        int p1 = pos[i], p2 = pos[i + 1];
        LL tans = absSum[n] - absSum[p2 - 1];
        tans += perfixSum[p1];
        cut(tans, p1 + 1, p2 - 1);
        ans = max(ans, tans);
    }
    cout << ans << endl;
}

int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
//    int val;
//    scanf("%d", &val);
//    cout << val << endl;
    work();
    return 0;
}

Measured memory_bytes: 2296
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;

const int N = (int) 2e4 + 100;
long long a[N], b[N];

vector <pair <long long, long long> > v, nv;

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif


	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i] );

	int ans = 0;
	long long x = 1;
	for (int it = 0; it < 17; it++)
	{
		long long x10 = x * 10;
		for (int i = 0; i < n; i++)
			b[i] = a[i] % x10;
	
		bool win = false;
		for (int d = 9; d >= 0; d--)
		{
			v.clear();
			v.emplace_back(x * d, x * (d + 1) - 1);
			if (d == 0) win = true;
			for (int i = 0; i < n && !win; i++)
			{
				nv.clear();
				for (auto p : v)
				{
					long long l = p.first - b[i], r = p.second - b[i];
					if (l < 0 && r >= 0)
					{
						win = true;
						break;
					}
					if (l < 0 && r < 0)
					{
						l += 10 * x;
						r += 10 * x;
					}
					nv.emplace_back(l, r);
					if (l == 0)
					{
						win = true;
						break;
					}
				}
				if (win) break;
				for (auto p : nv)
					v.push_back(p);
				sort(v.begin(), v.end() );
				nv.clear();
				long long l = -1, r = -1;
				for (auto p : v)
				{
					if (p.first > r)
					{
						if (l != -1)
							nv.emplace_back(l, r);
						l = p.first;
						r = p.second;
					}
					r = max(r, p.second);
				}
				nv.emplace_back(l, r);
				v = nv;
				nv.clear();
			}
			if (win)
			{
				ans += d;
				break;
			}
		}

		x *= 10;
	}
	printf("%d\n", ans);


	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    string a, b, c, ans;
    cin >> a >> b >> c;
    ans = string("A") + b[0] + string("C");
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
    int N, D;
    std::cin >> N >> D;
    
    int ans = 1;
    int i = 0;
    while(true){
        if(D * (ans + i) + ans + D >= N)
            break;
        ans++;
        i++;
    }
    std::cout << ans << std::endl;
        return 0;
}

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

signed main(){

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

  sum = a*100 + b * 10 + c;

  if(sum % 4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }


}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;
vii v[2000];
vi u[2000];
vii w[2000];
int ea[2000];
int eb[2000];
int cnt[2000][2];
int now[2000];
int was[2000];
//int last[2000];
//int ct;

int go (int x, int p, int z, int t) {
	if (x == z) re 1;
	for (int i = 0; i < sz (v[x]); i++) {
		int y = v[x][i].fi;
		int yi = v[x][i].se;
		if (y == p) continue;
		if (go (y, x, z, t)) {
			u[t].pb (yi);
			w[yi / 2].pb (mp (yi % 2, t));
			cnt[yi / 2][yi % 2]++;
			re 1;
		} 
	}
	re 0;
}

int go (int x) {
	vi can;
	for (int i = 0; i < sz (w[x]); i++)
		if (was[w[x][i].se] == 0)
			can.pb (w[x][i].se);
	if (can.empty ()) re 0;
	int xx = can[rand () % can.size ()];
//	last[xx] = ct;
	was[xx] = 1;
	vi need;
	now[xx] ^= 1;
	for (int i = 0; i < sz (u[xx]); i++) {
		int y = u[xx][i];
		cnt[y / 2][(y % 2) ^ now[xx]]++;
		cnt[y / 2][(y % 2) ^ now[xx] ^ 1]--;
		if (cnt[y / 2][0] + cnt[y / 2][1] > 1 && (cnt[y / 2][0] == 0 || cnt[y / 2][1] == 0)) need.pb (y / 2);
	}
	for (int i = 0; i < sz (need); i++) go (need[i]);
	re 0;
}

int main () {
	scanf ("%d%d", &n, &m);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		scanf ("%d%d", &a, &b); a--; b--;
		v[a].pb (mp (b, 2 * i));
		v[b].pb (mp (a, 2 * i + 1));
	}
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf ("%d%d", &a, &b); a--; b--;
		go (a, a, b, i);
		ea[i] = a;
		eb[i] = b;
	}
	int ans = 0;
	for (int i = 0; i < n - 1; i++)
		ans += min (2, sz (w[i]));
	printf ("%d\n", ans);
	while (true) {
	    vi can;
//		int st = -1;
		for (int j = 0; j < n - 1; j++)
			if (cnt[j][0] + cnt[j][1] > 1 && (cnt[j][0] == 0 || cnt[j][1] == 0)) {
				can.pb (j);
//				st = j;
//				break;
			}
		if (can.empty ()) break;
		int st = can[rand () % can.size ()];
		memset (was, 0, sizeof (was));
//		ct++;
//		printf ("%d\n", st + 1);
		go (st);
	}
	for (int i = 0; i < m; i++)
		if (now[i])
			printf ("%d %d\n", eb[i] + 1, ea[i] + 1);
		else
			printf ("%d %d\n", ea[i] + 1, eb[i] + 1);	
//	cerr << clock () << endl;
	return 0;
}

Measured memory_bytes: 19968
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<cstring>
#define ll long long
using namespace std;
ll dp[110][100000];
ll gaet[100000];
const ll mod = 1e9 + 7;
vector<ll> vt;
ll n, m;
int getidx(ll x) {
	return lower_bound(vt.begin(), vt.end(), x) - vt.begin();
}
ll func(ll here,ll xx) {
	if (here == m)return 1;
	if (xx < 0)return 0;
	ll &ret = dp[here][xx];
	if (ret != -1)return ret;
	ret = 0;
	ret += func(here, xx - 1);
	ret %= mod;
	ret += gaet[xx] * func(here + 1, getidx(n / vt[xx]));
	ret %= mod;
	return ret;
}
int main()
{
	memset(dp, -1, sizeof(dp));
	scanf("%lld %lld", &n, &m);
	for (ll i = 1; i <= sqrt(n); i++) {
		vt.push_back(i);
		gaet[vt.size() - 1] = 1;
	}
	for (ll i = sqrt(n); i >= 1; i--) {
		if(n/i!=vt[vt.size()-1])
			vt.push_back(n/i);
		gaet[vt.size() - 1] =n/i-n/(i+1);
	}
	printf("%lld", func(0, vt.size() - 1));
}

Measured memory_bytes: 284920
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int com(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(){
	int N,K,i,min;
	int h[100000]={'0'};
	unsigned int res= 1000000001;
	scanf("%d %d\n",&N,&K);
	for(i = 0; i < N; i++) scanf("%d\n",&h[i]);

	qsort(h,N,sizeof(h[0]),com);

	for(i = 0;i+K-1<N;i++){
		min = h[i+K-1]-h[i];
		res = min < res ? min : res;
	}
	printf("%d\n",res);

	return 0;

}

Measured memory_bytes: 892
#include "iostream"
using namespace std;
int main() {
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		ans += 800;
		if (i % 15 == 0)ans -= 200;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;


void solve() {
}

int H, A;
signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> H >> A;
    int ans = 0;
    ans = H / A;
    if (H % A != 0)
        ans++;
    cout << ans << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int main(){
	int n;
	scanf("%d",&n);
	long long int a[n+1]={};
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		a[i]+=a[i-1];
	}
	long long int ans=0;
	std::sort(a,a+n+1);
	long long int u=0;
	for(int i=1;i<=n;i++){
		if(a[i]==a[i-1]){
			u++;
		}else{
			ans+=(u*(u+1))/2;
			u=0;
		}
	}
	ans+=(u*(u+1))/2;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  int N, R;
  cin >> N >> R;
  int in = 0, disp = 0;
  if (N < 10)
  {
    disp = R;
    in = disp + 100 * (10 - N);
  }
  else
  {
    disp = R;
    in = R;
  }
  cout << in << endl;
}


Measured memory_bytes: 256
fn mod_pow(r: u64, mut n: u64, p: u64) -> u64 {
    let mut t = 1;
    let mut s = r;
    while n > 0 {
        if n & 1 == 1 {
            t = t * s % p;
        }
        s = s * s % p;
        n >>= 1;
    }
    t
}

fn inv(a: u64, p: u64) -> u64 {
    mod_pow(a, p - 2, p)
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let p: u64 = it.next().unwrap().parse().unwrap();
    let mut fact = vec![1; n + 1];
    let mut ifact = vec![0; n + 1];
    for i in 1..(n + 1) {
        fact[i] = fact[i - 1] * i as u64 % p;
    }
    ifact[n] = inv(fact[n], p);
    for i in (0..n).rev() {
        ifact[i] = (i + 1) as u64 * ifact[i + 1] % p;
    }
    let mut ans = 0;
    for i in 1..n {
        let way = fact[n] * ifact[i] % p * ifact[n - i] % p * mod_pow(2, (i * (i - 1) / 2) as u64 + ((n - i) * (n - i - 1) / 2) as u64, p) % p;
        let mut sum = 0;
        for a in 0..(i + 1) {
            let x = mod_pow(p - 1, a as u64, p) * mod_pow(2, ((i - a) * (n - i)) as u64, p) % p * fact[i] % p * ifact[a] % p * ifact[i - a] % p;
            let r = (1 + mod_pow(inv(2, p), (i - a) as u64, p) * (p - 1)) % p;
            sum += x * mod_pow(r, (n - i) as u64, p) % p;
        }
        ans += sum % p * way % p;
    }
    ans %= p;
    println!("{}", ans);
}

fn main() {
    run();
}



Measured memory_bytes: 5040
#include <iostream>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a+b==c)||(b+c==a)||(c+a==b)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n,x; cin >> n >> x;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int ans = 0;
    sort(ALL(v));
    rep(i,n){
        if(v[i]<=x){
            ans += 1;
            x -= v[i];
        }else{
            x = 0;
        }
    }
    if(x>0){
        ans -= 1;
    }

    cout << ans << endl;

    return 0;
}

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

L = list(range(M))
R = list(range(M))

for m in range(M):
  L[m], R[m] = map(int, input().split())

L_max = max(L)
R_min = min(R)

print(R_min - L_max + 1 if L_max <= R_min else 0)

Measured memory_bytes: 11764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
    int x, t;
    cin >> x >> t;

    if(x-t<0){
        cout << "0" << endl;
        return 0;
    }
    cout << x-t << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,m;
  cin>>n>>m;
  if(n>2&&m>2){
    	cout<<(n-2)*(m-2)<<endl;
  }else if(n==2||m==2){
    	cout<<0<<endl;
  }else{
    	cout<<max((ll)1,max(n,m)-2)<<endl;
  }
}


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

int main()
{
    int N;
    std::cin >> N;
    
    // 組み合わせ配列初期化
    int cmb[10][10];  // 先頭, 末尾
    for (int head = 0; head < 10; head++)
    {
        for (int tail = 0; tail < 10; tail++)
        {
            cmb[head][tail] = 0;
        }
    }

    // 組み合わせ配列を先に求める
    for (int i = 1; i <= N; i++)
    {
        std::string s = std::to_string(i);
        int head = s[0] - '0';
        int tail = s[s.size()-1] - '0';
        cmb[head][tail]++;
    }

    // AとBの組み合わせ数を求める
    int ans = 0;
    for (int head = 1; head <= 9; head++)
    {
        for (int tail = 1; tail <= 9; tail++)
        {
            ans += cmb[head][tail] * cmb[tail][head];
        }
    }

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

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        BigDecimal a = sc.nextBigDecimal();
        BigDecimal b = sc.nextBigDecimal();
        
        String tmp = a.multiply(b).toString();
        
        int dotIndex = tmp.indexOf(".");
        String ans = tmp.substring(0, dotIndex);
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 29000
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    int N;
    string S;
    cin >> N;
    cin >> S;
    int answer = 1;
    for(int i=1; i<N; i++) {
        if(S[i] != S[i-1]) {
            answer++;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
	int C,N,D,r,c,count,a,b,ans=0;
	static char cost[1000][1000];
	int i,j,k;
	bool mae;
	cin>>C>>N;
	for (i=0;i<N;i++)
	{
		cin>>cost[i];
	}
	count=0;
	for (i=0;i<N/2;i++)
	{
		for (j=0;j<N/2;j++)
		{
			//左上のマスを対称かどうか調べる
			if (cost[i][j]==cost[N-i-1][j]&&
				cost[N-i-1][j]==cost[N-i-1][N-j-1]&&
				cost[N-i-1][N-j-1]==cost[i][N-j-1]&&
				cost[i][N-j-1]==cost[i][j])
			{
				//対称である
			} else {
				count++;
				//printf("最初%d\n",count);
			}
		}
	}
	if (!count) ans++;
	if (C==1)
	{
		if (count) puts("0");
		else puts("1");
		return 0;
	}
	for (k=1;k<C;k++)
	{
		cin>>D;
		for (i=0;i<D;i++)
		{
			cin>>r>>c;
			r--;c--;
			//もともと対称か調べる
			a=N-r-1;
			b=N-c-1;
			if (cost[a][b]==cost[N-a-1][b]&&
				cost[N-a-1][b]==cost[N-a-1][N-b-1]&&
				cost[N-a-1][N-b-1]==cost[a][N-b-1]&&
				cost[a][N-b-1]==cost[a][b])
			{
				mae=true;
			} else {
				mae=false;
			}
			//変わったマス
			if (cost[r][c]=='0')
			{
				cost[r][c]='1';
			} else {
				cost[r][c]='0';
			}
			if (r>=N/2) r=N-r-1;
			if (c>=N/2) c=N-c-1;
			if (cost[r][c]==cost[N-r-1][c]&&
				cost[N-r-1][c]==cost[N-r-1][N-c-1]&&
				cost[N-r-1][N-c-1]==cost[r][N-c-1]&&
				cost[r][N-c-1]==cost[r][c])
			{
				count--;
				//printf("座標は対称%dk=%d\n",count,k+1);
			} else {
				if (mae)
				{
					count++;
					//printf("座標は対称でない%dk=%d\n",count,k+1);
				}
			}
		}
		if (!count) ans++;
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 4188
from collections import deque
# import heapq


N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    u,v = map(int,input().split())
    # グラフに頂点を追加
    G[u-1].append((v-1))
    G[v-1].append((u-1))
cs = sorted(list(map(int,input().split())),reverse=True)
gs = [len(g) for g in G]
K = gs.index(min(gs))

ds = [-1]*N
used = [False] * N
ans = 0

# BFS
q = deque([K])
ds[K] = cs[0]
i = 1
while len(q) > 0:
    a = q.popleft()
    Vs = G[a]
    for u in Vs:
        if ds[u] == -1:
            q.append(u)
            ds[u] = cs[i]
            used[u] = True
            i += 1
ansd = ""
for d in ds:
    ansd += str(d)+" "
print(sum(cs)-max(cs))
print(ansd)

Measured memory_bytes: 6256
/*スタック*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main (){
  int x; //整数を格納する変数
  char s[100]; //文字列配列
  int n[100]; // 整数を格納するスタック
  int i;
  
  i=0;
  while( scanf("%s", s) != EOF){

    switch(s[0]){
    case '+':
      n[i-2] += n[i-1];
      i--;      
      break;
    case '-':
      n[i-2] -= n[i-1];
      i--;      
      break;
    case '*':
      n[i-2] *= n[i-1];
      i--;      
      break;
    default:
      n[i] = atoi(s);
      i++;
    }
  }
  
  printf("%d\n", n[0]);
  
  return 0;
}



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

 int main() {
   int N, M;
   cin >> N >> M;
   vector<int> k(M);
   vector<vector<bool>> s(M, vector<bool>(N, false));
   rep(i, M) {
     cin >> k.at(i);
     rep(j, k.at(i)) {
       int tmp;
       cin >> tmp;
       s.at(i).at(tmp - 1) = true;
     }
   }

   vector<int> p(M);
   rep(i, M) cin >> p.at(i);

   int ans = 0;

   for (int i = 0; i < (1 << N); i++) {
     bitset<10> S(i);

     bool ok = true;
     for (int j = 0; j < M; j++) {
       int c = 0;
       for (int l = 0; l < N; l++) {
         if (S.test(l) && s.at(j).at(l)) c++;
       }
       if (c % 2 != p.at(j)) {
         ok = false;
         break;
       }
     }
     if (ok) ans++;
   }

   cout << ans << endl;

 }


Measured memory_bytes: 256
x, y, z = map(int, input().split())
if y - 1 >= z:
	print((x * z) // y - x * (z // y))
else:
	w = (z // y) * y - 1
	print(max((x * w) // y - x * (w // y), (x * z) // y - x * (z // y)))


Measured memory_bytes: 61848