akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>

using namespace std;

int color[100];
int d[100];
int f[100];
int G[100][100];
int nt[100];
int n;

int WHITE = 1;
int GRAY = 2;
int BLACK = 3;

int _time = 0;

int next(int u) {
  for (int v = nt[u]; v < n; v++) {
    nt[u] = v + 1;
    if (G[u][v]) return v;
  }

  return -1;
}

void dfs(int r) {
  for (int i = 0; i < n; i++) nt[i] = 0;

  stack<int> S;

  S.push(r);
  color[r] = GRAY;
  d[r] = ++_time;

  while(!S.empty()){
    int u = S.top();
    int v = next(u);

    if(v != -1) {
      if(color[v] == WHITE) {
        color[v] = GRAY;
        d[v] = ++_time;

        S.push(v);
      }
    } else {
      S.pop();
      color[u] = BLACK;
      f[u] = ++_time;
    }
  }
}

void dfs_init() {
  for(int i = 0; i < n; i++) {
    color[i] = WHITE;
  }
  _time = 0;

  for(int u = 0; u < n; u++) {
    if (color[u] == WHITE) {
      dfs(u);
    }
  }
}

int main() {
  int m, k, l;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> k;
    cin >> m;

    for (int j = 0; j < m; j++) {
      int l;
      cin >> l;

      G[k-1][l-1] = 1;
    }
  }

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

  for (int i = 0; i < n; i++) {
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }
}



Measured memory_bytes: 3128
def solve(S, T):
    L1 = len(S)
    L2 = len(T)
    dp = [[0]*(L2+1) for i in range(L1+1)]

    for i in range(L1-1, -1, -1):
        for j in range(L2-1, -1, -1):
            r = max(dp[i+1][j], dp[i][j+1])
            if S[i] == T[j]:
                r = max(r, dp[i+1][j+1] + 1)
            dp[i][j] = r

    # dp[0][0] が長さの解

    # ここからは復元処理
    res = []
    i = 0; j = 0
    while i < L1 and j < L2:
        if S[i] == T[j]:
            res.append(S[i])
            i += 1; j += 1
        elif dp[i][j] == dp[i+1][j]:
            i += 1
        elif dp[i][j] == dp[i][j+1]:
            j += 1
    return "".join(res)

S = input()
T = input()
print(solve(S,T))

Measured memory_bytes: 144428
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 600;
int ai[N], od[N];
int remin[N];
int fin[N * N], cnt[N][N];
stack <int> Q;
int comp(int a, int b)
{
    return ai[a] < ai[b];
}
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i) cin >> ai[i];
    for (int i = 1; i <= n; ++ i) od[i] = i;
    sort(od + 1, od + n + 1, comp); od[n + 1] = n + 1;
    ai[od[n + 1]] = n * n + 1;
    for (int i = 1; i <= n + 1; ++ i)
        remin[i] = ai[od[i]] - ai[od[i - 1]] - 1;
    for (int i = 1, v = (n - 1) * n / 2; i <= n; ++ i)
    {
        int x = od[i] - 1;
        for (int j = 1; j <= i; ++ j)
        {
            int k = min(remin[j], x);
            cnt[j][od[i]] += k;
            remin[j] -= k; x -= k;
        }
        for (int j = 1; j <= n - od[i]; ++ j) Q.push(od[i]);
        v -= n - od[i];
        while (Q.size() + n - i - 1 + v + ai[od[i + 1]] > n * n)
        {
            if (Q.empty()) return puts("No"), 0;
            cnt[i + 1][Q.top()] ++;
            remin[i + 1] --;
            Q.pop();
        }
    }
    for (int i = n + 1; i; -- i)
        while (remin[i])
        {
            if (Q.empty()) return puts("No"), 0;
            cnt[i][Q.top()] ++;
            remin[i] --;
            Q.pop();
        }
    puts("Yes");
    for (int i = 1; i <= n + 1; ++ i)
    {
        for (int j = 1; j <= n; ++ j)
            for (int k = 1; k <= cnt[i][j]; ++ k)
                cout << j << " ";
        if (i != n + 1) cout << od[i] << " ";
    }

}


Measured memory_bytes: 2816
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A, B = list(map(int, sys.stdin.readline().split()))
P = list(map(int, sys.stdin.readline().split()))

P = np.array(P, dtype=int)
c1 = (P <= A).sum()
c2 = (B < P).sum()
c3 = N - c1 - c2

print(min(c1, c2, c3))


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

int main(void){
  int n; 
  cin >> n;
  
  vector<int> b(n-1);
  for (int i = 0; i < n-1; i++) {
    cin >> b.at(i);
  }
  
  int ans = 0;
  
  ans += b.at(0);
  ans += b.at(n-2);
 
  for (int i = 1; i < n-1; i++) {
    int d = b.at(i-1);
    int e = b.at(i);
    int a = min(d,e);
    ans += a;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;

class segtree{
public:
	static const int N=1<<19;
	ll dp[2][1<<20];
	segtree(){
		memset(dp,0,sizeof(dp));
	}
	void update(int lv,int k,ll v){
		k+=N-1;
		dp[lv][k]+=v;
		while(k>0){
			k=(k-1)/2;
			dp[lv][k]=dp[lv][k*2+1]+dp[lv][k*2+2];
		}
	}

	ll query(int lv,int a,int b,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return 0;
		if(a<=l && r<=b)return dp[lv][k];
		int mid=(l+r)/2;
		ll vl=query(lv,a,b,k*2+1,l,mid);
		ll vr=query(lv,a,b,k*2+2,mid,r);
		return vl+vr;
	}

	ll get(int v){
		int l=0,r=N,k=0;
		int cnt=0;
		while(l+1<r){
			if(dp[0][k*2+2]+cnt<v){
				cnt+=dp[0][k*2+2];
				k=k*2+1;
				r=(l+r)/2;
			}else{
				k=k*2+2;
				l=(l+r)/2;
			}
		}
		//printf("%d %d %lld\n",v,r,query(1,r,N));
		return query(1,r-1,N);
	}

	ll find(){
		int vl=0,vr=n;
		for(int i=0;i<50;i++){
			int midl=(vl*2+vr)/3;
			int midr=(vl+vr*2)/3;
			if(get(midl*2)<=get(midr*2)){
				vl=midl;
			}else{
				vr=midr;
			}
		}
		ll maxi=0;
		for(int i=vl;i<vr;i++){
			maxi=max(maxi,get(i*2));
		}
		return maxi;
	}
};

segtree seg;

int q;
ll a[200005],b[200005];
int p[200005];
ll x[200005],y[200005];
vector<ll> vec;

int main(void){
	scanf("%d%d",&n,&q);
	ll ans=0;
	for(int i=0;i<n*2;i++){
		scanf("%lld",&a[i]);
		ans+=a[i];
	}
	for(int i=0;i<n*2;i++){
		scanf("%lld",&b[i]);
	}
	for(int i=0;i<n*2;i++){
		vec.push_back(b[i]-a[i]);
	}
	for(int i=0;i<q;i++){
		scanf("%d%lld%lld",&p[i],&x[i],&y[i]);
		p[i]--;
		vec.push_back(y[i]-x[i]);
	}
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	for(int i=1;i<n*2-1;i++){
		int lv=lower_bound(vec.begin(),vec.end(),b[i]-a[i])-vec.begin();
		seg.update(0,lv,1);
		seg.update(1,lv,b[i]-a[i]);
	}
	for(int i=0;i<q;i++){
		int lv=lower_bound(vec.begin(),vec.end(),b[p[i]]-a[p[i]])-vec.begin();
		if(p[i]!=0 && p[i]!=(n*2-1))seg.update(0,lv,-1);
		if(p[i]!=0 && p[i]!=(n*2-1))seg.update(1,lv,a[p[i]]-b[p[i]]);
		b[p[i]]=y[i];
		ans-=a[p[i]];
		a[p[i]]=x[i];
		ans+=a[p[i]];
		lv=lower_bound(vec.begin(),vec.end(),b[p[i]]-a[p[i]])-vec.begin();
		if(p[i]!=0 && p[i]!=(n*2-1))seg.update(0,lv,1);
		if(p[i]!=0 && p[i]!=(n*2-1))seg.update(1,lv,b[p[i]]-a[p[i]]);
		printf("%lld\n",ans+seg.find());
	}
	return 0;
}

Measured memory_bytes: 28656
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <cmath>      // sqrt
#include <cstdlib>    // exit
#include <algorithm>  // min,max
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forv(i,m,n) for (int i=(m); i>=(n); i--)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define R 1000000007
#define DBG 0

#define MAXN 100000
int a[22][22];
int dp[2*1024*1024];
int n,nn;

int dfs(int x, int y) {
  if (x == n)
    return 1;
  if (dp[y] > -1)
    return dp[y];
  int sum = 0;
  forr(j,0,n-1)
    if (a[x][j] == 1 && (y>>j)%2 == 0)
      sum = (sum + dfs(x+1, y|(1<<j))) % R;
  dp[y] = sum;
  if (DBG)
    cout << "dfs " << x << " " << y << " returns " << sum << endl;
  return sum;
}

int main() {
  cin >> n;
  nn = pow(2,n) - 1;
  forr(i,0,n-1)
    forr(j,0,n-1)
      cin >> a[i][j];
  forr(j,0,nn-1)
      dp[j] = -1;
  cout << dfs(0,0) << endl;
}


Measured memory_bytes: 8448
package main

import (
	"fmt"
)

func sort(a []int) {
	for i := 0; i < len(a)-1; i++ {
		for j := i + 1; j < len(a); j++ {
			if a[i] > a[j] {
				tmp := a[i]
				a[i] = a[j]
				a[j] = tmp
			}
		}
	}
}

func main() {
	var N int = 0
	var a []int

	var dist int = 0

	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		var tmp int = 0
		fmt.Scan(&tmp)
		a = append(a, tmp)
	}
	sort(a)
	for i := 0; i < len(a)-1; i++ {
		dist += a[i+1] - a[i]
	}
	fmt.Println(dist)
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    long long int n, a[100010];
    bool flg = true;

    cin >> n;

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

    sort(a, a+n);

    while (1) {
        int cnt = 0;
        int mod = a[0];
        for (int i = 0; i < n; i++) {
            if (a[i] % mod != 0) {
                a[i] = a[i] % mod;
                cnt++;
            }
        }

        if (cnt == 0) {
            break;
        }

        sort(a, a+n);
    }

    cout << a[0] << endl;

}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  	int a,b,c,x,y,cnt;
	cin>>a>>b>>c>>x>>y;
	if((a+b)<(2*c)){
		cout<<x*a+y*b<<endl;
	}
	else{
		if(x<y){
			cnt=x*2*c+(y-x)*b;
		}
			
		else{
			if(x==y)
				cnt=x*2*c;
			else cnt=y*2*c+(x-y)*a;
		
		}
		int sum=max(x,y)*c*2;
		int ans=min(sum,cnt);
		cout<<ans<<endl;
	}
  	return 0;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
C = [input() for _ in range(H)]

lit = []
for i in range(2 ** H):
    for j in range(2 ** W):
        row = str(bin(i))[2:].zfill(H)
        col = str(bin(j))[2:].zfill(W)
        lit.append([row, col])
# print(len(lit))
# print(lit)

black = sum([c.count('#') for c in C])
# print(black)

# 000011 000111 4 6 8 NG
res = 0
for row, col in lit:
# for row, col in [['000011', '000111']]:
    ans = black
    black_row = 0
    black_col = 0
    for i, r in enumerate(row):
        if r == '1':
            ans -= C[i].count('#')
            black_row += C[i].count('#')
        # print(ans)

    for j, c in enumerate(col):
        if c == '1':
            for k in range(H):
                if row[k] == '1':
                    continue
                if C[k][j] == '#':
                    ans -= 1
                    black_col += 1
    # print(row, col, black_row, black_col, ans)
    if ans == K:
        res += 1

print(res)


Measured memory_bytes: 9576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;

int main(){
	ll n;cin>>n;
	if(n&1){cout<<0<<endl;}
	else{
		ll f=0;
		ll now=1;
		while(now<=n){
			now*=5;
			f+=(n/(now*2));
		}
		cout<<f<<endl;
	}
}


Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    
    /*
    char s[h][w];
    for(int i=0; i<h; i++){
        cin >> s[i];
        //cout << s[i] << endl;
    }
    */
    double s = w*h/2.0;
    int flag = 0;
    if(x == w/2.0 && y == h/2.0){
        flag = 1;
    }
    printf("%.9lf %d\n",s,flag);
    //cout << s << " " << flag << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin>>n>>s;
    vector<ll> br(n+1,0),bg(n+1,0),bb(n+1,0);
    for(int i=n-1;i>=0;i--){
    	if(s[i]=='R')br[i]++;
    	if(s[i]=='G')bg[i]++;
    	if(s[i]=='B')bb[i]++;
    }
    for(int i=n-1;i>=0;i--){
    	br[i]+=br[i+1];
    	bg[i]+=bg[i+1];
    	bb[i]+=bb[i+1];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
    	for(int j=i+1;j<n;j++){
    		ll num=j+j-i;
    		bool r=false,g=false,b=false;
    		if(s[i]=='R')r=true;
    		if(s[i]=='G')g=true;
    		if(s[i]=='B')b=true;
    		if(s[j]=='R'){
    			if(r)continue;
    			r=true;
    		}
    		if(s[j]=='G'){
    			if(g)continue;
    			g=true;
    		}
    		if(s[j]=='B'){
    			if(b)continue;
    			b=true;
    		}
    		if(!r){
    			if(num<n)ans+=br[num+1];
    			ans+=br[j+1];
    			if(num<=n)ans-=br[num];
    		}
    		else if(!b){
    			if(num<n)ans+=bb[num+1];
    			ans+=bb[j+1];
    			if(num<=n)ans-=bb[num];

    		}else{
    			if(num<n)ans+=bg[num+1];
    			ans+=bg[j+1];
    			if(num<=n)ans-=bg[num];
    		}
    	}
    }
    cout << ans <<endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define drrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int MOD = 1'000'000'000 + 7;
const int INF = 1'000'000'000 + 5;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);

	int m1, d1; std::cin >> m1 >> d1;
	int m2, d2; std::cin >> m2 >> d2;
	if (m1 != m2)
		std::cout << 1 << "\n";
	else
		std::cout << 0 << "\n";
}


Measured memory_bytes: 256
#![allow(unused_imports, dead_code)]
use std::f64::*;
use std::cmp::*;
use std::collections::*;

macro_rules! dump{
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const INF: i64 = 0x3f3f3f3f3f3f3f3f;
const MOD: i64 = 1000000007;
const NOTHING: usize = std::usize::MAX;
const DX: [usize; 4] = [1, 0, std::usize::MAX, 0];
const DY: [usize; 4] = [0, 1, 0, std::usize::MAX];

fn main() {
    let s: Vec<char> = readln();
    let n = s.len();

    let mut cum: Vec<u32> = vec![0;n];
    fn char_bit(c: char) -> u32 {
        1 << (c as u32 - 'a' as u32)
    }

    cum[0] = char_bit(s[0]);
    for i in 1..n {
        cum[i] = cum[i - 1] ^ char_bit(s[i]);
    }

    let mut m: Vec<u32> = vec![0x3f3f3f3fu32;1<<26];
    m[cum[0] as usize] = 1;

    let mut ps: Vec<u32> = vec![0;27];
    for i in 1..27 {
        ps[i] = 1 << (i - 1);
    }

    for i in 1..n {
        let mut x = 0x3f3f3f3fu32;
        for &p in &ps {
            x = if p == cum[i] {
                1
            } else {
                min(x, m[(p ^ cum[i]) as usize] + 1)
            };
        }
        m[cum[i] as usize] = min(m[cum[i] as usize], x);
    }

    println!("{}", m[cum[n - 1] as usize]);

}

trait Read {
    fn read(s: &str) -> Self;
}

fn readln<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl{
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}


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

int main(){
   int N; cin >> N;
   vector<int> A(N);
   map<int,int64_t> a;
   for(int i=0;i<N;i++){
       cin >> A[i];
       if(a.count(A[i])){
           a[A[i]]++;
       }else{
           a[A[i]] = 1;
       }
   }
   int64_t sum = 0;
   for(auto p : a){
       auto key = p.first;
       auto value = p.second;
       sum += value*(value-1)/2;
   }
   for(int i=0;i<N;i++){
       cout << sum-(a[A[i]]-1) << endl;
   }

}




Measured memory_bytes: 10240
#include<iostream>

using namespace std;

int main(){
	

	int a,m,n;
	int i , j,k;
	int arr[300];
	int arr2[300];
	
	cin >> a;
	
	for(i=0;i<2*a;i++) arr[i] = i+1;
	
	cin >> m ;
	for(i=0;i<m;i++) {
		
		
		
		cin >> n;
		
		if(n==0){
			
			
			
			for(j=0;j<a;j++){
				
				arr2[j*2] = arr[j];
				arr2[j*2+1] = arr[j+a];
			}
			
			for(j=0;j<a*2;j++)arr[j] = arr2[j];
			
		}
		
		else{
			
			for(j=n,k=0;j<2*a;j++,k++) arr2[k]=arr[j];
			for(j=0;j<n;j++,k++) arr2[k]=arr[j];
			
			for(j=0;j<a*2;j++)arr[j] = arr2[j];			
		}
		
	}
	
	for(i=0;i<2*a;i++) cout << arr[i]<<endl;
	
	
	return 0;
	
}
	

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    vi a;
    for(int i=3;i<=55555;++i){
        int m=i;
        for(int j=2;j*j<=m;++j){
            while(m%j==0){
                m/=j;
            }
        }
        if(m==i&&m%5==3)a.PB(i);
    }
    rep(i,n){
        if(i!=n-1)cout<<a[i]<<" ";
        else cout<<a[i]<<endl;
    }
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 3");
            WillReturn.Add("2 2 2");
            //1
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("6 1");
            WillReturn.Add("1 6 1 2 0 4");
            //11
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("5 9");
            WillReturn.Add("3 1 4 1 5");
            //0
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("2 0");
            WillReturn.Add("5 5");
            //10
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray();

        long x = wkArr[1];
        long[] AArr = InputList[1].Split(' ').Select(X => long.Parse(X)).ToArray();

        long SousaCnt = 0;
        for (int I = 0; I <= AArr.GetUpperBound(0) - 1; I++) {
            long CurrSum = AArr[I] + AArr[I + 1];

            Action<int> wkAct = (pTargetInd) =>
            {
                if (CurrSum > x) {
                    long EatCnt = Math.Min(CurrSum - x, AArr[pTargetInd]);
                    CurrSum -= EatCnt;
                    SousaCnt += EatCnt;
                    AArr[pTargetInd] -= EatCnt;
                }
            };
            wkAct(I + 1);
            wkAct(I);
        }
        Console.WriteLine(SousaCnt);
    }
}


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

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

  string ans = "Yes";
  while (true) {
    C -= B;
    if (C <= 0) break;
    A -= D;
    if (A <= 0) {
      ans = "No";
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3592
n,k = map(int,input().split())
x = []
y = []
xx = []
yy = []
for i in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)
    xx.append(a)
    yy.append(b)
ans = 10 ** 40
x.sort()
y.sort()
for i in range(n):
    for j in range(i+1,n):
        for l in range(n):
            for h in range(l+1,n):
                lx = x[i]
                rx = x[j]
                uy = y[h]
                dy = y[l]
                cnt = 0
                for ii in range(n):
                    if lx <= xx[ii] <= rx and dy <= yy[ii] <= uy:
                        cnt += 1
                if cnt >= k:
                    if (rx-lx) * (uy-dy) != 0:
                        ans = min(ans,(rx-lx)*(uy-dy))
print(ans)

Measured memory_bytes: 49756
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;


int main()
{
    int n;
    cin >> n;
    vector<int> h;
    rep(i, n){ int tmp; cin >> tmp; h.push_back(tmp);}

    int ans = 0;
    int cnt = 0;
    rep(i, n-1){
        if (h[i] >= h[i+1]){
            cnt++;
        } else {
            cnt=0;
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}



Measured memory_bytes: 892
#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>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

//改造
typedef long long int ll;
using namespace std;


int main() {
    int a,b;
    cin >> a >> b;
    if( a + b >= 10) cout << "error" << endl;
    else cout << a + b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
const int INF = 1e8;
using namespace std;
 
int main(){
    int a, b;
    while(cin >> a >> b, a){
        int n;
        cin >> n;
 
        long long dp[20][20] = {{0}};
        rep(i,n){
            int x,y;
            cin >> x >> y;
            x--; y--;
            dp[x][y] = -1;
        }
 
        dp[0][0] = 1;
        rep(i,a){
            rep(j,b){
                if(i == 0 && j == 0) continue;
                if(dp[i][j] == -1) continue;
                long long tmp = 0;
                if(i - 1 >= 0) tmp += (dp[i - 1][j] == -1 ? 0 : dp[i - 1][j]);
                if(j - 1 >= 0) tmp += (dp[i][j - 1] == -1 ? 0 : dp[i][j - 1]);
                dp[i][j] = tmp;
            }
        //rep(i,a){ rep(j,b){ cout << dp[i][j] << ' '; } cout << endl; } cout << endl;
        }
        //cout << endl;
        cout << dp[a - 1][b - 1] << endl;
    }
}

Measured memory_bytes: 3000
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define int long long
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MAXIN(x) max_element(ALL(x)) - x.begin();
#define MIN(x) *min_element(ALL(x))
#define MININ(x) min_element(ALL(x)) - x.begin();
#define INF 1000000000000
#define MOD 100000070
#define MAXR 100000
#define PI 3.14159265358979323846

using namespace std;

signed main() {
    int n, x, t;
    cin >> n >> x >> t;

    if(n%x == 0){
        cout << (n/x)*t <<endl ;
    }else{
        cout << (n/x + 1)*t <<endl ;
    }


    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    
    int k[M];
    vector<vector<int> > s(N, vector<int>());
    for(int i=0; i<M; i++) {
        cin >> k[i];
        for(int j=0; j<k[i]; j++) {
            int sij;
            cin >> sij;
            s[sij-1].push_back(i);
        }
    }

    int p[M];
    vector<int> initcounter(M, 0);
    vector<bool> initflag(M, false);
    int initcc=0;
    for(int i=0; i<M; i++) {
        cin >> p[i];
        if(p[i]==initcounter[i]) initflag[i]=true, initcc++;
    }
    
    int ccc=0;
    for(int bit=0; bit<(1<<N); bit++) {
        vector<int> counter=initcounter;
        vector<bool> flag=initflag;
        int cc=initcc;
        for(int i=0; i<N; i++) {
            if(bit & 1<<i) {
                for(int j=0; j<s[i].size(); j++) {
                    counter[s[i][j]]++;
                    if(flag[s[i][j]]) flag[s[i][j]]=false, cc--;
                    else flag[s[i][j]]=true, cc++;
                }
            }
        }
        if(cc==M) ccc++;
    }
    
    cout << ccc << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj2104/input.txt"));
			// System.setOut(new PrintStream(new FileOutputStream("src/aoj2103/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}



	Scanner sc;
	void run() {
		sc = new Scanner(System.in);
		int T = sc.nextInt();
		while (T-- >0) {
			long ans = solve();
			System.out.println(ans);
		}
	}


	long solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n];
		for (int i = 0; i < n; i++)
			x[i] = sc.nextInt();

		if (n == 1) {
			return 0;
		}

		int[] d = new int[n-1];
		for (int i = 1; i < n; i++) d[i-1] = x[i] - x[i-1];
		Arrays.sort(d);

		long res = 0;
		for (int i = 0; i + k - 1 < d.length; i++) {
			res += d[i];
		}
		return res;
	}

	void tr(Object... os) {
		System.err.println(deepToString(os));
	}
}

Measured memory_bytes: 14000
#include<iostream>
using namespace std;
// Problem https://atcoder.jp/contests/abc129/tasks/abc129_a

int solver(int AB,int BC,int AC){
    int result=10000;
    int ABC,BAC,ACB;
    ABC = AB + BC;
    BAC = AB + AC;
    ACB = AC + BC;
    if(ABC < result){
        result = ABC;
    }
    if(BAC < result){
        result = BAC;
    }
    if(ACB < result){
        result = ACB;
    }
    return result;
}

int main(void){
    int P,Q,R;
    int answer=0;
    cin >> P >> Q >> R;
    answer = solver(P,Q,R);
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

//ll sq(ll num) { return num*num; }
//ll mod_pow(ll x, ll n) {
//	if (n == 0)return 1;
//	if (n == 1)return x%MOD;
//	ll res = sq(mod_pow(x, n / 2));
//	res %= MOD;
//	if (n % 2 == 1) {
//		res *= x;
//		res %= MOD;
//	}
//	return res;
//}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n, a, b, k;

ll fact[1000100];

ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	ll res = mod_pow(x*x % 998244353, n / 2);
	if (n & 1)res = res*x % 998244353;
	return res;
}

ll nCk(ll n, ll k) {
	return fact[n] * mod_pow(fact[k], 998244353 - 2) % 998244353 * mod_pow(fact[n - k], 998244353 - 2) % 998244353;
}

int main() {
	cin >> n >> a >> b >> k;
	fact[0] = 1;
	rep(i, n)fact[i + 1] = fact[i] * (i + 1) % 998244353;
	if (a > b)swap(a, b);
	vector<P> vp;
	rep(i, n + 1) {
		ll cb = i;
		if (k - cb*b >= 0 && (k - cb*b) % a == 0) {
			ll ca = (k - cb*b) / a;
			if (ca <= n)vp.push_back({ ca,cb });
		}
	}
	//rep(i, vp.size()) {
	//	cout << vp[i].first << " " << vp[i].second << endl;
	//}
	ll ans = 0;
	rep(i, vp.size()) {
		ll n1 = nCk(n, vp[i].first);
		ll n2 = nCk(n, vp[i].second);
		ans += (n1*n2 % 998244353);
		ans %= 998244353;
	}
	cout << ans << endl;
}

Measured memory_bytes: 9968
n = int(input())
a = list(map(int,input().split()))
l = [i+a[i] for i in range(n)]
r = [j-a[j] for j in range(n)]
import collections
cl = collections.Counter(l)
cr = collections.Counter(r)
ans = 0
for i in cl.keys():
    if i in cr.keys():
        ans += cl[i]*cr[i]
print(ans)

Measured memory_bytes: 141304
class UnionFind:
    def __init__(self, n):
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

N, M, K = map(int, input().split())

uf = UnionFind(N)
friend_suggested = [-1] * N


for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    friend_suggested[a] -= 1
    friend_suggested[b] -= 1
    uf.union(a, b)
for i in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if uf.find(c) == uf.find(d):
        friend_suggested[c] -= 1
        friend_suggested[d] -= 1

for i in range(N):
    parent_size = -uf.parents[uf.find(i)]
    friend_suggested[i] += parent_size
print(*friend_suggested)

Measured memory_bytes: 90456
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long LL;
const int LEN = 2e5 + 10;
int A[LEN], vis[LEN];

int main() {
    int N;
    LL K;
    scanf("%d%lld", &N, &K);
    for (int i = 1; i <= N; i++) {
        scanf("%d", &A[i]);
    }
    int pos = 1;
    vector<int> P;
    while (!vis[pos]) {
        vis[pos] = true;
        P.push_back(pos);
        pos = A[pos];
    }
    int begin = 0;
    while (begin < P.size() && P[begin] != pos) {
        begin += 1;
    }
    if (K < begin) {
        cout << P[K] << endl;
    } else {
        K = (K - begin) % (P.size() - begin);
        cout << P[begin + K] << endl;
    }
    return 0;
}


Measured memory_bytes: 5896
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
// #pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

//---------------------------------------------------------------------------------------------------
void _main() {
    ll n, l, x;
    cin >> n;
    map<ll, ll> res;
    rep(i, 0, n - 1) {
        cin >> x;
        res[x - 1]++;
    }
    rep(i, 0, n) {
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 16152
import itertools as itr
import collections as col
import numpy as np 
n = int(input())
a = list(map(int, input().split()))
ans_c = np.array(list(col.Counter([0] + list(itr.accumulate(a))).values())).astype("int64")
print(np.sum(ans_c * (ans_c - 1) // 2))

Measured memory_bytes: 50536
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            total = 500 * i + 100 * j + 50 * k
            if X == total:
                ans += 1

print(ans)

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

int main(void) {
    int n = 0, i, a[100], b[101] = {};
    while(cin >> i)
        a[n++] = i;
    for (int i= 0; i < n; ++i)
        ++b[a[i]];
    int max = 0;
    for (int i = 1; i <= 100; ++i)
        if (b[i] > max)
            max = b[i];

    for (int i = 1; i <= 100; ++i)
        if (max == b[i])
            cout << i << endl;

    return 0;
}



Measured memory_bytes: 2984
#include<iostream>
#include<algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <sstream>

using namespace std;
typedef long long ll;

int main() {
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(NULL);


	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int x; cin >> x;
		if (i & 1 && x & 1) {
			ans += 1;
		}
	}

	cout << ans << '\n';
}


Measured memory_bytes: 3164
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BAdditionAndMultiplication solver = new BAdditionAndMultiplication();
        solver.solve(1, in, out);
        out.close();
    }

    static class BAdditionAndMultiplication {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints(), k = in.ints();
            int ans = 1;
            for (int i = 0; i < n; i++) {
                ans = Math.min(ans * 2, ans + k);
            }
            out.println(ans);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 23380
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;
#define int long long

signed main(void) {
  int pos = -1;
  bool flag = false;
  string s;
  cin.tie(0);

  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if(s[i] == 'C') {
      pos = i;
      break;
    }
  }

  if(pos != -1) {
    for (int i = pos+1; i < s.size(); i++) {
      if(s[i] == 'F') {
        flag = true;
        break;
      }
    }
  }

  if(flag) cout << "Yes\n";
  else cout << "No\n";

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#define NUM 51

using namespace std;

int main(void){
    int n, k;
    scanf("%d %d", &n, &k);

    char s[NUM];

    cin >> s;
    
    s[k-1] = s[k-1] - 'A' + 'a';

    printf("%s\n", s);
}


Measured memory_bytes: 888
#include <iostream>
#include<stdio.h>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;


int main()
{
   int s[4],d;
   while(~scanf("%d%d%d%d",&s[1],&s[2],&s[3],&d))
   {
       if(abs(s[1]-s[3])<=d){
            printf("Yes\n");
            continue;}
        sort(s+1,s+4);
       //printf("%d%d%d",a,b,c);
        if(abs(s[1]-s[2])<=d&&abs(s[2]-s[3])<=d)
        printf("Yes\n");
    else
        printf("No\n");
   }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;


const int MAX_V = 10000;

class Edge{
    public:
        int dst, weight;
        Edge(){}
        Edge(int dst, int weight): dst(dst), weight(weight)  {}
};

typedef vector<vector<Edge>> Graph;

Graph g(MAX_V);

int visit(Graph &t, int i, int j) {
    if(t[i][j].weight >= 0) return t[i][j].weight;
    t[i][j].weight = g[i][j].weight;
    int u = t[i][j].dst;
    rep(k,t[u].size()) {
        if(t[u][k].dst == i) continue;
        t[i][j].weight = max(t[i][j].weight, visit(t,u,k) + g[i][j].weight);
    }
    return t[i][j].weight;
}
vector<int> height(int n) {
    Graph t = g;
    rep(i,n) rep(j,t[i].size()) t[i][j].weight = -1;
    rep(i,n) rep(j,t[i].size()) if(t[i][j].weight < 0) t[i][j].weight = visit(t, i, j);

    vector<int> ht(n); // gather results
    rep(i,n) rep(j,t[i].size()) ht[i] = max(ht[i], t[i][j].weight);
    return ht;
}

int main(){
    int n;
    cin >> n;
    rep(i,n - 1){
        int a, b, c;
        cin >> a >> b >> c;
        g[a].emplace_back(b,c);
        g[b].emplace_back(a,c);
    }

    vector<int> h = height(n);
    for(auto it:h) cout << it << endl;
}

Measured memory_bytes: 4684
def resolve():
    N = int(input())
    ans = [0 for _ in range(100005)]
    for x in range(1, 105):
        for y in range(1, 105):
            for z in range(1, 105):
                tmp = x * x + y * y + z * z + x * y + y * z + z * x
                if tmp < 10005:
                    ans[tmp] += 1
    
    for i in range(1, N+1):
        print(ans[i])
    return
 
resolve()

Measured memory_bytes: 9768
/// Author : Nhat Huy
/*

 ∧＿＿∧
(。・ω・)つー☆・ * 。
⊂     ノ         .  ゜
 し————Ｊ      Accepted
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define REP(i,n) for (int i = 0; i < n; ++ i)
#define FOR(i,a,b) for (int i = a; i <= b; ++ i)
#define FORD(i,b,a) for (int i = b; i >= a; -- i)
#define task "PeopleOnLine"
#define opfin(task) freopen(task".inp", "r", stdin)
#define opfout(task) freopen(task".out", "w", stdout)
#define ms(a) memset(a, 0, sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef vector<int> vi;
typedef vector <ii> vii;
typedef pair <int, double> id;
const int N = 1e5 + 5;
vii adj[N];
int sum[N];
bool ok = true, mark[N];
void dfs(int u) {
	mark[u] = 1;
	REP(i, adj[u].size()) {
		ii v = adj[u][i];
		if (!mark[v.first]) {
			sum[v.first] = sum[u] + v.second;
			dfs(v.first);
		}
		else if (sum[v.first] != sum[u] + v.second) {
			ok = 0;
		}
	}
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    clock_t begin = clock();
    //opfin(task);
    //opfout(task);
    //Code here !
    ms(mark); ms(sum);
    int n, m;
    cin >> n >> m;
    while (m--) {
    	int u, v, d;
    	cin >> u >> v >> d;
    	adj[u].pb(ii(v, d));
    	adj[v].pb(ii(u,-d));
    }
    FOR(i,1,n) {
    	if (!mark[i]) dfs(i);
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    clock_t end = clock();
    //cerr <<"Time run: "<<(float)(end-begin)/CLOCKS_PER_SEC<<" s"<<endl;
    return 0;
}




Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

int main(){

    int N;
    cin >> N;

    string s;
    cin >> s;

    ll ans = 0;
    for(int i = 0; i < N - 1; i++){
        if(s[i] != s[i+1]) ans ++;
    }
    cout << ans + 1 << endl;

}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>
#include<map>


#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
typedef pair<ll,ll> LL_LLP;
#define INF 1000000007
#define MAX_H 20000
#define MOD 1000000007


int main(){

    int n;
    cin >> n;
    string s,t,str;
    cin >> s >> t;
    for(int i = 0;i < s.length();){

        if(s[i] == t[i]){
            str.push_back('#');
            i++;
        }else{
            str.push_back('%');
            i += 2;
        }
    }
    //cout << str << endl;
    
    ll ans = 0;
    if(str[0] == '#'){
        ans = 3;
    }else{
        ans = 6;
    }

    for(int i = 1;i < str.size();i++){
        if(str[i-1] == '#'){
            if(str[i] == '#'){
                ans = ans*2%MOD;
            }else{
                ans = ans*2%MOD;
            }
        }else{
            /*前がyの場合*/
            if(str[i] == '%'){
                ans = ans*3%MOD;
            }else{
                ans = ans*1%MOD;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int a, b;
    cin >> a >> b;
    if(a <= b) {
        cout << a << endl;
    }
    else {
        cout << a-1 << endl;
    }
    return 0;
}

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

S = [0] * n
S[0] = list[0]
for i in range(1, n):
    S[i] = S[i - 1] + list[i]

count = 0
countDict = {}
countDict[0] = 1

for i in S:
    if i in countDict:
        count += countDict[i]
        countDict[i] += 1
    else:
        countDict[i] = 1
print(count)

Measured memory_bytes: 41324
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var s = br.readLine().split(" ");
      final var h = Integer.parseInt(s[0]);
      final var a = Integer.parseInt(s[1]);

      System.out.println(h % a == 0 ? h / a : (h / a) + 1);
    }
  }
}


Measured memory_bytes: 32520
process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const num = Number(inputs[0].split(' ')[0]);
  let sum = 0;

  if (num === 1) {
    console.log('1');
    return;
  }

  for (let i = 1; i <= num; i++) {
    sum += gcd([i, i, i]);

    for (let j = 1; j <= num - i; j++) {
      sum += gcd([i + j, i, i]) * 3;
      sum += gcd([i + j, i + j, i]) * 3;

      for (let k = 1; k <= num - (i + j); k++) {
        sum += gcd([i + j + k, i + j, i]) * 6;
      }
    }
  }

  console.log(sum);
}

// 最大公約数を算出
function gcd(num: number[]): number {
  let func = (a: number, b: number): number => (b !== 0 ? func(b, a % b) : a);
  let ans = num[0];

  for (var i = 1; i < num.length; i++) {
    ans = func(ans, num[i]);
  }
  return ans;
}


Measured memory_bytes: 36496
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    double l;
    scanf("%lf",&l);
    double side=l/3.0;
    double ans=side*side*side;
    printf("%.12lf\n",ans);
    return 0;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

ll mod=1000000007;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}


int main() {
  string s;cin>>s;
  if(s=="RRR")cout<<3;
  if(s=="SRR"||s=="RRS")cout<<2;
  if(s=="RSR"||s=="SSR"||s=="RSS"||s=="SRS")cout<<1;
  if(s=="SSS")cout<<0;
}

Measured memory_bytes: 3596