akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	fsc := NewFastScanner()
	A, B, K := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
	results := []int{}
	for i := A; i < A+K; i++ {
		if i > B {
			break
		}
		results = append(results, i)
	}
	for i := B; i > B-K; i-- {
		if i < A {
			break
		}
		results = append(results, i)
	}

	sort.Ints(results)
	pre := results[0]
	fmt.Println(results[0])
	for i := 1; i < len(results); i++ {
		if pre == results[i] {
			continue
		}
		fmt.Println(results[i])
		pre = results[i]
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
int main(){
  int n,i,j,l,max,c;
  double x[310],y[310],k,s,t,a,b,e=1e-6;
  while(scanf("%d",&n),n){
    max=1;
    for(i=0;i<n;i++)scanf("%lf %lf",&x[i],&y[i]);
    for(i=0;i<n;i++){
      for(j=i+1;j<n;j++){
	a=(x[i]-x[j])/2;
	b=(y[i]-y[j])/2;
	if(hypot(a,b)-e>1)continue;
	k=tan(acos(hypot(a,b)));
	s=x[j]+a+k*b;
	t=y[j]+b-k*a;
	for(l=c=0;l<n;l++){
	  if(hypot(x[l]-s,y[l]-t)-e<1)c++;
	}
	if(max<c)max=c;
	s=x[j]+a-k*b;
	t=y[j]+b+k*a;
	for(l=c=0;l<n;l++){
	  if(hypot(x[l]-s,y[l]-t)-e<1)c++;
	}
	if(max<c)max=c;
      }
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 748
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)
#define meax 100007
 vll a(meax,0);
  vll b(meax,meax);
  ll sum1=0;
ll maximize(ll i,ll n,ll prev){

    if(b[i]!=meax){
        return b[i];
    }
    if(i>=n){
        return meax;
    }

    if(i==n-1){
            b[i]=0;
        return b[i];
    }
    ll d1=maximize(i+1,n,a[i]);
    ll d2=maximize(i+2,n,a[i]);
    b[i]=min(abs(a[i]-a[i+1])+d1,abs(a[i+2]-a[i])+d2);
    return b[i];


}
int main(){
    ll n;
    cin>>n;

    rep(i,0,n,1){
        cin>>a[i];
    }
    ll d=maximize(0,n,a[0]);
    cout<<d<<endl;
}


Measured memory_bytes: 9484
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut n = n;
    let mut cnt = 0;
    while n > 0 {
        n /= k;
        cnt += 1;
    }

    println!("{}", cnt);
}


Measured memory_bytes: 4352
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  return 180*(n-2)

print(main())


Measured memory_bytes: 7836
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

int n;vector<int> v[110000];int c[110000],ans[110000];pair<int,int> dig[110000];
int cind,ansM;

void f(int ver){
  //cout << "ver : " << ver << endl;
  vector<int> next;
  for(int nver : v[ver]){
    if(ans[nver] != -1)continue;
  //cout << "nver : " << nver << " " << cind << endl;
    next.push_back(nver);
    ans[nver] = c[cind];
    ansM += c[cind];
    cind++;
  }
  for(int nver : next){
    f(nver);
  }
}

signed main(){  
  string s;cin>>s;
  rep(i,3){
    if(s[i] == s[i+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}


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

int main() {
  string S;
  cin >> S;
  int a = S.size();
  if(S.at(a-1) == 's'){
    cout << S + "es" << endl;
  }
  else{
    cout << S + "s" << endl;
  }
}


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

using namespace std;

void hawawa()
{
	int n;
	cin >> n;
	map<char, int> cnt;
	for (char c = 'a'; c <= 'z'; c++) {
		cnt[c] = numeric_limits<int>::max();
	}
	while (n--) {
		string str;
		cin >> str;
		sort(begin(str), end(str));
		for (char c = 'a'; c <= 'z'; c++) {
			cnt[c] = min<int>(cnt[c], upper_bound(begin(str), end(str), c) - lower_bound(begin(str), end(str), c));
		}
	}
	for (char c = 'a'; c <= 'z'; c++) {
		cout << string(cnt[c], c);
	}
	cout << "\n";
}

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


Measured memory_bytes: 256
import numpy as np

N, M, K = list(map(int, input().split()))
A = list(map(int, [0] + input().split()))
B = list(map(int, [0] + input().split()))
cost = 0
cumsum_a = np.cumsum(A)
cumsum_b = np.cumsum(B)

num_book = 0
max_a = 0
ind_b = 0
max_b = 0
for i in range(1, N + 1):
    if cumsum_a[i] <= K:
        max_a = i
    else:
        break

for i in range(1, M + 1):
    if cumsum_b[i] <= K:
        max_b = i
    else:
        break

for i in range(max_a, -1, -1):
    for j in range(ind_b, max_b+1):
        if cumsum_b[j] + cumsum_a[i] <= K:
            # print("ok")
            num_book = max(i + j, num_book)
            ind_b = j
        else:
            break
print(num_book)


Measured memory_bytes: 59564
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))

L = [0]
R = [0]

for i in range(N):
    L.append(gcd(L[i], A[i]))  # 0, gcd(0,A[0]), gcd(0,A[0],A[1]) , ...
    R.append(gcd(R[i], A[N - i -1])) # 0 , gcd(0, A[N-1]), gcd(0, A[N-1], A[N-2]))..

R.reverse() # R is gcd(0,A[N-1]...A[0]), gcd(0,A[N-1]...A[1]),....
# pairs are 
#  L     :R
#  0    : (0,A[N-1],A[n-2], ... A[1])
#  A[0] : (0,A[N-1],A[n-2], ... A[2])
#  ...
#  A[0,1,..N-3] :(0,A[N-1]
#  A[0,1,..N-2] :(0)
print(max( (gcd(L[i], R[i+1]) for i in range(N))))



Measured memory_bytes: 16116
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	LL n, k; cin >> n >> k;

	vector<pair<LL, LL>> p(n);

	for (int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;

		p[i].first = a;
		p[i].second = b;
	}

	sort(p.begin(), p.end());

	LL cnt = 0;
	for (int i = 0; i < n; i++) {
		cnt += p[i].second;
		if (cnt >= k) {
			cout << p[i].first << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
    int a;
    int n;
    int m;
    int x;
    int y;
    int cnt = 0;
    int sum;
    int tmp;
    int i;
    
    scanf("%d%d%d", &a, &n, &m);
    
    for(y = 1; y <= 72; y++)
    {
        x = 1;
        for(i = 0; i < n; i++)
        {
            x = x * (y + a);
        }
        
        sum = 0;
        tmp = x;
        while(tmp > 0)
        {
            sum = sum + tmp % 10;
            tmp = tmp / 10;
        }
        
        if((x <= m) && (sum == y))
        {
            cnt++;
        }
    }
    
    printf("%d\n", cnt);
    
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=b-1;i>=a;i--)
const ll maxn=3e3+5, mod=1e9+7;
ll n,dp[maxn][maxn];
string s;
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>n>>s;
    dp[1][1]=1;
    rep(i,2,n+1)
        if(s[i-2]=='<')
            rep(j,1,i+1)
                dp[i][j]=(dp[i-1][j-1]+dp[i][j-1])%mod;
        else
            per(j,1,i+1)
                dp[i][j]=(dp[i-1][j]+dp[i][j+1])%mod;
    ll ans=0; rep(i,1,n+1) (ans+=dp[n][i])%=mod;
    cout<<ans<<"\n";

}


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


void solve(long long S, long long W){
  cout << ((S <= W) ? "unsafe" : "safe") << endl;
}

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


Measured memory_bytes: 3688
#include<stdio.h>

int main(void)
{
 int  n, a[100000];
 int  i, s;
 long int   c1, c2;

scanf("%d", &n);

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

s=0;
c1=0;
for(i=0; i<n; i++){
s+=a[i];
if(i%2==0){
while(s >= 0){
s--;
c1++;
}
}else{
while(s <= 0){
s++;
c1++;
}
}
}
s=0;
c2=0;
for(i=0; i<n; i++){
s+=a[i];
if(i%2!=0){
while(s >= 0){
s--;
c2++;
}
}else{
while(s <= 0){
s++;
c2++;
}
}
}

if(c1 < c2)
printf("%ld\n",c1);
else
printf("%ld\n",c2);

return 0;
}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;

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

    static class CMakeARectangle {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            HashSet<Long> seen = new HashSet<>();
            PriorityQueue<Long> max = new PriorityQueue<>(Comparator.reverseOrder());

            for (int i = 0; i < n; i++) {
                long a = in.nextInt();
                if (seen.contains(a)) {
                    max.add(a);
                    seen.remove(a);
                } else {
                    seen.add(a);
                }
            }

            long answer = max.size() >= 2 ? max.poll() * max.poll() : 0;

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 46224
#include <bits/stdc++.h>
using namespace std;
#define  yn(a) cout << ( (a)?"Yes\n":"No\n" )

int main()
{
    int n;
    string s;
    cin>>n>>s;
    yn(s.substr(0,n/2)==s.substr(n/2));
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int dp[305][305][305];
char s[maxn];

int main()
{
	scanf("%s",s+1); int K=read(),len=strlen(s+1);
	rep(i,1,len) dp[i][i][0]=1;
	rep(i,2,len) for(int l=1;l+i-1<=len;l++) for(int k=0;k<=K;k++)
	{
		int r=l+i-1;
		dp[l][r][k]=max(dp[l+1][r][k],dp[l][r-1][k]);
		if(s[l]==s[r]) dp[l][r][k]=max(dp[l][r][k],dp[l+1][r-1][k]+2);
		if(k) dp[l][r][k]=max(dp[l][r][k],dp[l+1][r-1][k-1]+2);
	}
	int ans=0;
	rep(i,0,K) ans=max(ans,dp[1][len][i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 58600
package main

import (
	"fmt"
	"math"
)

func main() {
	var h, w, n float64
	fmt.Scan(&h)
	fmt.Scan(&w)
	fmt.Scan(&n)

	var large float64
	if h > w {
		large = h
	} else {
		large = w
	}

	c := math.Ceil(n / large)
	fmt.Println(c)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define FILL(i,n) memset(i,n,sizeof(i));
#define X first
#define Y second
#define pb push_back
#ifdef brian
#define  debug(...) do{\
    fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename t> void _do(t &&x){cerr<<x<<endl;}
template<typename t,typename ...T> void _do(t &&x,T &&...tail){cerr<<x<<", ";_do(tail...);}
#else
#define debug(...)
#endif // brian


ll n,k;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>k>>n;
    ll ans=0;
    REP(i,k+1)
    {
        REP(j,k+1)
        {
            if(n-i-j>=0&&n-i-j<=k)ans++;
        }
    }
    cout<<ans<<endl;

}


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

int main(){
int N;
  cin >> N;
  vector<double> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
  double s=0, t=0;
  for(int j=0 ; j< N ; j++){
     s=s+ 1.0/vec.at(j);
  }
  t= 1.0/s;
  cout << t << endl;




return 0;
}

Measured memory_bytes: 256
/*
Author : Chandan Agrawal
College : Poornima College of Engg. jaipur, Raj
Mail : chandanagrawal23@gmail.com


" when you are not practicing someone else is ,
 and the day u meet them u will lose "

*/
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 200050

#define ll long long
#define ld long double
#define lli long long int

#define pb push_back
#define INF 1000000000000
#define mod 1000000007

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))

#define loop(i,n)  for (lli i = 0; i < n; i++)
#define FOR(i,a,b) for (lli i = a; i < b; i++)

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define makeuniq(v) v.resize(unique(all(v)) - v.begin()); //only uniq element in vector after this
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>

#define pii pair<lli,lli>

#define vi vector<lli>
#define vvi vector<vi>
#define vpi vector<pii>
#define vbool vector<bool>

#define seti set<lli>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

#define endl '\n'

template <typename Head>
void print(Head&& head)
{
    cout<<head<<endl;
}
template <typename Head, typename... Tail>
void print(Head&& head, Tail... tail)
{
    cout<<head<<" ";
    print(tail...);
}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvec(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.pb(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvec(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define deb(x) cout<<#x<<" "<<x<<endl;

/*
1D vector -  vi dp(n,value);
2D vector -  vvi dp(n,vi(n,value));
*/

// chandan1,2
void chandan1(){int y=1;return;}
void chandan2(){
        loop(i,10){
        lli x=1;
    }
    return(chandan1());
}


int main(){
fastio
lli t=1;
//cin>>t;
chandan2();
while(t--) {
    string a,b;
    cin>>a>>b;
    lli mini = INF;
    for(lli i=0;i<=sz(a)-sz(b);i++)
    {
        lli j=i;
        lli k=0;
        lli cnt=0;
        while(j<sz(a) and k<sz(b))
        {
            if(a[j] == b[k])
                cnt+=1;
            j++;
            k++;
        }
        mini = min(mini , sz(b)-cnt);
    }
    print(mini);
  }
return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
int n,m,A,B;
char a[N][N];
int main()
{
    memset(a,'.',sizeof(a));
    scanf("%d%d%d%d",&n,&m,&A,&B);
    if(n&1)
        for(int i=1;i+1<=m;i+=2)
    {
        if(A)
        {
            A--;
            a[n][i]='<';
            a[n][i+1]='>';
        }
    }
    if(m&1)
        for(int i=1;i+1<=n;i+=2)
    {
        if(B)
        {
            B--;
            a[i][m]='^';
            a[i+1][m]='v';
        }
    }
    for(int i=1;i+1<=n;i+=2)
        for(int j=1;j+1<=m;j+=2)
    {
        if(A>=2)
        {
            a[i][j]='<';
            a[i][j+1]='>';
            a[i+1][j]='<';
            a[i+1][j+1]='>';
            A-=2;
        }
        else if(B>=2)
        {
            a[i][j]='^';
            a[i+1][j]='v';
            a[i][j+1]='^';
            a[i+1][j+1]='v';
            B-=2;
        }
        else if(A)
        {
            A--;
            a[i][j]='<';
            a[i][j+1]='>';
        }
        else if(B)
        {
            B--;
            a[i][j]='^';
            a[i+1][j]='v';
        }
    }
    if(n%2&&m%2&&(A||B))
    {
        for(int i=n-2;i<=n;i++)
            for(int j=m-2;j<=m;j++)
        {
            if(a[i][j]=='<'&&a[i][j+1]=='>') A++,a[i][j]=a[i][j+1]='.';
            if(a[i][j]=='^'&&a[i+1][j]=='v') B++,a[i][j]=a[i+1][j]='.';
        }
        if(B)
        {
            B--;
            a[n-2][m-2]='^';
            a[n-1][m-2]='v';
        }
        if(B)
        {
            B--;
            a[n-1][m]='^';
            a[n][m]='v';
        }
        if(A)
        {
            A--;
            a[n-2][m-1]='<';
            a[n-2][m]='>';
        }
        if(A)
        {
            A--;
            a[n][m-2]='<';
            a[n][m-1]='>';
        }
    }
    if(A||B)
        printf("NO\n");
    else
    {
        printf("YES\n");
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
        {
            putchar(a[i][j]);
            if(j==m) putchar('\n');
        }
    }
}


Measured memory_bytes: 2176
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
struct P{
	double x,y;
};
P p[100];
double func(int i){
	double a = sqrt((p[0].x - p[i-1].x)*(p[0].x - p[i-1].x)+(p[0].y - p[i-1].y)*(p[0].y - p[i-1].y));
	double b = sqrt((p[0].x - p[i].x)*(p[0].x - p[i].x)+(p[0].y - p[i].y)*(p[0].y - p[i].y));
	double c = sqrt((p[i].x - p[i-1].x)*(p[i].x - p[i-1].x)+(p[i].y - p[i-1].y)*(p[i].y - p[i-1].y));
	double z = (a + b + c)/2;
	return sqrt(z*(z-a)*(z-b)*(z-c));
}
int main(){
	double x,y;
	int cnt = 0;
	while(~scanf("%lf,%lf",&p[cnt].x,&p[cnt].y)){
		cnt++;
	}
	double ans = 0;
	for(int i = 2; i < cnt; i++){
		ans += func(i);
	}
	printf("%.6lf\n",ans);
}

Measured memory_bytes: 1240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		int sum = 0;
		for(int i = 1; sum <= A * B; i++) {
			sum = A * i;
			if(sum % B == C) {
				System.out.println("YES");
				break;
			}
			if(sum > A * B) {
				System.out.println("NO");
				break;
			}
		}
		scan.close();

	}

}


Measured memory_bytes: 23252
import sys

# N個の整数
N = int(input())

a = list(map(int, input().split()))

ans = 10**18
# 最小値から最大値の間の値のどれに書き換えるかをループで調べる
for i in range(min(a),max(a)+1):
    tmp=0
    # 試しに入れ替えてみる
    for j in range(N): 
        # 入れ替えたときのコスト計算
        tmp += (a[j]-i)**2
    # 最小値を記録する
    ans=min(ans,tmp)

print(ans)

Measured memory_bytes: 38512
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    uint64_t h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    uint64_t res = h * w / 2;
    if (h % 2 == 1 && w %2 == 1) {
        res++;
    }
    cout << res << endl;
}


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

int main(){
    const double PI=3.14159265358979323846;
    int r; cin >> r;
    cout << fixed << 2 * PI * r << endl;
}

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

using namespace std;

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

    vector<int> prime;

    for(int i=0;i<55555;i++){
        prime.push_back(1);
    }
    for(int i=2;i<sqrt(55555);i++){
        if(prime[i]){
            for(int j=0; i*(j+2) < 55555;j++){
                prime[i*(j+2)] = 0;
            }
        }
    }


    prime[0] = prime[1] = 0;

    vector<int> ans;

    for(int i=0; ans.size()<N;i++){
        if(prime[i] == 1 && i % 5 == 1){
            ans.push_back(i);
        }
    }

    for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";

    cout<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int A[20], n;

bool is_combinated(int i, int m){
  if(m == 0) return true;
  else if(m < 0  || i >= n) return false;
  bool res = is_combinated(i+1, m) || is_combinated(i+1, m-A[i]);
  return res;
}

int main(void){
  int q, m;
  scanf("%d", &n);
  for(int i=0; i<n; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);

  for(int i=0; i<q; i++){
    scanf("%d", &m);
    if(is_combinated(0, m)){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }
  return 0;
}



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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

constexpr int INF = 1e9 + 1;
constexpr ll LINF = 1e18;
constexpr int MOD = 1e9 + 7;

//-------------------------------------------------------------------------------
template<typename T>
class WeightedUnionFind{
public:
    WeightedUnionFind( int N );

    int FindRoot( int x );
    int GetWeight( int x );
    void Unite( int x, int y, T w );
    bool IsSameRoot( int x, int y );
    T DiffWeight( int x, int y );
    int GetComponent() const{ return mComponent; };

private:
    std::vector<int> mParent, mRank;
    std::vector<T> mDiffWeight;
    int mComponent;
};

template<typename T>
WeightedUnionFind<T>::WeightedUnionFind( int N ) :
    mComponent( N )
{
    mParent.resize( N ), mRank.resize( N ), mDiffWeight.resize( N );
    for( int i = 0; i < N; i++ ) mParent[i] = i, mRank[i] = mDiffWeight[i] = 0;
}

template<typename T>
int WeightedUnionFind<T>::FindRoot( int x ){
    if( x == mParent[x] ){
        return x;
    }else{
        int r = FindRoot( mParent[x] );
        mDiffWeight[x] += mDiffWeight[mParent[x]];
        return mParent[x] = r;
    }
}

template<typename T>
int WeightedUnionFind<T>::GetWeight( int x ){
    FindRoot( x );
    return mDiffWeight[x];
}

template<typename T>
void WeightedUnionFind<T>::Unite( int x, int y, T w ){
    w += GetWeight( x ), w -= GetWeight( y );
    x = FindRoot( x ), y = FindRoot( y );
    
    if( x == y ) return;
    if( mRank[x] < mRank[y] ) swap( x, y ), w = -w;
    if( mRank[x] == mRank[y] ) mRank[x]++;
    mParent[y] = x;
    mDiffWeight[y] = w;
    mComponent--;
}

template<typename T>
bool WeightedUnionFind<T>::IsSameRoot( int x, int y ){
    return FindRoot( x ) == FindRoot( y );
}

template<typename T>
T WeightedUnionFind<T>::DiffWeight( int x, int y ){
    return GetWeight( y ) - GetWeight( x );
}
//--------------------------------------------------------------------------

int main(){
    int N, M; cin >> N >> M;
    WeightedUnionFind<int> wuf( N );
    bool ok = true;
    for( int i = 0; i < M; i++ ){
        int l, r, d; cin >> l >> r >> d;
        l--, r--;
        if( wuf.IsSameRoot( l, r ) ){
            int diff = wuf.DiffWeight( l, r );
            if( d != diff ) ok = false; 
        }else{
            wuf.Unite( l, r, d );
        }
    }

    if( ok ) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define maxN 200005

using namespace std;

long long a[maxN], b[maxN], pA[maxN], pB[maxN], sum, k;

int main() {
    int n, m, ans = 0;

    cin >> n >> m >> k;
    for (int i=0; i<maxN; ++i) {
        a[i]=INT_MAX;
        b[i]=INT_MAX;
        pA[i]=INT_MAX;
        pB[i]=INT_MAX;
    }

    pA[0] = 0;
    pB[0] = 0;
    for (int i=0; i<n; ++i) {
        cin >> a[i];
        pA[i + 1] = (i==0?a[i]:pA[i]+a[i]);
    }
    for (int i=0; i<m; ++i) {
        cin >> b[i];
        pB[i + 1] = (i==0?b[i]:pB[i]+b[i]);
    }

    for (int i=0; i<=n; ++i) {
        if (k<pA[i]) continue;

        int x = k - pA[i];
        int y = upper_bound(pB, pB + maxN, x) - pB - 1;

        ans = max(ans, y + i);
    }

    cout << ans << "\n";
}


Measured memory_bytes: 9720
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;
                                                                                                     
ll MOD=1000000007;                                                                                     
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    vector<pp> u,d;
    rep(i,n){
        string s; cin>>s;
        int dmin=0,cur=0;
        rep(j,s.size()){
            if(s[j]=='(') cur++;
            else cur--;
            dmin=min(dmin,cur);
        }
        if(cur>0) u.push_back(mk(dmin,cur-dmin));
        else d.push_back(mk(cur-dmin,dmin));
    }
    if(u.size()>0){
        sort(al(u)); reverse(al(u));
    }
    if(d.size()>0){
        sort(al(d)); reverse(al(d));
    }
    int dmin=0,cur=0;
    rep(i,u.size()){
        cur+=u[i].first;
        dmin=min(dmin,cur);
        cur+=u[i].second;
    }
    rep(i,d.size()){
        cur+=d[i].second;
        dmin=min(dmin,cur);
        cur+=d[i].first;
    }
    if(cur==0 && dmin==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 11076
/* ex4_2
    riverstone*/

#include<stdio.h>
#include<math.h>

int main(void){

    double len_h, len_m, hour, min;
    scanf("%lf %lf %lf %lf", &len_h, &len_m, &hour, &min);

    double theta_h = 2 * M_PI * (hour + min/60)/12; //時針と12の間のなす角度 [rad]
    double theta_m = 2 * M_PI * min/60; //分針と12の間のなす角度[rad]
    double theta = theta_h - theta_m; //時針と分針の間のなす角度[rad]
    
    //余弦定理より距離を求める
    double ans = sqrt(pow(len_h, 2) + pow(len_m, 2) - 2*len_h*len_m * cos(theta)); 
 
    printf("%.10f\n", ans); //ansを出力
 
    return 0;

}

Measured memory_bytes: 2592
def gcd(a,b):
    if b==0:
        return a
    return (gcd(b,a%b))
def lcm(a,b):
    return a*b//gcd(a,b)
n=int(input())
if n==1:
    print(int(input()))
    exit()
ans=1
for i in range(n):
    ans=lcm(ans,int(input()))
print(int(ans))

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

using namespace std;

int main()
{
    int x,y;
    cin >> x >> y;
    int a = 4*x - y;
    int b = y - 2*x;
    if((a>=0)&&(a%2 == 0))
    {
        if((b>=0)&&(b%2 == 0))
        {
             cout << "Yes" << endl;
             return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> c(10, vector<int>(10));
    for (auto& e : c) for (auto& f : e) cin >> f;
    vector<int> m(10);
    for (int i = 0; i < h * w; i++) {
        int a;
        cin >> a;
        if (a != -1) m[a]++;
    }
    

    vector<int> to1(10);
    for (int i = 0; i < 10; i++) to1[i] = c[i][1];
    bitset<10> done;
    while (!done.all()) {
        vector<int> can(10, 1e9);
        for (int i = 0; i < 10; i++) {
            if (!done[i]) can[i] = to1[i];
        }
        int mi = min_element(begin(can), end(can)) - begin(can);
        done.set(mi);
        for (int i = 0; i < 10; i++) {
            if (!done[i] && to1[i] > to1[mi] + c[i][mi]) to1[i] = to1[mi] + c[i][mi];
        }
    }

    int ans = 0;
    for (int i = 0; i < 10; i++) ans += to1[i] * m[i];
    cout << ans << endl;
}


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

using namespace std;

const int INF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& v : a)
        cin >> v;
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 2; i < n; i++){
        for (int j = i - 1; j > 0; j--){
            int p = upper_bound(a.begin() ,a.end(), a[i] - a[j]) - a.begin();
            ans +=  max(j - p, 0);
        }
    }
    cout << ans;
}

Measured memory_bytes: 384
import heapq
import itertools
N,M,R=map(int, raw_input().split())
r=map(int, raw_input().split())

cost=[ [ float("inf") for i in range(N+1)] for i in range(N+1) ]
nl=[ [] for i in range(N+1) ]

for i in range(M):
	A,B,C=map(int, raw_input().split())
	cost[A][B]=C
	cost[B][A]=C
	nl[A].append(B)
	nl[B].append(A)


for i in range(N+1): cost[i][i]=0


def Dij(start):

	#Initialize
	d=[float("inf") for i in range(N+1)]
	d[start]=0
	q=[]
	heapq.heappush(q,(0,start))
	
	while len(q)!=0:
		tmp=heapq.heappop(q)
		u=tmp[1]

		for v in nl[u]:
			alt=d[u]+cost[u][v]
			if d[v]>alt:
				d[v]=alt
				heapq.heappush(q,(alt,v))
	return d


l=list(itertools.permutations(r))

C={}
for i in r:
	C[i]=Dij(i)


ans=float("inf")


for i in l:
	dist=0
	for j in range(R):
		if j==0:
			prev=i[j]
			continue
		cur=i[j]
		dist+=C[prev][cur]
		prev=cur
	ans=min(ans,dist)

print ans




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


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

void insert(int);
struct Node inorder(struct Node *);
struct Node preorder(struct Node *);

struct Node *root, *NIL;


int main(){
  int n=0;
  int i=0;
  int number=0;
  char word[6];
  char space;
  int print_flag=0;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%s",word);

    if(word[0]=='i')
      {
	scanf("%d%c",&number,&space);
	insert(number);
      }

    else if(word[0]=='p')
      {
	print_flag=1;
      }
    
    if(print_flag==1){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      print_flag=0;
    }
  }

 

    return 0;
}

void insert(int number){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=number;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if( z->key < x->key ) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if( z->key < y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}

struct Node inorder(struct Node *a){
  if(a==NIL)return;
  inorder(a->left);
  printf(" %d",a->key);
  inorder(a->right);
}

struct Node preorder(struct Node *a){
  if(a==NIL)return;
  printf(" %d",a->key);
  preorder(a->left);
  preorder(a->right);
}



Measured memory_bytes: 25180
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
for k in range(M):
    x, y, c = map(int, input().split())
    ans = min((ans), ((a[x - 1] + b[y - 1]) - c))
print(ans)

Measured memory_bytes: 18736
use std::io::Read;
use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut graph: Vec<Vec<(usize, usize)>> = vec![Vec::new(); n];
    for _ in 0..(n - 1) {
        let u: usize = iterator.next().unwrap().parse().unwrap();
        let v: usize = iterator.next().unwrap().parse().unwrap();
        let w: usize = iterator.next().unwrap().parse().unwrap();
        graph[u - 1].push((v - 1, w));
        graph[v - 1].push((u - 1, w));
    }

    let mut colors: Vec<usize> = vec![2; n];
    let mut q: VecDeque<usize> = VecDeque::new();
    colors[0] = 0;
    q.push_back(0);
    while let Some(u) = q.pop_front() {
        for &(v, w) in &graph[u] {
            if colors[v] != 2 {
                continue;
            }
            if w % 2 == 0 {
                colors[v] = colors[u];
            } else {
                colors[v] = if colors[u] == 0 { 1 } else { 0 };
            }
            q.push_back(v);
        }
    }
    let mut result = String::new();
    for i in 0..n {
        result.push_str(&format!("{}\n", colors[i]));
    }
    result.trim().to_string()
}


Measured memory_bytes: 12732
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int c[101];
int main()
{
    int a,b,k;
    while(cin>>a>>b>>k){
    	int n=min(a,b);
    	int t=0;
    	for(int i=n;i>=1;i--){
    		if(a%i==0&&b%i==0){
    			c[t++]=i;
    			if(t>k) break;
			}
    	}
    	cout<<c[k-1]<<endl;
    }
    
    return 0;
}


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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

void solve(){
	string s,t;
	cin >> s >> t;
	int ans = INT_MAX;
	int n = s.size(), m = t.size();
	for(int i = 0;i <= n-m;i++){
		int cnt = 0;
		for(int j = 0;j < m;j++){
			if(s[i+j]!=t[j])
				cnt++;
		}
		//cout << i << " " << ans << "\n";
		ans = min(cnt,ans);
	}
	cout << ans << "\n";
}

signed main(){
	fastio
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 102;
const int maxm = 100002;
const int mo = 1e9 + 7;

int n, m, f[maxn][maxm], d[maxn];

void add(int &a, int b) {
    a += b;
    a %= mo;
}

void sub(int &a, int b) {
    a = (a - b) % mo + mo;
    a %= mo;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	

    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> d[i];
    }

    f[0][0] = 1;
    int sum = 0;

    for (int i = 1; i <= n; ++i) {
        sum += d[i];
        for (int j = 0; j <= sum && j <= m; ++j) {
            f[i][j] = f[i-1][j];
            if (j > 0)
                add(f[i][j], f[i][j-1]);
            if (j-1 >= d[i])
                sub(f[i][j], f[i-1][j-1-d[i]]);
        }
    }

    cout << f[n][m] << endl;
	return 0;
}

Measured memory_bytes: 39296
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let N = R int
    let S = R string
    if S.[0..(S.Length/2 - 1)] = S.[S.Length/2..(S.Length - 1)] then "Yes" else "No"
    |>stdout.WriteLine
    0


Measured memory_bytes: 11220
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

std::string S;

int main()
{
  std::cin >> S;

  for( int K = S.size(); K >= 1; --K )
  {
    int len = 2*K-S.size();

    char prv = S.size()%2?S[S.size()/2]:'\0';
    repi( i, 1, len/2+1 )
    {
      if( S[S.size()/2+i+(S.size()%2?0:-1)] == S[S.size()/2-i] && (prv == '\0' || S[S.size()/2-i] == prv) )
      {}
      else
        goto next;

      prv = S[S.size()/2-i];
    }

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

next:;
  }

  return 0;
}

Measured memory_bytes: 512
x1=[]
y1=[]
for i in range(4):
    A=int(input())
    x1.append(A)
x=sorted(x1,reverse=True)
for j in range(2):
    E=int(input())
    y1.append(E)
y=sorted(y1,reverse=True)
sum=x[0]+x[1]+x[2]+y[0]
print(sum)


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000


//// UnionFind
struct UnionFind{
	vector<int> v,l,r;
	UnionFind(int n) : v(n, -1) {
		l=r=vector<int>(n);
		rep(i,n)l[i]=r[i]=i;
	}

	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
		minch(l[x],l[y]);
		maxch(r[x],r[y]);
		return true;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};


int n;
ll a[222222],idx[222222];

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(i,n){
		cin>>a[i];a[i]--;
	}
	rep(i,n)idx[a[i]]=i;
	ll sum=0;
	UnionFind uf(n);
	for(int v=n-1;v>=0;v--){
		int i=idx[v];
		if(i>0&&a[i-1]>a[i])uf.unite(i-1,i);
		if(i<n-1&&a[i+1]>a[i])uf.unite(i+1,i);
		int x=uf.find(i);
		ll l=i-uf.l[x],r=uf.r[x]-i;
		sum+=(l+1)*(r+1)*(v+1);
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 5760
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    int min_id;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] == 1) {
            min_id = i;
        }
    }
    int ans;
    if ((N - 1) % (K - 1) == 0) {
        ans = (N - 1) / (K - 1);
    } else {
        ans = (N - 1) / (K - 1) + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
int main()
{
  ll n,a[200];
  cin >> n;
  rep(i,n)cin >> a[i];
  sort(a,a+n);
  printf("%lld",a[n-1]-a[0]);
}

Measured memory_bytes: 256