akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

const int MOD = (int)1e9 + 7;

class BIT {
private:
    VL _bit;
    int _n;

public:
    BIT(int n): _n(n) {
        _bit.resize(n + 1, 0);
    }

    void add(int i, ll x) {  // 1-indexed
        for(int j = i; j <= _n; j += j & -j) _bit.at(j) = (x + _bit.at(j)) % MOD;
    }

    ll sum(int i) {  // 1-indexed, sum of [1, i]
        ll res = 0;
        for(int j = i; j > 0; j -= j & -j) res = (res + _bit.at(j)) % MOD;
        return res;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    VI a(n);
    REP(i, n) cin >> a.at(i);
    vector<BIT> bits(n + 1, BIT(k + 1));
    bits.at(0).add(0 + 1, 1);
    FOR(i, 1, n)FOR(j, 0, k) {
        ll sum = bits.at(i - 1).sum(j + 1) - bits.at(i - 1).sum(max(j - a.at(i - 1), 0));
        bits.at(i).add(j + 1, (sum + MOD) % MOD);
    }

    cout << (bits.at(n).sum(k + 1) - bits.at(n).sum(k) + MOD) % MOD << ln;
    return 0;
}


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

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  int ans;
  if(N % X == 0){
    ans = (N / X) * T;
    cout << ans << endl;
  }
  else{
    ans = ((N / X) + 1) * T;
    cout << ans << endl;
  }
}

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

using namespace std;
int main(){
  int n,m;
   cin >>n >> m;
  
  vector<vector<int>> s(m);
  for(int i=0;i<m;i++){
     int k;
    cin >> k;
      s[i].resize(k);
    for(int j=0;j<k;j++) {
       cin >> s[i][j];
      s[i][j]--;
    }
  }
  vector<int> p(m);
  for(int i=0;i<m;i++) cin >> p[i];
  
  int res=0;
  for(int i=0;i<(1<<n);i++){
   bool flag=true;
    
    for(int j=0;j<m;j++){
      int num=0;
       for(int id:s[j]){
        if((i>>id)&1) num++;
       }
       num%=2;
      if(num!=p[j]) flag=false; 
    }
    if(flag) res++;
 
  }
  
 cout << res << endl; 
  
  
}

Measured memory_bytes: 256
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


MY_NAMESPACE(sandbox)
ll gcd(ll a, ll b)
{
	if (a < b)
		swap(a, b);
	if (a % b == 0)
		return b;
	return gcd(b, a % b);
}

ll modpow(ll base, ll exponent, ll mod)
{
	ll retval = 1;
	while (exponent > 0)
	{
		if (exponent % 2)
			retval = (retval * base) % mod;
		exponent /= 2;
		base = (base * base) % mod;
	}
	return retval;
}

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

	ll modval = 1000000007;

	int n;
	cin >> n;
	map<pll, int> cnt;
	for (int i = 0; i < n; i++)
	{
		ll a, b;
		cin >> a >> b;
		if (a != 0 && b != 0)
		{
			if (a < 0)
			{
				a *= -1;
				b *= -1;
			}
			ll g = gcd(abs(a), abs(b));
			cnt[{a / g, b / g}]++;
		}
		else if (a == 0 && b == 0)
			cnt[{0, 0}]++;
		else if (a == 0)
			cnt[{0, 1}]++;
		else  // b == 0
			cnt[{1, 0}]++;
	}

	ll num00 = 1;
	if (cnt[{0, 0}] == 0)
		num00 = 0;
	else
		num00 = cnt[{0, 0}];
	cnt.erase(make_pair(0,0));

	ll num = 1;
	while (!cnt.empty())
	{
		auto this_item = *cnt.begin();
		cnt.erase(cnt.begin());
		pll this_pair = this_item.first;
		pll anti_pair = { this_pair.second, -this_pair.first };
		if (anti_pair.first < 0)
			anti_pair = { -this_pair.second, this_pair.first };
		else if (anti_pair.first == 0)
			anti_pair = { 0, 1 };
		if (cnt.find(anti_pair) == cnt.end())
			cnt[anti_pair] = 0;
		auto anti_item = cnt.find(anti_pair);

		num = num * (modpow(2, this_item.second, modval) - 1 + modpow(2, anti_item->second, modval) - 1 + 1) % modval;
		cnt.erase(anti_item);
	}
	ll retval = (num + modval - 1) % modval;
	cout << (retval + num00) % modval << "\n";
		
	return 0;
}
MY_NAMESPACE_

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

using namespace std;

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

    long long ans = 0;
    int n, k;
    cin >> n >> k;
    int arr[n];

    for (int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n, greater<int>());

    for (int i = k; i < n; i++)
        ans += arr[i];
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1024
gets
h = {}
a = gets.scan(/./)
a.each {|e| h[e] = (h[e]||0) + 1 }
x = m = 0
a.reverse_each {|e|
  if h[e] > 0
    x += 1
    h[e] *= -1
  end
  x -= 1  if 0 == h[e] += 1
  m = x  if m < x
}
p m

Measured memory_bytes: 3836
#include <iostream>
#define INF (1 << 20)
using namespace std;

int Prime[INF]={0};
void intPrime(){
    Prime[0] = Prime[1] = 1;
    for(int i=2;i<=INF/2;i++){
        for(int j=2;i*j<=INF;j++) Prime[i*j] = 1;
    }
}
int main(){
    intPrime();
    int n;
    while(cin >> n,n){
        int ans = 0;
        for(int i=2;i<=n/2;i++){
            if(Prime[i] == 0 && Prime[n-i] == 0) ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 5256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;
        

        static void Main(string[] args)
        {
            var xy = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var maxleg = 4 * xy[0];
            var ans = "No";

            for (int i = 0; i <= xy[0]; i++)
            {
                if (xy[1] > maxleg)
                {
                    ans = "No";
                    break;
                }
                else
                {
                    if (maxleg - 2 * i == xy[1])
                    {
                        ans = "Yes";
                        break;
                    }
                }

                //Console.WriteLine(maxleg - 2 * i);
                
            }
            Console.WriteLine(ans);

        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        /*static public void DFS(int h, int w, bool[][] _visited)
        {
            
            if (w < 0 || h < 0 || h > _visited.Length - 1 || w > _visited[h].Length-1 || map[h][w]=='x')
                return;
            if (_visited[h][w])
                return;
            //Console.WriteLine(h + " " + w+" "+ _visited[h].Length + " " + _visited.Length);
            _visited[h][w] = true;

            DFS(h + 1, w,_visited);
            DFS(h - 1, w,_visited);
            DFS(h, w + 1,_visited);
            DFS(h, w - 1,_visited);

        }*/
        
        
        
    }
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> vec(M,vector<int>(3));
  for(int i=0; i<M; i++){
    for(int j=0; j<2; j++){
      cin >> vec.at(i).at(j);
    }
    vec.at(i).at(2) = i;
  }
  
  vector<vector<int>> dist(N,vector<int>(N));
  for(int i=0; i<M; i++){
    int a = vec.at(i).at(0)-1;
    int b = vec.at(i).at(1)-1;
    dist.at(a).at(b) = 1;
    dist.at(b).at(a) = 1;
  }
  
  int ans = 0;
  
  for(int i=0; i<M; i++){
    queue<int> Q;
    vector<bool> seen(N,false);
    Q.push(0);
    bool flag = true;
    int y = vec.at(i).at(0)-1;
    int z = vec.at(i).at(1)-1;
    dist.at(y).at(z) = 0;
    dist.at(z).at(y) = 0;
    
  while(Q.size()){
    int x = Q.front();
    Q.pop();
    for(int i=0; i<N; i++){
      if(dist.at(x).at(i) == 1 && seen.at(i) == false){
        Q.push(i);
        seen.at(i) = true;
      }
    }
  }
  for(int i=0; i<N; i++){
    if(seen.at(i) == false){
      flag = false;
    }
    //cout << seen.at(i);
  }
    if(flag){
      ans++;
    }
    dist.at(y).at(z) = 1;
    dist.at(z).at(y) = 1;
    while(Q.size()){
      Q.pop();
    }
    flag = true;
  }
  cout << M - ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <queue>

using namespace std;

int main () {
    long X, Y;
    cin>>X>>Y;
    int count = 0;
    while (X <= Y) {
        count++;
        X *= 2;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 384
<?php
	$n = trim(fgets(STDIN));
	$n = explode(" ", $n);

	if ($n[0] < $n[1])
		$exp = '<';
	elseif ($n[0] > $n[1])
		$exp = '>';
	else
		$exp = '==';

	printf("a %s b\n", $exp);

Measured memory_bytes: 6544
h, w = map(int, input().split())
maze = [input() for i in range(h)]
graph = {}

for i, s_i in enumerate(maze):
  for j, s_ij in enumerate(s_i):
    if s_ij == ".":
      graph[i * w + j] = []
      if i > 0 and maze[i - 1][j] == ".":
        graph[i * w + j].append((i - 1) * w + j)
      if j > 0 and maze[i][j - 1] == ".":
        graph[i * w + j].append(i * w + j - 1)
      if j < w - 1 and maze[i][j + 1] == ".":
        graph[i * w + j].append(i * w + j + 1)
      if i < h - 1 and maze[i + 1][j] == ".":
        graph[i * w + j].append((i + 1) * w + j)

ans = 0
for start in graph.keys():
  dist = {}
  c = 0
  dist[start] = c
  hoge = {start}
  for _ in graph.keys():
    c += 1
    fuga = set()
    for h in hoge:
      fuga |= set(graph[h])
    fuga -= set(dist.keys())
    for f in fuga:
      dist[f] = c
    hoge = fuga
    if len(dist) == len(graph):
      break
  ans = max(ans, max(dist.values()))
  
print(ans)



Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) {

        solve_149_B();
      
        return;
    }

	private static void solve_149_B() {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();

        if (A >= K) {
            A = A - K;
        } else { // if( A<K )
            if (B >= (K - A)) {
                B = B - (K - A);
            } else {
                B = 0;
            }
            A = 0;
        }
        System.out.println(A + " " + B);
    }
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n][3];
	for(int i=0;i<n;i++)
	{
	    for(int j=0;j<3;j++)
	    {
	        cin>>a[i][j];
	    }
	}
	int dp[n][3];
	for(int i=0;i<3;i++)
	{
	    dp[0][i]=a[0][i];
	}
	for(int i=1;i<n;i++)
	{
	    dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
	    dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
	    dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
  int x,kyu;
  cin>>x;
  x-=400;
  
  kyu=8-x/200;
  cout<<kyu<<endl;
  
   
   
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  int B;
   cin >> A >> B ;
  int ans;
  ans = -1;
  int eighthasuu;
  eighthasuu = 0;
  int eightyouso;
  eightyouso = 13;
    if (A%2 == 1) {
      eighthasuu = 1;
      eightyouso = 12;
    }
  
  int eightstart;
  int tenstart;
  eightstart = 12.5*A;
  eightstart = eightstart + eighthasuu;
  tenstart = 10 * B;
  
  
  
  
  vector<int> eightarray(eightyouso);
  vector<int> tenarray(10);
  
  
  int i;
  for(i=0;i<eightyouso;i++){
  eightarray.at(i)=eightstart+i;
     //cout << eightarray.at(i) << endl;
  }
  for(i=0;i<10;i++){
  tenarray.at(i)=tenstart+i;
    //cout << tenarray.at(i) << endl;
  }
  int minint;
  int j;
  for(i=eightyouso-1;i>-1;i--){
   //cout << eightarray.at(i) << endl;
  for(j=10-1;j>-1;j--){
  
      if(eightarray.at(i)==tenarray.at(j)){
      ans = eightarray.at(i);
      }
    }
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
#print(A)

ans = 0
pre = 0
maxa = 0
for i in range(N):
  if A[i] > maxa:
    print(-1)
    exit()
  else:
    if A[i] == 0:
      maxa = 0
    elif A[i] == pre + 1:
      ans += 1
    else:
      ans += A[i]
      maxa = A[i]
    pre = A[i]
    maxa += 1
print(ans)


Measured memory_bytes: 62296
#include<bits/stdc++.h>
using namespace std;
#define PI 3.1415 
  
double circum(double r) 
{ 
    double cir = 2*PI*r; 
    return cir; 
}
int main()
{
  double r;
  cin>>r;
  cout <<circum(r); 
  return 0;
  
  
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll L; cin >> L;
  double L3 = ((double)L)/3.0;
  printf("%.8f\n", L3*L3*L3);

  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
Hs=list(map(int,input().split()))
results=[True]*N
for m in range(M):
    s,e=map(int,input().split())
    if Hs[s-1] <= Hs[e-1]:
        results[s-1] = False
    if Hs[s-1] >= Hs[e-1]:
        results[e-1] = False

print(sum(results))

Measured memory_bytes: 20108
// Created by sz
#include<bits/stdc++.h>
using namespace std;
const int maxn = 15;

char s[maxn], input[maxn], temp[maxn],character[]= "0357";
int len =0,cnt = 0;

void tell_ok(char* s){
    int label[3];
    memset(label, 0, sizeof(label));
    int less = 1;
    for(int i = 0; i < len; i++){
        if (s[i] =='3')label[0] = 1;
        if (s[i] == '5')label[1] =1;
        if(s[i] == '7')label[2] = 1;
    }
    for (int i = 0; i < len; i++){
        if (s[i]== input[i])continue;
        else{
            less = (s[i]<input[i]);
            break;
        }
    }
    if ((label[0] + label[1] + label[2] == 3 )&& less)cnt ++;
}

void permutation(char* s, int n){
    if(n==len) {
        tell_ok(s);
        return;
    }
    
    int i;
    if(n ==0||(n>0&& s[n-1] =='0'))i = 0;
    else i  = 1;
    for(;i<4; i++){
        s[n] = character[i];
        permutation(s, n+1);
    }
}

int main(){
//    freopen("./input.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    for(int m =n;m!=0;m = m/10)temp[len++] = m%10 + '0';
    for(int i = 0; i < len; i++){
        input[i] = temp[len-1-i];
    }
    permutation(s, 0);
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
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; }

int main()
{
    int K, S;
    cin >> K >> S;

    int cnt = 0;

    rep (X, K+1)
    {
        rep (Y, K+1)
        {
            int Z = S - X - Y;
            if (0 <= Z && Z <= K)
            {
                cnt++;
            }
        }
    }

    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

def solve(a):
    if a.lower() == a:
        ret = 'a'
    else:
        ret = 'A'
    print(ret)
    return

def main():
    a = input()
    solve(a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61676
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x, a, b;
  cin >> x >> a >> b;
  
  int m=b-a;
  
  if(m<=0){
    cout << "delicious" << endl;
  }
  
  else if(m>0&&m<=x){
    cout << "safe" << endl;
  }
  
  else{
    cout << "dangerous" << endl;
  }
  
  
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int K, P;
void input() {
    cin >> K >> P;
}
void solve() {
    if (K % P == 0) {
        cout << P << endl;
    } else {
        cout << K % P << endl;
    }
}

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        input(); solve();
    }
    return 0;
}

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

using ll = long long;

constexpr ll INF = 1LL << 60;
constexpr int MAX_N = 100;
constexpr int MAX_V = 1000;

ll dp[MAX_N+1][MAX_V*MAX_N+1];
int w[MAX_N], v[MAX_N];

int main() {
  int N, W;
  cin >> N >> W;
  for (int i{}; i < N; ++i)
    cin >> w[i] >> v[i];

  fill_n(dp[0], (MAX_N+1)*(MAX_V*MAX_N+1), INF);
  dp[0][0] = 0;

  for (int i{}; i < N; ++i) {
    for (int j{}; j <= MAX_V*MAX_N; ++j) {
      if (j >= v[i]) {
        dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
      } else {
        dp[i+1][j] = dp[i][j];
      }
    }
  }

  for (int j{MAX_V*MAX_N}; j >= 0; --j) {
    if (dp[N][j] <= W) {
      cout << j << endl;
      break;
    }
  }

  return 0;
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
typedef long long ll;
using namespace std;
vector<ll> g[200005];
ll h[200005];
ll n,m;
int main(void)
{
	cin>>n>>m;
	for(ll i=1;i<=n;i++) cin>>h[i];
	while(m--)
	{
		ll u,v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	ll cnt=0;
	for(ll i=1;i<=n;i++)
	{
		bool ok=true;;
		for(ll j=0;j<g[i].size();j++)
		{
			ll v=g[i][j];
			if(h[v]>=h[i]) ok=false;
		}
		if(ok) cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 12592
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
// #include <bitset>
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
using namespace std;
typedef long long LL;
typedef double db;
#define pritnf printf
//char buf[1<<24],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
	if (x< 0) putchar('-'),x=-x;
	if (x>=10) print(x/10);
	putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
int pri[N]; bool vis[N];
void init (const int n=2200)
{
	for (int i=2; i<=n; i++)
	{
		if (!vis[i]) pri[++pri[0]]=i;
		for (int j=i+i; j<=n; j+=i)
			vis[j]=1;
	}
}
LL a[N],b[N];
map <LL,int> cnt;
map <LL,bool> us;
int main ()
{
	// freopen (".in","r",stdin);
	// freopen (".out","w",stdout);
	init ();
	int n; sc(n);
	for (int i=1; i<=n; i++)
	{
		sc(a[i]);
		LL x=b[i]=1;
		for (int j=1; j<=pri[0]; j++) if (a[i]%pri[j]==0)
		{
			int p=pri[j],g=0;
			if (p> a[i]) break;
			while (a[i]%p==0) a[i]/=p,++g;
			g%=3;
			if (!g) continue;
			x*=p,b[i]*=p;
			g==1?b[i]*=p:x*=p;
		}
		if (a[i]> 1)
		{
			LL g=sqrt (a[i]);
			if (g*g==a[i]) b[i]*=g;
			else b[i]*=a[i]*a[i];
		}
		a[i]*=x;
		++cnt[a[i]];
	}
	int ans=0;
	for (int i=1; i<=n; i++)
	{
		if (a[i]==1||us[a[i]]||us[b[i]]) continue;
		us[a[i]]=1;
		ans+=max (cnt[a[i]],cnt[b[i]]);
	}
	pr(ans+(bool)cnt[1]);
	

	return 0;
}


Measured memory_bytes: 34176
n, m = map(int,input().split())
A = [list(map(int,input().split())) for i in range(m)]

n += 1

M = [[float("inf")] * n for i in range(n)]

for i in range(n):
    M[i][i] = 0
for i in range(m):
    M[A[i][0]][A[i][1]] = A[i][2]
    M[A[i][1]][A[i][0]] = A[i][2]

for k in range(n):
    for i in range(n):
        for j in range(n):
            M[i][j] = min(M[i][j], M[i][k] + M[k][j])

ans = 0
for i in range(m):
    if M[A[i][0]][A[i][1]] != A[i][2]:
        ans += 1
print(ans)

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

using namespace std;

int main() {
  int n;
  std::cin >> n;
  std::vector<int> ss(n);
  int minNotMod10 = INT_MAX;
  int sum = 0;
  for (auto& s : ss) {
    std::cin >> s;
    sum += s;
    if (s % 10) {
      minNotMod10 = std::min(s, minNotMod10);
    }
  }
  if (minNotMod10 > 100) {
    std::cout << 0 << std::endl;
    return 0;
  }
  if (sum % 10 == 0) {
    sum -= minNotMod10;
  }
  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define LL long long
#define PB push_back
#define MP make_pair
#define I insert

const LL N = 2e5+5, mod = 1000000007;

using namespace std;

LL n, m, i, j, k, l, r, t, ans, nn;
LL a[N], b[N], c[N];
LL xe[N*3];

void upd ( LL x ) {
	while ( x <= N ) {
		xe[x]++;
		x += (x & -x);
	}
}
 
LL get ( LL x ) {
	LL k = 0;
	while ( x > 0 ) {
		k += xe[x];
		x -= (x & -x);
	}
	return k;
}

int main(){
	cin >> n;
	nn = 131072;
	for ( i = 0; i < n; ++i ){
		cin >> a[i];
		b[i] = a[i];
	}
	sort ( b, b + n );
	for ( LL ww = 18; ww >= 0; --ww ){
		k = ans + ( 1 << ww );
		if ( k >= n ) continue;
		t = n;
		for ( i = 0; i < n; ++i ){
			if ( a[i] >= b[k] ) c[i] = 1;
			else c[i] = -1;
			if ( i ) c[i] += c[i-1];
			if ( c[i] < t ) t = c[i];
		}
		t = 1 - t;
		for ( i = 0; i <= N; ++i ) xe[i] = 0;
		l = 0;
		for ( i = 0; i < n; ++i ){
			if ( c[i] >= 0 ) l++; 
			c[i] += t;
			l += get ( c[i] );
			upd ( c[i] );
			//cout << c[i] << " ";
		}
		//cout << endl;
		if ( l >= (1LL*n * (n+1) / 2 + 1) / 2 ) ans = k;
		//cout << k << " " << b[k] << " " << l << endl;
	}
	cout << b[ans] << endl;
	return 0;
}
 
/**/
//      IIIIIIIII      OOOOO             A          NN        N    EEEEEEEEEE
//          I         O     O           A A         N N       N    E
//          I        O       O         A   A        N  N      N    E
//          I        O       O        A     A       N   N     N    E
//          I        O       O       AAAAAAAAA      N    N    N    EEEEEEEE
//          I        O       O      A         A     N     N   N    E
//          I        O       O     A           A    N      N  N    E
//          I         O     O     A             A   N       N N    E
//      IIIIIIIII      OOOOO     A               A  N        NN    EEEEEEEEEE ___ KAPANADZE

Measured memory_bytes: 6272
n = int(input())
numlist = [int(i) for i in input().split()]
cost = 0
ave_f = sum(numlist) / n
ave_ch = sum(numlist) // n
if ave_f - ave_ch >= 0.5 :
    ave_i = ave_ch + 1
else :
    ave_i = ave_ch
for i in range(n) :
    cost += (ave_i - numlist[i]) ** 2
print(cost)

Measured memory_bytes: 3060
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
if a[0]>x:
    ans,a[0]=a[0]-x,x
for i in range(1,n):
    if a[i-1]+a[i]>x:
        ans+=a[i-1]+a[i]-x
        a[i]=x-a[i-1]
print(ans)

Measured memory_bytes: 14132
#include <stdio.h>

int main(void)
{

  int a=0,b=0,i=0,B=0,K=0,N=0,answer=0,Max=0;
  
  scanf("%d %d",&K,&N);
  
  int A[N];
  
  while(i<N)
  {
    scanf("%d",&a);
    A[i]=a;
    i++;
  }
  
  a=A[0];
  b=A[1];
  Max=b-a;
  
  i=0;
  
  while(i<N-1)
  {
    a=A[i];
    b=A[i+1];
    
    B=b-a;
    
    if(Max<B)
    {
      Max=B;
    }
    i++;
  }
 
  a=A[N-1];
  b=A[0];
  B=K-a+b;
 
  if(Max<B)
   {
     Max=B;
   }
  
  answer=K-Max;
  
  printf("%d",answer);
  
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int digit(int n) {
    while(n!=0) {
        if(n%10==7) return 1;
        n/=10;
    }
    return 0;
}
int main() {
    int n{};
    cin >> n;
    if(digit(n)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
using namespace std;
void arraycout(int *arrayy,int n){
    for(int u=0;u<n;u++){//出力
        if(u==n-1){
            cout<<arrayy[u]<<endl;
        }else{
            cout<<arrayy[u]<<' ';
        }
    }
    
}

int bubble(int *sou,int n){
    int flag=1;
    int kaisuu=0;
    while(flag){
        flag=0;
        for(int j=n-1;j>0;j--){
            if(sou[j]<sou[j-1]){
                /*int h=sou[j];
                sou[j]=sou[j-1];
                sou[j-1]=h;*/
                swap(sou[j],sou[j-1]);
                flag=1;
                kaisuu++;
            }
        }
    }
    return kaisuu;
    
}

int main(){
    int n;
    cin>>n;
    int sou[n];
    for(int i=0;i<n;i++){
        cin>>sou[i];
    }

   int kaisuu=bubble(sou,n);
    arraycout(sou,n);
    cout<<kaisuu<<endl;

return 0;
}



Measured memory_bytes: 3136
#include<cstdio>
#include<algorithm>
using namespace std;

const int N=200005,P=924844033,G=5;
int n,tot,nxt[2*N],fst[N],to[2*N],size[N],f[N],rf[N],c[N*4],d[N*4];

int pw(int a,int x)
{
	int ans=1;
	for(;x;x>>=1,a=1ll*a*a%P)
		if(x&1)ans=1ll*ans*a%P;
	return ans;
}

void dfs(int u,int fa)
{
	size[u]=1;
	for(int i=fst[u];i;i=nxt[i])
		if(to[i]!=fa)
		{
			dfs(to[i],u);
			size[u]+=size[to[i]];
		}
	if(fa)d[size[u]]++,d[n-size[u]]++;
}

void ntt(int *a,int n,int inv)
{
	for(int i=0,j=0;i<n;i++)
	{
		if(i>j)swap(a[i],a[j]);
		for(int k=n>>1;(j^=k)<k;k>>=1);
	}
	for(int i=2;i<=n;i<<=1)
	{
		int m=i>>1,wn=pw(G,(P-1)+inv*(P-1)/i);
		for(int *p=a;p<a+n;p+=i)
		{
			int w=1;
			for(int j=0;j<m;j++)
			{
				int t=1ll*w*p[m+j]%P;
				p[m+j]=(p[j]-t)%P;
				p[j]=(p[j]+t)%P;
				w=1ll*w*wn%P;
			}
		}
	}
	if(inv==-1)
	{
		int t=pw(n,P-2);
		for(int i=0;i<n;i++)a[i]=1ll*a[i]*t%P;
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=1,u,v;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		nxt[++tot]=fst[u];fst[u]=tot;to[tot]=v;
		nxt[++tot]=fst[v];fst[v]=tot;to[tot]=u;
	}
	dfs(1,0);
	for(int i=1;i<n;i++)d[i]*=-1;
	d[n]=n;
	for(int i=f[0]=1;i<=n;i++)f[i]=1ll*f[i-1]*i%P;
	rf[n]=pw(f[n],P-2);
	for(int i=n;i;i--)rf[i-1]=1ll*rf[i]*i%P;
	for(int i=0;i<=n;i++)d[i]=1ll*d[i]*f[i]%P;
	for(int i=0;i<=n/2;i++)swap(d[i],d[n-i]);
	for(int i=0;i<=n;i++)c[i]=rf[i];
	int l;
	for(l=1;l<=n+n;l<<=1);
	ntt(c,l,1),ntt(d,l,1);
	for(int i=0;i<l;i++)c[i]=1ll*c[i]*d[i]%P;
	ntt(c,l,-1);
	for(int i=1;i<=n;i++)
	{
		int ans=1ll*c[n-i]*rf[i]%P;
		printf("%d\n",(ans+P)%P);
	}
	return 0;
}


Measured memory_bytes: 22528
import * as fs from 'fs'

function solve() {
  const [K, X] = (require('fs').readFileSync('/dev/stdin', 'utf8') as string).split(' ').map((x: string):number => +x);
  let A = [];
  for (let i = X - (K - 1); i <= X + (K - 1); i++) {
    A.push(i);
  }
  console.log(...A);
}

solve();


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

using namespace std;
typedef long long ll;

#define out(ans) cout << ans << endl
#define in(n) cin >> n
#define floop(i, N) for (ll i = 0; i < N; i++)
#define floop1(i, N) for (ll i = 1; i <= N; i++)
#define floopi(i, j, N) for (ll j = i + 1; j < N; j++)

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;
}

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

void solve();
ll lcm(ll, ll);

int main()
{
    solve();
}

ll lcm(ll a, ll b)
{
    ll s = a;
    ll t = b;
    while (b != 0)
    {
        ll tmp = b;
        b = a % b;
        a = tmp;
    }
    return s * t / a;
}

void solve()
{
    ll a, b;
    in(a);
    in(b);
    ll ans = lcm(a, b);
    out(ans);
}


Measured memory_bytes: 256
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Typical_Stairs2
{
    class Program
    {
        static void Main(string[] args)
        {
            //以下入力時の処理
            string input = ReadLine();            
            string[] array = input.Split(' ');
            var totalStep = int.Parse(array[0]);//零段目を抜いた段数の総数なので＋１
            var totalBrokenStep =int.Parse( array[1]);//壊れた段の総数
            var step = new long[totalStep + 1];//零段目も含めた段数分の箱を用意
            var brokenStep = new int[totalBrokenStep+2];//壊れた階段用の箱を用意
            for (int i = 0; i < totalBrokenStep ; i++) {
                brokenStep[i] = int.Parse(ReadLine()); //一行ずつ読み込み
            }//壊れた階段段数を記録
            step[0] = 1;//0段目は一通りなので
                        //以下」一段目以降の処理//
            int N = 1000000007;///定数
            int count = 0;//壊れた階段＝＝処理中の段数となったときに比較する壊れた段数を次に移すために使う
            for (int j = 1; j < totalStep+1; j++) {
                
                if ( j< 2)
                {
                    step[j] = step[j - 1] ;//totalStep==1の時step[j-2]は存在しない
                }
                else {
                    step[j] = step[j - 1] + step[j - 2]%N; //一つ前への行き方と二つ前への生き方の総和を代入           
                }
                if (j == brokenStep[count])
                { //j段目の値＝＝壊れた階段の時にstep[j]=0を代入
                    step[j] = 0;
                    count++;//処理する段数を次に移すうつす
                }
            }
            
            WriteLine(step[totalStep] % N);//結果を表示
            ReadKey();

        }
    }
}


Measured memory_bytes: 15276
while True :
    N, M = map(int, input().split())
    if N == 0 and M == 0 :
        break
    
    Ins = list(int(input()) for i in range(N))
    Sai = list(int(input()) for i in range(M))
    
    ans = 0
    Now = 0
    i = 0
    while True :
        if Now >= N-1 :
            break
        
        ans += 1
        Now += Sai[i]
        if Now >= N-1 :
            break
        Now += Ins[Now]
        i += 1
    print(ans)


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
template <typename Container>
void print(const Container &c, char end = '\n', char sep = ' ')
{
    for (const auto &x : c)
        cout << x << sep;
    cout << end;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b;

    return 0;
}

Measured memory_bytes: 3620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ShekharN
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int ans = (int) IntStream.range(0, n).map(i -> in.nextInt()).distinct().count();
            out.println(ans);
        }

    }

    static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        public String nextString() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 27852
#include <stdio.h>

int main(void)
{
	int a,b,c[7],i;
	for(i=0; i<7; i++){
		scanf("%d %d",&a,&b);
		c[i]=a-b;
	}
	for(i=0; i<7; i++){
		printf("%d\n",c[i]);
	}
	return 0;
}


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


void solve(long long N){
   cout << N * N * N << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
    public static void main(String args[]){
	BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
	try {
	    String s = r.readLine();
	    int num = Integer.valueOf(s);
	    while(num != 0){
		int result = 0;
		for(int i = 1;i< num; i++){
		    int tmp = i;
		    int next = i+1;
		    while(tmp < num){
			tmp = tmp + next;
			next++;
		    }
		    if(tmp == num) result++;
		}
		System.out.println(result);
		s = r.readLine();
                num = Integer.valueOf(s);
	    }
	}catch(Exception e){}

    }
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n,t;cin>>n>>t;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    int min = (int)1e9+1;
    int mnum = 0;
    int max = 0;
    int Mnum = 0;
    ll ans = 0;

    for(int i=0; i<n; i++){
        if(a[i]<min){
            min=a[i];
            mnum=1;
        }
        else if(a[i]==min){
            mnum++;
        }
        if(a[i]-min>max){
            max=a[i]-min;
            ans=mnum;
            Mnum=1;
        }
        else if(a[i]-min==max){
            ans+=mnum;
            Mnum++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize};
    let mut flag = true;

    for i in 1..n + 1 {
        if i * 108 / 100 == n {
            println!("{}", i);
            flag = false;
        }
    }

    if flag {
        println!(":(")
    }
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  int ans = 0;
  rep(i, n) {
    in(int, a);
    if (((i + 1) & 1) && (a & 1)) {
      ++ans;
    }
  }
  out(ans);
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> p;


int main()
{
  ll a, b, k;
  cin >> a >> b >> k;
  for (ll i = a; i <= b; i++){
    if (i <= (a + k - 1) || i >= (b - k + 1)) {
      cout << i << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define ull unsigned long long
#define inf 10000000000000000
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
const int N=300000;
vector<pair<int,int> >adj[N];
int dis[N];
bool vis[N];
bool no=false;
void dfs(int s)
{
	vis[s]=true;
	for(int i=0;i<adj[s].size();i++)
	{
		int x=adj[s][i].ff,y=adj[s][i].ss;
		if(vis[x])
		{
			if(dis[x]!=dis[s]+y)
			{
				no=true;
			}
		}
		else
		{
			dis[x]=dis[s]+y;
			dfs(x);
		}
	}
}
int32_t main()
{
   IOS;
  /* #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif
   /********************* Code starts here ************************/
   memset(vis,false,sizeof(vis));
   int n,m;
   cin>>n>>m;
   for(int i=0;i<m;i++)
   {
   	int a,b,c;
   	cin>>a>>b>>c;
   	adj[b-1].pb(mp(a-1,c));
   	adj[a-1].pb(mp(b-1,-c));
   }
   for(int i=0;i<n;i++)
   {
   	if(!vis[i])
   	{
   		dfs(i);
   	}
   }
   if(no)
   {
   	cout<<"No";
   }
   else
   {
   	cout<<"Yes";
   }
}     	

Measured memory_bytes: 22016
#include <iostream>
#define max 500000
#define sentinel 2000000000

using namespace std;

int l[max/2+2],r[max/2+2];
int cnt;

void Merge(int a[],int n,int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    //???l??°?????????
    for (int i = 0; i < n1; ++i) {
        l[i]=a[left+i];
    }
    //???r??°?????????
    for (int j = 0; j < n2; ++j) {
        r[j]=a[mid+j];
    }
    l[n1]=r[n2]=sentinel;
    int i=0,j=0;
    for (int k = left; k < right; ++k) {
        cnt++;
        if (l[i]<=r[j]){
            a[k]=l[i++];
        }
        else{
            a[k]=r[j++];
        }

    }
}

void merge_sort(int a[],int n,int left,int right){
    if (left+1<right){
        int mid=(left+right)/2;
        merge_sort(a,n,left,mid);
        merge_sort(a,n,mid,right);
        Merge(a,n,left,mid,right);
    }
}

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

    merge_sort(a,n,0,n);

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

    printf("\n");

    printf("%d\n",cnt);

    return 0;
}

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

ll N, K, t, d, sum, ans;
vector<ll> F, S;
vector<pair<ll, ll>> v;
map<ll, ll> mp;

main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> t >> d;
        v.push_back(make_pair(t, d));
    }
    sort(v.rbegin(), v.rend());
    for (int i = 0; i < v.size(); i++) {
        pair<ll, ll> p = v[i];
        if (mp[p.first] == 0) F.push_back(p.second);
        else S.push_back(p.second);
        mp[p.first]++;
    }
    sort(F.rbegin(), F.rend());
    sort(S.rbegin(), S.rend());
    ll L = F.size(), M = S.size();
    for (ll i = 0; i < min(K, L); i++) sum += F[i];
    if (K > L) {
        ll check = 0;
        for (ll i = 0; i < K - L; i++) sum += S[i], check = i;
        check++, ans = sum + L * L;
        for (ll j = L - 1; j > 0 && check < M; j--) {
            sum = sum - F[j] + S[check];
            check++;
            ans = max(ans, sum + j * j);
        }
        cout << ans << endl;
    }
    else {
        ans = sum + K * K;
        for (ll i = 0; i < K - 1 && i < M; i++) {
            sum -= F[K - 1 - i];
            sum += S[i];
            ans = max(ans, sum + (K - i - 1) * (K - i - 1));
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 8816
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  string ret;
  for (int i = 0; i < n; ++i) {
    ret += s[i];
    ret += t[i];
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
def Replacing():
    import sys
    input = sys.stdin.readline

    n = int(input())
    A = list(map(int,input().split()))
    q = int(input())
    
    total = sum(A) # これを基に各queryに対応(加算、減算)する
    
    l = [0 for i in range(10**5+1)] # 配列のインデックスを各valueとみなす
    for _ in A: # 各インデックスに各keyを加算
        l[_] += 1
    
    for i in range(q):
        b, c = map(int,input().split())
        total += c * l[b] # totalの調整のみ
        total -= b * l[b] # 同上
        print(total)
        l[c] += l[b] # ここでリストの更新
        l[b] = 0 # 同上

Replacing()

Measured memory_bytes: 20432
#include <bits/stdc++.h>
using namespace std;
  
int main(){
    string s; cin>>s;
    if(s[0]=='A' && s[1]=='A' && s[2]=='A'){
        cout<< "No";
        return 0;
    }
    else if(s[0]=='B' && s[1]=='B' && s[2]=='B'){
        cout<< "No";
        return 0;
    }
    cout<<"Yes";
}

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

using namespace std;
#define ll long long
#define mod 1000000007

vector<pair<ll, ll>> v;
ll dp[101][100001];

ll f(ll i, ll cv) {
    if (i == v.size() && !cv) {
        return 0;
    } else if (i == v.size()) {
        return -1;
    }

    if (dp[i][cv] != -2) return dp[i][cv];

    ll ans1, ans2 = -1, ans;
    ans1 = f(i + 1, cv);
    if (v[i].second <= cv) {
        ans2 = f(i + 1, cv - v[i].second);
        if (ans2 != -1) {
            ans2 += v[i].first;
        }
    }

    if (ans1 == -1 && ans2 == -1) ans = -1;
    else if (ans1 == -1) ans = ans2;
    else if (ans2 == -1) ans = ans1;
    else ans = min(ans1, ans2);

    dp[i][cv] = ans;
    return ans;
}

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

    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100000; j++) {
            dp[i][j] = -2;
        }
    }
    ll n, W;
    cin >> n >> W;

    v.resize(n);
    ll V = 0;
    for (ll i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
        V += v[i].second;
    }
    
    for (ll i = V; i >= 0; i--) {
        if (f(0, i) != -1 && f(0, i) <= W) {
            cout << i;
            break;
        }
    }
}


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

ll k;
ll kt;
ll ans;

ll dfs(string s,ll i){
    ll l=s.length();
    if(l==i){
        kt=kt+1;
        if(kt==k)ans=stoll(s);
        return i;
    }
    for(int j=-1;j<2;j++){
        string c=s;
        if(0<=c[l-1]+j-'0' && c[l-1]+j-'0'<10){
            c+=(c[l-1]+j);
            dfs(c,i);
        }
    }
}
int main(){
    kt=9;
    cin>>k;
    if(k<10){
        cout<<k<<endl;
        return 0;
    }
   
   ll keta=2;
   
    while(kt<k){
        rep2(1,i,10){
            string b="0";
            b[0]='0'+i;
            dfs(b,keta);
        }
        keta++;
    }
    
    
    

    cout<<ans<<endl;
    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);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] list = new int[n];
		double sum = 0;
		int count = 0;

		for (int i = 0; i < n; i++) {
			list[i] = sc.nextInt();
			sum += list[i];
		}

		for (int j = 0; j < n; j++) {
			if (list[j] >= sum / (4 * m)) {
				count++;
			}
		}

		if (count >= m) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();

	}
}


Measured memory_bytes: 35964