akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

const int MAX_PRIME = 1010;

vector<int> is_prime(MAX_PRIME,1);
vector<int> primes;

void calcPrime(){
	is_prime[0]=is_prime[1]=0;
	for(int i=2; i<MAX_PRIME; i++){
		if(is_prime[i]==1){
			for(int j=i*2; j<MAX_PRIME; j+=i){
				is_prime[j]=0;
			}
			primes.push_back(i);
		}
	}
}
void primeFact(int n, map<int, int>& mp){
	int k = n;
	for(int i = 0; primes[i]*primes[i] <= n; i++){
		while(k > 1 && k % primes[i] == 0){
			k /= primes[i];
			mp[primes[i]]++;
		}
	}
	if(k > 1) mp[k]++;
}


int main(){
	calcPrime();
	int n;
	cin>>n;
	if(n == 1) {
		cout<<1<<endl;
		return 0;
	}
	map<int, int> mp;
	for(int i = 2; i <= n; i++){
		primeFact(i, mp);
	}
	ll ans = 1LL;
	for(auto& p : mp){
		(ans *= (ll)(p.se+1))%=MOD;
		//cout<<" "<<p.fi<<" "<<p.se<<" "<<ans<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
even=Counter(v[0::2]).most_common()
odd=Counter(v[1::2]).most_common()
even.append((0,0))
odd.append((0,0))
if even[0][0]!=odd[0][0]:print(n-(even[0][1]+odd[0][1]))
else:print(min(n-(even[0][1]+odd[1][1]),n-(even[1][1]+odd[0][1])))

Measured memory_bytes: 20572
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

vector<int> size_(0);
vector<int> parent(0);

//unionSet作成
void DisjointSet(int size){
    for(int i=0; i<size; i++){
        size_.push_back(1);
        parent.push_back(i);
    }
}

void makeSet(int x){
    parent[x]=x;
    size_[x]=0;
}

//親を確認
int findSet(int x){
    if (x!=parent[x]){
        parent[x]=findSet(parent[x]);
    }
    return parent[x];
}

//同Setか判定
bool same(int x, int y){
    return (findSet(x) == findSet(y));
}

//内部の関数
void link(int x, int y){
    if (size_[x] > size_[y]){
        parent[y]=x;
        size_[x]+=size_[y];
    }else{
        parent[x]=y;
        size_[y]+=size_[x];
    }
}

//setを結合
void unite(int x, int y){
    link(findSet(x), findSet(y));
}

long long calc(int a){
    return (long long) a*(a-1)/2;
}

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int> > bridge(M,vector<int>(2,0));
    for(int i=0; i<M; i++){
        cin >> bridge[i][0] >> bridge[i][1];
        bridge[i][0]--;
        bridge[i][1]--;
    }

    vector<long long> ans(M,0);
    DisjointSet(N);
    for(int i=M-1; i>=0; i--){
        int a=findSet(bridge[i][1]);
        int b=findSet(bridge[i][0]);
        if(a==b){
            ans[i]=0;
            continue;
        }
        long long conv=calc(size_[a])+calc(size_[b]);
        unite(a,b);
        a=findSet(a);
        ans[i]=calc(size_[a])-conv;
    }

    for(int i=0; i<M; i++){
        if(i!=0)ans[i]+=ans[i-1];
        cout << ans[i] << endl;
    }
    
}

Measured memory_bytes: 8484
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <numeric>
#include <map>
#include <utility>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(void){
    int a,b;
    cin>>a>>b;
    cout<<(a%3&&a%3==b%3?"Impossible":"Possible")<<endl;
    return 0;
}

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

signed main(){
  int n,k;cin>>n>>k;
  vector<int>v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  int l=0,r=1e9+1;
  while(r-l>1){
    int mid=(r+l)>>1,cnt=0;
    for(int i=0;i<n;i++)cnt+=(v[i]-1)/mid;
    (cnt<=k?r:l)=mid;
  }
  cout<<r<<endl;
}


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

int main() {
  string S;
  cin >> S;
  
  int count0 = 0;
  int count1 = 0;
  int count2 = 0;  
  int count3 = 0;
  // 1文字目の個数
  count0 = count(S.cbegin(), S.cend(), S.at(0));
  // 2文字目の個数
  count1 = count(S.cbegin(), S.cend(), S.at(1));
  // 3文字目の個数
  count2 = count(S.cbegin(), S.cend(), S.at(2));
  // 4文字目の個数
  count3 = count(S.cbegin(), S.cend(), S.at(3));

  if(count0 + count1 + count2 + count3 == 8) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    int c0 = 0, c1 = 0;
    for (int i = 0; i < s.length(); i++) {
        if ((s[i] - '0') == (i%2)) c0++;
        else c1++;
    }

    cout << min(c0, c1) << endl;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    string N;
    cin >> N;

    bool ok = false;
    for (int i = 0; i < (int)N.size(); i++) {
        if (N[i] == '7') {
            ok = true;
        }
    }

    cout << (ok ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;

int main()
{
	int n , m;
	int arr[MaxN];
	LL ans = 0 ,ans1;
	cin >> n;
	for(int i = 1; i <= n ; i++)
	{
		cin >> arr[i];
		ans += arr[i];
	}
	cin >> m;
	while(m--)
	{
		int p , x;
		cin >> p >> x;
		ans1 = ans - arr[p] + x;
		cout << ans1 << endl;
		}
	return 0;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
using v = vector<int>;
using m = map<ll,ll>;
using vv = vector<v>;
int main(){
    ll n,k;
    cin >> n >> k;
    auto c = m();
    for (ll i = 0; i < n; i++)
    {
        ll a,b;
        cin >> a >> b;
        c[a]+=b;
    }

    ll ans = 0;
    for (auto  i:c)
    {
        ans += i.second;
        if(ans>=k) {
          	cout << i.first<<endl;
			break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 4224
package main

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

func main() {
	const m = 1000000007

	N := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}

	result := 0
	a := make([]int, N)
	bs := make([]int, N)
	for b := 0; b < 60; b++ {
		for i := 0; i < N; i++ {
			a[i] = (A[i] >> uint(b)) & 1
		}

		bs[N-1] = a[N-1]
		for i := N - 2; i > -1; i-- {
			bs[i] = bs[i+1] + a[i]
		}

		t := 0
		for i := 0; i < N-1; i++ {
			if a[i] == 0 {
				t += bs[i+1]
			} else {
				t += (N - (i + 1)) - bs[i+1]
			}
		}
		t %= m

		v := (1 << uint(b)) % m
		result += (t * v) % m
		result %= m
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 12928
N = int(input())
Ai = list(map(int,input().split()))
Alice = 0
Bob = 0
Ai.append(0)

while Ai:
    Alice += max(Ai)
    Ai.remove(max(Ai))
    if not Ai:
        break
    Bob += max(Ai)
    Ai.remove(max(Ai))

print(Alice-Bob)

Measured memory_bytes: 9048
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), cnt(45, 0);
    REP(i, N) {
        cin >> A[i];
        int j = 0;
        while ((A[i] >> j) > 0) {
            if ((A[i] >> j) & 1) {
                cnt[j]++;
            }
            j++;
        }
    }
    ll X = 0L;
    RREP(i, 44) {
        if (cnt[i] >= N - cnt[i]) {
            continue;
        }
        ll Y = X + (1L << i);
        if (Y > K) {
            continue;
        }
        X = Y;
    }
    ll res = 0L;
    REP(i, N) {
        res += (X ^ A[i]);
    }
    cout << res << "\n";
    return 0;
}


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

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

int main() {
    string s;
    cin >> s;
    cout << s.at(0) + to_string(s.size() - 2) + s.at(s.size()-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(N,-1);
	int res = 0;
	int b;
	
	for (int i = 0; i < N; i++) {
		cin >> b;
		b--;
		a[i] = b;
		if (a[b] == i) {
			res++;
		}
	}
	
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)

	s, _ := strconv.Atoi(a + b)

	if math.Sqrt(float64(s)) - float64(int(math.Sqrt(float64(s)))) == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 512
s = input()
t = input()
sls = list(s)
tls = list(t)

n = len(s)

for i in range(n) :

   snow = sls[i]
   tnow = tls[i]

   if snow == tnow :
      pass

   else:
      if tnow in sls[0:i]  :
         print('No')
         break

      else :
         for j in range(n) :
            if sls[j] == snow :
               sls[j] = tnow
            elif sls[j] == tnow :
               sls[j] = snow

else :
   if sls == tls :
      print('Yes')
   else :
      print('No')

Measured memory_bytes: 8240
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;


int main(){
	while(1){
		int n,m,s[100],t[100],sans=0,tans=0,ans=-1;
		bool ok=false;
		cin>>n>>m;
		if(n==0)break;
		rep(i,0,n)cin>>s[i],sans+=s[i];
		rep(i,0,m)cin>>t[i],tans+=t[i];
		sort(s,s+n);
		sort(t,t+m);
		int d=sans-tans;
		if(d%2){
			print(ans);
			continue;
		}
		if(d>0){
			rep(i,0,n){
				rep(j,0,m){
					if(s[i]-t[j]==d/2){
						print(s[i]<<" "<<t[j]);
						ok=true;
					}
					if(ok)break;
				}
				if(ok)break;
			}
		}

		if(d==0){
			rep(i,0,n){
				rep(j,0,m){
					if(s[i]==t[j]){
						ok=true;
						print(s[i]<<" "<<t[j]);
						break;
					}
				}
				if(ok)break;
			}
		}

		if(d<0){
			rep(j,0,m){
				rep(i,0,n){
					if(t[j]-s[i]==-d/2){
						print(s[i]<<" "<<t[j]);
						ok=true;
					}
					if(ok)break;
				}
				if(ok)break;
			}
		}
		if(ok)continue;
		print(ans);
	}
	return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <functional>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;





int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin >> n;
	vector<vector<vector<bool>>> dp(2 * n, vector<vector<bool>> (2 * n, vector<bool> (n, false)));
	vector<vector<char>> bd(2 * n, vector<char> (2 * n));
	int i, j, k;
	for(i = 0; i < n; i++) {
		for(j = 0; j < n; j++) {
			cin >> bd[i][j];
			bd[i][j + n] = bd[i][j];
			bd[i + n][j + n] = bd[i][j];
			bd[i + n][j] = bd[i][j];
			
		}
	}
	for(j = 0; j < 2 * n; j++) {
		dp[2 * n - 1][j][0] = true;
	}
	for(i = 2 * n - 2; i >= 0; i--) {
		for(j = 0; j < 2 * n; j++) {
			dp[i][j][0] = true;
			bool lftp = true;
			for(k = 1; k + i < 2 * n && k + j < 2 * n && k < n; k++) {
				if(bd[i + k][j] != bd[i][j + k]) {
					lftp = false;
				} 
				if(lftp && dp[i + 1][j + 1][k - 1]) {
					dp[i][j][k] = true;
				}
			} 
		}
	}
	int ct = 0;
	for(i = 0; i < n; i++) {
		for(j = 0; j < n; j++) {
			if(dp[i][j][n - 1]) {
				ct++;
			}
		}
	}
	cout << ct << '\n';
	
	return 0;	
}


Measured memory_bytes: 33664
#include <stdio.h>

int main(void) {

	int  i, j, H, W;

	while (1) {

		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0) {
			break;
		}

		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {

				if (i == 0) {
					printf("#");
				}
				else if (i == H - 1) {
					printf("#");
				}
				else if (j == 0) {
					printf("#");
				}
				else if (j == W - 1) {
					printf("#");
				}

				else {
				printf(".");
			}

			}

			printf("\n");

		}

		printf("\n");

	}

	return(0);

}


Measured memory_bytes: 2044
s = input()
n = len(s)
s1 = ''.join(str(i%2) for i in range(n))
s2 = ''.join(str((i+1)%2) for i in range(n))
s1cnt = 0
s2cnt = 0
for i in range(n):
    if s[i] != s1[i]:
        s1cnt += 1
    if s[i] != s2[i]:
        s2cnt += 1
print(min(s1cnt, s2cnt))


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

using namespace std;

#define REP(i,n) for(int i=0;(i)<(int)(n);(i)++)

int N,M;
int c[100010];

int main() {
  cin >> N >> M;
  REP(x,M) {
    int l,r;
    scanf("%d %d", &l, &r);
    l--; r--;
    c[l] += 1;
    c[r+1] -= 1;
  }

  int cnt = 0;
  REP(i,N-1) c[i+1] += c[i];
  REP(i,N) if (c[i] == M) cnt++;
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        cin>>A[i];
    }
    
    int dp[n];
    dp[0]=0;
    dp[1]=abs(A[1]-A[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(A[i-1]-A[i]),dp[i-2]+abs(A[i-2]-A[i]));
    }
    cout<<dp[n-1]<<endl;
}

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    int A,B;
    cin >> A >> B;
    if(A<=8 && B<=8) cout << "Yay!" << endl;
    else cout << ":(" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define ll long long int

using namespace std;

int main()
{
    ll n, m;
    cin >> n >> m;
    ll ans = -1LL;
    for(ll i = 1 ; i*i <= m ; i++){
        if( m%i == 0){
            if(i >= n ) ans = max(ans, m/i);
            if(m/i >= n ) ans = max(ans, i);
        }
    }
    cout << ans;
    return 0;
}

















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

int main(){
    int A,B,C,X,count,i,j,k;
    cin >> A >> B >> C >> X;
    count = 0;
    for(i=0;i<=A;i++){
        for(j=0;j<=B;j++){
            for(k=0;k<=C;k++){
                if(500*i+100*j+50*k==X)
                    count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
fn main() {
    let mut sc = Scanner::new();
    let h: usize = sc.read();
    let w: usize = sc.read();
    let mut grid: Vec<Vec<usize>> = vec![vec![0; (w + 2)]; (h + 2)];
    for i in 0..h {
        let symbols: String = sc.read();
        for (j, symbol) in symbols.chars().enumerate() {
            if symbol == '#' {
                grid[i + 1][j + 1] = 1;
            }
        }
    }

    let mut able = true;
    'outer: for i in 1..(h + 1) {
        'inner: for j in 1..(w + 1) {
            if grid[i][j] == 1 {
                if grid[i - 1][j] == 0 && grid[i + 1][j] == 0 && grid[i][j - 1] == 0 && grid[i][j + 1] == 0 {
                    able = false;
                    break 'outer;
                }
            }
        }
    }

    if able {
        println!("Yes");
    } else {
        println!("No");
    }

}


struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }
    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}

Measured memory_bytes: 4352
# coding: utf-8
"""this is python work script"""

CHECK_WORDS = ['dream', 'dreamer', 'erase', 'eraser']

def check_word(word, check_word_list):
    find_word = False

    # print(word, check_word_list)
    for i, cw in enumerate(check_word_list):
        find_result = word.find(cw)
        # print(i, cw, find_result)

    # # remove check word if not find it in string
    # if find_result == -1:
    #     check_word_list.remove(cw)

    #  remove word if find it in string head
        if find_result == 0:
            word_length = len(cw)
            word = word[word_length:]
            find_word = True
        # print(word, check_word_list)

    return find_word, word

def solver(word, check_word_list):
    """solve this problem"""
    wip = True
    while wip:
        wip, word = check_word(word, check_word_list)

    answer = 'NO'
    if len(word) == 0:
        answer = 'YES'
    return answer

def reverse_string_list(string_list):
    answer_list = []
    for word in string_list:
        answer_list.append(word[::-1])

    return answer_list

def main():
    """main function"""
    word = input().rstrip()[::-1]
    word_list = reverse_string_list(CHECK_WORDS)
    answer = solver(word=word, check_word_list=word_list)
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=k;i<=n;i++)
    {   
        ll mn=(ll)(i*(ll)(i-1))/2;

        double mx=((double(i/double(2.0)))*((2*(n-i+1)+(i-1))));
         ll mxx=mx;
        //cerr<<mxx<<" "<<mn<<endl;
        ans=((ans%mod+(mxx%mod-mn%mod+mod)%mod)%mod + 1)%mod;
        //cout<<ans<<endl;
    }
    cout<<(ans%mod+1%mod)%mod<<endl;
    
}
return 0;
}

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

int N;
int A[100005];

int main()
{
    cin >> N;

    int TotDist = 0;

    for(int i=0; i<N; i++)
    {
        cin >> A[i];
        TotDist += (i ? abs(A[i] - A[i-1]) : abs(A[i]));
    }

    TotDist += abs(A[N-1]);

    int DistOut ,DistIn;
    for(int i=0; i<N; i++)
    {
        DistOut = (i ? abs(A[i] - A[i-1]) : abs(A[i]))
                + (i == N-1 ? abs(A[i]) : abs(A[i] - A[i+1]));
        DistIn = (i ? abs(A[i-1] - A[i+1]) : abs(A[1]));

        if(i == N-1)
            DistIn = abs(A[N-2]);

        cout << TotDist + DistIn - DistOut << endl;
    }
}


Measured memory_bytes: 1664
n = int(input())
a = list(map(int,input().split()))
ans = []
k = 2
for i in range(n, 0, -1):
    if n/k < i:
        for x in range(2, k):
            a[i-1] += a[x * i - 1]
        a[i-1] = a[i-1] % 2
    else:
        while n/k >= i:
            k += 1
        else:
            for x in range(2, k):
                a[i-1] += a[x * i - 1]
            a[i-1] = a[i-1] % 2
    if a[i-1] == 1:
        ans.append(i)
print(len(ans))
print(*ans)

Measured memory_bytes: 12656
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define rep(i,n) for(int i=0;i<n;i++) 
#define all(v) v.begin(),v.end()
#define F first
#define S second
ll n,m,m1;
void solve()
{
	cin>>n>>m>>m1;
	map<ll,vector<pair<ll,ll>>> mr,mc;
	map<pair<ll,ll>,bool> m2;
	for(ll i=0;i<m1;i++)
	{
		ll x,y;
		cin>>x>>y;
		x--;
		y--;
		m2[{x,y}]=true;
		mr[x].push_back({x,y});
		mc[y].push_back({x,y});	
	}
	vector<ll> vr,vc;
	ll maxr=0;
	ll maxc=0;
	for(auto x:mr)
	{
		maxr=max(maxr,(ll)x.second.size());
	}
	for(auto x:mc)
	{
		maxc=max(maxc,(ll)x.second.size());
	}
	for(auto x:mr)
	{
		if((ll)x.second.size()==maxr)
		{
			vr.push_back(x.first);
		}
	}
	for(auto x:mc)
	{
		if((ll)x.second.size()==maxc)
		{
			vc.push_back(x.first);
		}
	}
	bool temp=false;
	for(ll i=0;i<vr.size();i++)
	{
		for(ll j=0;j<vc.size();j++)
		{
			if(m2[{vr[i],vc[j]}]==0)
			{
				temp=true;
				break;
			}
		}
	}
	if(temp)
	{
		cout<<maxr+maxc<<endl;
	}
	else
	{
		cout<<maxr+maxc-1<<endl;
	}
	
	
	
}

int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
	int t;
	t=1;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 111008
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s;
  int vl = 700;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'o') vl += 100;
  }
  cout << vl << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(20)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	vector<char> v;
	v.pb('z');
	for (char i = 'a'; i <= 'y'; ++i)
		v.pb(i);
	string ans;
	int n;
	cin >> n;
	while (n) {
		ans += v[n % 26];
		// reverse(all(ans));
		if (n >= 26)
			n--;
		n /= 26;

	}
	reverse(all(ans));
	cout << ans;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();

	return 0;
}


Measured memory_bytes: 3636
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include<iostream>
#include<cstdint>
#include<cstddef>
#include<algorithm>
#include<vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<int, int>;
int n, m;
vector<vector<int>> dist(100, vector<int>(100, 1e9));

void warshall_froyd() {
    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                if (dist[i][k] + dist[k][j] < dist[i][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                }
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cin >> n >> m;
    rep(i, n) {
        rep(j, n) {
            if (i == j)dist[i][j] = 0;
        }
    }
        vector<int> a(m),b(m),c(m);
    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        dist[a[i]][b[i]] = min(c[i],dist[a[i]][b[i]]);
        dist[b[i]][a[i]] = min(c[i],dist[a[i]][b[i]]);

    }
    warshall_froyd();
    int ans = m;
    rep(i,m){
        bool flag = false;
        rep(j,n){
            if(dist[j][a[i]] + c[i] == dist[j][b[i]]) flag = true;
        }
        if(flag)ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3704
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);

		//n?????????
		int n = sc.nextInt();

		//n?????????????????????
		for(int i = 1; i <= n; i++){
			//?????¶???3????????°????????¨???
			if(i % 3 == 0 || Integer.toString(i).contains("3")){
				System.out.print(" " + i);
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 29160
#include<bits/stdc++.h>							
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
const ll maxsize = 100000009;

void solve() {
	int n;
	cin >> n;
	string s, t, new_s = "";
	cin >> s >> t;
	for(int i = 0; i < n; ++i) {
		new_s += (s[i]);
		new_s += t[i];
		}
		cout << new_s << endl;
}


int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
}
 
 
 



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

int N,An;
std::vector<int> A;
 

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

int main(void){
    std::cin >> N;

    for(int i = 0;i < N;i++){
        std::cin >> An;
        A.push_back(An);
    }
    std::sort(A.begin(), A.end());
    //printVec(A);

    //std::cout << std::unique(A.begin(), A.end()) - A.end() << std::endl;

    if( ( std::unique(A.begin(), A.end()) - A.end()) < 0){
        std::cout << "NO";
        return 0;
    }
    std::cout << "YES";
    
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int cnt[100010];

int main(){
    int n,m;
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        cnt[a]++;
        cnt[b]++;
    }

    rep(i,100010){
        if(cnt[i]%2==1){
            cout<<"NO"<<endl;
            return 0;
        }
    }

    cout<<"YES"<<endl;

}

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

long long a[100005];

int main() {
	int n;
	cin >> n;
	for(int i=0;i<=n;i++){
		scanf("%d",&a[i]);
	}
	long long b,sum=0;
	for(int i=0;i<n;i++){
		scanf("%d",&b);
		if(a[i]>=b){
			a[i]=a[i]-b;
			sum+=b;
		}
		else{
			b=b-a[i];
			sum+=a[i];
			a[i]=0;
			if(a[i+1]>=b){
				a[i+1]=a[i+1]-b;
				sum+=b;
			}else{
				b=b-a[i+1];
				sum+=a[i+1];
				a[i+1]=0;
			}
		}
	}
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
loop{ m,f,r=gets.split.map(&:to_i)
  break if [m,f,r]==[-1,-1,-1]
  if m==-1 || f==-1
    puts "F"
  elsif m+f>=80
    puts "A"
  elsif m+f>=65
    puts "B"
  elsif m+f>=50
    puts "C"
  elsif m+f>=30
    puts r>=50 ? "C":"D"
  else
    puts "F"
  end
}

Measured memory_bytes: 6104
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll          long long   
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sum+=__gcd(i,__gcd(j,k));    
            }
        }
    }
    cout<<sum<<endl;


}


Measured memory_bytes: 3616
#pragma GCC optimize(2)
#include <bits/stdc++.h>

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

 
#define MP make_pair
#define INF 0x3f3f3f3f
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, a, n) for (int i=(a); i<=(n); i++)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) { cerr << " " << to_string(H);    debug_out(T...);}
 
set<pii> s;
set<pii> t;
int main()
{closeSync;
#ifdef DEBUG
	//freopen("C:/Users/86159/Desktop/input.txt", "r", stdin);
	//freopen("C:/Users/86159/Desktop/output.txt", "w", stdout);
#endif
	//clock_t c1 = clock();
	int h,w;
	cin>>h>>w;
	rep (i,1,w)
	{
		s.insert(MP(i,0));	
		t.insert(MP(0,i));
	}
	rep (i,1,h)
	{
		int a,b;
		cin>>a>>b;
		auto l = s.lower_bound(MP(a,-1));
		auto r = s.upper_bound(MP(b,INF));
		int d = w;   // d代表右移几步 , b 代表右移后离左边的距离
 		while (l!=r)
		{
			auto [x, y] = *l;
			//debug(x,y);
			d = min(d,(b + 1) - (x - y));
			//debug(d,(b + 1) - (x - y));
			l = s.erase(l);
			t.erase(MP(y,x));
		}
		if ( d < w && b < w)
		{
			//debug(b,d);
			s.insert(MP(b + 1,d)),t.insert(MP(d,b + 1));
		}
		int ans = -1;
		if (!t.empty())
			ans = i  + t.begin()->first;
		cout<<ans<<endl;
	}	
	//cerr << "Time:" << clock() - c1 << "ms" <<endl;
    return 0;
}

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

using std::cin;
using std::cout;
using std::endl;

bool check_tanku(std::vector<std::string> v, int ind) {
	int piv = 0;
	int n = v.size();
	int l = 0;
	for (int i = ind+piv; i < n && l < 5; i++) {
		l += v[i].length();
		if (l > 5) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 7; i++) {
		l += v[i].length();
		if (l > 7) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 5; i++) {
		l += v[i].length();
		if (l > 5) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 7; i++) {
		l += v[i].length();
		if (l > 7) {
			return false;
		}
		piv++;
	}
	l = 0;
	for (int i = ind+piv; i < n && l < 7; i++) {
		l += v[i].length();
		if (l > 7) {
			return false;
		}
		piv++;
	}

	return true;
}

int main(void) {
	int n;
	int limit = 31;
	cin >> n;

	while ( n != 0 ) {
		std::vector<std::string> tan(n);
		std::vector<int> len(n,0);
		bool find = false;
		for (int i = 0; i < n; i++) {
			cin >> tan[i];
		}

		for (int i = 0; i < n; i++) {
			for (int j = i; j < n && len[i] < limit; j++) {
				len[i] += tan[j].length();
			}
		}

		int temp;
		for (int i = 0; i < n && !(find); i++) {
			if (len[i] == limit) {
				if (check_tanku(tan,i)) {
					cout << i+1 << endl;
					find = true;
				}
			}
		}

		cin >> n;
	}

	return 0;
}

Measured memory_bytes: 3080
/*mjytxdy!*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define size(x) ((int)x.size())
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define inl inline
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define travel(i,u) for(int i=head[u];i;i=e[i].next)
#define lb(x) ((x)&(-(x)))
#define lson root<<1
#define rson root<<1|1
#define Mid (l+r>>1)
#define debug(x) cout<<#x":"<<x<<'\n'
#define myput puts("QaQ")
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
typedef long long ll;
int a,b,c;
inl char read(){
	static const int IO_LEN=1024*1024;
	static char buf[IO_LEN],*ioh,*iot;
	if(ioh==iot){
		iot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);
		if(ioh==iot) return -1;
	}
	return *ioh++;
}
template<class T>inl void read(T &x){
	static int iosig;static char ioc;
	for(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;
	for(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');
	if(iosig) x=-x;
}
int main(){
//	freopen("in.txt","r",stdin);
	read(a),read(b),read(c);
	puts(a+b+c>=22?"bust":"win");
	return 0;
}


Measured memory_bytes: 256
A,B,C,X = [int(input()) for i in range(4)]#500,100, 50, 合計

ans = 0

for a in range(0,A+1):
    for b in range(0,B+1):
        for c in range(0,C+1):
            total = 500 * a + 100 * b + 50 * c
            if total == X:
                ans +=1


# スペース区切りの整数の入力
# 出力
print(ans)

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

int main() {
    int H, W, N;
    cin >> H >> W >> N;

    int ma = max(H, W);
    cout << N/ma + bool(N%ma) << endl;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    a = LI()

    from collections import Counter

    cnt = Counter(a)

    if len(cnt) == 1 and a[0] == 0:  # all elements are zero
        print('Yes')
        return

    if len(cnt) == 2:
        x, y = cnt.keys()
        if x^y==y and y^y==x and cnt[x]*2==cnt[y]:
            print('Yes')
            return
        if x^x==y and x^y==x and cnt[y]*2==cnt[x]:
            print('Yes')
            return

    if len(cnt) == 3:
        x, y, z = cnt.keys()
        if x^y==z and y^z==x and z^x==y and cnt[x]==cnt[y]==cnt[z]:
            print('Yes')
            return

    print('No')




main()

Measured memory_bytes: 14816
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    int H[100000];
    for(int i=0; i<N; i++){
        cin >> H[i];
    }
    int ans=0;
    int temp=0;
    for(int i=1; i<=N; i++){
        if(i<N && H[i]<=H[i-1]){
            temp++;
        }else{
            ans=max(ans,temp);
            temp=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
 
int main(void)
{
  int left,right,weight1,weight2,weight3,weight4;
  char str[16];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d%d%d%d",&weight1,&weight2,&weight3,&weight4);
  
  left = weight1 + weight2;
  right = weight3 + weight4;
  
  if(left > right)
  {
    puts("Left");
  }else if(left == right)
  {
    puts("Balanced");
  }else
  {
    puts("Right");
  }
  
  return 0;
}
  

Measured memory_bytes: 128
N = int(input())
CSF = [list(map(int, input().split())) for _ in range(N-1)]

for i in range(N):
    ans = 0
    for j in range(i, N-1):
        if j == i:
            ans += CSF[i][1]
            ans += CSF[i][0]
        else:
            if ans < CSF[j][1]:
                ans += CSF[j][1] - ans
            else:
                mod = (ans - CSF[j][1]) % CSF[j][2]
                if mod != 0:
                    ans += CSF[j][2] - mod
            ans += CSF[j][0]
    print(ans)

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

struct edge{int to,len;	};

struct graph{
	int n;
	vector<vector<edge>>g;
	vector<bool> used;
	vector<int> pos;

	graph(){};
	graph(int _n){
		n=_n;
		g.resize(n);
		pos.resize(n,0);
		used.resize(n,false);
	};

	void add_edge(int a,int b,int c){
		g[a].push_back(edge({b,c}));
		g[b].push_back(edge({a,-c}));
	}

	void check(int a){
		used[a]=true;
		for(auto&& w:g[a]){
		if(used.at(w.to)){
		if(pos.at(a)+w.len!=pos.at(w.to)){
		cout<<"No"<<endl;
		//cerr<<a<<" "<<w.to<<endl;
		//for(auto&& w:pos)cerr<<w<<" ";
		exit(0);}
		}else{
			pos.at(w.to)=pos.at(a)+w.len;
			check(w.to);
		}
		}
	}
	void checkAll(){
		for(int i=0;i<n;i++){
			if(used[i])continue;
			else check(i);
		}
		cout<<"Yes"<<endl;
	}
	

};

	


int main(){
	int n,m;cin>>n>>m;
	graph gr(n);
	for(int i=0;i<m;i++){
		int x,y,z;cin>>x>>y>>z;x--;y--;
		gr.add_edge(x,y,z);
	}
	gr.checkAll();

}

Measured memory_bytes: 11520
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n - 1); i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

int n, m;
ll a[300005];
ll s[300005];
bool check(ll k, ll t) {
    ll sum = 0;
    auto idx = lower_bound(a, a + m, t) - a;
    sum += s[idx] + t * (ll)(m - idx);
    return sum >= k * t;
}

ll cnt[300005];
void solve() {
    cin >> n;
    rep(i, n) {
        int x;
        cin >> x;
        ++cnt[x - 1];
    }

    rep(i, n) if (cnt[i] > 0) a[m++] = cnt[i];
    sort(a, a + m);
    rep(i, m) s[i + 1] = s[i] + a[i];

    reps(k, n) {
        ll l = 0, r = n / k + 1;
        while (r - l > 1) {
            auto mid = (l + r) / 2;
            if (check((ll)k, mid))
                l = mid;
            else
                r = mid;
        }
        cout << l << endl;
    }
}

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


Measured memory_bytes: 7808
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        q: usize,
        v: [(usize1, usize1, usize, usize); q]
    }
    let mut ar = vec![0; n];
    let mut ans = 0;
    while ar[0] < m {
        let mut t = 0;
        for &(a, b, c, d) in &v {
            if ar[b] - ar[a] == c {
                t += d;
            }
        }
        ans = max(ans, t);
        ar[n - 1] += 1;
        let mut i = n - 1;
        while i > 0 {
            if ar[i] == m {
                i -= 1;
                ar[i] += 1;
            } else {
                break;
            }
        }
        while i < n - 1 {
            ar[i + 1] = ar[i];
            i += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2124
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000001;
const long double E = 0.00000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a[5];
    for (int q = 0; q < 5; q++){
        cin >> a[q];
        if (a[q] == 0){
            cout << q+1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int d[100005];
int main(void){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>d[i];
	}
	sort(d,d+n);
	int a=n/2;
	cout<<d[a]-d[a-1]<<endl;
	
}


Measured memory_bytes: 640
import sys
MOD = 10 ** 9 + 7

n, m, *broken = map(int, sys.stdin.read().split())
broken = set(broken)

def main():
    ways = [0] * (n + 1)
    ways[0] = 1
    ways[1] = int(not 1 in broken)
    for i in range(2, n + 1):
        ways[i] = (not i in broken) * (ways[i-1] + ways[i-2]) % MOD
    print(ways[n])

if __name__ ==  '__main__':
    main()

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

vector<bool> seen;
vector<int> first_order;
vector<int> last_order;

void dfs(vector<vector<int>> &G, int v, int& ptr) {
    first_order[v] = ptr++;

    seen[v] = true;
    for(auto next_v : G[v]){
        if(seen[next_v]) continue;
        dfs(G, next_v, ptr);
    }

    last_order[v] = ptr++;
}

int main(){
    int n;
    cin >> n;
    int u;
    int k;
    vector<vector<int>> G(n);
    for (int i = 0; i < n; i++)
    {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++)
        {
            int a; cin >> a;
            a--;
            G[u].push_back(a);
        }
    }
    
    seen.assign(n, false);
    first_order.resize(n);
    last_order.resize(n);
    int ptr = 1;
    for(int i = 0; i < n; i ++){
        if(!seen[i]) dfs(G, i, ptr);
    }

    for (int v = 0; v < n; v++)
        cout << v + 1 << " " << first_order[v] << " " << last_order[v] << endl;
}


Measured memory_bytes: 3172
S = input()
len_S = len(S)
n = len_S // 2
A = "01" * n
if len_S % 2 == 1:
    A += "0"
an, bn = 0, 0
for s, a in zip(S, A):
    if s == a:
        bn += 1
    else:
        an += 1
print(min(an, bn))

Measured memory_bytes: 3188