akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=998244353;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=1e9+7){
	//p_a^p_n mod p_p
	long long int p_b=1,p_t=1;
	for(;p_b<=p_n;p_b<<=1);
	for(p_b>>=1;p_b>0;p_b>>=1){
		p_t*=p_t;
		if(p_t>=p_p)p_t%=p_p;
		if(p_n&p_b)p_t*=p_a;
		if(p_t>=p_p)p_t%=p_p;
	}
	return p_t;
}

long long int gcd(long long int g_a,long long int g_b){
	if(g_a<g_b)gcd(g_b,g_a);
	if(g_b==0)return g_a;
	return gcd(g_b,g_a%g_b);
}

long long int divide(long long int d_a,long long int d_b,long long int d_p=1e9+7){
	// d_a/d_b mod d_p
	// prime:d_p is prime
	if(d_a>=d_p)d_a%=d_p;
	if(d_a<0)d_a+=d_p;
	if(d_b>=d_p)d_b%=d_p;
	if(d_b<0)d_b+=d_p;
	d_a*=pow_mod(d_b,d_p-2,d_p);
	return d_a%d_p;
}

LL dp[3300];

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n>>m;
	dp[0]=pow_mod(2,n,MAX);
	b=divide(1,2,MAX);
	for(i=0;i<n;i++){
		cin>>a;
		for(j=m;j>=a;j--){
			dp[j]+=dp[j-a]*b;
			if(dp[j]>=MAX)dp[j]%=MAX;
		}
	}
	cout<<dp[m]<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
   int n, m;
   cin >> n >> m;
   int sum = 0;
   rep(i,m) {
       int a;
       cin >> a;
       sum += a;
   }
   int ans = n - sum;
   if (ans < 0) {
       cout << -1 << endl;
       return 0;
   } else {
       cout << ans << endl;
       return 0;
   }

}


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

using namespace std;

int main(){

    int n;
    cin >> n;
    cin.ignore();
    int hoge=0;
    int count = 0;
    vector<string> out;
    while(n!=0){
        int hoge=0;
        vector< pair<int,int> > island(n);
        pair<int,int> row;

        for(int i=0;i<n;i++){
            int t,w;
            cin >> t >> w;
            cin.ignore();
            row.first = w;
            row.second = t;
            island[hoge] = row;
            hoge ++;
        }

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

        int total = 0;
        int flag = 0;
        for(int i=0;i<n;i++){
            total += island[i].second;

            if(total > island[i].first){
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            out.push_back("Yes");
        }else{
            out.push_back("No");
        }
        count ++;

        cin >> n;
        cin.ignore();

    }

    for(int i=0;i<count;i++){
        cout << out[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3004
#include<stdio.h>

int main(void){
	long a,b;
	while (scanf("%ld %ld",&a,&b) && a!=0 || b!=0){
	
	long n;
	if(b>=a){
		n=a;
		a=b;
		b=n;
	}
	long k,count=0;
	while(b > 0){
		k = a%b;
		a = b;
		b = k;
		count++;
	}
	printf("%ld %ld\n",a,count);
	}
	return 0;	
}


Measured memory_bytes: 1980
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
int w, a, b;
int main(void){
    cin >> w >> a >> b;
    if (a > b) swap(a, b);
    if (a + w < b) cout << b - (a + w) << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
using namespace std;
const int N=101101;
char s[N];
int n,m;
int check(int x,int y){
	int len=y-x+1;
	for (int i=1; i<=len/2; i++)
		if (s[x+i-1]!=s[y-i+1])	return 0;
	return 1;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	if (check(1,n)&&check(1,(n-1)/2)&&check((n+3)/2,n))	printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD1 1000000007

int main() {
  int N;
  cin >> N;
  int H[N];
  rep(i,N) cin >> H[i];

  bool f=true;
  int a = H[0] - 1;

  rep(i,N-1){
    if(a > H[i+1]){
      f = false;
      break;
    }
    a = max(a, H[i+1] - 1);
  }

  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;


}

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

int main(){
    ll n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) a[i]--;
    vector<int> visit(n,-1);
    visit[0] = 0;
    ll now = 0;
    ll movecount = 0;
    ll cycle;
    while(true){
        //移動するよー
        now = a[now];
        movecount++;
        k--;
        if(visit[now] == -1){
            visit[now] = movecount;
        }else{
            //来たことある
            cycle = movecount - visit[now];
            break;
        }
        if(k <= 0){
            cout << now + 1 << endl;
            return 0;
        }
    }
    k = k % cycle;
    while(k > 0){
        now = a[now];
        k--;
    }
    cout << now + 1 << endl;
}

Measured memory_bytes: 4824
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

struct Sushi
{
    int64_t pos;
    int64_t value;
};

int main()
{
    int64_t n, circumference;
    cin >> n >> circumference;

    vector<Sushi> sushi(n);
    for (auto &s : sushi) {
        cin >> s.pos >> s.value;
    }

    vector<int64_t> balance_clock(n);
    vector<int64_t> balance_counter(n);

    int64_t balance = 0;
    for (int64_t i = 0; i < n; i += 1) {
        balance -= sushi[i].pos - (i == 0 ? 0 : sushi[i - 1].pos);
        balance += sushi[i].value;
        balance_clock[i] = balance;
        if (i > 0) {
            balance_clock[i] = max(balance_clock[i], balance_clock[i - 1]);
        }
    }

    balance = 0;
    for (int64_t i = n - 1; i >= 0; i -= 1) {
        balance -= (i == n - 1 ? circumference : sushi[i + 1].pos) - sushi[i].pos;
        balance += sushi[i].value;
        balance_counter[i] = balance;
        if (i < n - 1) {
            balance_counter[i] = max(balance_counter[i], balance_counter[i + 1]);
        }
    }

    int64_t res = 0;
    for (int64_t i = 0; i < n; i += 1) {
        int64_t value = balance_clock[i];
        res = max(res, value);

        value += (i + 1 < n ? balance_counter[i + 1] : 0) - sushi[i].pos;
        res = max(res, value);
    }

    for (int64_t i = n - 1; i >= 0; i -= 1) {
        int64_t value = balance_counter[i];
        res = max(res, value);

        value += sushi[i].pos - circumference + (i > 0 ? balance_clock[i - 1] : 0);
        res = max(res, value);
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3328
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0,0 };


int main(void) {
	vector<int> a(3);

	FOR(i, 0, 2) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	K := ReadInt()
	N := 50
	r := K % N
	A := (K + (N - 1)) / N
	B := K / N
	v := make([]int, N)
	for i := 0; i < r; i++ {
		v[i] = (N - 1) - (K - B - 1) + A*N
	}
	for i := r; i < N; i++ {
		v[i] = (N - 1) - (K - B) + B*N
	}
	fmt.Println(len(v))
	for i := 0; i < N; i++ {
		fmt.Printf("%d ", v[i])
	}
	fmt.Println()
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
//#define int long long
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

vector<bool> is_prime(100010, true);
vector<ll> prime;

void prime_init() {
	for (int i = 2; i < 100010; i++) {
		if (is_prime[i]) {
			for (int j = 2 * i; j < 100010; j += i) {
				is_prime[j] = false;
			}
			prime.pb(i);
		}
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	prime_init();

	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	map<ll, ll> mp;
	rep(i, n) {
		for (int idx = 0; prime[idx] * prime[idx] * prime[idx] <= a[i]; idx++) {
			ll j = prime[idx];
			while (a[i] % (j*j*j) == 0) a[i] /= j * j * j;
		}
		mp[a[i]]++;
	}
	int ans = 0;
	ll maxval = 10000000010;
	for (auto i : mp) {
		if (i.second == 0) continue;
		ll num = i.first;
		if (num == 1) ans++;
		else {
			ll rev = 1;
			ll k = num;
			bool flag = true;
			for (ll idx = 0; prime[idx] * prime[idx] <= k; idx++) {
				ll j = prime[idx];
				if (k % (j*j) == 0) {
					k /= j * j;
					if (j >= maxval / rev) {
						flag = false;
						break;
					}
					rev *= j;
				}
				if (k % j == 0) {
					k /= j;
					if (j >= maxval / rev) {
						flag = false;
						break;
					}
					rev *= j;
					if (j >= maxval / rev) {
						flag = false;
						break;
					}
					rev *= j;
				}
			}
			if (k > 1) {
				if (k >= maxval / rev) {
					flag = false;
				}
				if (flag) rev *= k;
				if (k >= maxval / rev) {
					flag = false;
				}
				if (flag) rev *= k;
			}
			if (flag) {
				ans += max(i.second, mp[rev]);
				mp[rev] = 0;
			}
			else {
				ans += i.second;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 11392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
#define fori(i,a,b) for(int i=(a);i<(int)(b);i++)
#define repi(i,n) fori(i,0,n)
#define forr(i,a,b) for(int i=int(b-1);i>=int(a);i--)
#define repr(i,n) forr(i,0,n)
#define all(x) (x).begin(),(x).end()
#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mp make_pair
#define pcnt __builtin_popcount
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;}

void solve(){
    ll n,k;
    cin>>n>>k;
    vector<ll> cnt(26,0);
    repi(i,n){
        string s;cin>>s;
        cnt[s[0]-'A']++;
    }

    ll high=10010;
    ll low=0;
    while(high-low>1){
        ll mid=(high+low)/2;
        ll sum=0;
        repi(i,26)sum+=min(mid,cnt[i]);
        if(k*mid<=sum)low=mid;
        else high=mid;
    }
    cout<<low<<endl;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		String T = sc.next();
		
		char[] SC = S.toCharArray();
		char[] TC = T.toCharArray();
		
		int count = 0;
		for(int i=0;i<3;i++) {
			if(SC[i] == TC[i]) {
				count++;
			}
		}
		
		System.out.println(count);
		
		sc.close();	
	}
}

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

using namespace std;

int main(void){
  int n;
  string s;
  cin >> n >>  s;
  
  int len = s.length();
  
  if(len%2 == 0){
    string len1 = s.substr(len/2);
    string len2 = s.substr(0, len/2);
    if(len1 == len2){
    cout << "Yes" << endl;
    }
    else{
    cout << "No" << endl;
    }
  }
  else {
  cout << "No";
  }
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        Pair[] pairs = new Pair[n];
         for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            Pair p = new Pair();
            p.a = a[i];
            p.b = b[i];
            pairs[i] = p;
        }

         Arrays.sort(a);

         int aMax = a[n - 1];

         Arrays.sort(pairs);

         int count = 0;
         for (int i = n - 1 ; i >= 0 ; i--) {
             if (h > 0 && pairs[i].b > aMax) {
                 count++;
                 h -= pairs[i].b;
             }
         }

         if (h <= 0) {
             System.out.println(count);
         } else {
             int mod = h / aMax;
             h -= aMax * mod;
             count += mod;
             if (h > 0) {
                 count++;
             }
             System.out.println(count);
         }


    }

}

class Pair implements Comparable {
    int a;
    int b;
    @Override
    public int compareTo(Object other) {
        Pair otherpair = (Pair) other;
        return b - otherpair.b;
    }
}


Measured memory_bytes: 88368
import std.stdio;
import std.string;
import std.array;

string card, next, tmp;
string[] queue;
int pos;
int[string] memo;
int[4] d = [-1, 1, 4, -4];


void main(){
	string s;
	card = "01234567";
	queue ~= card;
	memo[card] = 0;
	solve();
	while (s = readln(), s) {
		string[] tmp = split(s);
		card = "";
		foreach (t; tmp) card ~= t;
		writeln(memo[card]);
	}
}

void solve(){
	while (queue.length) {
		card = queue.front;
		queue.popFront();
		for (int i = 0; i < d.length; i++) {
			pos = position() + d[i];
			if (pos < 8 && pos >= 0 && !(pos == 4 && d[i] == 1) && !(pos == 3 && d[i] == -1)){
				tmp = "" ~ card[pos];
				next = replace(replace(replace(card, "0", "z"), tmp, "0") , "z", tmp);
				if(!(next in memo)){
					queue ~= next;
					memo[next] =  memo[card] + 1;
				}
			}
		}
	}
}

int position(){
	foreach (i;0..8) if (card[i] == '0') return i;
	return -1;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  int d;
  bool c[10];
  for ( int i = 0; i < 10; i++)c[i] = true;
  for ( int i = 0; i < k; i++){
    cin >> d;
    c[d] = false;
  }
  int crr = n;
  while (1){
    ostringstream oss;
    oss << crr;
    string s = oss.str();
    bool flag = true;
    for ( int i = 0; i < s.size(); i++){
      int num = s[i] - '0';
      if ( !c[num]){
        flag = false;
        break;
      }
    }
    if ( flag ){
      break;
    } else {
      crr++;
    }
  }

  cout << crr << endl;


  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	N := nextInt()
	M := nextInt()

	a := make([]int, 0, N)
	b := make([]int, 0, N)
	for i := 0; i < N; i++ {
		a = append(a, nextInt())
		b = append(b, nextInt())
	}

	c := make([]int, 0, M)
	d := make([]int, 0, M)
	for i := 0; i < M; i++ {
		c = append(c, nextInt())
		d = append(d, nextInt())
	}

	keys := make([]int, 0, N)
	for i := 0; i < N; i++ {
		result, k := 0, 0
		for j := 0; j < M; j++ {
			r := abs(a[i]-c[j]) + abs(b[i]-d[j])
			if k == 0 || r < result {
				result = r
				k = j + 1
			}
		}

		keys = append(keys, k)
	}

	for _, k := range keys {
		fmt.Println(k)
	}
}

// go.util
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

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

// Scanner
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}
	return sc.Text()
}


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

int main(){
    int N;
    cin >> N;
    vector<int> c(N);
    for(int i=1; i<N+1; i++){
        int a;
        cin >> a;
        c[a-1] = i;
    }

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

Measured memory_bytes: 1152
#pragma GCC optimze("Ofast")
#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;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

void solve() {
    ll n,k;cin>>n>>k;
    if(k==n+1){
        cout<<"1\n";
        return;
    }
    // ll arr[n+1];
    // fr(i,0,n)arr[i]=i;
    // cout<<"vv0"<<endl;
    ll cum1[n+1];
    // cout<<"bb"<<endl;
    cum1[0]=0;
    fr(i,1,n)cum1[i]=cum1[i-1]+i;
    // cout<<"bb"<<endl;
    ll cum2[n+1];
    cum2[n]=n;
    // cout<<"bb"<<endl;
    frr(i,n-1,0)cum2[i]=cum2[i+1]+i;

    // fr(i,0,n)cout<<cum1[i]<<" ";cout<<endl;
    // fr(i,0,n)cout<<cum2[i]<<" ";cout<<endl;
    ll sum=0ll;
    fr(i,k,n)sum=(sum%mod+(cum2[n-i+1]-cum1[i-1]+1)%mod)%mod;
    cout<<(sum+1)%mod<<endl;
    return ;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
   
    return 0;
}

Measured memory_bytes: 6780
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int n;
 	cin >> n;
 	for(int i=1;i<=n;i++)
 	{
 		if(int(i*1.08)==n) return cout << i, 0;
 	}
 	cout << ":(";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char** argv)
{
	int n;
	int a;
	scanf("%d%d", &n, &a);
	n %= 500;
	if( n > a ){
		printf("No\n");
	} else {
		printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define N 101

int g[N][N];

int main(){

  int i,j,n,v,node,a;

  scanf("%d",&n);

  for(i=0;i<n;i++) {
    for(j=0;j<n;j++){
      g[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&a,&v);
    for(j=0;j<v;j++){
      scanf("%d",&node);
      g[i][node-1]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j!=0)printf(" ");
      printf("%d",g[i][j]);
    }
    printf("\n");
  }

  return 0;
}



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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;

ll n, a, b, c, d;

int main(){

cin >> n >> a >> b >> c >> d;
b -= a;
n--;

for(int i = 0; i <= n; i++) {
    ll l1 = c * 1ll * i;
    ll r1 = d * 1ll * i;
    ll l2 = c * 1ll * (n - i);
    ll r2 = d * 1ll * (n - i);
    if(l1 - r2 <= b && r1 - l2 >= b) {
        cout << "YES";
        return 0;
    }
}
cout << "NO";
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define MOD 1000000007
using namespace std;

int main() {
  int n; cin >> n;
  vector<int> v(n);
  for (auto &a: v) cin >> a;
  if (v[0] != 0) {
     cout << 0 << endl;
     exit(0);
  }
  
  long long int ans = 3;
  vector<int> cnt(3, 0);
  cnt[0] = 1;
  
  for(int i = 1; i < n; i++) {
    int tmp = 0;
    bool flag = false;
    for(int j = 0; j < 3; j++) {
      if (cnt[j] == v[i]) {
        tmp += 1;
        if (!flag) {
          cnt[j] += 1;
          flag = true;
        }
      }
    }
    ans = (ans * tmp) % MOD;
  }
  cout << ans << endl;
}



Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n;
        n = sc.nextInt();
        List<Rest> list1 = new ArrayList<>();
        List<Rest> list = new ArrayList<>();
        for(int i=0;i<n ;i++){
            Rest rest = new Rest(sc.next(),sc.nextInt(),i+1);
            list.add(rest);
            list1.add(rest);
        }
        Collections.sort(list);
        int i=1;
        for(Rest r:list){
            System.out.println(r.id);
        }

    }
    static class Rest implements Comparable<Rest>{
        public  String name;
        public Integer score;
        public Integer id;
        public Rest(String name,Integer score,Integer id){
            this.name = name;
            this.score = score;
            this.id = id;
        }
        @Override
        public int compareTo(Rest o) {
            int c = this.name.compareTo(o.name);
            if(c == 0){
                return o.score.compareTo(this.score);
            }
            return c;
        }
    }
}


Measured memory_bytes: 22224
#include <cstdio>
#include <algorithm>

using namespace std;

const int MAXN = 202;

int n, A[MAXN], sol;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < 2*n; ++i) {
    scanf("%d", A+i);
  }
  sort(A, A+2*n);
  for (int i = 0; i < n; ++i) {
    sol += A[i*2];
  }
  printf("%d\n", sol);
  return 0;
}


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

int nt[5010000];
bool bl[5010000];
int cnt;

int main(){
	string s;cin>>s;
	nt[0]=-1;
	int k=-1,j=0;
	int l=s.size();
	int xh;
	while(j<l){
		if(k==-1||s[j]==s[k]){
			j++;k++;xh=j-k;
			bl[j-1]=(xh!=j&&j%xh==0);
			if(s[j]!=s[k]) nt[j]=k;
			else nt[j]=nt[k];
		}
		else k=nt[k];
	}
	xh=l-nt[l];
	if(xh==1) 	cout<<l<<"\n"<<1<<"\n",exit(0);
	if(xh==l||l%xh!=0) cout<<1<<"\n"<<1<<"\n",exit(0);
	for(int i=0;i<l/2;++i)	swap(s[i],s[l-1-i]);
	memset(nt,-1,sizeof(nt));
	k=-1,j=0;
	while(j<l){
		if(k==-1||s[j]==s[k]){
			j++;k++;xh=j-k;
			bool B=(xh!=j&&j%xh==0);
			if(B==0&&bl[l-1-j]==0) cnt++;
			if(s[j]!=s[k]) nt[j]=k;
			else nt[j]=nt[k];
		}
		else k=nt[k];
	}
	cout<<2<<"\n"<<cnt<<"\n";
	return 0;
}

Measured memory_bytes: 21764
#include <iostream>
using namespace std;
#define INF 10000000

int M[101][101],p[101];

int main() {
  int n; cin >> n;
  for ( int i = 1; i <= n; i++ ) {
    cin >> p[i-1] >> p[i];
  }
  for ( int i = 1; i <= n; i++ ) M[i][i] = 0;
  for ( int l = 2; l <= n; l++ ) {
    for ( int i = 1; i <= n-l+1; i++ ) {
      int j = i+l-1;
      M[i][j] = INF;
      for ( int k = i; k <= j-1; k++ ) {
	int q = M[i][k] + M[k+1][j] + p[i-1]*p[k]*p[j];
	M[i][j] = min(M[i][j],q);
      }
    }
  }
  cout << M[1][n] << endl;
  return 0;
}



Measured memory_bytes: 3096
void main() {
    string s = readln.chomp;
    writeln(s[0], s.length - 2, s[$-1]);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

#define deb(x) cerr<<"["#x<<" : "<<x<<" ]\n";

int main()
{
	int n;
	cin >> n;
	int mini = INT_MAX, maxi = INT_MIN;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		mini = min(mini, x);
		maxi = max(maxi, x);
	}
	cout << maxi - mini;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int K = Integer.parseInt(reader.readLine());
            String[] array = reader.readLine().split(" ");
            int X = Integer.parseInt(array[0]);
            int Y = Integer.parseInt(array[1]);

            if (K % 2 == 0 && Math.abs(X + Y) % 2 == 1) {
                System.out.println(-1);
                System.exit(0);
            }

            int x = 0, y = 0;

            int s = 0;
            StringBuilder pos = new StringBuilder();

            while (true) {
                s++;

                int d = Math.abs(X - x) + Math.abs(Y - y);

                // 2K以上離れていれば単に近づける
                if (d >= 2 * K) {
                    int dx = Math.min(K, Math.abs(X - x));
                    x += (X - x >= 0 ? 1 : -1) * dx;
                    y += (Y - y >= 0 ? 1 : -1) * (K - dx);
                }
                // 距離がKならそのままゴールイン
                else if (d == K) {
                    x = X;
                    y = Y;
                }
                // 2K未満の距離で、残り距離が偶数なら、距離Kの位置に移動
                else if (d % 2 == 0) {
                    if (Math.abs(X - x) >= K) {
                        int dx = d / 2;
                        x += (X - x >= 0 ? 1 : -1) * dx;
                        y -= (Y - y >= 0 ? 1 : -1) * (K - dx);
                    } else if (Math.abs(Y - y) >= K) {
                        int dx = K - d / 2;
                        x -= (X - x >= 0 ? 1 : -1) * dx;
                        y += (Y - y >= 0 ? 1 : -1) * (K - dx);
                    } else {
                        if (Math.abs(X - x) >= d / 2) {
                            int dx = d / 2;
                            x += (X - x >= 0 ? 1 : -1) * dx;
                            y -= (Y - y >= 0 ? 1 : -1) * (K - dx);
                        } else {
                            int dx = Math.abs(X - x) + (K - d / 2);
                            x += (X - x >= 0 ? 1 : -1) * dx;
                            y += (Y - y >= 0 ? 1 : -1) * (K - dx);
                        }
                    }
                }
                // 2K未満の距離で、残り距離が奇数なら、ゴールの近くに移動
                else {
                    int dx = Math.min(K, Math.abs(X - x));
                    x += (X - x >= 0 ? 1 : -1) * dx;
                    y += (Y - y >= 0 ? 1 : -1) * (K - dx);
                }

                pos.append(x).append(" ").append(y).append("\n");

                if (x == X && y == Y) {
                    break;
                }
            }

            System.out.println(s);
            System.out.print(pos.toString());
        }
    }

}


Measured memory_bytes: 39220
import scala.io.StdIn

object Main extends App {

  //
  // 駅： 1, 2, 3, ・・・ N
  // 1 ・・・ i ・・・ N - 1
  //         i, i+1, : Ci
  // Si 
  // Fi 秒ごとに出発
  // Si / Fi で割り切れる
  // Si <= t , t % Fi = 0
  // ------------------------
  // N
  // C1 S1 F1
  //   :
  // CN−1 SN−1 FN−1

  case class Stations(idx: Int, c: Int, s: Int, f: Int)

  val n = StdIn.readLine().toInt
  val trains = (0 until n - 1).map { i =>
    val Array(ci, si, fi) = StdIn.readLine().split(' ').map(_.toInt)
    Stations(i, ci, si, fi)
  }.toArray

  (0 until n).foreach { i =>
    var time = 0
    (i until n - 1).foreach { j =>
      val next = trains(j)
      if (time < next.s) {
        time = next.s
      }
      else if (time % next.f == 0) {

      } else {
        time = time + next.f - (time % next.f)
      }
      time += next.c
    }
    println(time)
  }
}

Measured memory_bytes: 25712
eval'N,M,K,*X='+`dd`.split*?,
s=X[0,z=i=j=N].sum
X<<K
(s+=X[~-j+=1]until s+X[j]>K
s>K||z=[z,i+j].max
s-=X[i-=1])until i<0
p z-N

Measured memory_bytes: 93876
import java.math.BigInteger;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger N = new BigInteger(sc.next());
        sc.close();

        for (int i=new Double(Math.sqrt(N.doubleValue())).intValue(); i>0; i--) {
            if (N.mod(new BigInteger(Integer.toString(i))).compareTo(BigInteger.ZERO)==0) {
                System.out.println(N.divide(new BigInteger(Integer.toString(i))).add(new BigInteger(Integer.toString(i-2))));
                break;
            }
        }
    }
}

Measured memory_bytes: 89796
#include <bits/stdc++.h>
using namespace std;
int main() {
    while (true) {
        int a, b, r; char op; cin >> a >> op >> b;
        if (op == '?') break;
        switch(op) {
            case '+': r = a + b; break;
            case '-': r = a - b; break;
            case '*': r = a * b; break;
            case '/': r = a / b; break;
        }
        cout << r << endl;
    }
}


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];
  sort(ALL(A));



  map<int, int> cnt;
  REP(i, N){
    cnt[A[i]]++;
  }


  vector<bool> ok(1000001, true);

  int ans = 0;
  int past = -INF;
  REP(i, N){
    if(past == A[i]) continue;
    if(!ok[A[i]]) continue;
    if(cnt[A[i]] == 1) ans++;

    for(int j = 2; j*A[i] <= 1000000; j++){
      ok[A[i]*j] = false;
    }
    past = A[i];
  }

  cout << ans << "\n";

  return 0;
}


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

using namespace std;

int main() {
  string s;
  getline(cin, s);

  for (int i = 0; i < s.size(); i++) {
    if (s[i] >= 'a' && s[i] <= 'z') {
      s[i] += ('A' - 'a');
    } else if (s[i] >= 'A' && s[i] <= 'Z') {
      s[i] += ('a' - 'A');
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 3148
#include <stdio.h>

#define N 10000
#define Q 500

int search(int*,int,int);

int main(){
    int i,n,q;
    int cnt=0;
    int S[N],T[Q];

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

    for(i=0;i<q;i++){
        cnt += search(S,T[i],n);
    }

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

int search(int *temp,int key,int n){
    int i;

    for(i=0;i<n;i++){
        if(temp[i] == key) return 1;
    } 
    return 0;
}



Measured memory_bytes: 2108
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(scanner.nextInt());
        }
        System.out.println(set.size());
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 100005;
int a[N],b[N],c[N];
ll f[N],ans;
int n;

int main(){
	scanf("%d",&n);
	for(int i = 0;i < n;i++)
		scanf("%d",&a[i]);
	for(int i = 0;i < n;i++)
		scanf("%d",&b[i]);
	for(int i = 0;i < n;i++)
		scanf("%d",&c[i]);
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	for(int i = 0;i < n;i++){
		if(b[i] >= c[n-1]) break;
		f[i+1] = 1ll*n-(upper_bound(c,c+n,b[i])-c);
	}
	f[0] = 0;
	for(int i = 1;i <= n;i++)
		f[i] += f[i-1];
	for(int i = 0;i < n;i++){
		if(a[i] >= b[n-1]) break;
		int s = upper_bound(b,b+n,a[i])-b;
		ans += f[n]-f[s];
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

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

  if (b == 1) {
    cout << 0 << endl;
    return 0;
  }

  int res = 1;
  int tmp = a;
  while (tmp < b) {
    tmp += (a - 1);
    res++;
  }

  cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 3;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) exp(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define endl '\n'
ll prime[100000];
ll exp(ll a,ll b);
void sieve(ll n);
ll gcd(ll a ,ll b);
ll countdigit(ll n);
int main()
{

	flash
	ll n,m,c=0,c1=0;
	cin >> n >> m ;
	//set<ll>s;
	ll arr[n+1]={0};
	ll wa[n+1]={0};
	rep(i,0,m) {
		string a;
		ll x;
		cin >> x >> a;
		if(a=="AC") {
			if(arr[x]==0){arr[x]=1;}	
		}
		else if(a=="WA"&&arr[x]==0){
			wa[x]++;
		}
	} 
	rep(i,0,n+2){
		if(arr[i]==1)c1++;
	}
	rep(i,0,n+1){
		if(arr[i]==1&&wa[i]>0)c=c+wa[i];
	}
	cout<<c1<<" "<<c;
}
//
//
//
//
//
// IMPORTANT FUNCTIONS
ll exp(ll a, ll b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
void sieve(ll n) {
    for(ll i=0;i<=n;i++) {
        prime[i]=1;
    }
    prime[0]=0;prime[1]=0;
    for(ll i=2;i<=n;i++) {
        if(prime[i]==1) {
            for(ll j=2;i*j<=n;j++) {
                prime[i*j]=0;
            }
        }
    }
}
ll countdigit(ll  n) 
{ 
    return floor(log10(n) + 1); 
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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 dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

struct UnionFind{
  vector<int> par;

  UnionFind(int N): par(N){
    for(int i=0;i<N;i++) par[i]=i;
  }

  int root(int x){
    if(par[x]==x) return x;
    else return par[x]=root(par[x]);
  }

  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx!=ry) par[rx]=ry;
  }

  bool sameroot(int x,int y){
    return root(x)==root(y);
  }

};

vector<int> ok[100010];
vector<int> ng[100010];



int main() {
    int N,M,K; cin>>N>>M>>K;
    UnionFind uf=UnionFind(N);
    vector<int> root_cnt(N,0),friend_cnt(N,0),bad_cnt(N,0);
    int a,b;
    for (int i = 0; i < M; ++i) {
        cin>>a>>b; --a; --b;
        uf.unite(a,b);
        friend_cnt[a]++; friend_cnt[b]++;
    }

    for(int i=0;i<N;++i){
        root_cnt[uf.root(i)]++;
    }

    for (int i = 0; i < K; ++i) {
        cin>>a>>b; --a; --b;
        if(uf.sameroot(a,b)){
            bad_cnt[a]++;
            bad_cnt[b]++;
        }
    }

    for (int i = 0; i < N; ++i) {
        cout<<root_cnt[uf.root(i)]-1-friend_cnt[i]-bad_cnt[i]<<" ";
    }
    cout<<endl;


    return 0;
}


Measured memory_bytes: 7424
//Template
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

int main() {
	ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	a--; b--; c--; d--;
	string s; cin >> s;
	rep(i, b + 1, d - 1) {
		if (s[i] == '#' && s[i + 1] == '#') {
			cout << "No" << endl;
			return 0;
		}
	}
	rep(i, a + 1, c - 1) {
		if (s[i] == '#' && s[i + 1] == '#') {
			cout << "No" << endl;
			return 0;
		}
	}
	if (c < d) {
		cout << "Yes" << endl;
		return 0;
	}
	//c >d;
	repe(i, b, d) {
		if (i == d) {
			if (s[i - 1] == '.') {
				cout << "Yes" << endl;
				return 0;
			}
		}
		else {
			if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;

void cinv(vector<ll> &V){
	ll t;
	cin >> t;
	V.push_back(t);
}

int main()
{
	int N;
	string ANS="Three";
	vector<char>S;
	cin >> N;
	fore(i,0,N){
		char a;
		cin >> a;
		if(a=='Y')ANS="Four";
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int n,t,min,cnt=0;
	int arr[100] = { 0 };

	cin >>n;
	for (int i = 0; i != n; ++i)
	{
		cin >> arr[i];
	}
	
	for (int i = 0; i != n - 1; ++i)
	{
		min = i;
		for (int j = i+1; j != n; ++j)
		{
			if (arr[j] < arr[min])
			{
				min = j;
			}
		}
		if (i != min)
		{
			++cnt;
			t = arr[i];
			arr[i] = arr[min];
			arr[min] = t;
		}
		
	}

	for (int i = 0; i != n; ++i)
	{
		cout << arr[i];
		if (i == n - 1)
		{
			cout << endl;
			break;
		}
		cout << " ";
	}
	cout << cnt << endl;

	return 0;

}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
    private static final long MOD = 1_000_000_007;

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        final int[] colors = new int[3];
        long sum = 1;
        for (int i = 0; i < n; i++) {
            final int a = scanner.nextInt();
            long tmp = 0;
            int index = 0;
            for (int j = 0; j < colors.length; j++) {
                if (colors[j] == a) {
                    tmp++;
                    index = j;
                }
            }
            sum *= tmp;
            sum %= MOD;
            colors[index]++;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 48732
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    bool check_c = false;
    bool enable = false;
    for ( int i = 0; i < s.size(); i++ ) {
	if ( !check_c ) {
	    if ( s[i] == 'C' ) check_c = true;
	}
	else {
	    if ( s[i] == 'F' ) {
		enable = true;
		break;
	    }
	}
    }

    if ( enable ) {
	printf("Yes\n");
    }
    else {
	printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b, c, d;
	scanf("%d %d %d", &a, &b, &c);
	if (a > b) {
		d = a; a = b; b = d;
	}
	if (b > c) {
		d = c; c = b; b = d;
	}
	if (b < a) {
		d = b; b = a; a = d;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 2720
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

pii A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

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

    cin>>n;

    for(int i=0;i<n;i++)
    {
        cin>>a>>x;
        A[i].f = a+x;
        A[i].s = a-x;
    }

    sort(A,A+n);

    int pre = -2*INF;

    for(int i=0;i<n;i++){
        if(pre<=A[i].s){
            ++cnt;
            pre = A[i].f;
        }
    }

    cout<<cnt<<"\n";

    return 0;
}


Measured memory_bytes: 1024
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const int N = 1e2 + 7;
const int mod = 1e9 + 7;

int n, a[N], b[N], ans;

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> n;
    for ( int i = 1; i < n; i++ ) cin >> b[i];
    a[1] = b[1];
    a[n] = b[n - 1];
    ans = b[1] + b[n - 1];
    for ( int i = 2; i < n; i++ ) {
        a[i] = min( b[i - 1], b[i] );
        ans += a[i];
    }
    cout << ans;
}



Measured memory_bytes: 256
N = int(input(""))
a = list(map(int, input("").split(" ")))
f = int(1e4)

count = 0
for i in range(len(a)-1):
    if a[i]==a[i+1]:
        a[i+1]=f
        f -= 1
        count += 1
        continue

print(count)


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

int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  cout << n / 2 - (n % 2 == 0) << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np
MOD = 10 ** 9 + 7
N, K = map(int, input().split())
gcds = np.zeros((K + 1,), dtype=np.int64)
for n in range(K, 0, -1):
    gcds[n] = (pow(K // n, N, MOD) - gcds[np.arange(1, K // n + 1, dtype=np.int64) * n].sum()) % MOD
print(gcds @ np.arange(K + 1, dtype=np.int64) % MOD)


Measured memory_bytes: 29808