akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>


typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

constexpr ll DEF_VAL = (1LL << 31) - 1;
constexpr ll SEG_LEN = (1LL << 17);

ll segTree[SEG_LEN * 2];

void initialize() {
	for (ll i = 0; i < SEG_LEN * 2; i++) {
		segTree[i] = DEF_VAL;
	}
}

void setVal(ll idx, ll val) {
	idx += SEG_LEN;
	segTree[idx] += val;
	while (true) {
		idx /= 2;
		if (idx <= 0) break;
		segTree[idx] = segTree[2 * idx] + segTree[2 * idx + 1];
	}
}

ll getSum(ll ql, ll qr, ll sl = 0, ll sr = SEG_LEN, ll idx = 1) {
	if (qr <= sl || sr <= ql) {
		return 0;
	}
	if (ql <= sl && sr <= qr) {
		return segTree[idx];
	}
	ll sm = (sl + sr) / 2;
	ll m1 = getSum(ql, qr, sl, sm, 2 * idx);
	ll m2 = getSum(ql, qr, sm, sr, 2 * idx + 1);
	return m1 + m2;

}

int main() {
	ll aLen, Q;
	cin >> aLen >> Q;
	
	for (ll i = 0; i < Q; i++) {
		ll com, l, r;
		cin >> com >> l >> r;
		if (com == 0) {
			setVal(l, r);
		}
		else {
			cout << getSum(l, r + 1) << endl;
		}
	}
}



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

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int l, r;
        cin >> l >> r;
        
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

//const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 200 + 6;

i64 n, k;
i64 gcds[MAXN][MAXN];

inline i64 gcd(i64 a, i64 b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> k;

    for (i64 i = 1; i <= k; i++) {
        for (i64 j = 1; j <= k; j++) {
            gcds[i][j] = gcd(i, j);
        }
    }

    i64 R = 0;
    for (i64 x = 1; x <= k; x++) {
        for (i64 y = 1; y <= k; y++) {
            i64 gxy = gcds[x][y];
            for (i64 z = 1; z <= k; z++) {
                i64 g = gcds[gxy][z];
                R += g;
            }
        }
    }

    cout << R << endl;


    return 0;
}

Measured memory_bytes: 3928
#include<bits/stdc++.h>
using namespace std;
string a;
string fz(string x)
{
	string a="";
	for(int i=x.size()-1; i>=0; i--)
	a+=x[i];
	return a;
}
string jx(string x)
{
	string a="";
	for(int i=0; i<x.size(); i++)
	{
		if(x[i]=='q')a+='p';
		if(x[i]=='p')a+='q';
		if(x[i]=='d')a+='b';
		if(x[i]=='b')a+='d';
	}
	return a;
}
bool check(string x,string y)
{
	for(int i=0; i<x.size(); i++)
	if(x[i]!=y[i])return 0;
	return 1;
}
int main()
{
	cin>>a;
	string b=fz(a);
	if(check(a,b)){cout<<"Yes";return 0;}
	string c=jx(fz(a));
	if(check(a,c)){cout<<"Yes";return 0;}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 896
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

const double g=10.0,eps=1e-7;
const int N=100+10,maxn=500+100,inf=0x3f3f3f;

ll ans[N][N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll k;
    cin>>k;
    cout<<50<<endl;
    memset(ans,0,sizeof ans);
    for(int i=1;i<50;i++)
    {
        for(int j=0;j<50;j++)
        {
            if(j==i)ans[i][j]=ans[i-1][j]+50;
            else ans[i][j]=ans[i-1][j]-1;
        }
    }
    ll s=k/50,p=k%50;
    for(int i=0;i<50;i++)
        cout<<ans[p][i]+49ll+s<<(i==49?'\n':' ');
    return 0;
}
/********************

********************/


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n, k;
  cin >> n >> k;
  double ans = 0;
  for (i64 i = 1; i <= n; i++)
  {
    double tmp = 1;
    i64 t = i;
    while (t < k)
    {
      tmp *= 0.5;
      t *= 2;
    }
    ans += tmp / n;
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


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

int main(){
  string S; cin >> S;
  for(int i=0; i<S.size(); i++){
    if((i%2==1 && S[i]=='R')||(i%2==0 && S[i]=='L')){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n = int(input())
    if n%2==0:
        print(n)
    else:
        print(n * 2)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38508
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;
ll longinf=(1ll<<31)-1;
int inf=1<<29;
int dh[4]={1,0,-1,0};
int dw[4]={0,1,0,-1};



struct segTree{
      ll n;
      vector<ll> dat;
      segTree(ll n_){
            n = 1;
            //かんたんのため要素数を2冪にする
            while(n < n_) n *= 2;
            //すべての値をinfにする
            for(ll i = 0; i < 2*n-1; i++) dat.push_back(longinf);
            dat.push_back(n);
      }
      //k番目の値(0-indexed)をaに変更
      void update(ll k,ll a){
            //葉の節点
            k += dat.back() - 1;
            dat[k] = a;
            while(k > 0){
                  k = (k - 1) / 2;
                  dat[k] = min (dat[k * 2 + 1], dat[k * 2 + 2]);
            }
      }
      //[a,b)の最小値を求める
      //後ろの方の引数は、計算のかんたんのための引数
      //kは節点の番号,l,rはその節点が[l,r)に対応づいていることを表す
      //したがって外からはq(a, b, 0, 0, n)と呼ぶ
      ll q(ll a,ll b,ll k,ll l,ll r){
            //[a,b)と[l,r)が交差しなければ,inf
            if(r<=a||b<=l) return longinf;
            //[a,b)が[l,r)を完全に含んでいればこの節点の値
            if(a<=l&&r<=b) return dat[k];
            else{
                  //そうでなければ2つの子の最小値
                  ll vl = q(a,b,k*2+1,l,(l+r)/2);
                  ll vr = q(a,b,k*2+2,(l+r)/2,r);
                  return min(vl,vr);
            }
      }
      ll query(ll a,ll b){
            return q(a,b,0,0,n);
      }
};
int main(){
      int n,q;
      cin>>n>>q;
      segTree seg(n);
      /*rep0(i,n){
            ll a;
            cin>>a;
            seg.update(i,a);
      }*/
      rep0(i,q){
            ll f,g,h;
            cin>>f>>g>>h;
            if(f==1){
                  cout<<seg.query(g, h+1)<<endl;
            }
            else{
                  seg.update(g,h);
            }
      }
      return 0;
}



Measured memory_bytes: 4932
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            for (; ; )
            {
                var inputLine = Console.In.ReadLine();
                var inputs = inputLine.Split(new char[] { ' ', '\t', '　' });
                if (inputs.Length != 2)
                {
                    return;
                }

                var integers = new List<int>();
                foreach (var s in inputs)
                {
                    integers.Add(int.Parse(s));
                }
                if (integers[0] == 0 && integers[1] == 0)
                {
                    break;
                }

                integers.Sort();

                Console.WriteLine("{0} {1}", integers[0], integers[1]);
            }
        }
    }
}


Measured memory_bytes: 15940
using System;
using System.Linq;

namespace _026_DroppingInk
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;
			DroppingInk map = new DroppingInk ();

			while ((inputStr = Console.ReadLine ()) != null)
			{
				int[] inputNum = inputStr.Split (',').Select (int.Parse).ToArray ();

				switch (inputNum[2])
				{
					case 1:
						map.SmallInk (inputNum[0], inputNum[1]);
						break;
					case 2:
						map.MediumInk (inputNum[0], inputNum[1]);
						break;
					case 3:
						map.BigInk (inputNum[0], inputNum[1]);
						break;
				}
			}

			Console.WriteLine (map.GetSpaceNum ());
			Console.WriteLine (map.GetDeepNum ());
		}
	}

	class DroppingInk
	{
		public DroppingInk ()
		{
			this.Map = new int[10 + Shift * 2, 10 + Shift * 2];
		}

		private int[,] Map { set; get; }
		private const int Shift = 2;

		//?°? ?????°??¨????????????????????§?¨????+2????????????????????°????????´?????????????????¨??????
		public void SmallInk ( int x, int y )
		{
			x += Shift;
			y += Shift;

			Map[x, y - 1]++;
			Map[x - 1, y]++;
			Map[x, y]++;
			Map[x + 1, y]++;
			Map[x, y + 1]++;
		}

		//???
		public void MediumInk ( int x, int y )
		{
			x += Shift;
			y += Shift;

			Map[x - 1, y - 1]++;
			Map[x, y - 1]++;
			Map[x + 1, y - 1]++;
			Map[x - 1, y]++;
			Map[x, y]++;
			Map[x + 1, y]++;
			Map[x - 1, y + 1]++;
			Map[x, y + 1]++;
			Map[x + 1, y + 1]++;
		}

		//??§
		public void BigInk ( int x, int y )
		{
			x += Shift;
			y += Shift;

			Map[x - 1, y - 1]++;
			Map[x, y - 1]++;
			Map[x + 1, y - 1]++;
			Map[x - 1, y]++;
			Map[x, y]++;
			Map[x + 1, y]++;
			Map[x - 1, y + 1]++;
			Map[x, y + 1]++;
			Map[x + 1, y + 1]++;

			Map[x, y - 2]++;
			Map[x - 2, y]++;
			Map[x + 2, y]++;
			Map[x, y + 2]++;
		}

		//????????????????????°????????????
		public int GetSpaceNum ()
		{
			int count = 0;

			for (int row = Shift; row < Map.GetLength (0) - Shift; row++)
			{
				for (int col = Shift; col < Map.GetLength (1) - Shift; col++)
				{
					if (Map[row, col] == 0)
					{
						count++;
					}
				}
			}

			return count;
		}

		//???????????????????????????
		public int GetDeepNum ()
		{
			int max = 0;

			for (int row = Shift; row < Map.GetLength (0) - Shift; row++)
			{
				for (int col = Shift; col < Map.GetLength (1) - Shift; col++)
				{
					if (max < Map[row, col])
					{
						max = Map[row, col];
					}
				}
			}

			return max;
		}
	}
}

Measured memory_bytes: 9500
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a , b;
	cin >> a >> b;
	int i = 0 , l = 0;
	string res = "";
	while(i < a.size() && l < b.size())
		res += a[i] , res += b[l] , i ++ , l ++;
	while(i < a.size())
		res += a[i] , i ++;
	while(l < b.size())
		res += b[l] , l ++;
	cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
main()
{
	cin>>n;
	vector<int>a(n);
	for(int&i:a)cin>>i;
	cin>>m;
	vector<int>b(m);
	for(int&i:b)cin>>i;
	cout<<lexicographical_compare(a.begin(),a.end(),b.begin(),b.end())<<endl;
}


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

using namespace std;

typedef long long ll;

int main(){
	ll n;
	cin >> n;
	if(n == 0){
		cout << '0' << endl;
		return 0;
	}
	char minus[40];
	fill(minus,minus+40,'0');
	ll div=2;
	for(int i = 0;n; i++){
		if(n%div){
			if(i%2)n+=div/2;
			else n-=div/2;
			minus[i]='1';
		}
		div*=2;
	}
	bool first=true;
	for(int i = 40; i >= 0; i--){
		if(first&&minus[i]=='1')first=false,cout << minus[i];
		else if(first==false)cout << minus[i];
	}
	cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[101][101][4],h,w;
main(){
  while(cin>>h>>w,h){
    int ans=0;
    memset(a,0,sizeof(a));
    r(i,101)a[0][i][3]=1;
    r(i,101)a[i][0][2]=1;
    for(int i=1;i<h;i++)
      for(int j=1;j<w;j++){
        a[i][j][0]=a[i-1][j][3];
        a[i][j][1]=a[i][j-1][2];
        a[i][j][2]=a[i-1][j][0]+a[i-1][j][2];
        a[i][j][3]=a[i][j-1][3]+a[i][j-1][1];
        r(k,4)a[i][j][k]%=100000;

      }
    r(i,4)ans+=a[h-1][w-1][i];
    cout<<ans%100000<<endl;
  }
}

Measured memory_bytes: 3244
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod=1e9+7;

int main(){
	int n;
  cin >> n;
  vector<vector<int>> to(n), co(n);
  rep(i,n-1){
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
    co[a].push_back(c);
    co[b].push_back(c);
  }
  vector<int> res(n,-1);
  queue<int> q;
  q.push(0);
  res[0]=0;
  while(!q.empty()){
  	int f=q.front();
  	q.pop();
    rep(i,to[f].size()){
      int t=to[f][i];
      int c=co[f][i];
      if(res[t]!=-1)
      	continue;
      res[t]=(res[f]+c)%2;
      q.push(t);
    }
  }
  rep(i,n) cout << res[i] << endl;
  return 0;
}

Measured memory_bytes: 11904
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

k = inp()
dt = {}
no = 0
ans = -1
i = 0
while True:
    no = (no*10+7)%k
    if no in dt:
        break
    dt[no] = 1
    #print(dt,no)
    if no == 0:
        ans = i+1
        break
    i += 1
print(ans)


Measured memory_bytes: 158096
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)
from math import gcd

mm=[[[0]*200 for i in range(200)] for j in range(200)]

def d(a,b,c):
    return gcd(gcd(a+1,b+1),c+1)

def solve(K: int):
    ans=0
    a=[0,0,0]
    for i in range(K):
        for j in range(K):
            for k in range(K):
                ans+=d(i,j,k)
                continue
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 134212
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
vector <ull>numbers;
vector<ull>accumsum;
ull dp[105][100005];
ull mod = 1e9 + 7;

int main() {

	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ull n, k;
	cin >> n >> k;
	accumsum.push_back(0);
	for (int i = 0; i < n; ++i) {
		ll e;
		cin >> e;
		numbers.push_back(e);
		if (i == 0)
			accumsum.push_back(e);
		else
			accumsum.push_back(e + accumsum.back());
	}


	

	for (int i = 0; i <= k; ++i) {
		if (i == 0)
			dp[n][0] = 1;
		else
			dp[n][i] = 0;
	}

	for (int i = numbers.size() - 1; i >= 0; --i) {
		ll right = k, left = k, m = 0;
		for (int j = k; j >= 0; --j) {
			ll taken = k - j;
			if (taken > accumsum[i])
				break;

			if (left == right) {
				for (int h = 0; h <= min((ull)j, numbers[i]); ++h) {

					m = (m + dp[i + 1][j - h]);
					left = j - h;
				}

			}
			else {
				m -= dp[i + 1][j + 1];
				if (left > 0)
					--left, m += dp[i + 1][left];
			}

		    dp[i][j] = m % mod;
		}
		
	}
	
	
	cout << dp[0][k] << "\n";
	
	return 0;
}



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

int main() {
	
	string S;
	cin >> S;
	int ans = 0;

	for (int i = 0; i < S.size(); i++) {
		if (S.at(i) == 'o')ans++;
	}



	if (ans + 15 - S.size() >= 8) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vll a(n+1, 0); REP(i, n) cin >> a.at(i);
  ll r=0;
  ll ans = 0, xsum=0, xxor=0;
  REP(l, n) {
    while (r<=n) {
      xsum += a.at(r); xxor ^= a.at(r);
      if (xsum != xxor || r==n) {
        ans += r - l;
        xsum -= a.at(r); xxor ^= a.at(r);
        xsum -= a.at(l); xxor ^= a.at(l);
        break;
      }
      r++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
private var count = 0
private var cumulativeLen = 0.0

fun main(args: Array<String>) {
    val nLine = readLine()!!.toInt()
    val locList = mutableListOf<Array<Int>>()
    for (i in 0..nLine-1) {
        val token = readLine()!!.split(" ")
        val loc = arrayOf(token[0].toInt(), token[1].toInt())
        locList.add(loc)
    }
    genPattern(locList, listOf<Array<Int>>())
    val averageLen = cumulativeLen / count.toDouble()
    println(averageLen)
}

private fun genPattern(numbers: List<Array<Int>>, pattern: List<Array<Int>>) {
    if (numbers.size == 0) {
        val len = calcLength(pattern)
        cumulativeLen += len
        count++
        return
    }

    for (i in 0..numbers.size-1) {
        val newList = mutableListOf<Array<Int>>()
        newList.addAll(numbers)
        newList.removeAt(i)
        val newPattern = mutableListOf<Array<Int>>()
        newPattern.addAll(pattern)
        newPattern.add(numbers[i])
        genPattern(newList as List<Array<Int>>, newPattern)
    }
}

private fun calcLength(pattern: List<Array<Int>>): Double {
    var totalLen = 0.0
    for (i in 0..pattern.size-2) {
        val x1 = pattern[i][0]
        val x2 = pattern[i+1][0]
        val y1 = pattern[i][1]
        val y2 = pattern[i+1][1]
        val len = Math.sqrt(
            ((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)).toDouble()
        )
        totalLen += len
    }
    return totalLen
}

Measured memory_bytes: 50216
import java.util.Scanner;

public class Main {

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

    for (int i = 0; i < s.length(); i++) {
      if ((i % 2) == 0) {// odd
        if (s.charAt(i) == 'L') {
          System.out.println("No");
          return;
        }
      } else {
        if (s.charAt(i) == 'R') {
          System.out.println("No");
          return;
        }
      }
    }

    System.out.println("Yes");

  }
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a,aa[10000],b=0,c=0;
signed main(){
	cin>>a;
	rep(i,a){
		cin>>aa[i];
	}
	sort(aa,aa+a);
	rep(i,a){
		if(i%2==0){
			b=b+aa[i];
		}else{
			c=c+aa[i];
		}
	}
	cout<<abs(b-c);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <fstream>
#include<string>
#include<sstream>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
#include <math.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const int INF = 1000000007;
const double EPS = 1e-10;
const double PI = 3.14159265359;
const int N = 100005;
//cout << fixed << std::setprecision(9)
//--------------------------

vector<int> g[N];
int dp[N];
int n, m;

int solve(int u)
{
	if (dp[u] != -1) return dp[u];
	if (g[u].size() == 0) return 0;
	for (int i = 0; i < g[u].size(); i++) {
		int v = g[u][i];
		dp[u] = max(dp[u], solve(v) + 1);
	}
	return dp[u];
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		g[u].push_back(v);
	}
	for (int i = 0; i < n; i++) dp[i] = -1;

	int ans = 0;
	for (int i = 0; i < n; i++) {
		dp[i] = solve(i);
		ans = max(ans, dp[i]);
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
typedef vector<ll> vll;
typedef pair<ll, ll> Pll;

ll N;

int main() {
    ll N;
    cin >> N;
    ll L0 = 2;
    ll L1 = 1;
    ll tmp;
    if (N == 0) {
        cout << L0 << endl;
    } else if (N == 1) {
        cout << L1 << endl;
    } else {
        for (int i = 2; i <= N; ++i) {
            tmp = L1;
            L1 += L0;
            L0 = tmp;
        }
        cout << L1 << endl;
    }
    return 0;
}

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

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            string target = Console.ReadLine();
            int commandNum = int.Parse(Console.ReadLine());

            for (int i = 0; i < commandNum; i++)
            {
                string[] command = Console.ReadLine().Split(' ');

                int startIdx = int.Parse(command[1]);
                int endIdx   = int.Parse(command[2]);

                switch (command[0])
                {
                    case "print":
                        Console.WriteLine(target.Substring(startIdx, endIdx - startIdx + 1));
                        break;
                    case "reverse":
                        target = target.Substring(0, startIdx)
                                +
                                new string(target.Substring(startIdx, endIdx - startIdx + 1)
                                                  .Reverse()
                                                  .ToArray() )
                                + target.Substring(
                                    endIdx + 1 >= target.Length ? endIdx : endIdx + 1);
                        break;
                    case "replace":
                        target = target.Substring(0, startIdx)
                                + command[3]
                                + target.Substring(
                                    endIdx + 1 >= target.Length ? endIdx : endIdx + 1);
                        break;
                }


            }
        }
    }
}

Measured memory_bytes: 9696
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if((i+j)%2 == 0) printf("#");
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2568
package main

import (
	"fmt"
	"os"
)

func main() {

	var x string
	_, _ = fmt.Scan(&x)
	var A = [26]string{"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","w","x","y","z"}

	for i:=0; i < 26; i++ {
		if x==A[i] {
			fmt.Println("a")
			os.Exit(0)
		}
	}
	fmt.Println("A")
}


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

int hash[244140625] = {};
string str;

int getChar(char ch){
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else return 4;
}

int getKey(){
  ll sum = 0, p = 1;
  for(int i = 0; i < str.size(); i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int main(){

  int n;
  string com;

  cin >> n;
  while(n--){
    cin >> com >> str;
    if(com == "insert"){
      hash[getKey()] = 1;
    }else{
      if(hash[getKey()]) cout << "yes" << endl;
      else cout << "no" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 20064
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<long long>;
using vlad=valarray<double>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

double msum(vlad a,vlad b){
    return (double)((a*b).sum());
}
double msum(vlad a){
    return (double)((a*a).sum());
}

double dot(vlad a,vlad b){
    return msum(a,b)/sqrt(msum(a))/sqrt(msum(b));
}

int main(){
    int n,m;cin>>n>>m;
    vector<pair<vlad,vlai>> obs(n,mp(vlad(0.0,3),vlai(0ll,2)));
    rep(i,n){cin>>obs[i].fs[0]>>obs[i].fs[1]>>obs[i].fs[2]>>obs[i].sc[0]>>obs[i].sc[1];}
    vlad a(0.0,3),b(0.0,3);
    rep(i,m){
        cin>>a[0]>>a[1]>>a[2]>>b[0]>>b[1]>>b[2];
        double d=sqrt(msum(a-b));
        vlad u=(b-a)/d;
        ll ans=0;
        rep(j,n){
            double dst=0.0;
            if(dot(b-a,b-obs[j].fs)<0){
                dst=sqrt(msum(obs[j].fs-b));
            }else if(dot(a-b,a-obs[j].fs)<0){
                dst=sqrt(msum(obs[j].fs-a));
            }else{
                vlad p=msum(obs[j].fs-a,u)*u+a;
                dst=sqrt(msum(p-obs[j].fs));
                //cout<<p[0]<<","<<p[1]<<","<<p[2]<<","<<endl;
            }
            //cout<<dst<<","<<obs[j].sc[0];
            if(dst<=obs[j].sc[0]+EPS) {
                //cout<<" OK : "<<obs[j].sc[1];
                ans+=obs[j].sc[1];
            }
            //cout<<endl;
        }
        cout<<ans<<endl;
    }
	return 0;
}



Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
#define N 100000 + 5
#define int long long
#define rep(i, l, r) for(int i = l; i <= r; ++i)
int n, nl, nr, al, ar, ans, l[N], r[N], len[N];
priority_queue <int> Qs;
priority_queue <int, vector <int>, greater <int> >  Qb;
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
signed main(){
    n = read();
    rep(i, 1, n) l[i] = read(), r[i] = read(), len[i] = r[i] - l[i];
    Qs.push(l[1]), Qb.push(l[1]);
    rep(i, 2, n){
        al += r[i] - l[i], ar += r[i - 1] - l[i - 1];
        nl = Qs.top() - al, nr = Qb.top() + ar;
        if(l[i] < nl) ans += nl - l[i], Qs.pop(), Qs.push(l[i] + al), Qs.push(l[i] + al), Qb.push(nl - ar);
        else if(l[i] > nr) ans += l[i] - nr, Qb.pop(), Qs.push(nr + al), Qb.push(l[i] - ar), Qb.push(l[i] - ar);
        else Qs.push(l[i] + al), Qb.push(l[i] - ar);
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 4340
n = int(raw_input())
s1 = raw_input()
s2 = raw_input()
used = 0
pat = 1
i = 0
while i < n:
    if s1[i] == s2[i]:
        pat = pat*(3 - used) % (10**9+7)
        used = 1
        i += 1
    else:
        if used == 0:
            pat = pat*6 % (10**9+7)
        else:
            pat = pat*(used + 1) % (10**9+7)
        used = 2
        i += 2
print pat


Measured memory_bytes: 2568
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *

N = int(input())
h = list(map(int, input().split()))
INF = float('inf')
dp = [INF] * N
dp[0] = 0
for i in range(N-1):
    for j in range(i+1, min(N, i+3)):
        dp[j] = min(dp[j], dp[i]+abs(h[i]-h[j]))
print(dp[N-1])


Measured memory_bytes: 53644
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define Sim template<class n
Sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
Sim> auto operator << (ostream &p, n y) -> 
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
Sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
Sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
Sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "
const int M = 1024 * 1024;

int n, m;
VPII V[M];
VPII E;
bool vis[M], done[M];
PII EE[M];

void DFS(int v, int par)
{
	vis[v] = true;
	for (auto x : V[v])
	{
		if (!vis[x.f])
		{
			DFS(x.f, v);
		}
	}
	VPII tmp;
	for (auto x : V[v])
	{
		if (!done[x.s] && x.f != par)
		{
			tmp.PB(x);
		}
	}
	for (auto x : V[v])
	{
		if (!done[x.s] && x.f == par)
		{
			tmp.PB(x);
		}
	}
	for (int i = 0; i < SIZ(tmp) - 1; i += 2)
	{
		done[tmp[i].s] = true;
		done[tmp[i + 1].s] = true;
		E.PB(MP(v, tmp[i].f));
		E.PB(MP(v, tmp[i + 1].f));
	}
}

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(NULL);
	scanf("%d%d", &n, &m);
	FOR(i, 1, m)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		V[a].PB(MP(b, i));
		V[b].PB(MP(a, i));
		EE[i] = MP(a, b);
	}
	if (m % 2 == 1)
	{
		printf("-1\n");
		return 0;
	}
	DFS(1, 0);
	
	for (auto x : E)
	{
		printf("%d %d\n", x.f, x.s);
	}
	return 0;
}




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

int main(){
    ll n;
    string a;
    set<string> s;
    cin >> n;
    while(n--){
        cin >> a;
        s.insert(a);
    }
    cout << (ll)s.size() << "\n";
}


Measured memory_bytes: 19224
#include<bits/stdc++.h>
using namespace std;
int N;
int memo[100001];
int arr[100001];
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		scanf("%d",&arr[i]);
		memo[i]=1000000000;
	}
	memo[0]=0;
	for(int i=0;i<N;i++)
	{
		if(i+1<N)	memo[i+1]=min(memo[i+1],memo[i]+abs(arr[i]-arr[i+1]));
		if(i+2<N)	memo[i+2]=min(memo[i+2],memo[i]+abs(arr[i]-arr[i+2]));
	}
	printf("%d\n",memo[N-1]);
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let mut price = 700;
    for c in s.chars() {
        if let 'o' = c {
            price += 100;
        }
    }

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


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

int main(void){
    int x, n;
    cin>>x>>n;
    vector<int> v(n);
    rep(i, n) cin>>v[i];
    if(n == 0) {
        cout<<x<<endl;
        return 0;
    }
    vector<int> ans(105);
    rep(i, 105){
        ans[i] = abs(i-x);
    }
    rep(i, n){
        ans[v[i]] = INF;
    }
    int mini = INF;
    int res = 0;
    for(int i = 104;i>=0;i--){
        if(mini>=ans[i]) {
            res = i;
            mini = ans[i];
        }
    }
    cout<<res<<endl;
    return 0;
}

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

using namespace std;

int ve[8],ho[8],po[15],ne[15];
string mp[8];//mp[row][col]

bool dfs(int row) {
	if(row==8) return true;
	if(ho[row] != -1) {
		return dfs(row+1);
	}
	for(int i = 0;i < 8;i++) {
		if(ve[i] == -1 && 
			po[i+row] == -1 &&
			ne[(7-i)+row] == -1) {
			mp[row][i] = 'Q';
			ho[row] = row;
			ve[i] = row;
			po[i+row] = row;
			ne[(7-i)+row] = row;
			if(dfs(row+1)) return true;
			mp[row][i] = '.';
			ho[row] = -1;
			ve[i] = -1;
			po[i+row] = -1;
			ne[(7-i)+row] = -1;
		}
	}
	return false;
}

int main() {
	for(int i = 0;i < 8;i++)mp[i]="........";
	for(int i = 0;i < 8;i++){ho[i]=-1;ve[i]=-1;}
	for(int i = 0;i < 15;i++){po[i]=-1;ne[i]=-1;}
	int n,r,c;
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> r >> c;
		mp[r][c] = 'Q';
		ho[r]=r;ve[c]=r;po[r+c]=r;ne[(7-c)+r]=r;
	}
	dfs(0);
	for(int i = 0;i < 8;i++) cout << mp[i] << endl;
}


Measured memory_bytes: 3224
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
	ll n;
	ll a[100000];
	pii pa[100000];
	scanf("%lld",&n);
	for(int i=0;i<n;i++) scanf("%lld",a+i);
	for(int i=0;i<n;i++){
		pa[i].first = a[i];
		pa[i].second = n - i;
	}
	sort(pa,pa+n);
	reverse(pa,pa+n);
	for(int i=0;i<n;i++) pa[i].second = n - pa[i].second;
	vector<ll> usisan;
	for(int i=0;i<n;i++) usisan.push_back(pa[i].first);
	sort(usisan.begin(),usisan.end());
	reverse(usisan.begin(),usisan.end());
	usisan.erase(unique(usisan.begin(),usisan.end()),usisan.end());
	int now = 0;
	ll ans[100000];
	fill(ans,ans+n,0);
	int mi = 1000000000;
	for(int i=0;i<n;i++){
		if(usisan[now]!=pa[i].first){
			now++;
			ans[mi] += i * (usisan[now - 1] - usisan[now]);
		}
		mi = min(mi,pa[i].second);
	}
	ans[0] += usisan[now] * n;
	for(int i=0;i<n;i++) printf("%lld\n",ans[i]);
}


Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int e = 1,o = 2;
	vector<int> vi,vi1;
	for(int i=0;i<n;i++)
	{
		vi.push_back(e);e+=2;	
	 } 
	for(int i=0;i<m;i++)
	{
		vi1.push_back(o);o+=2;	
	 } 
	 int sum = 0;
	for(int i=0;i<n;i++)
	{
		int k = vi[i];
		for(int j = i+1;j<n;j++)
		{
			int m = vi[j];
			int su = k+m;
			if(su%2 == 0)sum++;
		}
	}
	cout<<sum+m*(m-1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    string s,t;
    cin>>s>>t;
    int sz=s.size();
    int tsz=t.size();
    int ses=tsz;
    for(int i=0;i<sz;i++)
    {
       string yo=s.substr(i,tsz);
       int cnt=0;
       if(yo.size()!=tsz)continue;
       for(int j=0;j<tsz;j++)
       {
           if(yo[j]!=t[j])cnt++;
       }
       ses=min(ses,cnt);
    }
    cout<<ses<<"\n";
    return 0;

}





































Measured memory_bytes: 3668
def swap(a, b):
    tmp = a
    a = b
    b = tmp
    return a, b


def solve(): # 072D- Derangement
    N = int(input())
    p = list(map(int, input().split(" ")))
    p.insert(0, 0)
    cnt = 0

    for i in range(1, N+1):
        if i == p[i] and i != N:
            p[i], p[i+1] = swap(p[i], p[i+1])
            cnt += 1
        elif i == N and i == p[i]:
            p[i-1], p[i] = swap(p[i-1], p[i])
            cnt += 1
        else:
            pass

    print(cnt)
    
    
solve()

Measured memory_bytes: 14008
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.nextLine();
		String a = s.replace("apple", "peach");
		String b = s.replace("peach", "apple");

		String result = "";
		for(int i = 0; i < a.length(); i++){


			if(a.charAt(i) == b.charAt(i)){
				result += a.charAt(i);

			}else if(a.charAt(i) == s.charAt(i)){
				result += b.charAt(i);

			}else{
				result += a.charAt(i);
			}



		}
		System.out.println(result);
    }
}

Measured memory_bytes: 26584
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    if(n%2==0)
    cout<<n/2;
    else
    cout<<(n/2)+1;
}



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

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

  int A = N / 100;
  int B = N % 100;

  if (0 < A && A < 13 && 0 < B && B < 13) cout << "AMBIGUOUS" << endl;
  else if (0 < B && B < 13) cout << "YYMM" << endl;
  else if (0 < A && A < 13) cout << "MMYY" << endl;
  else cout << "NA" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  vector<vector<int>> vec(N,vector<int>(2));
  map<pair<int,int>,int> mp;
  pair<int,int> P;
  for(int i=0; i<N-1; i++){
    int a, b;
    cin >> a >> b;
    vec.at(i).at(0) = a-1;
    vec.at(i).at(1) = b-1;
    G.at(a-1).push_back(b-1);
    G.at(b-1).push_back(a-1);
  }
  
  vector<int> edge(N);
  queue<int> Q;
  Q.push(vec.at(0).at(0));
  int M = 0;
  set<int> S;
  S.insert(vec.at(0).at(0));
  
  while(Q.size()){
    int a = Q.front();
    S.insert(a);
    Q.pop();
    int cnt = 0;
    int i = 0;
    while(i < G.at(a).size()){
      cnt++;
      if(cnt == edge.at(a)){
        continue;
      }
      else if(S.count(G.at(a).at(i))){
        i++;
        cnt--;
        continue;
      }
      else{
        P = make_pair(min(a,G.at(a).at(i)), max(a,G.at(a).at(i)));
        mp[P] = cnt;
        Q.push(G.at(a).at(i));
        edge.at(G.at(a).at(i)) = cnt;
        i++;
        M = max(M,cnt);
      }
    }
  }
   
  cout << M << endl;
  for(int i=0; i<N-1; i++){
    P = make_pair(vec.at(i).at(0), vec.at(i).at(1));
    cout << mp[P] << endl;
  }
}

Measured memory_bytes: 22784
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2;
    cin >> k;

    int total = (h2-h1) * 60;
    if (m2 <= m1)
    	total -= (m1-m2);
    else
    	total += (m2-m1);

    cout << total - k << "\n";

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3648
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import deque
 
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
q = deque()
done = [-1]*N
done[0] = 1
q.appendleft(0)
while q:
    now = q.pop()
    for to in G[now]:
        if done[to] != -1: continue
        done[to] = now+1
        q.appendleft(to)
print("Yes")
print(*done[1:], sep="\n")

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

using namespace std;

typedef long long ll;

vector <ll> V;
ll n, ans;

int main()
{
  	ios::sync_with_stdio(false);
  	cin.tie(NULL);
  	
  	int a, i;
  
  	cin >> n;
  	
  	for(i=0; i<n*3; i++){
      	cin >> a;
      	V.push_back(a);
    }
  	
  	sort(V.rbegin(), V.rend());
  	
  	for(i=1; i<n+n; i+=2){
      	ans += V[i];
    }
  	
  	cout << ans << endl;
  	
  	return 0;
}

Measured memory_bytes: 6128
#include "bits/stdc++.h"
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=0;



void solve(){
	int n,k;
	cin>>n>>k;
	
	if(k == 0){
		cout<<(n*n);
		return;
	}
	
	int ans = 0;
	rep(b,k+1,n+1){
		ans += (n/b) * (b-k);
		if(n%b){
			ans += max(n%b - k + 1,0LL);
		}
	}
	
	cout<<ans;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SIEVE
		sieve();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


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



int main(){
    //ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("../input.txt","r",stdin);

    int X;
    cin >> X;
    int c_500,c_5;
    c_500 = X/500;
    X = X - c_500*500;
    c_5 = X/5;

    cout << c_500*1000 + c_5*5 << "\n";


}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MOD = 998244353;

const int MAX = 10010;

int DP[MAX][MAX];

char buf[MAX];
int A[MAX];
int B[MAX];

LL F[MAX];

LL bpow(LL a, LL b)
{
	LL res = 1;
	while(b)
	{
		if (b & 1) res = (res * a) % MOD;
		b /= 2;
		a = (a * a) % MOD;
	}

	return res;
}

LL inv(LL a)
{
	return bpow(a, MOD - 2);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	F[0] = 1;
	FOR (i, 1, MAX)
	{
		F[i] = (F[i-1] * (LL)i) % MOD;
	}

	scanf("%s", buf);
	int n = strlen(buf);
	FOR (i, 0, n)
	{
		A[i] = buf[i] - '0';
	}

	scanf("%s", buf);
	FOR (i, 0, n)
	{
		B[i] = buf[i] - '0';
	}

	int x, y;
	x = y = 0;
	FOR (i, 0, n)
	{
		if (A[i] == 1 && B[i] == 1) x++;
		if (A[i] == 0 && B[i] == 1) y++;
	}

	DP[0][0] = 1;
	FOR (i, 0, x+1)
	{
		FOR (j, 0, y+1)
		{
			if (i == 0 && j == 0) continue;
			LL cur = 0;
			if (j)
			{
				LL c = 1;
				c *= DP[i][j-1];
				cur += c;
			}

			if (i && j)
			{
				LL c = j;
				c *= DP[i-1][j];
				cur += c;
			}

			DP[i][j] = cur % MOD;
		}
	}

	LL C = 1;
	LL C2 = 1;

	LL N = x + y;

	LL res = 0;
	FOR (i, 0, x+1)
	{
		LL cur = DP[x - i][y];
		//LL cur = bpow(y, y + (x - i) - 1);
		cur *= F[y];
		cur %= MOD;
		cur *= F[y];
		cur %= MOD;
		cur*= F[x - i];
		cur %= MOD;
		cur *= F[i];
		cur %= MOD;
		cur *= F[i];
		cur %= MOD;
		cur *= C;
		cur %= MOD;
		cur *= C2;
		res = (res + cur) % MOD;

		C = (C * (N - i)) % MOD;
		C = (C * inv(i + 1)) % MOD;

		C2 = (C2 * (x - i)) % MOD;
		C2 = (C2 * inv(i+1)) % MOD;
	}

	cout<<res<<endl;


}


Measured memory_bytes: 389760
import java.util.*;

public class Main {
    int[] InsertionSort(int[]lst){
		int n=lst.length;
		for(int i=1;i<n;i++){
			int j=i-1,v=lst[i];
			while( 0 <= j  && v < lst[j]){
				lst[j+1]=lst[j];
				lst[j]=v;
				j--;
			}
			new Main().print(lst);
		}
		return lst;
	}
	void print(int[]a){
	    for(int i=0;i<a.length;i++){
	        if(i==0){System.out.printf("%d",a[i]);continue;}
	        System.out.printf(" %d",a[i]);
	    }
	    System.out.println();
	}
	
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] x=new int[n];
        for(int i=0;i<n;i++){x[i]=sc.nextInt();}
        Main a=new Main();
        a.print(x);
        a.InsertionSort(x);
    }
}


Measured memory_bytes: 42096