akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int findFac (int len) {
  int fac = 1;
  for (int i = 2; i <= len; i++) {
    fac *= i;
  }
  return fac;
}

int findPosOfPermutation (int len, vector<int> v) {
  if (len == 1) {
    return 0;
  }
  int permutationsBelow = findFac(len - 1) * (v[0] - 1);
  // cout << permutationsBelow << endl;
  // vector<int> vv = v;
  for (int i = 1; i < len; i++) {
    if (v[i] > v[0]) {
      v[i]--;
    }
  }
  vector<int> vv(v.begin() + 1, v.end());
  // for (auto i: vv) {
  //   cout << i << " ";
  // }
  // cout << endl;
  return permutationsBelow + findPosOfPermutation(len - 1, vv);

}

int main () {
  int n;
  cin >> n;
  vector<int> v1, v2;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v1.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v2.push_back(x);
  }
  int v1P = findPosOfPermutation(n, v1);
  int v2P = findPosOfPermutation(n, v2);
  // cout << v1P << v2P << endl;
  if (v1P - v2P < 0) {
    cout << v2P - v1P << endl;
  }
  else {
    cout << v1P - v2P << endl;
  }
}

Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    S = input()
    print(S.count("+") - S.count("-"))

main()


Measured memory_bytes: 4928
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REPC(x,c) for(auto x:(c))
#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int sum = 0;
	REP(i, b - a + 1) {
		sum += i;
	}
	cout << sum - b << endl;
}


Measured memory_bytes: 256
/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀⠺⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⠀⠈⢿⣦⣄⣈⣁⣀⣠⣴⣦⡀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⣠⣶⣿⣿⣿⣿⣿⣿⣶⡄⠙⢿⣿⣿⣿⣿⣿⡿⠓⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠙⣿⣿⠿⠛⠛⠛⠛⣿⣿⡄⠀⠈⠉⠉⠉⣁⣀⡀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠈⠁⠀⠀⠀⠀⠀⣸⣿⡇⠀⠀⠀⣴⣿⣿⡿⠿⢷⣄⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠠⣤⣤⣴⣾⣿⡿⠁⠀⢀⣾⣿⣿⠏⠀⠀⠈⣿⣧⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣏⠀⠀⣠⣾⣿⣿⠏⠀⠀⠀⠀⢹⣿⡄⠀⠀
⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠻⣿⣿⡟⠻⠿⠛⠁⠀⠀⠀⠀⠀⣾⣿⡇⠀⠀
⠀⠀⠘⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⡄⠀⣄⠀⠀⠀⠀⠀⣰⣿⣿⠇⠀⠀
⠀⠀⠀⢿⡄⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⠇⠀⠹⣷⣤⣤⣤⣾⣿⣿⡟⠀⠀⠀
⠀⠀⠀⠈⢿⣦⣄⣀⠀⠀⣀⣠⣾⣿⣿⡟⠀⠀⠀⠘⠻⣿⣿⣿⠿⠋⠀⠀⠀⠀
⠀⠀⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⣿⡿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠉⠙⠛⠛⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

           KRISHNA ASHOK⠀
*/

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Tree;
// order_of_key(k), find_by_order(k)


#define dbg(x) cout<<#x<<"="<<x<<'\n'
#define ll long long
#define pr pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define For(i,n) for(int i=0;i<(n);++i)
#define Forr(i,n) for(int i=n-1;i>=0;i--)
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#define fin ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define sz(a) (int)a.size()
#define Fill(a,b) memset(a,b,sizeof(a));
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
const int INF=1e9;
#define endl '\n'
#define fit(i,x) for(auto i:x)
#define gcd(a,b) __gcd(a,b)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
#define vt vector




void solve(){
    double d,t,s,ans=0.0;
    cin>>d>>t>>s;
    ans=d/s;
    if(ans>t)cout<<"No";
    else cout<<"Yes";
    cout<<endl;


}



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

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
using namespace std;
 
int main() {

    int x;
    int i = 0;
    vector<int> v(10000);

  while (1)
  {
      cin >> x;
      if(x == 0) break;
      v[i] = x;
      i++;
  }

  for (size_t j = 0; j < i; j++)
  {
         cout << "Case " << j + 1 << ": "<< v[j]<<endl;
  }
        
}


Measured memory_bytes: 3052
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();	
		int[] arr = r.ria();
		for(int i = arr[0]; i<=arr[1]; i++) {
			if(i == arr[0]+arr[2]) break;
			print(i);
		}
		for(int i = Math.max(arr[0]+arr[2], arr[1]-arr[2]+1); i<=arr[1]; i++) {
			print(i);
		}
	}
	//a & b =1...k=1/2
	// k > a & b
	
	public static int getDigitSum(int n) {
		String str = ""+n;
		int sum = 0;
		for(int i = 0; i<str.length();i++) {
			sum += Integer.parseInt(""+str.charAt(i));
		}
		return sum;
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


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

class Program
{
    public static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] d = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        Array.Sort(d);
        int idx = N / 2;
        int num1 = d[idx - 1];
        int num2 = d[idx];
        Console.WriteLine(num2 - num1);
    }
}

Measured memory_bytes: 18784
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	int n;
	cin >> n;
	ll a[300000]={};
	ll sum = 0;
	
	rep(i,n){
		cin >> a[i];
		sum += a[i];
	}

	ll dif = sum - 2*a[0];
	ll mi = abs(dif);

	FOR(i,1,n-1){
		dif -= 2*a[i];
		mi = min(abs(dif),mi);
	}

	cout << mi << endl;
	return 0;
}


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

using namespace std;
using i32 = std::int_fast32_t;
using u64 = std::uint_fast64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  i32 N;
  cin >> N;
  vector<i32> cnt(N + 1, 0);
  for (i32 i = 0; i < N; i++) {
    i32 p;
    cin >> p;
    cnt[p] = cnt[p - 1] + 1;
  }
  i32 res = 0;
  for (i32 i = 1; i < N + 1; i++) {
    res = max(res, cnt[i]);
  }
  cout << N - res << '\n';
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define all(a) (a).begin(),(a).end()
using namespace std;

signed main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;

    map<string,int>mp;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        mp[s]++;
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;

    return 0;
}


Measured memory_bytes: 3632
import numpy as np

N, K = map(int, input().split())
A = np.zeros(N+1, dtype = np.int)
A[1:] = list(map(int, input().split()))

machis = {1}

now_machi = 1
count = 0

while True:
    next_machi = A[now_machi]
    count += 1
    if next_machi in machis:
        point = next_machi
        break
    machis.add(next_machi)
    now_machi = next_machi

now_machi = point
count2 = 0
while True:
    count2 += 1
    next_machi = A[now_machi]
    if next_machi == point:
        break
    now_machi = next_machi

if K - count > 0:
    times = (K - count) % count2
    now_machi = point
    for t in range(times):
        next_machi = A[now_machi]
        now_machi = next_machi
else:
    now_machi = 1
    for k in range(K):
        next_machi = A[now_machi]
        now_machi = next_machi

print(now_machi)

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

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

  vector<int> a(n);

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

  sort(a.begin(), a.end(), greater<int>());

  int alice, bob;
  alice = 0;
  bob = 0;

  for(int i = 0; i < n; i++){
    if(i % 2 == 1){
      bob += a[i];
    } else{
      alice += a[i];
    }
  }

  cout << alice - bob << endl;
}



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

struct edge {
    int u, v, cost;
};

int main() {
    int V, E, d[105][105];
    vector<edge> es;
    cin >> V >> E;
    REP(i, V) fill(d[i], d[i] + V, IINF / 2);
    REP(i, E) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
        es.push_back({a, b, c});
    }
    REP(k, V) REP(i, V) REP(j, V)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    int cnt = 0;
    for (auto e : es)
        if (d[e.u][e.v] != e.cost) cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	void run(){
		ArrayList<Integer> mt = new ArrayList<Integer>();
		for(int i = 0;i < 10; i++){
			mt.add(sc.nextInt());
		}
		Collections.sort(mt, new Comparator<Integer>(){
			@Override
			public int compare(Integer a, Integer b) {
				return b-a;
			}
		});
		for(int i = 0; i < 3; i++){
			System.out.println(mt.get(i));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17184
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))
int s[4];
char f[4];
void dfs(int dep, int res) {
	if (dep == 3) {
		if (res == 7) {
			cout << s[0] << f[0] << s[1] << f[1] << s[2] << f[2] << s[3] << "=7" << endl;
			exit(0);
		}
		return;
	}
	f[dep] = '-';
	dfs(dep + 1, res - s[dep + 1]);
	f[dep] = '+';
	dfs(dep + 1, res + s[dep + 1]);
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	char str[4]; cin >> str;
	rep(i, 4) s[i] = str[i] - 48;
	dfs(0, s[0]);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long k = scanner.nextLong();
			long[] sum = new long[n + 1], patty = new long[n + 1];
			sum[0] = patty[0] = 1L;
			IntStream.rangeClosed(1, n).forEach(i -> {
				sum[i] = (sum[i - 1] << 1) + 3;
				patty[i] = (patty[i - 1] << 1) + 1;
			});
			System.out.println(getResult(n, k, sum, patty));
		}
	}

	/**
	 * パティは何枚あるかを計算する
	 * 
	 * @param n
	 * @param k
	 * @param sum   階層数の配列
	 * @param patty バティ総数の配列
	 * @return パティは何枚あるか
	 */
	private static long getResult(int n, long k, long[] sum, long[] patty) {
		if (k <= n) {
			// パティまで食べられない
			return 0L;
		} else if (k == sum[n]) {
			// すべて食べた場合
			return patty[n];
		} else if (1 == n) {
			return k - 1;
		} else {
			if (k <= sum[n - 1] + 1) {
				// 前半までしか食べない場合
				return getResult(n - 1, k - 1, sum, patty);
			} else if (k == sum[n - 1] + 2) {
				// 前半＋真ん中のパティを食べる場合
				return patty[n - 1] + 1;
			} else {
				// 後半まで食べる場合
				return patty[n] - getResult(n - 1, sum[n] - k - 1, sum, patty);
			}
		}
	}
}


Measured memory_bytes: 35988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,d,c=0;
    cin>>n>>d;
    vector<vector<int>> x(n,vector<int>(d));
    for(auto&j:x) for(auto&i:j) cin>>i;
    fr(i,n){
        fr(j,i){
            int k=0;
            fr(l,d) k+=(x[i][l]-x[j][l])*(x[i][l]-x[j][l]);
            c+=(k==(int)sqrt(k)*sqrt(k));
        }
    }
    cout<<c<<endl;
}

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

int pow(int x, int n) {
  int ans = 1;
  for(int i = 0; i < n; i++) {
    ans *= x;
  }
  return ans;
}

int main() {
  int p[8];
  int data[8] = {4,1,4,1,2,1,2,1};
  while(cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]) {
    int V = 999999;
    int min = 999999;
    for(int i = 0; i < 8; i++) {
      int sum = 0;
      for(int j = 0; j < 8; j++) {
	int tmp = p[j] - data[(j+i)%8];
	if(tmp > 0) sum += tmp;
      }
      if(sum < min) {
	min = sum;
	V = 0;
	for(int j = 0; j < 8; j++) {
	  V += pow(10, 7-j) * data[(j+i)%8];
	}
      } else if(sum == min) {
	int v = 0;
	for(int j = 0; j < 8; j++) {
	  v += pow(10, 7-j) * data[(j+i)%8];
	}
	if(v < V) V = v;
      }
    }
    for(int i = 0; i < 8; i++) {
      if(i != 0) cout << ' ';
      cout << V % pow(10, 8-i) / pow(10, 7-i);
    }
    cout << endl;
  }
  return 0;
}

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

#define rep(X, N) for (ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(), (V).end()
#define endl "\n"

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;


int main(){

    int x;
    cin >> x;

    cout << 1 - x << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define id second
#define vtx first
const int maxn=(int)1e6+5;
typedef  pair<int,int> pii;
int colmx;
vector<pii> E[maxn];
int color[maxn];
void dfs(int cur,int fa,int cf){//color of fa
    int col=0;
    for(auto p:E[cur]){
        if(p.vtx==fa)continue;
        col++;
        if(col==cf)col++;
        colmx=max(colmx,col);
        color[p.id]=col;
        dfs(p.vtx,cur,col);
    }
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    rep(i,1,n-1){
        int x,y;
        cin>>x>>y;
        E[x].push_back({y,i});
        E[y].push_back({x,i});
    }
    dfs(1,0,0);
    cout<<colmx<<endl;
    rep(i,1,n-1)cout<<color[i]<<endl;
}
/* 
一棵1e5树
给出一个染色方案使得连向某点的边颜色都不同。
其实没wa:wa:dfs,只要记录每个点和父边的颜色，dfs时跳过。
不用：记录所有遍历过的点的颜色->bfs可以
然后记录答案。

3
1 2
2 3
3
1 2
1 3
 */

Measured memory_bytes: 31360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
	
    string S,T; cin >> S >> T;
    int A,B; cin >> A >> B;
    string U; cin >> U;

    if(S == U) {
        cout << A-1 << " " << B << endl;
    }else{
        cout << A << " " << B - 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
struct edge{int to;ll cost;};
vector<edge> G[60000];
ll dp[60000];
priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> qu;//dp[],2*(n-1)*c+v

int a,b,c;
int nextv(int v){ return (a*v+b)%c;}

int main(void){
	int n,m,v0;
	cin>>n>>m;
	vector<int> x(m),y(m);
	vector<ll> t(m); 
	rep(i,m){
		cin>>x[i]>>y[i]>>t[i];
		--x[i];
		--y[i];
	}
	cin>>v0>>a>>b>>c;
	rep(i,m)rep(v,c){
		G[x[i]*c+v].push_back({y[i]*c+nextv(v),t[i]*v});
		G[y[i]*c+v].push_back({x[i]*c+nextv(v),t[i]*v});	
		G[((n-1)*2-x[i])*c+v].push_back({((n-1)*2-y[i])*c+nextv(v),t[i]*v});
		G[((n-1)*2-y[i])*c+v].push_back({((n-1)*2-x[i])*c+nextv(v),t[i]*v});
	}
	rep(i,60000)dp[i]=LLONG_MAX;
	dp[v0]=0;
	qu.push({0,v0});
	while(qu.size()){
		pair<ll,int> u = qu.top();
		qu.pop();
		if(u.second/c==2*(n-1)){
			cout<<dp[u.second]<<endl;
			return 0;			
		}
		if(dp[u.second] < u.first)continue;
		for(auto e:G[u.second]){
			if(dp[e.to] > dp[u.second] + e.cost){
				dp[e.to] = dp[u.second] + e.cost;
				qu.push({dp[e.to],e.to});
			}
		}

	}
	
	// ll res = LLONG_MAX;
	// rep(i,c){
	// 	res = min(res,dp[2*(n-1)*c+i]);
	// }
	// cout<<res<<endl;

	return 0;
}

Measured memory_bytes: 29568
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
#define _GLIBCXX_DEBUG

using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    int sum = 0;
    rep(i, N) {
        cin >> a.at(i);
        sum += a.at(i);
    }

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    
    
    for (int i = 0; i < a.size(); i++) {
        cerr << a.at(i) << "\n";
    }
    
    cerr << (sum*((double)1/(double)(4*M))) << endl;
    int ans = 0;
    rep(i, N) {
        if(a.at(i) >= sum*((double)1/(double)(4*M))) {

        ans++;
        }
        }
    if(ans >= M)
    cout << "Yes" << "\n";
    else cout << "No" << "\n";
}


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

res = 10 ** 100

def f(fir):
    prv_pos = fir > 0
    margin = fir - a[0]
    ret = abs(margin)
    for i in range(1, n):
        cur = margin + acc[i]
        if prv_pos and cur < 0:
            prv_pos = not prv_pos
            continue
        if not prv_pos and cur > 0:
            prv_pos = not prv_pos
            continue
        if prv_pos:
            need = -1
            sa = need - cur
            margin += sa
            ret += abs(sa)
        else:
            need = 1
            sa = need - cur
            margin += sa
            ret += abs(sa)
        prv_pos = not prv_pos
    return ret


res = min(res, f(1))
res = min(res, f(-1))
if a[0] != 0:
    res = min(res, f(a[0]))
print(res)


Measured memory_bytes: 14468
#include<iostream>
 
using namespace std;
 
int main() {
	int n, i, suretu[100], max, mix;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> suretu[i];
	}
	max = suretu[0];
	mix = suretu[0];
	for (i = 1; i < n; i++) {
		if (max <= suretu[i])max = suretu[i];
		if (mix >= suretu[i])mix = suretu[i];
	}
	cout << max - mix << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int> d(N);
	for(int i = 0; i < N; i++)
		cin >> d.at(i);
	int sum = 0;
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++)
			sum += d.at(i)*d.at(j);
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, A, B;
  std::cin >> N >> A >> B;
  std::vector<i64> P;
  tools::read(P, N);
  std::cout << std::min({
    std::count_if(P.begin(), P.end(), [&A](const i64& P_i) { return P_i <= A; }),
    std::count_if(P.begin(), P.end(), [&A, &B](const i64& P_i) { return A < P_i && P_i <= B; }),
    std::count_if(P.begin(), P.end(), [&B](const i64& P_i) { return B < P_i; })
  }) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }

int main() {
  int s, w;
  cin >> s >> w;
  if (s <= w) cout << "unsafe" << endl;
  else cout << "safe" << endl;

  return 0;
}


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

const int MAX = 1e5;

class myStack{
public:
  int a[MAX];
  int top;
  myStack(){
    top = 0;
  }
  bool isEmpty(){
    return top == 0;
  }
  bool isFull(){
    return top >= MAX - 1;
  }
  void push(int x){
    if(isFull()) {cerr << "isFull." << endl; return;}
    top++;
    a[top] = x;
  }
  int pop(){
    if(isEmpty()) {cerr << "isEmpty." << endl; return 0;}
    top--;
    return a[top + 1];
  }
};

int main(){
  myStack s;
  string str;
  while(cin >> str){
    if(str == "+"){
      int a = s.pop();
      int b = s.pop();
      s.push(a + b);
    }
    else if(str == "-"){
      int a = s.pop();
      int b = s.pop();
      s.push(- a + b);
    }
    else if(str == "*"){
      int a = s.pop();
      int b = s.pop();
      s.push(a * b);
    }
    else{
      int a = stoi(str);
      s.push(a);
    }
  }
  cout << s.pop() << endl;
}



Measured memory_bytes: 3200
n = gets.to_i
a = gets.split.map(&:to_i)
sp = Array.new(n).map{|q| q = []}
ans = []
0.upto(n-1){|i|
  z = a[i]-1
  ans << z
  sp[z] << i
}
x = 0
sizear = []
0.upto(n-1){|j|
  if sp[j] != nil
    y = sp[j].size
    sizear << y
    x += (y*(y-1))/2
  end
}
0.upto(n-1){|k|
  puts x - (sizear[ans[k]]) + 1
}

Measured memory_bytes: 38172
import math
N, K = map(int, input().split())
As = list(map(int, input().split()))


def cut_num(a, cut_length):
    return math.ceil(a/cut_length) - 1


"""cut length N binary search
if cut num > K, search more longer cut length,
"""
l = 1
r = max(As)
m = (l+r)//2
ans = r
while r > l + 1:
    current_cut_num = sum([cut_num(a, m) for a in As])
    if current_cut_num <= K:
        r = m
    else:
        l = m
    m = (l+r)//2

if sum([cut_num(a, l) for a in As]) <= K:
    print(l)
else:
    print(r)

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

int main(){
  int a,b,c;
  int d;
    cin>>a>>b>>c;
  cin >> d;
  int e[15];
   e[0] = max(max(a,b),c) ;
  
  for(int i=0; i<d;i++){
    e[i] *=2;
    e[i+1] = e[i];
  }
    cout <<a+b+c+e[d]-max(max(a,b),c)<<endl;
  }


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, std::vector<long long> A){
    //* solve for x0
    ll x = 0;
    rep(i, N){
        if(i % 2 == 0)
            x += A[i];
        else
            x -= A[i];
    }
    x/=2;
    cout << 2*x;
    for(ll i=1; i< N; i++){
        x = A[i-1] -x;
        cout << " "<< 2*x;
    }
    cout << endl;


}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
using namespace std;
typedef pair<int,int>P;
typedef vector<P>VP;
typedef priority_queue<P,VP,greater<P>>PQ;
int flg[100000],d[100000];
VP v[100000];
int main(void){
	int n,m,s;
	int x,y,cost;
	int now,next;
	int now_cost,next_cost;
	int i,j;
	int flag;
	P pp;
	PQ que;
	cin>>n>>m>>s;
	for(i=0;i<n;i++){
		flg[i]=0;
		d[i]=INT_MAX;
	}
	for(i=0;i<m;i++){
		cin>>x>>y>>cost;
		v[x].PB(P(cost,y));
	}
	que.push(P(0,s));
	while(!que.empty()){
		pp=que.top();
		que.pop();
		now_cost=pp.F;
		now=pp.S;
		if(flg[now]==0){
			flg[now]=1;
			d[now]=now_cost;
			for(i=0;i<(int)v[now].size();i++){
				next_cost=v[now][i].F;
				next=v[now][i].S;
				if(flg[next]==0)	que.push(P(now_cost+next_cost,next));
			}
		}
	}
	for(i=0;i<n;i++){
		if(d[i]==INT_MAX)	cout<<"INF"<<endl;
		else				cout<<d[i]<<endl;
	}
	return 0;
}


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

int main(){
  string s;
  cin>>s;
  int q1=0,q2=0;
  for(int i=0;i<3;i++){
    if(s[i]=='A')
      q1+=1;
    if(s[i]=='B')
       q2+=1;
  }
  if(q1>0 && q2>0) 
     cout<<"Yes";
  else
     cout<<"No";
}


Measured memory_bytes: 256
def keyboard_function(input_keyboard, editor_display):

    if input_keyboard=='B':
        if editor_display==[]:
            return editor_display
        else:
            editor_display.pop()
    if input_keyboard=='0':
        editor_display.append('0')
    if input_keyboard=='1':
        editor_display.append('1')
        
    return editor_display

def show_editor_display(input_keyboard_sequence):
    editor_display=[]
    for i in input_keyboard_sequence:
        keyboard_function(i, editor_display)        
    return ''.join(editor_display)

if __name__=='__main__':
    input_keyboard_sequence=input()
    print(show_editor_display(input_keyboard_sequence))



Measured memory_bytes: 3060
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


int main() {
    string S;
    cin >> S;

    ll count=0;
    rep(i,S.size()){
        if(i % 2 == 0){
            if(S[i] == '0'){
                count++;
            }
        }else{
            if(S[i] == '1'){
                count++;
            }
        }
    }

    ll ans = count;
    count=0;
    rep(i,S.size()){
        if(i % 2 == 0){
            if(S[i] == '1'){
                count++;
            }
        }else{
            if(S[i] == '0'){
                count++;
            }
        }
    }
    ans = min(ans,count);
    cout << ans << endl;    

}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define forn1 for(i=1; i<=n; i++)




int main()
{
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r;
    string s,ss;
    cin>>n;
    forn1
    {
        if(i%3!=0&&i%5!=0)c+=i;
    }
    cout<<c<<endl;
}


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

int num[100005];
int main(){
	int n;
	cin>>n;
	int i;
	for(i=0;i<n;i++){
		int a;
		cin>>a;
		if(a){num[a]++;num[a+1]++;num[a-1]++;}
		else {num[a]++;num[a+1]++;}
	}
	int max=-1;
	for(i=0;i<=100000;i++){
		if(num[i]>max)max=num[i];
	}
	printf("%d\n",max);
	return 0;	
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}
int main(){
  string s; cin >> s;
  ll n = SZ(s);
  REP(i,n-1){
    if(s[i] == 'A' && s[i+1] == 'C') yes();
   }
  no(); 
}

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

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

typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;

const int mod = 998244353;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

const int n = 1e9;

int main(){
    int n;
    cin >> n;
    vi a(n);
    vi b;
    int cnt = 1;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(i>0){
            if(a[i] == a[i-1])
                cnt++;
            else{
                b.push_back(cnt);        
                cnt=1;
            }
        }
    }
    b.push_back(cnt);
    int sol = 0;
    for(int x : b){
        sol+=x/2;
    }
    cout << sol;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

static X : usize = 1000000007;

fn fib(n: usize) -> usize {
    let mut s0 = 0;
    let mut s1 = 1;
    for _ in 0..n {
        let s = (s0 + s1) % X;
        s0 = s1;
        s1 = s;
    }
    s0
}

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [usize; m],
    }
    let mut intervals = Vec::new();
    intervals.resize(m + 1, 0);

    if m == 0 {
        intervals[0] = n;
    } else {
        intervals[0] = a[0] - 1;
        for i in 1..m {
            if a[i] - a[i - 1] < 2 {
                println!("0");
                return;
            }
            intervals[i] = a[i] - a[i - 1] - 2;
        }
        intervals[m] = n - a[m - 1] - 1;
    }

    let mut result = 1;
    for v in intervals.iter() {
        result = ((result % X) * fib(v + 1)) % X;
    }

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


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

#define ll long long
#define mx 100005

int ar[mx];
char ch[mx];
int n,m;

void solve()
{
    cin>>n>>m;
    int re=0;
    if(n>=2)re+=(n*(n-1))/2;
    if(m>=2)re+=(m*(m-1))/2;
    cout<<re<<endl;
}

int main()
{
    int t=1;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

using P = pair<int, int>;
int main() {
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    if (2 * x == W && 2 * y == H) {
        cout << ((double)H * (double)W) / 2.0 << " " << 1 << endl;
    } else {
        cout << ((double)H * (double)W) / 2.0 << " " << 0 << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	vector<int> b;
	for (int i = 0; i < N; i++) {
		if (i % 2 == N % 2) {
			b.push_back(a[i]);
		}
		else {
			b.insert(b.begin(), a[i]);
		}
	}

	for (int i = 0; i < N; i++) {
		cout << b[i] << " ";
	}
	cout << endl;

}


Measured memory_bytes: 3828
#include <iostream>
#include <cstring>
#include <cstdio>
#include<algorithm>
#include <queue>
#include <cmath>
#include <limits>
#include <map>
#include <iomanip>
using namespace std;
#define ll long long int

 
int main () 
{
  ll n, k, min, max;
  ll ans = 0;
  ll mod = 1000000007;
  cin >> n >> k;
  for (ll i = k; i <= n + 1; i++) {
  min = (i - 1) * i / 2;
  max = (n + 1) * n / 2 - (n - i) * (n - i + 1) / 2;
  ans = ans +  (max - min + 1); 
  ans = ans % mod;
  }
  cout << ans <<endl;
 }

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

int main(){
  const string MARCH= "MARCH";
  const int Nletter= MARCH.size();

  unordered_map<char, int64_t> freq;
  for(auto c:MARCH){
    freq[c]= 0;
  }

  int N;
  cin >> N;
  string buf;
  for(int i=0; i<N; i++){
    cin >> buf;

    if(freq.count(buf.at(0))){
      freq.at(buf.at(0))++;
    }
  }

  int64_t ans= 0;
  for(int i=0; i<Nletter; i++){
    for(int j=i+1; j<Nletter; j++){
      for(int k=j+1; k<Nletter; k++){
        ans+= freq.at(MARCH.at(i))* freq.at(MARCH.at(j))* freq.at(MARCH.at(k));
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;

//----------------library in this time--------------------------------
uint gcd(const uint a,const uint b){
    return (b == 0) ? a : gcd (b, a % b);
}
uint lcm (const uint a, const uint b){
    return a * b / gcd(a,b);
}

f64 ave(const f64 a, const f64 b){
    return (a + b) / 2.0f;
}
//------------------------main function-------------------------------
void Main(){
    uint n;
    cin >> n;
    vector<u64>v(n);
    Rep(i,n)cin >> v[i];
    sort(v.begin(), v.end());
    f64 average = v[0];
    For(i, 1, n){
        average = ave(static_cast<f64>(v[i]), average);
    }
    cout << average <<endl;
}
//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    
    Main();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)

int main() {
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  if(n <= k){
    cout << x * n << endl;
  }else{
    cout << x * k + (n-k) * y << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def main():
    k = int(input())
    if k % 2 == 0 or k % 5 == 0:
        print(-1)
        return
    a = 1
    b = 0
    h = set()
    for i in range(10**6):
        a = a * 10 % k
        b = (a * 7 + b) % k
        if b == 0:
            print(i + 1)
            break
        if b in h:
            print(-1)
            break
        h.add(b)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 77944
n, m = map(int, input().split())
S = [None]*m
L = 0
R = n

for i in range(m):
    l, r = map(int, input().split())
    L = max(l, L)
    R = min(r, R)

ans = R-L+1
if ans < 0:
    ans = 0
print(ans)

Measured memory_bytes: 3828
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		// N人の参加者
		int N = scan.nextInt();
		// Kポイント
		int K = scan.nextInt();

		int Q = scan.nextInt();

		int a[] = new int[N];

		for(int i = 0; i < Q; i++) {
			int b = scan.nextInt();
			a[b - 1]++;
		}
		for (int i = 0; i < N; i++) {
			if (K - (Q - a[i]) > 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 56908
#include <bits/stdc++.h>
using ll= long long ;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
using namespace std;
using P = pair<ll,ll>;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}

int main() {
    ll n;
    string s;
    cin>>n>>s;
    vector<ll> a(n);

    rep(i,n){
        if(s[i]=='R') a[i]=0;
        if(s[i]=='G') a[i]=1;
        if(s[i]=='B') a[i]=2;
    }
    vector<ll> cnt(3);
    rep(i,n) cnt[a[i]]++;
    ll ans = 1;
rep(i,3){ans*=cnt[i];}
  rep(j,n){
      rep(i,j){
          ll k = 2*j - i;
          if(k<n){
              if(a[i]==a[j]) continue;
              if(a[i]==a[k]) continue;
              if(a[k]==a[j]) continue;
              ans--;

          }
      }
  }
  cout<<ans<<endl;
  
}
    

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int n;
long long C;
long long x[100010];
int v[100010];
long long ans;
long long c[100010],cc[100010];
long long cmx[100010],ccmx[100010];
int a, b;
int main()
{
    cin >> a >> b;
    if (a <= b) {
        cout << a;
    }else {
        cout << a - 1;
    }
}

Measured memory_bytes: 256