akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b;
    cin >> a >> b;
    cout << a+1 -b<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
let n=Int(readLine()!)!
let dd=readInts()
var count=0
for i in 0...n-2{
  for j in i+1...n-1{
    count+=dd[i]*dd[j]
  }
}
print(count)

Measured memory_bytes: 8256
import sys
input = sys.stdin.readline
N = int(input())
x = []
y = []
for i in range(N) :
    p, q = map(int,input().split())
    x.append(p)
    y.append(q)

ans = 0
for i in range(N) :
    for j in range(N) :
        ans += ((x[i]-x[j])**2 + (y[i]-y[j])**2)**0.5

ans = ans / N
print(ans)


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

int main() {
    vector<int> a(1);
    cin >> a.at(0);
    int i = 0;
    int ans = 0;
    while (true) {
        for (int j = 0; j < i; j++) {
            if (a.at(i) == a.at(j)) {
                ans = i + 1;
            }
        }
        if (a.at(i) % 2 == 0) {
            a.push_back(a.at(i) / 2);
        }
        else {
            a.push_back(a.at(i) * 3 + 1);
        }
        if (ans != 0) {
            break;
        }
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define INF 1 << 30

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

int main(void) {
	ll num, a, b;
	cin >> num >> a >> b;
	if ((a & 1) == (b & 1))
		cout << (b - a) / 2 << "\n";
	else
		cout << min(min(b - 1, a + (b - a) / 2), min(num - a, num - b + 1 + (b - a) / 2)) << "\n";
	return 0;
}

Measured memory_bytes: 256
#Toll Gates

#入力
N,M,X = map(int,input().split())
A = list(map(int, input().split()))

#進む側
temp1 = X
cost1 = 0
while(1):
	if temp1 == N:
		break
	temp1 += 1
	for j in range(M):
		if temp1 == A[j]:
			cost1 += 1

#戻る側
temp2 = X
cost2 = 0
while(1):
	if temp2 == 0:
		break
	temp2 -= 1
	for j in range(M):
		if temp2 == A[j]:
			cost2 += 1

#出力
print(min(cost1,cost2))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string a, b,ans="";
	cin >> a >> b;
	int lena = a.length(),lenb=b.length();
	for (int i = 0; i < lenb; i++)
		ans =ans+ a[i]+b[i];
	if (lena > lenb)ans += a[lenb];
	cout << ans << endl;
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<int> vi;

void solve(){
	
	ll n; cin >> n;
	ll curr = 100;
	ll ans = 0;
	while(curr<n){
		curr += curr/100;
		++ans;
	}
	cout << ans << "\n";
	
	
	return;
}

int main(){
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	
	solve();
		
	return 0;
}


Measured memory_bytes: 3652
def InputData():
    
    sequence_len = int(input())
    sequence = [int(a) for a in input().split(" ")]

    return sequence_len, sequence

def bubbleSort(A):
    cnt = 0
    for i in range(len(A)-1):
        for j in range(len(A)-1, i+1, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                cnt += 1
    
    return cnt

def merge(sequence, left, mid, right):
    global merge_cnt
    n1 = mid - left
    n2 = right - mid
    sequence_left = sequence[left:left + n1]
    sequence_right = sequence[mid:mid + n2]
    sequence_left.append(float('inf'))
    sequence_right.append(float('inf'))

    left_cnt = 0
    right_cnt = 0
    for i in range(left, right):
        if sequence_left[left_cnt] <= sequence_right[right_cnt]:
            # print(sequence_left[left_cnt])
            sequence[i] = sequence_left[left_cnt]
            left_cnt += 1
        else:
            # print(sequence_right[right_cnt])
            sequence[i] = sequence_right[right_cnt]
            right_cnt += 1
            merge_cnt += n1 - left_cnt

def mergeSort(sequence, left, right):
    if left + 1 < right:
        # print(merge_cnt)
        mid = (left + right) // 2
        mergeSort(sequence, left, mid)
        mergeSort(sequence, mid, right)
        merge(sequence, left, mid, right)

def PrintOut(cnt):
    print(cnt)

def main():
    [sequence_len, sequence] = InputData()
    # cnt = bubbleSort(sequence)
    global merge_cnt
    merge_cnt = 0
    mergeSort(sequence, 0, sequence_len)
    PrintOut(merge_cnt)

if __name__=="__main__":
    main()


Measured memory_bytes: 28356
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  unordered_map<int, int> D{};
  REP(i, N) {
    int a;
    cin >> a;
    D[a]++;
  }
  int M;
  cin >> M;
  bool ok = true;
  REP(i, M) { int a;
    cin >> a;
    if (D[a] <= 0) ok = false;
    D[a]--;
  }
  puts(ok?"YES":"NO");
  cout << "\n";
}

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

int main() {
  int x, y;
  cin >> x >> y;
  vector<vector<char>> v(x,vector<char>(y));
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      cin >> v[i][j];
    }
  }
  
  set<int> AllDotx, AllDoty;
  for (int i = 0; i < x; i++) {
    bool b = true;
    for (int j = 0; j < y; j++) {
      if (v[i][j] == '#') b = false;
    }
    if (b) {
      AllDotx.insert(i);
    }
  }
  for (int j = 0; j < y; j++) {
    bool b = true;
    for (int i = 0; i < x; i++) {
      if (v[i][j] == '#') b = false;
    }
    if (b) {
      AllDoty.insert(j);
    }
  }
  
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      if (AllDotx.count(i) || AllDoty.count(j)) continue;
      cout << v[i][j];
    }
    if (!AllDotx.count(i)) cout << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep (i ,n) for(int i=0;i<(n);i++) 
ll gcd (ll a,ll b) {return b?gcd(b,a%b):a;}   
ll lcm (ll a,ll b) {return a/gcd(a,b)*b;} 
const int mod=1e9+7;
int main(){
	int n,m;
	cin>>n>>m;
	vector<int>v(n+1,true);
	for(int i=0;i<m;i++){
		int a;
		cin>>a;
		v[a]=false;
	}
	vector<ll>dp(n+1);
	dp[0]=1;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<=min(n,i+2);j++){
			if(v[i]){
				dp[j]+=dp[i];
				dp[j]%=mod;
			}
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main{
    public static void Sort(int x, int y, int z){
        int w;
        if(x > y){
            w = x;
            x = y;
            y = w;
        }
        if(y > z){
            w = y;
            y = z;
            z = w;
        }
        if(x > y){
            w = x;
            x = y;
            y = w;
        }
        System.out.println(x + " " + y + " " + z);
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        Sort(a, b, c);
    }
}


Measured memory_bytes: 26276
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<ll, ll> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

struct Point{
    int xi;
    int yi;
    int id;
    bool operator<(const Point &T) const{
        return xi<T.xi;
    }
};

struct Dist{
    int dis;
    int i1;
    int i2;
    bool operator<(const Dist &D) const {
        return dis < D.dis;
    }
};

const int N = (int)1e5 + 9;

int pi[N];
int sz[N];

int fin(int u){
    if(pi[u]==u)
        return u;
    return pi[u]=fin(pi[u]);
}

bool merge(int a, int b){
    a=fin(a);
    b=fin(b);
    if(a==b)
        return false;
    if(sz[a] > sz[b])
        swap(a, b);
    sz[b] += sz[a];
    pi[a] = b;
    return true;
}

int main(){
    fastIO;
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++ )pi[i] = i, sz[i] = 1;
    vector<Point> xx, yy;
    int x, y;
    for(int i = 1; i <= n; i ++ ){
        cin >> x >> y;
        xx.push_back({x,y,i});
        yy.push_back({y,x,i});
    }
    sort(xx.begin(), xx.end());
    sort(yy.begin(), yy.end());
    vector<Dist> dd;
    for(int i = 1; i < n; i ++ ){
        dd.push_back({xx[i].xi - xx[i-1].xi, xx[i-1].id, xx[i].id});
        dd.push_back({yy[i].xi - yy[i-1].xi, yy[i-1].id, yy[i].id});
    }
    int res = 0;
    sort(dd.begin(), dd.end());
    for(int i = 0; i < dd.size(); i ++ ){
        if(merge(dd[i].i1, dd[i].i2))
            res += dd[i].dis;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 7852
import java.io.*;
class Main{
	public static void main(String[] args)throws IOException{
		int w = 0;
		int x;
		int y;
		int z = 0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
            String str = br.readLine();
            String array[] = str.split(" ");
            
            x = Integer.parseInt(array[0]);
			y = Integer.parseInt(array[1]);
			
			w = x * y;
			z = 2*x + 2*y;
				System.out.println(w + " " +z);
				}
				}

Measured memory_bytes: 24248
#include<stdio.h>
int main(){
  long long s,t,u;
  scanf("%lld",&s);
  t=s/1000000000+1;
  u=1000000000-s%1000000000;
  if(s%1000000000==0){
    t--;
    u=0;
  }
  printf("0 0 %lld 1000000000 %lld 1",u,t);
}


Measured memory_bytes: 128
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/14/20 07:28:46
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<int> P(n); for(auto& p:P) cin>>p;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (P[i] == i+1) {
      ans++;
      ++i;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>

int main() {
  int a, b;
  std::cin >> a >> b;
  int num = 0;
  for (int i = a; i < b + 1; i++) {
    int ten_thousand = i / 10000;
    int thousand = i / 1000 % 10;
    int ten = i / 10 % 10;
    int one = i % 10;
    if (ten_thousand == one && thousand == ten) {
      num++;
    }
  }
  std::cout << num << std::endl;

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

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

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


u = UnionFind(N)
for a, b in AB:
    u.union(a - 1, b - 1)

print(u.group_count() - 1)


Measured memory_bytes: 29412
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    int n,x,t;
    cin >> n >> x >> t;
    int ans;
    if(n%x) ans = (n/x + 1)*t;
    else ans = n/x*t;

    cout << ans << endl;
    return 0;
}

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

int main(void) {
    int64_t A,B;
    cin >> A >> B;

    if(B == 1){ 
        cout << "0\n";
        return 0;
    }
    if(B <= A) {
        cout << "1\n";
    } else {
        if((B-A)%(A-1)) {
            cout << (B-A)/(A-1) + 2 << "\n";
        } else {
            cout << (B-A)/(A-1) + 1 << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll n,k,i,j;
	cin >> n >> k;
	vector<ll>v;
	for(i=0;i<n;i++)
	{
		ll x;
		cin >> x;
		v.push_back(x);
	}
	bool dp[k+1];
	memset(dp,false,sizeof(dp));
	// dp[i] is True if 1st player wins if there are i stones remaining
	for(ll stones=0;stones<=k;stones++)
	{
		for(i=0;i<n;i++)
		{
			if(stones>=v[i] && !dp[stones-v[i]])
				dp[stones]=true;
		}
	}
	if(dp[k])
		cout<<"First\n";
	else
		cout<<"Second\n";
}

Measured memory_bytes: 384
import sys

def solve(N, X):
    ans = float("inf")
    for i in range(max(X)+1):
        cost = 0
        for x_i in X:
            cost +=  (x_i - i) ** 2
        ans = min(ans, cost)
    print(ans)

if __name__ == '__main__':
    N = int(sys.stdin.readline().strip())
    X = list(map(int,sys.stdin.readline().strip().split(" ")))
    
    solve(N, X)

Measured memory_bytes: 38896
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using pii = pair<int,int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

ll n;
string s;
ll moji[27]={0};

int main(){
	cin>>n>>s;
	rep(i,n){
		moji[s[i]-'a']++;
	}
	ll ans = 0;
	rep(i,26){
		ans += moji[i]*(ans+1);
		ans %= Mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<tuple<string, int, int> > v;
	for(int i = 0; i < N; ++i) {
		string S;
		int P;
		cin >> S >> P;
		v.push_back(make_tuple(S, -P, i));
	}
	sort(v.begin(), v.end());
	for(int i = 0; i < N; ++i) {
		cout << (get<2>(v[i]) + 1) << '\n';
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    string S;
    cin >> S;
    char a = S[0];
    ll sum = 0;

    for (int i = 0; i < S.size(); i++) {
        if (i%2) {
            if (S[i] == a) sum++;
        }
        else {
            if (S[i] != a) sum++;
        }
    }
    if (sum < S.size() - sum) cout << sum << endl;
    else cout << S.size() - sum << endl;

    return 0;
}


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

int main()
{
	int64_t n, k;
	cin >> n >> k;
	vector<int64_t> ps(n);
	for (auto &&p : ps)
	{
		cin >> p;
	}

	vector<long double> qs(n);
	for (int64_t i = 0; i < n; i++)
	{
		qs[i] = (long double)(ps[i] + 1) / 2;
	}

	long double ans = 0;

	{
		long double tmp = 0;
		for (int64_t i = 0; i < n; i++)
		{
			if (k <= i)
			{
				tmp -= qs[i - k];
			}

			tmp += qs[i];

			ans = max(ans, tmp);
		}
	}

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

	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int check(int a){
    bool f=0;
    for(int i=1;i*i<=a;i++){
        if(i*i==a){f=1;break;}
    }
    return f;
}
int n,d,cnt;
int main(){
    cin>>n>>d;
    vector<vector<int> > x(n,vector<int>(d));
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>x[i][j];
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int sum=0;
            for(int k=0;k<d;k++){
                int p=abs(x[i][k]-x[j][k]);
                sum+=p*p;
            }
            if(check(sum))cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
INFTY = 10**6
N,M = map(int,input().split())
S = input().strip()
S0 = []
for i in range(N+1):
    if S[i]=="0":
        S0.append(i)
flag = 0
for i in range(1,len(S0)):
    if S0[i]-S0[i-1]>M:
        flag = 1
        break
if flag==1:
    print(-1)
else:
    C = [[INFTY,-1,-1] for _ in range(N+1)]
    C[N] = [0,0,N]
    cur = N
    curN = -1
    a = 0
    for i in range(len(S0)-2,-1,-1):
        j = S0[i]
        if cur-j<=M:
            pass
        else:
            cur = curN
            a += 1
        C[j] = [a+1,cur-j,cur]
        curN = j
    i = 0
    A = []
    while i<N:
        A.append(C[i][1])
        i = C[i][2]
    print(*A)

Measured memory_bytes: 71156
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 1e5 + 10;
vector<ll> graph[MAXN];
ll n,k;
vector<ll> mul;
ll marked_at_dist_1[MAXN];
ll marked_at_dist_2[MAXN];

void dfs(ll u,ll p){

    marked_at_dist_2[u] = marked_at_dist_1[p];
    if(p!=0) marked_at_dist_1[u] = 1;
    else marked_at_dist_1[u] = 0;

    ll req = k - marked_at_dist_1[u] - marked_at_dist_2[u];
    mul.push_back(req);

    for(ll v:graph[u]){
        if(v != p) dfs(v,u);
    }

    marked_at_dist_1[p]++;
}

const ll MOD = 1e9 + 7;

void solve(){ 
    cin>>n>>k;

    FOR(i,1,n-1){
        ll u,v; cin>>u>>v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    dfs(1,0);

    ll ans = 1;
    for(ll v:mul){
        ans = (ans*v)%MOD;
    }

    ans = (ans + MOD)%MOD;
    cout<<ans<<endl;
}

signed main(){

   FastRead;    


    ll t;
    t = 1; 
   // cin>>t;
    FOR(i,1,t){
        // cout<<"Case "<<i<<":\n";
        solve();
    }
}


Measured memory_bytes: 12916
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define mo 998244353
using namespace std;
char s[200010];
int f[200010][4][4][2];
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1),x=0,cnt=0,ans=0;
	for (int i=1;i<=len;i++)
	{
		int y=0;
		if (s[i]=='a') y=0;
		if (s[i]=='b') y=1;
		if (s[i]=='c') y=2;
		x=(x+y)%3;
		if (i!=1&&s[i]==s[i-1]) cnt++;
	}
	if (cnt==len-1) { puts("1");return 0;}
	if (len<=3)
	{
		if (len==1) { puts("1");return 0;}
		if (len==2) { puts("2");return 0;}
		if (len==3&&!cnt&&s[1]!=s[3]) { puts("3");return 0;}
		if (len==3&&cnt==1) puts("6");
			else puts("7");
		return 0;
	}
	f[1][0][0][0]=1;
	f[1][1][1][0]=1;
	f[1][2][2][0]=1;
	for (int i=2;i<=len;i++)
		for (int j=0;j<3;j++)
			for (int k=0;k<3;k++)
				for (int l=0;l<3;l++)
				{
					(f[i][(j+l)%3][l][1]+=f[i-1][j][k][1])%=mo;
					(f[i][(j+l)%3][l][(k==l)]+=f[i-1][j][k][0])%=mo;
				}
	if (!cnt) ans++;
	for (int i=0;i<3;i++) ans=(ans+f[len][x][i][1])%mo;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 25472
hw = gets.split(' ').map(&:to_i)

h = hw[0]
w = hw[1]

h_move = (w/2.0).ceil
h_move2 = ((w-1)/2.0).ceil


if h == 1 || w == 1 then
    print "1"
elsif h % 2 == 0 then
    total = (h_move+h_move2) * (h/2.0).floor
    print total.to_s
else
    total = (h_move+h_move2) * (h/2.0).floor
    total += h_move
    print total.to_s
end


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

#define sd1(a) scanf("%d",&a)
#define sd2(a,b) scanf("%d %d",&a,&b)

using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G,int v,int before,int step,vector<int> &Array) {
		Array[v]=step;
    for(int i=0;i<G[v].size();i++)
			if(G[v][i]!=before) dfs(G,G[v][i],v,step+1,Array);
}

int main()
{
	int a,b;
	int N;
	int ans=0;
	sd1(N);
	vector<int> Fennec(N+10);
	vector<int> Sunuke(N+10);
	Graph G(N+10);
	for(int i=0;i<N-1;i++){
		sd2(a,b);
		a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(G,0,-1,0,Fennec);
	dfs(G,N-1,-1,0,Sunuke);

//	for(int i=0;i<N;i++) cout<<Fennec[i]<<" ";
//	cout<<endl;
//	for(int i=0;i<N;i++) cout<<Sunuke[i]<<" ";
	for(int i=0;i<N;i++) ans+=(Fennec[i]<=Sunuke[i])?1:-1;
	printf("%s",(ans>0)?"Fennec":"Snuke");
}


Measured memory_bytes: 14336
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n;
int A,B,C;
int L[10];
int cou;
int sselect[8];
int eachsum[8];
int subans;
int ans;
int asize;
int num[4];
vector<int> array;
void saiki(int now)
{
	if(now==n)
	{
		rep(i,4)
		{
			eachsum[i]=0;
			num[i]=0;
		}
		rep(i,n)
		{
			eachsum[sselect[i]]+=L[i];
			num[sselect[i]]++;
		}
		rep(i,3)
		{
			if(num[i]==0)break;
			if(i==2)
			{
				subans=10*(num[0]+num[1]+num[2]-3);
				subans+=abs(eachsum[0]-A);
				subans+=abs(eachsum[1]-B);
				subans+=abs(eachsum[2]-C);
				if(ans==-1||ans>subans)ans=subans;
			}
		}
		
	}
	else
	{
		rep(i,4)
		{
			sselect[now]=i;
			saiki(now+1);
		}
	}
}
int main()
{
	ans=-1;
	cin>>n;
	cin>>A>>B>>C;
	rep(i,n)
	{
		cin>>L[i];
	}
	saiki(0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)
dp = [[0]*N for _ in range(1<<N)]
#dp[i][j]:=集合iをすでに通っていて、最後が頂点jのときの組み合わせ
dp[1][0] = 1

for bit in range(1<<N):
  for n in range(N):
    if(bit>>n & 1 == 0):
      continue
    for to in graph[n]:
      if(bit>>to & 1 == 1):
        continue
      next_bit = bit | (1<<to)
      dp[next_bit][to] += dp[bit][n]

ans = 0
for i in range(1, N):
  ans += dp[(1<<N)-1][i]
print(ans)

Measured memory_bytes: 39792
#include <stdio.h>

char a[9][9];
int dx[] = {0,  0, 0,  0, 0,  0, 1, -1, 2, -2, 3, -3};
int dy[] = {3, -3, 2, -2, 1, -1, 0,  0, 0,  0, 0,  0};

void bomb(int i, int j)
{
	int newx, newy;
	int k;
	
	if (a[i][j] == '1'){
		a[i][j] = '0';
		for (k = 0; k < 12; k++){
			newx = i + dx[k];
			newy = j + dy[k];
			
			if (newx >= 0 && newy >= 0 && newx < 8 && newy < 8 && a[newx][newy] == '1'){
				bomb(newx, newy);
			}
		}
	}
}

int main(void)
{
	int i, j;
	int n;
	int x, y;
	int count;
	
	count = 1;
	scanf("%d", &n);
	while (n){
		for (i = 0; i < 8; i++){
			scanf("%s", a[i]);
		}
		scanf("%d", &x);
		scanf("%d", &y);
		
		bomb(y - 1, x - 1);
		
		printf("Data %d:\n", count);
		for (i = 0; i < 8; i++){
			printf("%s\n", a[i]);
		}
		n--;
		count++;
	}
	
	return (0);
}

Measured memory_bytes: 1036
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int x;
    cin>>x;

    int a,b;
    cin>>a>>b;

    int l=iceil(a,x),r=b/x;
    if(r-l>=0)
        cout<<"OK";
    else
        cout<<"NG";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
string s;
cin >> s;
bool ans = true;
for(int i=1;i<s.size();i+=2){
    if(s.at(i-1)=='h'&&s.at(i)=='i'){}
    else ans =false;
}
if(ans&&s.size()%2==0)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}





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

int main(){
  string S,T; cin >> S >> T;
  int MAX = 0;
  for(int i=0;i<S.size() - T.size() + 1;i++){
    string W = S.substr(i,T.size());
    int num = 0;
    for(int j=0;j<T.size();j++){
      if(W.at(j) == T.at(j))  num++;
    }
    if(num > MAX) MAX = num;
  }
  cout << T.size() - MAX << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
const long long MAX=1000000007;
long long powmod(long long a,long long b)
{
    long long c=1;
    while(b!=0)
    {
        if(b&1)
        {
            c=a*c%MAX;
        }
        a=a*a%MAX;
        b>>=1;
    }
    return c;
}
long long nCr(long long n,long long r)
{
    long long x=1,y=1,i;
    for(i=1;i<=r;i++)
    {
        x=x*(n-(i-1))%MAX;
        y=y*i%MAX;
    }
    return x*powmod(y,MAX-2)%MAX;
}
int main()
{
    long long n,a,b,ans;
    cin>>n>>a>>b;
    ans=powmod(2,n)-1-nCr(n,a)-nCr(n,b);
    cout<<((ans%MAX)+MAX)%MAX<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void)
{
	int n, i, j, k;
	int a[100000];
	int max, maxi;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = n - 2; i >= 0; i--) {
		if (a[i] - a[i + 1] == 1) {
			a[i]--;
		}
		else if (a[i] - a[i + 1] == 0) {
			continue;
		}
		else if (a[i] - a[i + 1] > 1) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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


fn main()
{
    input! {
        n: usize,
        v: [i32; n],
    };
    
    for e in v.iter()
    {
      if (e % 2 == 0)
      {
        if (e % 3 == 0 || e % 5 == 0)
        {
        }
        else
        {
          println!("DENIED");
          return;
        }
      }
    }
    
    println!("APPROVED");
}

Measured memory_bytes: 4352
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

#define SIZE(x) (int((x).size()))
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
#define repd(i,r,l) for (int i=(r); i>=(l); i--)
#define rept(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

#ifndef ONLINE_JUDGE
#define debug(x) { cerr<<#x<<" = "<<(x)<<endl; }
#else
#define debug(x) {}
#endif

#define maxn 100010

char buf[maxn];

void lemon()
{
	scanf("%s",buf+1); int n=strlen(buf+1), m;
	scanf("%d",&m);
	rep(i,1,n)
	{
		int order=buf[i]-'a', req=0;
		if (order) req=26-order;
		if (m>=req) 
		{
			buf[i]='a';
			m-=req;
		}
		else  continue;
	}
	buf[n]='a'+(buf[n]-'a'+m)%26;
	printf("%s\n",buf+1);
	
}

int main()
{
	ios::sync_with_stdio(true);
	#ifndef ONLINE_JUDGE
	//	freopen("c.in","r",stdin);
	#endif
	lemon();
	return 0;
}



Measured memory_bytes: 760
n, x, y = map(int, input().split())
x -= 1
y -= 1
d = [0 for _ in range(n)]
for i in range(n - 1):
    for j in range(i + 1, n):
        if j <= x or i >= y:
            d[j - i] += 1
        else:
            k = min(j - i, abs(x - i) + abs(y - j) + 1)
            d[k] += 1
for ans in d[1:]:
    print(ans)


Measured memory_bytes: 3444
import numpy as np

n, c = map(int, input().split())
stc = [[] for i in range(c+1)]
for i in range(n):
  s_, t_, c_ = map(int, input().split())
  stc[c_].append([s_,t_])
  

stc_ = []
for i in range(1, c+1):
    stc[i] = sorted(stc[i], key=lambda x:(x[0], x[1]))
    j = 0
    l = len(stc[i])
    flg = False
    while j < l:
        if not flg:
            cs, ct = stc[i][j][0], stc[i][j][1]
        if j == l-1:
            stc_.append([cs, ct])
            break
        ns, nt = stc[i][j+1][0], stc[i][j+1][1]
        if ct != ns:
            flg = False
            stc_.append([cs, ct])
        else:
            flg = True
            ct = nt
            if j == l - 2:
                stc_.append([cs, ct])
                break
        j += 1
stc_ = sorted(stc_, key=lambda x:(x[0], x[1]))

m = len(stc_)

cnt = np.zeros(10**5+5, dtype=int)
for i in range(m):
    s, t = stc_[i][0]-1, stc_[i][1]
    cnt[s:t] += 1
print(cnt.max())


Measured memory_bytes: 60040
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
//桁
int kt(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b[i];
  int d=0,c=0;
  rep(i,a-1){
    if(b[i]<b[i+1])
      c=0;
  else{
    c++;
    if(d<c)
      d=c;
  }
  }
  cout<<d;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;

using namespace std;

int main() {
    string s;
    cin >> s;
    int len = s.length();
    vector<ll> a;
    ll f[len] = {};

    int now;
    for(int i=0; i<len; i++) {
        now=1;
        while(s[i]==s[i+1]) {
            now++;
            i++;
        }
        a.push_back(now);
    }

    now=-1;
    for(int i=0; i<a.size(); i+=2) {
        now += a[i];

        f[now] += a[i]/2 + a[i]%2;
        f[now+1] += a[i]/2;

        f[now] += a[i+1]/2;
        f[now+1] += a[i+1]/2 + a[i+1]%2;

        now += a[i+1];
    }

    for(int i=0; i<len-1; i++) cout << f[i] << ' ';
    cout << f[len-1] << endl;


    return 0;
}



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

int main(void) {
    int N;
    cin >> N;
    int a[N];
    for(int i=0; i<N; i++) cin >> a[i];
    int res = 0;
    int memo = -1;
    int cnt = 1;
    for(int i=0; i<N; i++) {
        if (memo == a[i]) {
            cnt++;
        } else {
            memo = a[i];
            res += cnt/2;
            cnt = 1;
        }
    }
    res += cnt/2;
    cout << res << endl;
    return 0;
}


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

using namespace std;

// long long nc3(long long n){
//     if(n < 3){
//         return (long long)0;
//     }
//     return (n * (n - 1) * (n - 2)) / 6;
// }

// int main(){
//     long long N;
//     cin >> N;
//     string s;
//     cin >> s;
//     long long r = 0, g = 0, b = 0;
//     for(long long i = 0; i < N; i++){
//         if(s[i] == 'R'){
//             r++;
//         }
//         else if(s[i] == 'G'){
//             g++;
//         }
//         else{
//             b++;
//         }
//     }
//     long long cnt = 0;
//     for(long long i = 1; i < N / 2; i++){
//         for(long long j = 0; j < N - i; j++){
//             if(j + i < N && j + 2 * i < N){
//                 // if(s[j] != s[j + i] && s[j + i] != s[j + 2 * i] && s[j] != s[j + 2 * i]){
//                     cnt++;
//                 // }
//             }
//         }
//     }
//     cout << r << " " << g << " " << b << endl;
//     long long ans = nc3(N) + cnt - nc3(r + g) - nc3(r + b) - nc3(g + b);
//     cout << ans << endl;
//     return 0;
// }
 
int main(){
    long long n;
    string s;
    cin >> n >> s;
    long long cnt1[4005] = {0}, cnt2[4005] = {0}, cnt3[4005] = {0};
    for(long long i = n - 1; i >= 0; i--){
        if(s[i] == 'R'){
            cnt1[i] = cnt1[i + 1] + 1;
            cnt2[i] = cnt2[i + 1];
            cnt3[i] = cnt3[i + 1];
        }
        if(s[i] == 'G'){
            cnt2[i] = cnt2[i + 1] + 1;
            cnt1[i] = cnt1[i + 1];
            cnt3[i] = cnt3[i + 1];
        }
        if(s[i] == 'B'){
            cnt3[i] = cnt3[i + 1] + 1;
            cnt1[i] = cnt1[i + 1];
            cnt2[i] = cnt2[i + 1];
        }
    }
    long long sum = 0;
    for(long long i = 0;i < n - 1; i++){
        for(long long j = i + 1; j < n; j++){
            if(s[i] == s[j])
                continue;
            else if((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R')){
                long long x = j - i;
                sum += cnt2[j+1];
                if(j + x < n)
                    if(s[j + x] == 'G')
                        sum--;
            }
            else if((s[i] == 'G' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'G')){
                long long x = j - i;
                sum += cnt1[j+1];
                if(j + x < n)
                    if(s[j + x] == 'R')
                        sum--;
            }
            else if((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R')){
                long long x = j - i;
                sum += cnt3[j+1];
                if(j + x < n)
                    if(s[j + x] == 'B')
                        sum--;
            }
            
        }
    }
    cout << max(sum, (long long)0) << endl;
    return 0;
}

Measured memory_bytes: 3736
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class DColoringEdgesOnTree {
private:
    void dfs(int current, int previous, int previousColor) {
        int color = 1;
        for (auto& p : edgeAndIndex_[current]) {
            const auto next = p.first;
            const auto index = p.second;
            if (next == previous) continue;
            if (color == previousColor) color++;
            answers_[index] = color;
            maxColor_ = max(color, maxColor_);
            dfs(next, current, color);

            color++;
        }
    }

    vector<vector<pair<int, int> > > edgeAndIndex_;
    vector<int> answers_;
    int maxColor_ = 0;

public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in >> N;
	    vector<int> a(N), b(N);
	    REP(i,1,N) in >> a[i] >> b[i];

        edgeAndIndex_ = vector<vector<pair<int, int> > > (N+1);
        answers_ = vector<int>(N);
	    REP(i,1,N) {
            edgeAndIndex_[a[i]].emplace_back(b[i], i);
            edgeAndIndex_[b[i]].emplace_back(a[i], i);
	    }
	    dfs(1, -1, -1);
	    out << maxColor_ << "\n";
	    REP(i,1,N) {
	        out << answers_[i] << "\n";
	    }
	}
};


signed main() {
	DColoringEdgesOnTree solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
void solve()
{
 ll n;
 cin>>n;
 ll a[n],b[n],i,cnt=0,ma=0;
 for(i=0;i<n;i++)
 {
     cin>>a[i]>>b[i];
     if(a[i]==b[i])
        cnt++;
     else
        ma=max(cnt,ma),cnt=0;
 }
 if(cnt>0)
    ma=max(ma,cnt);
 if(ma>=3)
    cout<<"Yes"<<endl;
 else
    cout<<"No\n";
 }

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


return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
char s[105], t[105];
int main() {
	int n;
	scanf("%d%s%s", &n, s, t);
	string ss = s, tt = t;
	int ans = 2 * n;
	for (int i = 1; i <= n; ++i) {
		string sub = ss.substr(n - i, i);
		string sub2 = tt.substr(0, i);
		if (sub == sub2) ans = min(ans, 2 * n - i);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var H, W, K int
	fmt.Scan(&H, &W, &K)
	grids := make([][]rune, H)
	for i := range grids {
		var s string
		fmt.Scan(&s)
		grids[i] = []rune(s)
	}
	max := 1 << uint(H+W)
	ans := 0
	for f := 0; f < max; f++ {
		count := 0
		for i := 0; i < H; i++ {
			for j := 0; j < W; j++ {
				if f&(1<<uint(i+W)) == 0 && f&(1<<uint(j)) == 0 && grids[i][j] == '#' {
					count++
				}
			}
		}
		if count == K {
			ans++
		}
	}
	fmt.Printf("%d\n", ans)
}


Measured memory_bytes: 1836
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
    std::cin >> N;
    std::vector<int64_t> A(N);
    for (auto& v : A) std::cin >> v;

    int64_t money = 1000;
    for (int64_t i = 1; i < N; i++)
    {
        if (A[i - 1] < A[i])
        {
            money += (A[i] - A[i - 1]) * (money / A[i - 1]);
        }
    }

    std::cout << money << std::endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-

import sys

def isprime(n):
    for i in xrange(2, int(n ** 0.5)+1 ):
        if n % i == 0: return False
    return True


outList = []
for line in sys.stdin.readlines():
    List = map(int, line.strip().split())

    [a, b] = List

    # LCM
    LCM = 1
    i = 1
    while( i <= min(a, b) ):
        i += 1
        if not isprime(i): continue
        while(a % i == 0 and b % i == 0):
            LCM *= i
            a /= i
            b /= i

    # GCD
    GCD = List[0] * b

    print LCM, GCD

Measured memory_bytes: 4312
*> AtCoder My Practice
       *> author: Leonardone @ NEETSDKASU
       *>
       IDENTIFICATION DIVISION.
       PROGRAM-ID. Answer.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
              FUNCTION ALL INTRINSIC.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
              01 For-Inputing-Values.
                     05 file-access PIC X USAGE COMP-X VALUE IS 1.
                     05 file-handle PIC X(4) USAGE COMP-X.
                     05 file-offset PIC X(8) USAGE COMP-X VALUE IS 0.
                     05 file-nbytes PIC X(4) USAGE COMP-X VALUE IS 100.
                     05 file-buffer PIC X(100).
              01 Input-Values.
                     05 a      BINARY-SHORT.
                     05 b      BINARY-SHORT.
              01 Calc-Values.
                     05 disp   PIC X(5).
       PROCEDURE DIVISION.
       AnswerMain SECTION.
       000-Start.
       
              CALL "CBL_OPEN_FILE"
                     USING "/dev/stdin" file-access 0 0 file-handle.
              CALL "CBL_READ_FILE"
                     USING file-handle file-offset
                            file-nbytes 0 file-buffer.
              CALL "CBL_CLOSE_FILE" USING file-handle.      
              UNSTRING file-buffer DELIMITED BY SPACE INTO a b
              
              MOVE MOD(a,2) TO a.
              MOVE MOD(b,2) TO b.
              
              MOVE "Odd" TO disp.
              IF a = 0 OR b = 0 THEN
                     MOVE "Even" TO disp
              END-IF.

              DISPLAY TRIM(disp).
       END PROGRAM Answer.


Measured memory_bytes: 384
A, B, C, K = map(int, input().split())
ans = 0
if A >= K:
    print(K)
    exit(0)
else:
    K -= A
    ans += A
    if B >= K:
        print(ans)
        exit(0)
    else:
        K -= B
        ans -= K
        print(ans)

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

int main() {
  int a;
  cin >> a;
  int b;
  cin >> b;
  int c;
  cin >> c;
  int max;
  max = 10*a + b + c;
  if (max < 10*b + c + a) {
    max = 10*b + c + a;
  }
  if (max < 10*c + a + b) {
    max = 10*c + a + b;
  }
  cout << max << endl;
}
    

Measured memory_bytes: 256