akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int V, E;
vector< vector<int> > graph;
int color[100010];

Pi dfs(int u, int c) {
  Pi res(0, 0);
  color[u] = c;
  if(c == 1) res.first++;
  else res.second++;
  for(int v : graph[u]) {
    if(color[v] == c) return Pi(-1, -1);
    if(color[v] == 0) {
      Pi tmp = dfs(v, -c);
      if(tmp.first < 0) return Pi(-1, -1);
      res.first += tmp.first;
      res.second += tmp.second;
    }
  }
  return res;
}

map<int, int> mp;

int dp[100010]; // ?????°??¶???????????¨?????? ????????????????????¨?????¨??°??????????????£?????????????????¨?????¨??°???????????§?????????????????§????????????????????£??????????????????????????????????¢?????????????

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

  cin >> V >> E;
  resz(graph, V);
  rep(i, E) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  mp.clear();
  memset(color, 0, sizeof(color));
  int v = 0; // ?????¨??°?????????????????§?????????????°??????¨??????????????§??????
  rep(i, V) {
    if(color[i] != 0) continue;
    Pi p = dfs(i, 1);
    int a = min(p.first, p.second);
    int b = max(p.first, p.second);
    if(a < 0) {
      cout << -1 << endl;
      return 0;
    }
    mp[b-a]++;
    v += a;
  }

  memset(dp, -1, sizeof(dp));
  dp[0] = 0;
  for(auto p : mp) {
    int plus = p.first, num = p.second;
    rep(i, V+1) {
      if(dp[i] >= 0) dp[i] = num;
      else if(i < plus || dp[i-plus] <= 0) dp[i] = -1;
      else dp[i] = dp[i-plus]-1;
    }
  }
  int ans = 0;
  rep(i, V+1) if(dp[i] >= 0) chmax(ans, (v+i)*(V-v-i));
  cout << ans-E << endl;

  return 0;
}

Measured memory_bytes: 11012
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

#define mp make_pair
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14
#define fi first
#define se second
#define all(v) v.begin(),v.end()

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;
pii dp[34][34][34][34];
int u[34][34];
int jud;

pii update(pii ta,pii ma){
	if(ma.se < ta.se){
		return ta;
	}else if(ma.se == ta.se){
		if(ma.fi < ta.fi){
			return ta;
		}
	}
	return ma;
}

pii f(int sy,int sx,int ey,int ex){
	// cout << " sy : " << sy << " sx : " << sx << 
	//         " ey : " << ey << " ex : " << ex <<
	//          endl; 
	if(dp[sy][sx][ey][ex].fi!=0) return dp[sy][sx][ey][ex];
	if(sy == ey && sx == ex) {
		// cout << "mp : " << u[sy][sx]<<endl; 
		dp[sy][sx][ey][ex] = mp(u[sy][sx],1);
		return mp(u[sy][sx],1);
	}
	pii ma = mp(0,1);

	//?????????????????£???????????????
	for (int y = sy; y <= ey; ++y)
	{
		for (int x = sx; x <= ex; ++x)
		{
		 	ma.fi += u[y][x];
		}
	}
	//????????????????????????
	for(int x = sx;x < ex;x++){
		pii a1 = f(sy,sx,ey,x);
		pii a2 = f(sy,x+1,ey,ex);
		if(a1.fi < jud || a2.fi < jud) continue;
		pii ta = mp(min(a1.fi,a2.fi),a1.se+a2.se);
		ma = update(ta,ma);
	}

	for(int y = sy;y < ey;y++){
		pii a1 = f(sy,sx,y,ex);
		pii a2 = f(y+1,sx,ey,ex);
		if(a1.fi < jud || a2.fi < jud) continue;
		pii ta = mp(min(a1.fi,a2.fi),a1.se+a2.se);
		ma = update(ta,ma);
	}
	// cout << "ma : " << ma.fi << " " << ma.se << endl;
	dp[sy][sx][ey][ex] = ma;
	return ma;
}
int main(){
	while(1){
		rep(x1,34){
		rep(x2,34){
		rep(x3,34){
		rep(x4,34){
			dp[x1][x2][x3][x4] = mp(0,0);
		}}}}
		int h,w,s;
		int sum = 0;
		cin >> h >> w >> s;
		if(h==0) break;
		rep(y,h){
			rep(x,w){
				cin >> u[y][x];
				sum += u[y][x];
			}
		}
		jud = sum - s;
		pii ans = f(0,0,h-1,w-1);
		cout << ans.se << " "<< ans.fi-jud << endl;
	}
	return 0;
}

Measured memory_bytes: 13496
#include<stdio.h>
#include<string.h>
typedef long long ll;
ll a,b,c;
int main()
{
    int i,j;
    while(~scanf("%lld%lld%lld",&a,&b,&c))
    {
        if(!(a%2) || !(b%2) || !(c%2))
        {
            printf("0\n");continue;
        }
        if((a/2)*b>(b/2)*a)
        {
            if((a/2)*c>(c/2)*a) printf("%lld\n",(a-a/2*2)*b*c);
            else printf("%lld\n",(c-c/2*2)*a*b);
        }
        else
        {
            if((b/2)*c>(c/2)*b) printf("%lld\n",(b-b/2*2)*a*c);
            else printf("%lld\n",(c-c/2*2)*a*b);
        }


    }
    return 0;
}


Measured memory_bytes: 128
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B,C = MI()
    ans = 7*(C//(A*7+B)) #1週間
    C %= A*7+B
    ans += min(7,ceil(C/A))
    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 6404
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int N, C;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N >> C;
  vector<priority_queue<P, vector<P>, greater<P>>> ques(C);

  REP(i, N) {
    int s, t, c;
    cin >> s >> t >> c;
    c--;
    ques[c].push(P(s, t));
  }

  vector<int> memo(100005, 0);

  REP(i, C) {
    while(!ques[i].empty()) {
      P p = ques[i].top(); ques[i].pop();
      int s = p.first, e = p.second;

      while(!ques[i].empty()) {
        P np = ques[i].top();
        if(e == np.first) {
          e = np.second;
          ques[i].pop();
        } else {
          break;
        }
      }

      memo[s] += 1; memo[e + 1] -= 1;
    }
  }
  int ans = 0, sum = 0;
  REP(i, 100005) {
    sum += memo[i];
    ans = max(ans, sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1920
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  ll n,m;cin>>n>>m;
  vector<ll>A[n];
  rep(i,n){
    ll K;cin>>K;
    A[i].resize(K);
    rep(j,K){
      cin>>A[i][j];
      A[i][j]--;
    }
  }
  ll ans=0;
  rep(j,m){
    //食べ物jが好きか
    bool isOK=true;
    rep(i,n){
      bool isLike=false;
      rep(k,A[i].size()){
        if(A[i][k]==j)isLike=true;
      }
      if(!isLike)isOK=false;
    }
    if(isOK)ans++;
  }
  cout<<ans<<endl;return false;
}


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
	int A,B,C,D,P,a,b,c;
	scanf("%d %d %d %d %d",&A,&B,&C,&D,&P);
	a = P*A;
	if(P>C){
		b = (P-C)*D+B;
	} else {
		b = B;
	}
	c = fmin(a,b);
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 600
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        int N=gi();
        int[][] F=new int[N][10];
        int[][] P=new int[N][11];
        
        for (int i=0; i<N;i++) {
        	for (int j=0; j<10;j++) {
        		F[i][j]=gi();
        	}
        }
        for (int i=0; i<N;i++) {
        	for (int j=0; j<11;j++) {
        		P[i][j]=gi();
        	}
        }
        
        long max = Long.MIN_VALUE;
        for (int i=1; i<1024;i++) {
        	long sum=0;
        	for(int j=0; j<N; j++) {
        		int c=0;
        		for (int k=0; k<10;k++) {
        			if(F[j][k]==((i>>k) & 1) && F[j][k]==1) {
        				c++;
        			}
        		}
        		sum+=P[j][c];
        	}
        	if(sum>max) {
        		max=sum;
        	}
        }


	    System.out.println(max);

//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 38808
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

iscanl :: (Int -> a -> b -> a) -> a -> V.Vector b -> V.Vector a
iscanl !k !a !v = V.scanl' (\(!x) (!i, !v) -> k i x v) a (V.indexed v)

iscanlU
  :: (VU.Unbox a, VU.Unbox b)
  => (Int -> a -> b -> a)
  -> a
  -> VU.Vector b
  -> VU.Vector a
iscanlU !k !a !v = VU.scanl' (\(!x) (!i, !v) -> k i x v) a (VU.indexed v)

ipostscanlU
  :: (VU.Unbox a, VU.Unbox b)
  => (Int -> a -> b -> a)
  -> a
  -> VU.Vector b
  -> VU.Vector a
ipostscanlU !k !a !v = iscanlU (\(!i) (!a) (!b) -> k (i + 1) a b)
                               (k 0 a (VU.unsafeHead v))
                               (VU.unsafeTail v)

solve :: Int -> VU.Vector Int8 -> Double
solve !n !pn = dp VU.! ((n + 1) `div` 2)
 where
  dp :: VU.Vector Double
  dp = VU.ifoldl'
    ( \(!prev) (!i) (!pint) -> VU.generate
      (i + 2)
      ( \(!j) ->
        let
          pi = fromIntegral pint / 100
          qi = 1 - pi
        in
          if j == 0
          then
            1
          else
            prev
            VU.! (j - 1)
            *    pi
            +    (if j == i + 1 then 0 else prev VU.! j * qi)
      )
    )
    (VU.singleton 1)
    pn

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt
  let readDouble :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readDouble b = readInt $ B.drop 2 b

  n  <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  pn <- VU.unfoldrN n readDouble <$> B.getLine
  print $ solve n pn


Measured memory_bytes: 1916
//2017-10-10
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)

multiset<string> s;

int main(){
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);

	For(i, 1, A) s.insert("a");
	For(i, 1, B) s.insert("b");
	For(i, 1, C) s.insert("c");

	string tmp;
	while(s.size() > 1){
		tmp = (*s.begin()) + (*s.rbegin());
		s.erase(s.begin());
		s.erase(--s.end());
		s.insert(tmp);
	}

	printf("%s\n", (*s.begin()).c_str());

	return 0;
}

Measured memory_bytes: 256
def readinput():
    a,b,c,d=map(int,input().split())
    return a,b,c,d

def main(a,b,c,d):
    l=max(a,c)
    r=min(b,d)
    return max(r-l,0)

if __name__=='__main__':
    a,b,c,d=readinput()
    ans=main(a,b,c,d)
    print(ans)


Measured memory_bytes: 9112
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
my @p = split / /, <STDIN>;
my $ans = 0;
my $m = $p[0];
for (my $i=0; $i<$n; $i++) {
  if($m >= $p[$i]) {
    $ans++;
    $m = $p[$i];
  }
}
say $ans;

Measured memory_bytes: 33572
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

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

    ll l = 0, r = 1e9, mid;
    while (r - l > 1) {
        mid = l + (r - l) / 2;
        ll a = 0;
        REP(i, 0, N) {
            ll diff = H[i] - B * mid;
            if (diff > 0) {
                a += (diff + (A - B) - 1) / (A - B);
            }
        }
        if (a <= mid) r = mid;
        else l = mid;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 4020
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <cmath>
#include <vector>
using namespace std;


int main(){
	/*input*/
	int n;
	int x[100];
	int Max=0;
	int all = 0;
	int ave = 0;
	cin >> n ;
	for(int i = 0; i < n; i++){
		cin >> x[i];
		Max = max(Max,x[i]);
		all += x[i];
	}
//	ave = all / n + 1;
//	cout << ave << endl;

	/*calc*/
	long long ans = 0;

//	for(int i = 0; i < n; i++){
//		ans += pow(x[i] - ave,2.0);
//	}

	long long Min = 100000000;
	for(int i = 1; i <= Max; i++){
		ans = 0;
		for(int j = 0; j < n; j++){
			ans += pow(x[j] - i,2.0);
		}
		Min = min(Min,ans);
//		cout << i << " : " << Min <<endl;
	}

	/*output*/
	cout<< Min <<endl;
//	cout<< ans <<endl;
    return 0;
}


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


int main() {
	int n;
	cin >> n;
	bool ok = true;
	map<int, bool> vis;
	for(int i = 1; i <= n; ++i) {
		int x;
		cin >> x;
		if(ok)
			ok = !vis[x];
		vis[x] = true;
	}
	cout << (ok ? "YES" : "NO");
}


Measured memory_bytes: 12884
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

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

    for(int i=1; i<=9; i++)
        if(N%i==0 && N/i <=9){
            cout << "Yes" << endl;
            return 0;
        }

    cout << "No" << endl;

    return 0;
}

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

int main() {
    int W,H,x,y,r; cin >> W >> H >> x >> y >> r;
    if(x+r<=W && y+r<=H && x-r>=0 && y-r>=0)
    cout << "Yes" << endl;
    else 
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3116
import math

n=int(input())
P=list(map(int, input().split()))
Q=list(map(int, input().split()))

P1=P
P2=[0]*n
for i in range(n):
    P1=[p-1 if p>=P1[i] else p for p in P1]
    P2[i]=P1[i]
A=0
for j in range(n):
    A+=math.factorial(n-j-1)*P2[j]
    
Q1=Q
Q2=[0]*n
for i in range(n):
    Q1=[q-1 if q>=Q1[i] else q for q in Q1]
    Q2[i]=Q1[i]
B=0
for j in range(n):
    B+=math.factorial(n-j-1)*Q2[j]

print(abs(A-B))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
vector<int> nodeCount;


// 木上の探索
// v: 現在探索中の頂点、p: v の親 (v が根のときは -1)
void dfs(const Graph &G, int v, int p=-1) {
	for (auto new_v : G[v]) {
		if (new_v == p) continue; // nv が親 p だったらスルー
		nodeCount[new_v] += nodeCount[v];
		dfs(G, new_v, v); // v は新たに nv の親になります
	}
}


int main() {

	// 頂点数 (木なので辺数は N-1 で確定)
	int n; cin >> n;
	
	nodeCount.assign(n, 0);

	int q; cin >> q;
	
	Graph G(n);
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	for (int i = 0; i < q; ++i) {
		int p, x;
		cin >> p >> x;
		nodeCount[--p] += x;
	}

	int root = 0;
	dfs(G, root);


	for (int i = 0; i < n; ++i) {
		cout << nodeCount[i] << " ";
	}

	return 0;

}

Measured memory_bytes: 26624
function main(input) {
  const args = input.split(" ");
  const A = Number(args[0]);
  const B = Number(args[1]);
  var ans = 0;
  if (A <= B) {
    ans = 0;
  } else {
    if (A <= B * 2) {
      ans = 0;
    } else {
      ans = A - B - B;
    }
  }

  console.log(ans);
}

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


Measured memory_bytes: 23112
# 関数定義
def partition(A, p, r):
    x = A[r]["number"]
    i = p - 1
    
    for j in range(p, r):
        if A[j]["number"] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    
    A[i + 1], A[r] = A[r], A[i + 1]
    
    return i + 1

def quickSort(A, p, r):
    if p < r:
        q = partition(A, p ,r)
        quickSort(A, p, q-1)
        quickSort(A, q+1, r)
        
def is_stable(A):
    for i in range(0, len(A) - 1):
        j = i + 1
        #print(A[i]["number"], A[j]["number"], ":", A[i]["order"], A[j]["order"])
        if (A[i]["number"] == A[j]["number"] and A[i]["order"] > A[j]["order"]):
            return False
    return True

# 入力
N = int(input())
A = []
for i in range(N):
    card = input().split()
    A.append({'mark': card[0], 'number': int(card[1]), 'order': i})
    
# ソート
quickSort(A,0,N-1)

# is_stable()
if(is_stable(A)):
    print("Stable")
else:
    print("Not stable")
    
# 中身
for a in A :
    print(a["mark"], a["number"])


Measured memory_bytes: 37048
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    vl a(n);
    vl index(n+1);
    rep(i,n){
        cin >> a[i];
        index[a[i]] = i;
    }
    set<ll> se;
    se.insert(n);
    se.insert(-1);
    ll ans = 0;
    REP(i,1,n+1){
        auto itr = se.lower_bound(index[i]);
        ll right = *itr - index[i];
        itr--;
        ll left = index[i] - *itr;
        ans += i * right * left;
        se.insert(index[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12800
#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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin >> s;
  rep(i,3){
    cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 3652
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))

n,k = mp()
a = lmp()
a.insert(0,0)
here = 1
cnt = 0
hajimete = [0]*(n+1)
hajimete[0] = -1
used = set()
used.add(1)
flag = False
for i in range(k):
    cnt += 1
    here = a[here]
    if here not in used:
        used.add(here)
        hajimete[here] = cnt
    else:
        flag = True
        break
if not flag:
    print(here)
else:
    loop = cnt - hajimete[here]
    town = hajimete[here] + ((k-hajimete[here]) % loop)
    print(hajimete.index(town))





Measured memory_bytes: 105660
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int t = sc.nextInt();
        int s = sc.nextInt();

        double ret = (double)d/(double)s;

        if (ret <= t) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 36036
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll n, x;
ll a[50], p[50];

ll f(ll n, ll x) {
    if (n == 0) return x <= 0 ? 0 : 1;
    else if (x <= 1 + a[n - 1]) return f(n - 1, x - 1);
    else if (x == 2 + a[n - 1]) return 1 + p[n - 1];
    else return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);
}

void solve() {
    a[0] = 1, p[0] = 1;
    repone(i, n - 1) {
        a[i] = a[i - 1] * 2 + 3;
        p[i] = p[i - 1] * 2 + 1;
    }
    cout << f(n, x) << endl;
}

int main() {
    cin >> n >> x;
    solve();
    return 0;
}

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

using namespace std;

int main() {
	long long int h, w;
	cin >> h >> w;
	long long int ans = h*w;
	long long int k = h % 3;
	if (k != 0) {
		k = 1;
	}
	if (h / 3 > 0) {
		ans = min(ans, k*w);
	}
	k = w % 3;
	if (k != 0) {
		k = 1;
	}
	if (w / 3 > 0) {
		ans = min(ans, k*h);
	}
	//cout << ans << endl;
	for (long long int i = 1; i < h; i++) {
		long long int a = i;
		long long int b = h - i;
		long long int ka = a*w;
		long long int kb = b*(w / 2);
		long long int kc = b*(w / 2);
		if (w % 2 == 1) {
			kc += b;
		}
		long long int MAX = max(ka, max(kb, kc));
		long long int MIN = min(ka, min(kb, kc));
		ans = min(ans, MAX - MIN);
	}
	for (long long int i = 1; i < w; i++) {
		long long int a = i;
		long long int b = w - i;
		long long int ka = a*h;
		long long int kb = b*(h / 2);
		long long int kc = b*(h / 2);
		if (h % 2 == 1) {
			kc += h;
		}
		long long int MAX = max(ka, max(kb, kc));
		long long int MIN = min(ka, min(kb, kc));
		ans = min(ans, MAX - MIN);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    double a,b;
    cin>>a>>b;
    double socket_remains = a-1;
    double empty_socket_remains = b-1;
    double ans = ceil(empty_socket_remains/socket_remains);
    int anss = ans;
    cout<<anss<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <numeric>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};
 
signed main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // cout << sieve(30000) << endl;

  int N;
  cin >> N;

  if (N == 3) {
    cout << "2 5 63" << endl;
    return 0;
  }

  for (int x=3; x+6<=30000 && N>=4; x+=12, N-=2) {
    cout << x << " " << x + 6 << " ";
  }
  int x = 2;
  for (; N>=3; x+=6, N-=3) {
    cout << x << " " << x + 2 << " " << x + 4 << " ";
  }

  if (N == 1) {
    cout << x + 4 << endl;
  } else if (N == 2) {
    cout << x << " " << x + 2 << endl;
  }
}

Measured memory_bytes: 384
#include <stdio.h>

#define MAX(x, y) ((x) > (y) ? (x) : (y))

int main (void)
{
        unsigned maxa, maxb, maxc;
        unsigned n;

        scanf("%u%u%u%u", &n, &maxa, &maxb, &maxc);
        while (--n) {
                unsigned u = maxa, v = maxb;
                unsigned a, b, c;
                scanf("%u%u%u", &a, &b, &c);
                maxa = a + MAX(maxb, maxc);
                maxb = b + MAX(maxc, u);
                maxc = c + MAX(u, v);
        }
        printf("%u\n", MAX(maxa, MAX(maxb, maxc)));

        return 0;
}


Measured memory_bytes: 128
program test01
 implicit none
 integer A, B, C

 read *, A, B, C

 if ( A == B ) then
  if ( B == C ) then
   print '(A)', 'No'
   stop
  else
   print '(A)', 'Yes'
  end if
 else
  if ( B == C ) then
   print '(A)', 'Yes'
  end if
  if ( C == A ) then
   print '(A)', 'Yes'
  end if
 end if
  if ( A /= B .and. B /= C .and. C /= A ) then
   print '(A)', 'No'
  end if

endprogram test01


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e3+10,mod=1e9+7;
inline int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=(ll)res*x%mod;
		x=(ll)x*x%mod;
		y>>=1;
	}
	return res;
}
int dp[maxn][maxn],fac[maxn*maxn],ifac[maxn*maxn];
inline int C(int n,int m){
	return (ll)fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
inline void init(int n){
	fac[0]=1;
	REP(i,1,n) fac[i]=(ll)i*fac[i-1]%mod;
	ifac[n]=ksm(fac[n],mod-2);
	DREP(i,n,1) ifac[i-1]=(ll)i*ifac[i]%mod;
}
int main(){
	int n=read(),k=read();
	if(k==1){
		printf("1\n");
		return 0;
	}
	init(n*k);
	dp[0][0]=1;
	REP(i,1,n) REP(j,0,i){
		dp[i][j]=dp[i-1][j];
		if(j) dp[i][j]=(dp[i][j]+(ll)dp[i][j-1]*(n-j+1)%mod*C(n*k-i-(j-1)*(k-1)-1,k-2))%mod;
	}
	printf("%d\n",dp[n][n]);
	return 0;
}


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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

int main() {
	int ans = 0, minmt = 10;
	for(int i = 0; i < 5; i++) {
		int x;
		cin >> x;
		int mt = x % 10;
		if(mt == 0)
			mt = 10;
		minmt = min(minmt, mt);
		ans += x - mt + 10;
	}
	ans -= 10 - minmt;
	cout << ans << endl;
}


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

int main() {
  int n, l = 0, r = 0, m = 0;
  string s, o;
  cin >> n >> s;
  for(int i = 0; i < n; i++) {
    l += s[i] == '(';
    r += s[i] == ')';
    m = min(m, l - r);
  }
  for(int i = 0; i < -m; i++)
    o.push_back('(');
  for(int i = 0; i < s.size(); i++)
    o.push_back(s.at(i));
  for(int i = 0; i < l - r - m; i++)
    o.push_back(')');
  cout << o << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin >> n>>a>>b;
  int ans;
  if(n%a != 0)
  {
    ans = n/a + 1;
  }
    else
    {
      ans = n/a;
}
ans *= b;
  
  cout <<ans <<endl;
}


Measured memory_bytes: 3604
import sys
f=lambda:map(int,sys.stdin.readline().split())
n,st,sa=f()
st-=1
sa-=1
g=[[] for _ in range(n)]
for _ in range(n-1):
  a,b=f()
  g[a-1].append(b-1)
  g[b-1].append(a-1)
def bfs(s):
  l=[-1]*n; l[s]=0; q=[s]
  while q:
    v=q.pop(); d=l[v]+1
    for c in g[v]:
      if l[c]<0: l[c]=d; q+=[c]
  return l
lt=bfs(st)
la=bfs(sa)
m=0
for i in range(n):
  if lt[i]<la[i]: m=max(m,la[i])
print(m-1)

Measured memory_bytes: 28464
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vll = vector<pll>;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define BIT(x,n) ((x>>n)&1)
const int inf = 1e9;

int main() {
    int N, ans = inf; cin >> N;
    vvl AB(N, vl(2));
    rep(i,N) cin >> AB[i][0];
    rep(i,N) cin >> AB[i][1];

    rep(bits,(1<<N)) {
        vll num(N); rep(i,N) num[i] = make_pair(AB[i][BIT(bits,i)], i);

        bool ok = true;
        int count = 0;
        rep(i,N-1) {
            int mx = 0, idx = -1;
            rep(j,N-i) {
                if (BIT(bits,num[j].second) != abs(N-1-i - num[j].second)%2) continue;
                int val = num[j].first;
                if (val >= mx) { mx = val; idx = j; }
            }
            if (idx == -1) { ok = false; break; }

            rng(j,idx,N-i-1) {
                swap(num[j], num[j+1]);
                count++;
            }
        }
        rep(i,N-1) if (num[i].first > num[i+1].first) ok = false;
        rep(i,N) if (BIT(bits,num[i].second) != abs(i - num[i].second)%2) ok = false;
        if (ok) ans = min(ans, count);
    }
    cout << (ans==inf?-1:ans) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
    LL x;
    cin >> x;
    LL ans = 0;
    LL k = 100;
    while(true) {
      if(k * 1.01 >= x) {
        ans++;
        cout << ans << endl;
        return 0;
      } else {
        ans++;
        k *= 1.01;
      }
    }
}


Measured memory_bytes: 5972
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef std::pair<string, int> key; // for convenience
struct compare_keys {
    bool operator()(key const & lhs, key const & rhs) {
        if (lhs.first > rhs.first) return false;
        if (rhs.first > lhs.first) return true;
        return lhs.second > rhs.second;
    }
};
int main()
{
    int n;
    cin>>n;
    map<pair<string , int> , int, compare_keys > m;
    for(int i=1;i<=n;i++)
    {
        string s;
        int p;
        cin>>s>>p;
        m[{s, p}]=i;
    }
    for(auto i:m)
        cout<<i.second<<endl;
}


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

using namespace std;
int main(void){
  int n, m;
  int mi = n, ma = 0;
  vector<int> ls, rs;

  cin >> n >> m;

  for(int i=0; i<m; ++i){
    int l, r;
    cin >> l >> r;
    ls.push_back(l);
    rs.push_back(r);
  }

  for(int i=0; i<m; ++i){
    if(ma <= ls.at(i)){
      ma = ls.at(i);
    }
    if(mi >= rs.at(i)){
      mi = rs.at(i);
    }
  }

  int res;
  if((mi - ma) < 0){
    res = 0;
  }else{
    res = (mi - ma) +1;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1276
#include <iostream>

using namespace std;

int main(){
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }
    else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }
    else if(s == "Rainy"){
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100005
#define M 1000000007
#define ll long long
ll dp[105][N], n, k, arr[N], sum[N];

int main()
{
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> arr[i];
    for(int i = 0; i <= n; i++) dp[i][0] = 1;
    for(int i = 1; i <= n; i++)
    {
        sum[0] = dp[i - 1][0];
        for(int j = 1; j <= k; j++) sum[j] = (sum[j - 1] + dp[i - 1][j]) % M;
        for(int j = 1; j <= k; j++)
        {
            ll idx = j - arr[i] - 1;
            ll rm = (idx < 0? 0 : sum[idx]) % M;
            dp[i][j] = (dp[i][j] + sum[j] - rm + M) % M;
        }
    }
    cout << dp[n][k] << endl;
}



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

using Graph=vector<vector<int>>;
using P=pair<int,int>;
const int INF=1e9;

int main()
{
   int N; cin>>N;
   Graph G(N);
   for(int i=0;i<N-1;i++){
      int a,b; cin>>a>>b;
      a--; b--;
      G[a].push_back(b);
      G[b].push_back(a);
   }
   int K; cin>>K;
   vector<int> num(N,-1);
   for(int i=0;i<K;i++){
      int v,p; cin>>v>>p;
      num[v-1]=p;
   }

   priority_queue<P,vector<P>,greater<P>> Q;
   vector<int> dist(N,INF);
   for(int i=0;i<N;i++) if(num[i]>=0){
      dist[i]=num[i];
      Q.push({dist[i],i});
   }

   while(!Q.empty()){
      int v=Q.top().second; Q.pop();
      for(int u:G[v]){
         if(dist[u]>dist[v]+1){
            dist[u]=dist[v]+1;
            Q.push({dist[u],u});
         }
      }
   }
   bool ok=true;
   for(int i=0;i<N;i++){
      if(num[i]>=0 and dist[i]!=num[i]) ok=false;
      for(int j:G[i]) if(dist[i]==dist[j]) ok=false;
   }
   cout<<(ok? "Yes":"No")<<endl;
   if(ok) for(int i=0;i<N;i++) cout<<dist[i]<<endl;
   return 0;
}


Measured memory_bytes: 8308
use proconio::input;

fn main() {
    input![
        mut n:i64
    ];

    let mut len = 1;
    let lowercase =  [
        'a', 'b', 'c', 'd', 'e', 
        'f', 'g', 'h', 'i', 'j', 
        'k', 'l', 'm', 'n', 'o',
        'p', 'q', 'r', 's', 't', 
        'u', 'v', 'w', 'x', 'y', 
        'z',
    ];
    let ans = loop {
        let mut sz = 1;
        for i in 0..len {
            sz*=26;
        }

        if n<=sz {
            n-=1;
            let mut ans = Vec::<char>::new();
            for _ in 0..len {
                ans.push(lowercase[(n%26) as usize]);
                n/=26;
            }
            ans.reverse();
            break ans
        }
        n-=sz;
        len+=1;
    };

    let ans:String = ans.into_iter().collect();
    println!("{}",ans);


}


Measured memory_bytes: 2192
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE Strict #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = readInts >>= output . solve

solve :: [Int] -> _
solve = null . filter (=='7') . show . head

output :: _ -> IO ()
output = print . bool Yes No

data YesNo = Yes | No
  deriving Show

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine


Measured memory_bytes: 3772
#include<iomanip>
#include<iostream>
#include<string>

using namespace std;

typedef long long int ll;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	string s;
	cin >> s;
	string t;
	for (int i = 0; i < s.size();i++){
		if(i+1 < s.size() && s[i] == 'B' && s[i+1] == 'C'){
			t.push_back('D');
			i++;
		}else{
			t.push_back(s[i]);
		}
	}

	ll ans = 0;
	int cnt = 0;
	for (int i = 0; i < t.size();i++){
		if(t[i] == 'A'){
			cnt++;
		}else if(t[i] == 'D'){
			ans += cnt;
		}else{
			cnt = 0;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
#define sortv(x) sort(x.begin(), x.end())
#define dump(x) cerr << #x << " = " << x << endl
typedef long long ll;

struct UnionFind
{
  vector<int> par;
  UnionFind(int N) : par(N)
  {
    for (int i = 0; i < N; i++)
      par[i] = i;
  }
  int root(int x)
  {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y)
  {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry)
      return;
    par[rx] = ry;
  }
  bool same(int x, int y)
  {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
} typedef UF;

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> p(N);
  for (int i = 0; i < N; i++)
    cin >> p[i], p[i]--;
  vector<int> x(M), y(M);
  for (int i = 0; i < M; i++)
  {
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
  }
  int ans = 0;
  UF uf(N);
  for (int i = 0; i < M; i++)
    uf.unite(x[i], y[i]);
  for (int i = 0; i < N; i++)
    if (uf.same(i, p[i]))
      ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
N=int(input())
A=sorted(list(map(int,input().split())))
C=[0]*(max(A)+1)

for i in A:
    C[i]+=1

if len(C)==1:
    print(C[0])
else:
    T=max(C[0]+C[1],C[-1]+C[-2])
    for i in range(1,max(A)):
        T=max(T,C[i-1]+C[i]+C[i+1])
    print(T)

Measured memory_bytes: 13964
import sys
import math
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n, m = map(int, input().rstrip().split())
    if abs(n - m) >= 2:
        print("0")
        return
    if n == m:
        print(math.factorial(n) * math.factorial(m) * 2 % (pow(10, 9) + 7))
    else:
        print(math.factorial(n) * math.factorial(m) % (pow(10, 9) + 7))


if __name__ == '__main__':
    main()


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

void solve(){
  int C, A, N, T = 0;

  cin >> C >> A >> N;

  while( C > 0 && N > 0 && A > 0 ){
    C--;
    N--;
    A--;
    T++;
  }

  while( C >= 2 && A > 0 ){
    C-=2;
    A--;
    T++;
  }

  while( C >= 3 ){
    C-=3;
    T++;
  }

  cout << T << endl;
}

main(){
  int q;
  cin >> q;
  for ( int i = 0; i < q; i++ ) solve();
}

Measured memory_bytes: 1160
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string.h>
#include<algorithm>

int main() {

	int N, mymax = 0,tmp,sum = 0;

	scanf("%d", &N);

	int L[1000];

	for (int i = 0; i < N; i++) {
		scanf("%d", &L[i]);

		if (mymax < L[i]) {
			mymax = L[i];
			tmp = i;
		}
	}

	for (int j = 0; j < N; j++) {
		if (j == tmp)continue;
		sum += L[j];
	}

	if (sum > mymax)puts("Yes");
	else puts("No");

	return(0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define Nmax 200005
const long double PI = acos(-1);


int n, m, nrR[Nmax], nrB[Nmax], uz[Nmax];
vector<int> v[Nmax];
string s;

void read(){
	cin >> n >> m;
	cin >> s;
	for (int i=1;i<=m;i++){
		int x,y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
		if (s[y-1] == 'A') nrR[x]++;
		else nrB[x]++;
		if (s[x-1] == 'A') nrR[y]++;
		else nrB[y]++;
	}
}

bool OK(int nod){
	return nrB[nod] && nrR[nod];
}

void update(int nod, char c){
	if (c == 'A') nrR[nod]--;
	else nrB[nod]--;
}

int Q[Nmax], lg = 0, cnt = 0;
void elim(){
	cnt = n;
	for (int i=1;i<=n;i++){
		if (!OK(i)){
			cnt--;
			uz[i] = 1;
			Q[++lg] = i;
		}
	}
	while (lg && cnt){
		int crt = Q[lg--];
		for (auto it : v[crt]){
			if (uz[it]) continue;

			update(it, s[crt-1]);
			if (!OK(it)){
				Q[++lg] = it;
				uz[it] = 1;
				cnt--;
			}
		}
	}

	cout << (cnt ? "Yes\n" : "No\n");
}


int main(){
    ios::sync_with_stdio(false);
    
    read();
    elim();

    return 0;
}

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

int main(void)
{
    string S;
    cin >> S;
    if((S[0]==S[1]&&S[1]!=S[2]&&S[2]==S[3])||
       (S[0]==S[2]&&S[1]==S[3]&&S[2]!=S[3])||
       (S[0]==S[3]&&S[1]!=S[3]&&S[2]==S[1]))cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, x, ans = 0;
  cin >> a >> b >> c >> x;
  
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= b; j++) {
      for(int k = 0; k <= c; k++){
        if(500*i + 100*j + 50*k == x) ans++;
      }
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3636
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

k = int(readline())
s = readline().rstrip().decode()
if len(s) <= k:
    print(s)
else:
    print(s[:k] + '...')


Measured memory_bytes: 61616
#include <algorithm>
#include <iostream>
using namespace std;
#define MAX_N 110000
typedef long long ll;
ll N, X[MAX_N], L[MAX_N];
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> X[i] >> L[i];
  pair<ll, ll> itv[MAX_N];
  for (int i = 0; i < N; i++) {
    itv[i].first = X[i] + L[i];
    itv[i].second = X[i] - L[i];
  }

  sort(itv, itv + N);

  ll ans = 0, t = -10000000000;
  for (int i = 0; i < N; i++) {
    if (t <= itv[i].second) {
      ans++;
      t = itv[i].first;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3584
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int H = in.nextInt();
		int W = in.nextInt();
		int h = in.nextInt();
		int w = in.nextInt();
		int[][] m = new int[H][W]; 
		System.out.println((H - h) * (W - w));
	}

}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {

			String s = sc.next();
			int k = s.length();
			int win = 0;

			for (int i = 0; i < k; i++) {
				if (s.substring(i, i + 1).equals("o")) {
					win++;
				}
			}

			if ((15 - k + win >= 8)) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}

		}

	}

}

Measured memory_bytes: 21204