akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"math"
	"os"
)

func main() {
	var n, k int
	fmt.Fscanf(os.Stdin, "%d %d", &n, &k)

	nums := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Fscanf(os.Stdin, "%d", &nums[i])
	}

	fmt.Println(Count(nums, k))
}

func Count(nums []int, K int) int {
	if len(nums) <= 1 {
		return 0
	}
	n := len(nums)

	dp := make([]int, n)

	dp[0] = 0
	dp[1] = abs(nums[1] - nums[0])

	for i := 2; i < n; i++ {
		m := math.MaxInt64
		for j:=1; j<=K && i-j >= 0; j++ {
			m = min(m, dp[i-j] + abs(nums[i-j] - nums[i]))
		}
		dp[i] = m
		// fmt.Println(dp[i])
	}

	return dp[n-1]
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}


Measured memory_bytes: 5504
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc145/tasks/abc145_b
n = int(input())
s = input()
if n % 2 != 0:
    print('No')
    exit()
n2 = n // 2
if s[0:n2] == s[n2:n]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
int main(){
    int a, b;
    char op;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if(op=='?'){
            break;
        }else if(op=='+'){
            printf("%d\n", a+b);
        }else if(op=='-'){
            printf("%d\n", a-b);
        }else if(op=='*'){
            printf("%d\n", a*b);
        }else if(op=='/'){
            printf("%d\n", a/b);
        }
    }
    return 0;
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    
    int sum = 0;
    int n = N;
    while (n>0) {
        sum += n % 10;
        n /= 10;
    }
    
    if (N % sum == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>

#define INF 1000000000000000000
using namespace std;
typedef long long ll;

int main() {
	ll x, y;
	cin >> x >> y;
	bool flg = true;
	if ((x*y - x) % y)flg = false;
	if (!flg)cout << x * y - x << endl;
	else cout << "-1" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pow power
#define int long long
using namespace std;
const int mod=1e9+7;
int sqr(int x){return x*x%mod;}
int pow(int a,int n){return !n?1:sqr(pow(a,n/2))*(n&1?a:1)%mod;}
int n,a,b,c,f[220001],invf[220001];
int C(int x,int y){return f[x]*invf[y]%mod*invf[x-y]%mod;}
main()
{
	cin>>n>>a>>b>>c;
	int inv100=pow(100,mod-2);
	a=a*inv100%mod;
	b=b*inv100%mod;
	c=c*inv100%mod;
	int ab=(a+b)%mod,invab=pow(ab,mod-2);
	a=a*invab%mod;
	b=b*invab%mod;
	f[0]=1;
	for(int i=1;i<=2*n;i++)f[i]=f[i-1]*i%mod;
	invf[2*n]=pow(f[2*n],mod-2);
	for(int i=2*n-1;i>=0;i--)invf[i]=invf[i+1]*(i+1)%mod;
	int ans=0;
	for(int i=0;i<n;i++)ans+=C(n+i-1,i)*(pow(a,n)*pow(b,i)%mod+pow(a,i)*pow(b,n)%mod)%mod*(n+i)%mod;
	cout<<ans%mod*pow((mod+1-c)%mod,mod-2)%mod<<'\n';
}


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<string> s(N);
  
  rep(i, N){
  	s[i] = S.at(i);
  }
  
  int count = 0;
  rep(i, N-1){
  	if(s[i]!=s[i+1]) count++;
  }
  
  cout << count+1 << endl;
  

}

Measured memory_bytes: 5760
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	int N;
	scanf("%d", &N);

	map <int, int> mp;
	for (int i = 0; i < N; ++i)
	{
		int tmp;
		scanf("%d", &tmp);

		mp[tmp]++;
	}

	int ans = 0;

	for (auto& a : mp)
	{
		if (a.second > a.first)
		{
			ans += a.second - a.first;
		}
		else if (a.second < a.first)
		{
			ans += a.second;
		}
	}


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

	return 0;

}


Measured memory_bytes: 4736
import java.util.*;

class Main {
	 Scanner sc = new Scanner(System.in);

	public void run() {
		while(sc.hasNext()){
			String[] str=sc.next().split(",");
			P p1=new P(Double.parseDouble(str[0]),Double.parseDouble(str[1]));
			P p2=new P(Double.parseDouble(str[2]),Double.parseDouble(str[3]));
			P p=new P(Double.parseDouble(str[4]),Double.parseDouble(str[5]));
			P pa=p2.s(p1);
			P s=p.s(p1);
			double arg=s.arg()- pa.arg();
			P res=p1.a(s.rotate(-2*arg));
			ln(String.format("%.6f",res.x)+" "+String.format("%.6f",res.y));
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

class P{
	double x;
	double y;
	P(double _x,double _y){
		x=_x;
		y=_y;
	}

	public static  final P Xunit=new P(1,0);
	public static  final P Yunit=new P(0,1);


	public static double dot(P a,P b){
			return a.x*b.x+a.y*b.y;
	}
	public static  double cross(P a,P b){
		return a.x*b.y-a.y*b.x;
	}
	public static boolean isParallel(P a1,P a2,P b1,P b2){
		return Math.abs(cross(a2.s(a1),b2.s(b1)))<Double.MIN_NORMAL;
	}
	public static boolean isVertical(P a1,P a2,P b1,P b2){
		return Math.abs(dot(a2.s(a1),b2.s(b1)))<Double.MIN_NORMAL;
	}

	public P a(P a){
		return new P(x+a.x,y+a.y);
	}
	public P s(P a){
		return new P(x-a.x,y-a.y);
	}

	public double norm(){
		return Math.sqrt(x*x+y*y);
	}
	public double arg(){
		double s=Math.acos(x/norm());
		return y>0?s:2*Math.PI-s;
	}

	public P rotate(double t){
		return new P(Math.cos(t)*this.x-Math.sin(t)*this.y,Math.sin(t)*this.x+Math.cos(t)*this.y);
	}

	public static int ccw(P a,P b,P c){
		if(P.cross(b.s(a),c.s(a))>Double.MIN_NORMAL){
			return 1;
		}
		if(cross(b.s(a),c.s(a))<-Double.MIN_NORMAL){
			return -1;
		}
		if(dot(b,c)<-Double.MIN_NORMAL)return 2;
		if(b.norm()<c.norm()-Double.MIN_NORMAL)return -2;
		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof P){
			P p=(P)obj;
			return x==p.x && y==p.y;
		}
		return false;
	}
	public String toString(){
		return "("+x+","+y+")";
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <map>
#include <numeric>
#include <set>
using namespace std;

#define ll long long
#define ld long double
const double PI = 3.14159265359;

// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// vector 要素の総和算出
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// vector 最大値( return ite )
#define _max_element(v) max_element(v.begin(),v.end())
// vector 最大値が格納されている要素値
#define _max_element_number(v) distance(v.begin(),max_element(v.begin(),v.end()))

//set<uint32_t> member;	// 重複するデータを保持する事はできない member.insert(2) member.insert(2) ⇒ member.count(2)は1
//                                                              member.emplace(2)とかも同じ
//multiset<uint32_t> v;	// 重複するデータも保持する事はできる   member.insert(2) member.insert(2) ⇒ member.count(2)は2

// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値 ex) 3.30303 ⇒ 4
#define _ceil(x) ceil(x)
// 指定された要素以上の値が現れる最初の位置のイテレータを取得する
#define _lower_bound(v,min) lower_bound(v.begin(), v.end(), min)
// 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
#define _upper_bound(v,min) upper_bound(v.begin(), v.end(), min)

// 順列 n個の数が与えられる
// 0,1,2,...,n-1
// 全ての並べ方を1行ごとに出力する
// ex 0 1 2 / 0 2 1 / 1 0 2 / 1 2 0 / 2 0 1 / 2 1 0
#define _next_permutation(v) do {   \
	for (auto num : v) {            \
		printf("%d ", num);         \
	}                               \
	printf("\n");                   \
} while (next_permutation(v.begin(), v.end()))

// 絶対値
static int32_t _abs(const int32_t x) { return  (x > 0 ? x : -x); }
// 最大公約数
static int gcd(int a, int b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}
// 最小公倍数
static int lcm(int a, int b) { return a * b / gcd(a, b); }
// 多次元 std::vector 生成
template<class T>
vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
// ex) auto dp = make_vec<uint64_t>(SIZE + 1, 2, 2);

// UINT32_MAX
// 4294967295 ≒ 4 * 1e9 


/*

*/
// ABC 162 A
// https://atcoder.jp/contests/abc162/tasks/abc162_a
int main()
{

#if 1
	string s;
	cin >> s;

	if (s[2] == '7' || s[1] == '7' || s[0] == '7') {
		printf("Yes\n");
		return 0;
	}

	printf("No\n");
#else
	uint32_t n;
	cin >> n;

	for (uint32_t i = 0; i < 3; i++) {
		if ((n % 10) == 7) {
			printf("Yes\n");
			return 0;
		}
		n /= 10;
	}
#endif // 0
	return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(){
	int n;
	long long int sum=0;
	scanf("%d",&n);

	for(int i =1;i<=n;i++){
		if(i%5 == 0 || i%3==0){
			continue;
		}
		else{
			sum += i;
		}
	}
			printf("%lld\n",sum);

	
	return 0;
}

Measured memory_bytes: 2112
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a[] = new int[N];
    int count = 0;

    for(int i = 0; i < N; i++){
      a[i] = sc.nextInt();
    }

    for(int i = 0; i < N; i++){
      if(i%2 == 0 && a[i]%2 == 1){
        count++;
      }
    }
    System.out.println(count);
  }
}


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

signed main() {
  int n;
  cin >> n;

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

  int answer = 1000;
  int stock = 0;
  int low = a[0];
  int high = a[0];


  for (int i = 1; i < n; i++) {
    if(a[i] > low && stock == 0) {
      stock = answer / low;
      answer -= stock * low;
      high = 100;
    }
    if(a[i] < high) {
      answer += stock * high;
      stock = 0;
      low = 200;
    } else if(i == n - 1 && a[i] >= high) {
      answer += stock * a[i];
    }
    low = min(low, a[i]);
    high = max(high, a[i]);
  }

  cout << answer << '\n';

}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	lint N;
	cin >> N;
	vector<lint>A(3 * N);
	rep(i, 3 * N) {
		cin >> A[i];
	}
	sort(A);
	reverse(A);
	lint ans = 0;
	rep(i, N) {
		ans += A[i * 2 + 1];
	}
	cout << ans << endl;
}


Measured memory_bytes: 2688
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
      
        int NA = N * A;
      
        if(NA < B){
          System.out.println(NA);
        }else{
          System.out.println(B);
        }
	}

}

Measured memory_bytes: 35688
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
int main(){
ll n;
cin>>n;
ll a[n];
for(ll i=0;i<n;i++)cin>>a[i];
ll temp[n+1];
for(ll i=0;i<n+1;i++)temp[i]=0;
for(ll i=0;i<n;i++){
    temp[a[i]]+=1;
    }
 ll sum=0;

 for(ll i=1;i<=n;i++){
    sum+=(temp[i]*(temp[i]-1))/2;

    }

    for(ll i=0;i<n;i++){
          ll ans;
        if(temp[a[i]]>=1){
        ans=sum-(temp[a[i]]-1);}
        else ans=sum;


    cout<<ans<<"\n";


    }





return 0;

}


Measured memory_bytes: 5760
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

typedef ll T;
struct P{
    T x,y;
    P(){} P(T x,T y):x(x),y(y){}
    void read(){scanf("%lld%lld",&x,&y);}
    P operator - (const P&b) const {return P(x-b.x,y-b.y);}
    T operator * (const P&b) const {return x*b.x+y*b.y;}
    T operator ^ (const P&b) const {return x*b.y-y*b.x;}
};

struct L{
    P s,t;
    L(){} L(P s,P t):s(s),t(t){}
    void read(){s.read();t.read();}
};
int relation(L a,L b){
    int cross=(a.t-a.s)^(b.t-b.s);
    int dot=(a.t-a.s)*(b.t-b.s);
    if(cross==0) return 2;
    if(dot==0) return 1;
    return 0;
}

int main(){
    int Q;scanf("%d",&Q);
    rep(i,0,Q){
        L a,b;
        a.read();b.read();
        printf("%d\n",relation(a,b));
    }
    return 0;
}

Measured memory_bytes: 3212
/**
 *Code Author: codeknight13
 *Institution: IIT(ISM)
**/

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

/*
use these format of input when number of inputs not provided
while(scanf("%lld",&n)!=EOF)
*/

#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define vi vector< ll >
#define vii vector< vi >
#define viii vector< vii >
#define pii pair< ll , ll >
#define vpii vector< pii >
#define mii unordered_map< ll , ll >
#define mci map< char , ll >
#define pq priority_queue
#define str string
#define len length()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl cout <<  endl
#define sp " "
#define all(ar) ar.begin(), ar.end()
#define itern(n) for (int i=0; i<n; i++)
#define ritern(n) for (int i=n-1; i>=0; i--)
#define sz(x) ((int)(x).size())
#define pi acos(1);                   /* pi */
#define inf (int(1e9+7))
#define fl(x) int(x)
#define mod %(inf)
#define yes "YES"
#define no "NO"
#define null NULL
//debugger
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
//functions
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}


//#------------------------------complete template------------------------------#//



int main()
{
	fast;
	map<char,int> m;
	m['A']++;
	m['C']++;
	m['G']++;
	m['T']++;
	string s;
	cin >> s;
	int ans=0,cnt=0;
	for (int i=0; i<s.length(); i++)
	{
		if (m.find(s[i])!=m.end())
		{
			cnt++;
			ans=max(ans,cnt);
		}
		else
		{
			cnt=0;
		}
	}
	cout << ans;
	return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  double ans = 0;
  for (int i=1; i<=n; i++){
    double a = 1 / (double)n;
    int x = i;
    while (x < k){
      x *= 2;
      a /= 2;
    }
    ans += a;
  }

  cout << fixed << setprecision(10);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdlib.h>

using namespace std;

int main(){
    int N;
    cin >> N;
    int W[N];

    int s2 = 0;
    for(int i=0;i<N;i++){
        cin >> W[i];
        s2 += W[i];
    }

    int s1 = 0;
    int min_diff = abs(s2);
    for(int T=0;T<N;T++){
        s1 += W[T];
        s2 -= W[T];
        int diff = abs(s2 - s1);
        if(diff < min_diff){
            min_diff = diff;
        }
    }
    cout << min_diff << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>
#include <numeric>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	while (1) {
		int m;
		cin >> m;
		if (m == 0) break;
		vector<pair<int, int>>id(m);
		vector<vector<int>>score(m, vector<int>(10, 0));
		vector<vector<int>>eachScore(m);
		rep(i, m) {
			cin >> id[i].first;
			int num = 0;
			int point = 0;
			int cnt = 0;
			int tenNum = 0;
			while (num != 10) {
				if (num == 9) tenNum++;
				cnt++;
				int tmp;
				cin >> tmp;
				point += tmp;
				eachScore[i].push_back(tmp);

				if (tenNum == 3) {
					score[i][num] = point;
					break;
				}

				if (cnt == 2) {
					if (num == 9 && point >= 10) {
						continue;
					}
					score[i][num] = point;
					//cout << num << "番目に" << point << "はいる" << endl;
					cnt = 0;
					num++;
					point = 0;
				}
				else if (point == 10) {
					if (num == 9) continue;
					score[i][num] = point;
					if (cnt == 1) // ストライク
						score[i][num] += 10;
					//cout << num << "番目に" << point << "はいる" << endl;
					cnt = 0;
					num++;
					point = 0;
				}
			}
		}
		
		rep(i, m) {
			id[i].second = 0;
			int cnt = 0;
			int point = 0;
			int num = 0;
			rep(j, (int)eachScore[i].size()) {
				if (num == 9) {
					id[i].second += eachScore[i][j];
				}
				else {
					//cout << j << endl;
					point += eachScore[i][j];
					cnt++;
					if (point == 10) {
						// 10投目かどうか確かめる
						if (cnt == 1) {
							// ストライク
							for (int k = j + 1; k < (int)eachScore[i].size() && k < j + 3; k++) {
								id[i].second += eachScore[i][k]; // 次2回の投球をみる
							}
						}
						else { // スペア
							for (int k = j + 1; k < (int)eachScore[i].size() && k < j + 2; k++) {
								id[i].second += eachScore[i][k]; // 次の投球を見る
							}
						}
						id[i].second += point;
						point = 0;
						cnt = 0;
						num++;
					}
					if (cnt == 2) {
						id[i].second += point;
						cnt = 0;
						point = 0;
						num++;
					}
				}
			}
		}

		sort(allof(id), [&](const pair<int, int>& x, const pair<int, int>& y) {
			if (x.second == y.second) {
				return x.first < y.first;
			}
			return x.second > y.second;
		});
		
		rep(i, m) {
			cout << id[i].first << " " << id[i].second << endl;
		}
		/*rep(i, m) {
			cout << id[i].first << " ";
			rep(j, (int)eachScore[i].size()) {
				cout << eachScore[i][j] << " ";
			}
			cout << endl;
		}*/
	}

	return 0;
}



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

const int MOD = 1e+09 + 7;

int main() {
    string S;
    cin >> S;
    int64_t N = S.size();
    
    vector<vector<int64_t>> dp(N,vector<int64_t>(13,0));
    
    if ( S.at(N-1) == '?' ){
        for ( int64_t j = 0; j < 10; ++j){
            dp[N-1][j] = 1;
        }
    } else {
        int num = S.at(N-1) - '0';
        dp[N-1][num] = 1;
    }
    
    int ten = 10;
    for ( int64_t i = N-1; i >= 1; --i){
        if ( S.at(i-1) == '?' ){
            for ( int64_t k = 0; k < 10; ++k){
                for ( int64_t j = 0; j < 13; ++j){
                    dp[i-1][( k * ten + j ) % 13] = ( dp[i-1][( k * ten + j ) % 13] + dp[i][j] ) % MOD;
                }
            }
        } else {
            int64_t num = S.at(i-1) - '0';
            for ( int64_t j = 0; j < 13; ++j){
                dp[i-1][( num * ten + j ) % 13] = ( dp[i-1][( num * ten + j ) % 13] + dp[i][j] ) % MOD;
            }
        }
        /*for ( int64_t j = 0; j < 13; ++j){
            dp[i-1][j] = dp[i-1][j] % MOD;
        }*/
        ten = ( ten * 10 ) % 13;
    }
    
    /*for ( int i = 0; i < N; ++i){
        for ( int j = 0; j < 13; ++j){
            cout << i << j << " " << dp[i][j] << " ";
        }
        cout << endl;
    }*/
    
    cout << dp[0][5] << endl;
    
    return 0;
}


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


#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lmax1 9223372036854775807
#define max1 2147483647
#define lmin1 -9223372036854775808
#define pi 3.141592653589793116
#define mod 1e9+7

int main() {
    off;
    long long  n,m,c;
    cin>>n>>m>>c;
    int a[m];
    for(int i=0;i<m;i++)
        cin>>a[i];
    int count =0;
    for(int i=0;i<n;i++)
    {   long long sum=0;
        for(int j=0;j<m;j++)
        {
            long long  x;
            cin>>x;
            sum+=a[j]*x;
        }
        sum+=c;
        if(sum>0)
            ++count;
    }
    cout<<count<<'\n';
      return 0;
    }


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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n, k; cin >> n >> k;
	ll cnt[2] = {0, 0};
	REPU(i, 1, n + 1) {
		if ((i + i) % k == 0) {
			if (i % k == 0) cnt[0]++;
			else cnt[1]++;
		}
	}
	ll ans = cnt[0] * cnt[0] * cnt[0] + cnt[1] * cnt[1] * cnt[1];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
// Type alias
using ll=long long;
using ld=double;
 
using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;
 
using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;
 
// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();
 
// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl
 
#define ALL(a) a.begin(),a.end()
 
// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
 
 
void solve(){
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5])
    cout << "Yes";
  else
    cout << "No";
  cout << endl;
}
 
int main(){
  // FastIO
  //ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}





















Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    val ave = Math.round(list.average()).toInt()
    var sum = 0
    for (i in 0 until list.size) {
        sum += Math.pow((list[i] - ave).toDouble(), 2.0).toInt()
    }
    println(sum)
}

Measured memory_bytes: 38052
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt
  val ts = Vector.fill(n)(sc.nextInt)
  val m = sc.nextInt
  val pxs = Vector.fill(m)((sc.nextInt, sc.nextInt))

  pxs.foreach { case (p, x) => println(ts.updated(p - 1, x).sum) }
}


Measured memory_bytes: 25800
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    string s;
    cin>>s;
    string ans="Yes";
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]!='h')ans="No";
        }
        else{
            if(s[i]!='i')ans="No";
        }
    }
    if(s.size()%2==1)ans="No";
    cout<<ans<<endl;
}


Measured memory_bytes: 3584
#include<stdio.h>
int main()
{
	int m,a,y,n,s,t,b,_,dy,da;
	double r;
	scanf("%d",&m);
	while(m--)
	{
		s=0;
		scanf("%d%d%d",&a,&y,&n);
		while(n--)
		{
			da=a,dy=y;
			scanf("%d%lf%d",&t,&r,&b);
			if(t)while(dy--)da=da*(1+r)-b;
			else 
			{
				_=0;
				while(dy--)_+=da*r,da-=b;
				da+=_;
			}
			s=(s>da?s:da);
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int X, Y;
	bool flag=false;
	cin >> X >> Y;
	for (int i = 0; i <= 100;i++) {
		for (int j = 0; j <= 100; j++) {
			if (i + j == X && 2 * i + 4 * j == Y)flag = true;
		}
	}
	if (flag)cout << "Yes";
	else cout << "No";
}

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

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	int ans = 0;
	rep(i,n-2) {
		if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
			ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int width,height,i,j;
    height = sc.nextInt();
    width = sc.nextInt();
    int [][] a = new int[height][width];
    int [][] b = new int[width][1];
    int [][] c = new int[height][1];
    for(i = 0;i < height;i++){
      for(j = 0;j < width;j++){
        a[i][j] = sc.nextInt();
      }
    }
    for(i = 0;i < width;i++){
      b[i][0] = sc.nextInt();
    }

    for(i = 0;i < height;i++){
      for(j = 0;j < width;j++){
        c[i][0] += a[i][j] * b[j][0];
      }
    }

    for(i = 0;i < height;i++){
      System.out.println(c[i][0]);
    }
  }
}

Measured memory_bytes: 40904
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n,a[10005],sum;
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
	while(1){
		cin>>n;if(n==0) return 0;
		sum = 0;
		rep(i,n) {cin>>a[i];sum+=a[i];}
		int cnt = 0;
		rep(i,n) if(a[i] <= sum/n) cnt++;
		cout << cnt << endl;
	}
}



Measured memory_bytes: 3140
n = int(input())
a = list(map(int , input().split()))
b = [a[i] - (i+1) for i in range(n)]

b.sort()
idx= n//2
bi = b[idx]
ans = 0
for i in range(n):
    ans += abs(a[i] - (i + 1 + bi))
print(ans)



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

public class Main{
	static int[]memo;
	static int mod=(int)1e9+7;
	static int dp(int sum) {
		if(sum==0)return 1;
		if(sum<0)return 0;
		if(memo[sum]!=-1)return memo[sum];
		int ans=0;
		for(int j=3;j<=sum;j++) {
			ans=(ans+dp(sum-j))%mod;
		}
		return memo[sum]=ans;
	}
	static void main() throws Exception{
		int x=sc.nextInt();
		memo=new int[x+1];
		Arrays.fill(memo, -1);
		pw.println(dp(x));
	}
	public static void main(String[] args) throws Exception{
		sc=new MScanner(System.in);
		pw = new PrintWriter(System.out);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*(i+1));
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*(i+1));
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

Measured memory_bytes: 26140
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x,y,m;
    cin>>x>>y;
    int l= x-1;
    int o = m = (y - l);
    int n = y + l;

    while ( m <= n){
        cout<<o<<" ";
        o++;
        m++;
    }

    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] array = new int[n];
		for(int i = 0; i < n; i++)
			array[i] = sc.nextInt();
		Arrays.sort(array);
		
		double ans = (array[0] + array[1]) / 2.0;
		for(int i = 2; i < n; i++)
			ans = (array[i] + ans) / 2.0;
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
#!/usr/bin/python
# -*- coding: utf-8 -*-

MOD = 998244353


############
l = raw_input()
N, A, B, K = [int(x) for x in l.split()]

Fac = [1] * (N+1)
invFac = [1] * (N+1)
for i in xrange(2, N+1):
	Fac[i] = (Fac[i-1] * i) % MOD
for i in xrange(2, N+1):
	invFac[i] = pow(Fac[i], MOD-2, MOD)

def C(n, m):
	return (((Fac[n] * invFac[m]) % MOD) * invFac[n-m]) % MOD

# print invFac[:20]

pl = []
for a in xrange(N+1):
	b = (K-A*a)//B
	if b < 0 or b > N:
		continue
	if A*a + B*b != K:
		continue
	pl.append((a, b))

# print pl

ans = 0
for a, b in pl:
	ans = (ans + (C(N, a) * C(N, b)) % MOD) % MOD
print ans

Measured memory_bytes: 50692
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;
int f[N];

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n,d,k,T,cas=0;
    cin>>n>>k;
    while(k--) {
        cin>>d;
        for(int i=0;i<d;++i) {
            cin>>a;
            f[a]++;
        }
    }
    int cnt=0;
    for(int i=1;i<=n;++i) {
        if(!f[i]) cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
char c;int ans=0;
int main(){
	#ifdef LOCAL
		freopen("A.in","r",stdin);freopen("A.out","w",stdout);
	#endif
	for(register int i=1;i<=4;++i){c=getchar();if(c=='+')ans++;else ans--;}printf("%d\n",ans);return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args){
    try{
      Scanner scanner = new Scanner(System.in);
      boolean flag = true;
      int i=0;
      int[] num={0,1,0,0,1,0,0,1,0,1};
      for(i=0;i<4;i++){
        int N = scanner.nextInt();
        num[N]--;
        if(num[N]!=0){
          flag = false;
        }
      }
      if(flag){
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
      scanner.close();
    }catch(Exception e){
      System.out.println("何か入力してください");
    }
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;
const int max_n = 101010;
// const int max_n = 1000;
bool memo[max_n];

void dfs(int n){

	for(int i = 100; i <= 105; i++){
		if(n+i >= max_n) return;
		if(memo[n + i]) continue;
		memo[n+i] = true;
		// cout << n + i << endl;
		dfs(n+i);
	}

}

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

	int x;
	cin >> x;

	rep(i, max_n) memo[i] = false;
	memo[0] = true;

	dfs(0);

	cout << memo[x] << endl;
}


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

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

bool is_ok(int cand, set<int> d){
	while(cand > 0){
		int curr = cand % 10;
		if (d.count(curr)){
			return false;
		} // end if
		cand /= 10;
	} // end while

	return true;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, K; cin >> N >> K;
	vector<int> D(K, 0);
	rep (i, K) cin >> D[i];


	set<int> d; d.clear();
	rep (i, K) d.insert(D[i]);
	int res = 0;
	for(int i = N;; ++i){
		if (is_ok(i, d)){
			res = i;
			break;
		} // end if
	} // end for

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	int n;
	cin >> n;
	map<string,int> m;

	rep(i,n){
		string s;
		cin >> s;
		m[s]++;
	}
	int maxi = -1;
	for(auto x:m)chmax(maxi,x.se);
	vector<string> ans;
	for(auto x:m)if(x.se == maxi)cout << x.fi << endl;


	

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc155.contest.atcoder.jp/tasks/abc155_c

Measured memory_bytes: 19212
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;


std::vector<std::vector<pii>> edges;
std::vector<int> colors;

void dfs(int node, int parent_color = -1, int pnode = -1){

    int color = 0;

    for(int i=0; i<edges[node].size(); i++){

        int next_node = edges[node][i].first;
        if(next_node==pnode) continue;

        color++;

        if(color==parent_color) color++;

        int ei = edges[node][i].second;

        colors[ei] = color;
        dfs(next_node, color, node);
    }

    return;

}

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

    int n; cin >> n;

    edges.resize(n);
    colors = std::vector<int>(n-1,0);

    rep(i,n-1){
        int a,b; cin >> a >> b; --a; --b;

        edges[a].push_back(make_pair(b,i));
        edges[b].push_back(make_pair(a,i));
    }
    
    dfs(0);

    cout << *max_element(begin(colors), end(colors))  << endl;

    rep(i,colors.size()){
        cout << colors[i] << endl;
    }

    return 0;
}

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

int main(){
  string S; cin >> S;
  if (S == "SUN") cout << 7 << endl;
  else if (S[0] == 'M') cout << 6 << endl;
  else if (S == "TUE") cout << 5 << endl;
  else if (S[0] == 'W') cout << 4 << endl;
  else if (S == "THU") cout << 3 << endl;
  else if (S[0] == 'F') cout << 2 << endl;
  else if (S == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

int n,n2;
lint ar[300005]; 
lint mx[300005],mx2[300005][18];
int main(){
  cin>>n;
  n2=(1<<n);
  REP(i,n2) cin>>ar[i];

  REP(i,n2){
    mx[i]=ar[i];
    REP(j,n) if(i>>j&1) chmax(mx[i],mx[i^(1<<j)]);
    REP(j,n) if(i>>j&1){
      mx2[i][j]=ar[i];
      REP(k,n) if(i>>k&1 && j!=k){
        chmax(mx2[i][j],mx2[i^(1<<k)][j]);
      }
    }
  }

  lint evmax=-1;

  REPN(i,n2,1){
    lint tmp=0;
    lint subtop=0;
    REP(j,n) if(i>>j&1) chmax(subtop,mx[i^(1<<j)]);
    REP(j,n) if(i>>j&1) chmax(tmp,mx2[i][j]+mx[i^(1<<j)]);
    chmax(tmp,subtop+ar[i]);

    chmax(evmax,tmp);
    printf("%lld\n",evmax);
  }
  return 0;
}


Measured memory_bytes: 47616
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

int main(){
	int n;
	cin>>n;
	vector<vector<int> > v(n);
	vector<int> k(n);
	int x;
	rep(i,n){
		cin>>x;
		cin>>k[i];
		v[i].resize(k[i]);
		rep(j,k[i]){
			cin>>v[i][j];
			v[i][j]--;
		}
	}
	vector<int> a(n),b(n);
	stack<int> s;
	int count=1;
	s.push(0);
	a[0]=1;
	while(s.empty()==0){
		count++;
		int x=s.top();
		rep(i,k[x]){
			if(a[v[x][i]]==0){
				s.push(v[x][i]);
				a[v[x][i]]=count;
				break;
			}
			if(i==k[x]-1){
				k[x]=0;
			}
		}
		if(k[x]==0){
				b[x]=count;
				s.pop();
		}
		if(s.empty()==1){
			rep(i,n){
				if(a[i]==0){
					s.push(i);
					count++;
					a[i]=count;
					break;
				}
			}
		}
	}

	rep(i,n){
		cout<<i+1<<" "<<a[i]<<" "<<b[i]<<endl;;
	}

		



	return 0;
}

Measured memory_bytes: 3072
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N=int(input())
print(A[N-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define AC 0
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,m,cx,cy,dx,dy,go1[4][2]={{1,0},{-1,0},{0,1},{0,-1}},go2[20][2]={{-2,-2},{-2,-1},{-2,0},{-2,1},{-2,2},{-1,-2},{-1,-1},{-1,1},{-1,2},{0,-2},{0,2},{2,-2},{2,-1},{2,0},{2,1},{2,2},{1,-2},{1,-1},{1,1},{1,2}};
	cin>>n>>m>>cx>>cy>>dx>>dy;
	cx--,cy--,dx--,dy--;
	vector< vector<bool> > g(n,vector<bool>(m));
	vector< vector<int> > dis(n,vector<int>(m,1e9));
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++) {
			char c;
			cin>>c;
			g[i][j]=c=='#';
		}
	priority_queue< pair<int,pair<int,int> > > q;
	q.push(pair<int,pair<int,int> >(0,pair<int,int>(cx,cy)));
	dis[cx][cy]=0;
	while(q.size()) {
		pair<int,pair<int,int> > h=q.top();
		q.pop();
		int hx=h.second.first,hy=h.second.second;
		for(int j=0;j<4;j++) {
			int xx=hx+go1[j][0],yy=hy+go1[j][1];
			if(xx>=0&&xx<n&&yy>=0&&yy<m&&!g[xx][yy]&&dis[xx][yy]>dis[hx][hy]) {
				dis[xx][yy]=dis[hx][hy];
				q.push(pair<int,pair<int,int> >(-dis[xx][yy],pair<int,int>(xx,yy)));
			}
		}
		for(int j=0;j<20;j++) {
			int xx=hx+go2[j][0],yy=hy+go2[j][1];
			if(xx>=0&&xx<n&&yy>=0&&yy<m&&!g[xx][yy]&&dis[xx][yy]>dis[hx][hy]+1) {
				dis[xx][yy]=dis[hx][hy]+1;
				q.push(pair<int,pair<int,int> >(-dis[xx][yy],pair<int,int>(xx,yy)));
			}
		}
	}
	if(dis[dx][dy]==1e9) cout<<"-1";
	else cout<<dis[dx][dy];
	return AC;
}

Measured memory_bytes: 7604
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
const ll INF = 1LL << 60;
const double PI = acos(-1.0);

const ll MOD = 1000000007LL;

int main() {

	ll n, m;
	cin >> n >> m;
	if (abs(n - m) >= 2) {
		cout << 0 << endl;
		return 0;
	}
	vector<ll> fn(n+1), fm(m+1);
	fn[0] = 1; fm[0] = 1;
	for (int i = 1; i <= n; i++) {
		fn[i] = (ll)i * fn[i - 1] % MOD;
	}
	for (int i = 1; i <= m; i++) {
		fm[i] = (ll)i * fm[i - 1] % MOD;
	}

	if (abs(n - m) == 1) {
		cout << fn[n] * fm[m] % MOD << endl;
	}
	else {
		cout << 2LL * fn[n] * fm[m] % MOD << endl;
	}

	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

// https://atcoder.jp/contests/abc165/tasks/abc165_c
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long n = sc.nextLong();
		sc.close();


		long x = b-1L;
		if(x>n) {
			x = n;
		}


		System.out.println(a*x/b-a*(x/b));


	}
}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b > c+d)
        cout << "Left\n";
    else if(a+b < c+d)
        cout << "Right\n";
    else
        cout << "Balanced\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<vector>
#include<numeric>
#include<random>
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int cnt = 0;
	int n;
	cin >> n;
	vector<int> a;
	int x;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		a.push_back(x);
	}

	rep(i, n-1) {
		for(int j=n-2;j>=i;j--)
		{
			if(a[j]>a[j+1])
			{
				swap(a[j], a[j + 1]);
				cnt++;
			}
		}
	}

	rep(i,n)
	{
		if (i) { cout << " " << a[i]; }
		else { cout << a[i]; }
	}
	cout << endl << cnt << endl;

	return 0;
}


Measured memory_bytes: 3148
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main() {
	int N, M; cin >> N >> M;
	if (N & 1) {
		for (int i = 1; i <= M; ++i)
			cout << i << " " << (N - i) << endl;
	}
	else {
		for (int i = 1; i <= M; ++i) {
			int tmp = N - i;
			if (N - 2 * i <= N / 2) --tmp;
			cout << i << " " << tmp << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3632