akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstdio>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

LL divsum(LL n, LL i){
    if(n < i){
        return n;
    }else{
        return n%i + divsum(n/i,i);
    }
}

LL bin_search(LL a, LL b, LL n,LL s){
    LL ok = a;
    LL ng = b+1;
    while(abs(ok-ng) > 1){
        LL middle = (ok+ng)/2;
        LL x = divsum(n,middle);
        if(x < s){
            ng = middle;
        }else{
            ok = middle;
        }
    }
    return ok;
}

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

    LL n;
    cin >> n;

    LL s;
    cin >> s;

    function<LL(LL,LL)> func = [&](LL a,LL b)->LL{
        if(a < b){
            return a;
        }else{
            return a%b + func(a/b,b);
        }
    };

    LL i = 2;

    if(n == s){
        printf("%lli\n",n+1);
        return 0;
    }

    while(true){
        if(i*i > n){
            break;
        }else{
            if(func(n,i) == s){
                printf("%lli\n",i);
                return 0;
            }
        }
        i++;
    }

    while(i <= n){
        LL m = n/i;
        LL tmp = func(n,i);
        LL dist = tmp/m;
        LL min = func(n,dist+i);
        LL tdist = dist;
        LL t = func(n,dist+i+1);
        if(t < min){
            min = t;
            dist++;
        }
        if(tdist+i-1 >= i){
            t = func(n,tdist+i-1);
            if(t < min){
                min = t;
                dist = tdist - 1;
            }
        }

        LL ret = bin_search(i,i+dist,n,s);

        if(func(n,ret) == s){
            printf("%lli\n",ret);
            return 0;
        }
        i += dist+1;
    }

    printf("-1\n");
    
    return 0;
}

Measured memory_bytes: 256
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();

        char t = s[0];
        int cnt = 1;
        for (int i = 1; i < s.Length; i++)
        {
            if (s[i] != t)
            {
                cnt++;
                t = s[i];
            }
        }

        Console.WriteLine(cnt - 1);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13108
import kotlin.math.pow
import kotlin.math.sqrt

fun main (){
    val (n, d) = readLine()!!.split(" ").map(String::toInt)
    var resultCount = 0
    for(i in 1..n){
        val (x, y) = readLine()!!.split(" ").map(String::toDouble)
        val xy = sqrt(x.pow(2) + y.pow(2))
        if(xy <= d) resultCount++
    }
    print(resultCount)
}

Measured memory_bytes: 60660
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define speed ios::sync_with_stdio(false)
#define pb push_back
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define all(x) (x).begin(), (x).end()
#define uint usigned int
typedef vector <long long> vi;
const int N=3e5+10;
int main() {
    ll i,n,m,k,len,sum=0,l=0,r=0,flag=0;
    cin>>i>>n>>m;
    cout<<min(n/i,m);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 200000
void hashclear(void);
void hash_inc(long int);
long int hash_getc(long int);
 
typedef struct {
    long int value;
    long int count;
} kv;
kv mmm[2*N];
void hash_clear(){
    long int t;
    for(t=0;t<2*N;t++){
        mmm[t].count=0;
        mmm[t].value=-1;
    }
}
void hash_inc(long int q){
    long int x=q%(N-1);
    while(mmm[x].value!=-1&&mmm[x].value!=q)
        x++;
    if (mmm[x].value==-1)
        mmm[x].value=q;
    mmm[x].count++;
}
long int hash_getc(long int q){
    long int x=q%(N-1); 
    while(mmm[x].value!=q){
        if(mmm[x].value==-1) break;
        x++;
	}
    return(mmm[x].count);
}
int main(){
    long int n;
    long int a[N];
    long int i,j,c;
    hash_clear();
    scanf("%ld",&n);
    for(i=0;i<n;i++)
        scanf("%ld",&a[i]);
    for(i=0;i<n-1;i++)
            hash_inc(a[i]+i);
    c=0;
    for(j=1;j<n;j++)
            if(j-a[j]>0) c+=hash_getc(j-a[j]);
 
    printf("%ld\n",c);
 
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int W, a, b; cin >> W >> a >> b;
    if(a > b) swap(a, b);
    int ans = max(b - (a + W), 0);
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
const double eps = 1e-9;

int a,c;

int32_t main()
{
	int c = 0, s = 0;
	for(int i=0; i<3; i++)
	{
		cin >> a;
		if(a == 5) c++;
		else if(a == 7) s++;
	}
	
	if(c == 2 and s == 1)
		cout << "YES\n";
	else
		cout << "NO\n";
}

Measured memory_bytes: 256
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int n;
long double x, res;

int main() {
  init_ios();
  cin >> n;
  while (n--) {
    cin >> x;
    res += 1./x;
  }
  res = 1./res;
  cout<<fixed<<setprecision(10)<<res<<"\n";
}

Measured memory_bytes: 256
import sys

isword = True
w = ""
ism = False
m = 0

for l in sys.stdin:
    if l == "-\n":
        break
    elif isword:
        w = str(l).rstrip()
        isword = False
        ism = True

    elif ism:
        m = int(l)
        ism = False

    else:
        frontw = w[:int(l)]
        endw = w[int(l):]
        w = endw + frontw
        m -= 1
        if m == 0:
            print(w)
            isword = True



Measured memory_bytes: 5604
#include <stdio.h>
#include <math.h>

int main(){
    int N, T, A,i;
    long H[1000];
    scanf("%d", &N);
    scanf("%d %d", &T, &A);
    for(i = 0; i < N; i++){
        scanf("%ld", &H[i]);
    }

    // printf("N = %d, T = %d, A = %d\n", N, T, A);
    // for(i = 0; i < N; i++){
    //     printf("H%d = %ld, ", i, H[i]);
    // }
    // printf("\n");
    double cnt, dis = 10000.0;
    int ans;
    for(i = 0; i < N; i++){
        cnt = T - 0.006 * H[i];
        if(dis > fabs(A-cnt)){
            dis = fabs(A-cnt);
            ans = i + 1;
        } 
    }
    printf("%d\n",ans);

    return 0;
}

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

using namespace std;
    int N;
     vector<int>dp(2e5 , -1);   
     vector<int>H(2e5);
      int so(int index){
            if(index == N) return 0;
          if(dp[index] != -1) return dp[index];
          if(index == N-1) return so(index+1) + abs(H[index] - H[index+1]);
        int result = 1e9;
        result = min(so(index+1) + abs(H[index] - H[index+1]),so(index+2) + abs(H[index] - H[index+2]));
        dp[index] = result ;
        return result;
      }


    void solve(){
        cin>>N;
        for(int i = 1; i <= N;++i) cin>>H[i];
        cout<<so(1)<<'\n';
    }

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int tc = 1;
    //cin>>tc;
    while (tc--)
    {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 7056
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;
int n, a, ans;
vector <pair<int, int> > v;

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n;
	for(int i =1; i <= n; i++) {
		cin >> a;
		v.push_back({a, i - 1});
	}
	sort(v.begin(), v.end());

	for(int i = 0; i < v.size(); i++) 
		ans += (v[i].nd % 2 != i % 2);
	cout << ans / 2 << '\n';
}	

	

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

int main(){
    int n,k; cin >> n >> k;
    vi p(n);
    for(int ix=0;ix<n;ix++) cin >> p.at(ix);
    
    sort(p.begin(),p.end());
    int sum=0;
    for(int ix=0;ix<k;ix++) sum += p.at(ix);
    
   cout << sum << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define erep(i, n) for (int i = 0; i <= (int)(n); i++)
using p = pair<ll, ll>;

int main() {
    int n; cin >> n;
    vector<p> arms(n);
    rep (i, n) {
        ll x, l;
        cin >> x >> l;
        arms[i].first = x + l;
        arms[i].second = x - l;
    }
    sort(arms.begin(), arms.end());

    ll ans = 0;
    ll tgt = -(1LL<<60);
    rep (i, n) {
        if (arms[i].second < tgt) continue;
        ans++;
        tgt = arms[i].first;
    }
    cout << ans << endl;
    
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 8;
int g[MAX_N][MAX_N];

int main2() {
  CLR(g, 0);

  int N = nextInt();
  int M = nextInt();

  REP(i, M) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a][b] = 1;
    g[b][a] = 1;
  }
  int ans = 0;
  vector<int> order;
  REP(i, N) order.push_back(i);
  do {
    if (order[0] == 0) {
      bool ok = true;
      REP(i, N-1) {
        if (!g[order[i]][order[i+1]]) ok = false;
      }
      if (ok) {
        ans++;
      }
    }
  } while (next_permutation(ALL(order)));
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B;
    cin >> A >> B;
    string S;
    cin >> S;
    for(int i = 0; i < A+B+1; i++){
        if(i < A && S[i] == '-'){
            cout << "No" << endl;
            return 0;
        }
        if(i == A && S[i] != '-'){
            cout << "No" << endl;
            return 0;
        }
        if(A < i && S[i] == '-'){
            cout << "No" << endl;
            return 0;
        } 
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}


// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;

    ll ans = n;
    while(ans - 1000 >= 0){
        ans -= 1000;
    }
    if(ans == 0){
        ans = 0;
    }else{
        ans = 1000 - ans;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if((a==1&&b==1)||(a==1&&b==2)||(a==1&&b==3)||(a==1&&b==4)||(a==1&&b==5)||(a==1&&b==6)||(a==1&&b==7)||(a==1&&b==8)||(a==2&&b==1)||(a==2&&b==2)||(a==2&&b==3)||(a==2&&b==4)||(a==2&&b==5)||(a==2&&b==6)||(a==2&&b==7)||(a==3&&b==1)||(a==3&&b==2)||(a==3&&b==3)||(a==3&&b==4)||(a==3&&b==5)||(a==3&&b==6)||(a==4&&b==1)||(a==4&&b==2)||(a==4&&b==3)||(a==4&&b==4)||(a==4&&b==5)||(a==5&&b==1)||(a==5&&b==2)||(a==5&&b==3)||(a==5&&b==4)||(a==6&&b==1)||(a==6&&b==2)||(a==6&&b==3)||(a==7&&b==1)||(a==7&&b==2)||(a==8&&b==1)||(a==0&&b==0)||(a==1&&b==0)||(a==2&&b==0)||(a==3&&b==0)||(a==4&&b==0)||(a==5&&b==0)||(a==6&&b==0)||(a==7&&b==0)||(a==8&&b==0)||(a==9&&b==0)||(a==0&&b==1)||(a==0&&b==2)||(a==0&&b==3)||(a==0&&b==4)||(a==0&&b==5)||(a==0&&b==6)||(a==0&&b==7)||(a==0&&b==8)||(a==0&&b==9))
		cout<<a+b<<endl;
	else 
		cout<<"error"<<endl;
		return 0;
} 

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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=2e5+10;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

i32 N;
i64 Ans;
ar A;
map<i32,i32> M;

int main(){
    N=read();
    f(i,1,I,N) A[i]=read(),M[i-A[i]]=0,M[i+A[i]]=0;
    g(i,N,I,1)
        Ans+=M[i+A[i]],M[i-A[i]]++;
    print(Ans);
    output();
    return 0;
}

Measured memory_bytes: 21392
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while (cur != nil && cur->key != key) {
      cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
    if ( t == nil) return ;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void delete(int key){
    deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }
  printList();
  return 0;
}



Measured memory_bytes: 32960
object Main extends App {
  val n = readInt
  val as = Range(0,n).map(t => (readInt, t)).sorted
  val biggest_i = as(n-1)._2
  val biggest = as(n-1)._1
  val second = as(n-2)._1
  println(Range(0,n).map(i=>if(i==biggest_i) second else biggest).mkString("\n"))
}

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

int main(){
int N, i, p=0, q=0; string S; cin >> N >> S;
for(i=0; i<N; i++){ if(S[i]==')'){if(p){p--;}else{q++;}}else{p++;} }
cout << string(q, '(')+S+string(p, ')') << "\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;
using vvi=vector<vi>;


struct v_t
{
	vpii e;
	int s;
	int d;
	v_t() : s(-999999999), d(-1) {}
};


using vvt=vector<v_t>;


void rchk(vvi&v, vi&f)
{
	int n=v.size()-1;
	deque<int> c;

	c.push_back(n);
	f[n]=1;
	while(!c.empty())
	{
		int p=c.front();
		c.pop_front();
		for(int mv:v[p])
		{
			if(!f[mv])
			{
				f[mv]=1;
				c.push_back(mv);
			}
		}
	}
}


int chk(vvt&v, vi&f, int l, int cost)
{
	deque<int> c;

	v[1].s=0;
	v[1].d=0;
	c.push_back(1);
	for(;!c.empty();)
	{
		int p=c.front();
		c.pop_front();

		int d=v[p].d;
		int s=v[p].s;
		if(d>l) return 0;

		for(auto&e:v[p].e)
		{
			int np=e.first;
			int ns=s+e.second-cost;
			if(!f[np]) continue;
			if(v[np].s>=ns) continue;
			v[np].s=ns;
			v[np].d=d+1;
			c.push_back(np);
		}
	}
	return 1;
}


int main(void)
{
	int n, m, p;

	while(scanf("%d%d%d", &n, &m, &p)==3)
	{
		vvt v(n+1);
		vvi rv(n+1);
		vi f(n+1);

		for(int i=0;i<m;i++)
		{
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			v[a].e.push_back(make_pair(b, c));
			rv[b].push_back(a);
		}
		rchk(rv, f);
		int is_limited=chk(v, f, m, p);

		int ans=-1;
		if(is_limited)
		{
			ans=max(v[n].s, 0);
		}
		printf("%d\n", ans);

//for(int i=1;i<=n;i++) printf("%d:%d\n", i, f[i]);
	}
	return 0;
}


Measured memory_bytes: 1536
import sys
o = input ()
e = input ()
for i in range (len(e)):
  sys.stdout.write(o[i])
  sys.stdout.flush()
  sys.stdout.write(e[i])
  sys.stdout.flush()
if len(o) > len(e):
  sys.stdout.write(o[-1])
  sys.stdout.flush()

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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int n; cin >> n;
    vi perm(n), p(n), q(n);
    FOR(i, 0, n - 1) cin >> p[i];
    FOR(i, 0, n - 1) cin >> q[i];
    FOR(i, 0, n - 1) perm[i] = i + 1;
    int a = 0, b = 0;
    vi tt(perm);
    do {
        a++;
        if (tt == p) break;
    } while (next_permutation(all(tt)));
    tt = perm;
    do {
        b++;
        if (tt == q) break;
    } while (next_permutation(all(tt)));
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

int N;
int A[100010];

signed main(){
	cin>>N;
	int cnt=0;
	REP(i,N){
		cin>>A[i];
		if(A[i]<0){
			cnt++;
		}
	}
	if(cnt%2==0){
		int ans=0;
		REP(i,N){
			ans+=abs(A[i]);
		}
		cout<<ans<<endl;
	}
	else{
		int ans=0;
		int Min=INF;
		REP(i,N){
			ans+=abs(A[i]);
			Min=min(Min,abs(A[i]));
		}
		cout<<ans-Min*2<<endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	long long int n;
	cin >> n;
	long long int dp[70] = {};
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		int b = 0;
		while (a > 0) {
			if (a % 2 == 1) {
				dp[b] = dp[b] + 1;
			}
			a = a / 2;
			b++;
		}
	}
	long long int ans = 0;
	long long int ni = 1;
	for (int i = 0; i < 70; i++) {
		ni = ni % MOD;
		long long int s = (n - dp[i]) * dp[i] % MOD;
		long long int k = (s * ni) % MOD;
		ans = (ans + k)%MOD;
		ni = ni * 2;
	}
	cout << ans;
}

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

int main(){
    int a, b;
    cin >> a >> b;

    for(int i=1; i<=1300; i++){
        int tax8 = floor(i * 0.08);
        int tax10 = floor(i * 0.1);
        if(tax8 == a && tax10 == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;

    //最遅である日までにできる仕事の配列
    vector<vector<int>> jobs(M);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        if(a > M) continue;
        //a日後に給料が振り込まれる仕事は、最遅でM-a日目にできる
        jobs[M-a].push_back(b);
    }

    priority_queue<int> q;
    ll ans = 0;
    //最後の日から逆に辿り、その日に出来る仕事のうち
    //最良の仕事を選択する。M日目は仕事をしても意味がないので
    //考えない(A=0である仕事は存在しない)
    for(int i=M-1; i>=0; i--) {

        //最遅でi日目にできる仕事を優先度付きキューに格納
        for(int b : jobs[i]) {
            q.push(b);
        }

        if(!q.empty()) {
            ans += q.top();
            q.pop();
        }
        
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	double a;

	rep(i, n){
		int d;
		cin >> d;
		a += (double)1/d;	
	}

	cout << fixed << setprecision(10) << (double)1/a << endl;

	return 0;

}


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

int main() {
  char b;
  cin >> b;
  map<char, char> mp;
  mp['A'] = 'T';
  mp['T'] = 'A';
  mp['C'] = 'G';
  mp['G'] = 'C';
  cout << mp[b] << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> ans(k+1);
  for(int i=k;i>=1;i--) {
    long long base = k / i;
    long long total = modpow(base, n, MOD);
    for(int j=2;i*j<=k;j++) {
      total -= ans[i*j];
      total %= MOD;
    }
    if(total < 0) total += MOD;
    ans[i] = total;
  }
  long long result = 0;
  for(int i=1;i<=k;i++) {
    result += (long long)i * ans[i];
    result %= MOD;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 4048
s=input()
win=0
ls=0
for i in s:
    if i=='x':
        ls+=1
    else:
        win+=1
if len(s)==15:
    if win>=8:
        print('YES')
    else:
        print('NO')

if len(s) < 15:
    if (win+(15-len(s)))>=8:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 3060
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  val n = readInt
  val a = readLine.split(" ").map(_.toInt)

  println(a.mkString(" "))
  var j = 0
  for(i<-1 until a.length) {
    val key = a(i)
    j = i-1
    while( j >= 0 && a(j) > key ) {
      a(j+1) = a(j)
      j -= 1
    }
    a(j+1) = key

    println(a.mkString(" "))
  }
}

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

using namespace std;

const int N = 81;
const int T = 2 * N * N;
bitset<2 * T> dp[N][N];
int a[N][N];

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

  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      int x;
      cin >> x;
      a[i][j] = abs(a[i][j] - x);
    }
  }
  dp[0][0][T + a[0][0]] = dp[0][0][T - a[0][0]] = 1;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      dp[i + 1][j] |= dp[i][j] >> a[i + 1][j];
      dp[i + 1][j] |= dp[i][j] << a[i + 1][j];
      dp[i][j + 1] |= dp[i][j] >> a[i][j + 1];
      dp[i][j + 1] |= dp[i][j] << a[i][j + 1];
    }
  }
  for (int i = T; i <= 2 * T; ++i) {
    if (dp[h - 1][w - 1][i]) {
      cout << i - T;
      return 0;
    }
  }


  return 0;
}

Measured memory_bytes: 21376
use std::io;

fn main() {
    let mut s = String::new();

    io::stdin().read_line(&mut s)
        .expect("Failed to read line");

    let mut s = s.chars();

    let mut t = String::new();

    io::stdin().read_line(&mut t)
        .expect("Failed to read line");

    let mut t = t.chars();

    let mut c = 0;

    for i in 0..3 {
        if s.next() == t.next() {
            c = c + 1;
        }
    }
    println!("{}", c);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, W;
	cin>>n>>W;
	vector<long long> val, wt;
	for(int i =0;i<n;i++){
		long long kg ,p;
		cin>>kg>>p;
		wt.push_back(kg);
		val.push_back(p);
	}
	long long dp[n+1][W + 1];
	for(int i =0;i<=n;i++)
	{
		for(int w =0; w <= W; w++)
		{
			if(i == 0 || w == 0)
				dp[i][w] = 0;
			else if(wt[i-1] <= w)
				dp[i][w] = max(dp[i-1][w], val[i-1] + dp[i-1][w-wt[i-1]]);
			else
				dp[i][w] = dp[i-1][w];
		}
	}
	cout<<dp[n][W]<<endl;
	return 0;
}

Measured memory_bytes: 79104
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N, M;
    cin >> N >> M;
    VV<ll> task(1e5 + 10);
    for(ll i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        task[a].push_back(b);
    }
    priority_queue<ll> pq;
    ll ans = 0;
    for(ll i = M - 1; i >= 0; i--) {
        ll day = M - i;
        for(auto &&ele : task[day]) pq.push(ele);
        if(pq.size()) {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5632
import bisect

N = int(input())
L = list(map(int, input().split()))

L.sort()

count = 0
for i in range(0, N - 2):
    for p in range(i + 1, N - 1):
        count += bisect.bisect_left(L, L[i] + L[p]) - p - 1
print(count)

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}

int main(){
  int n;
  ll sum = 0;
  cin >> n;
  for(int i = 1;i<n+1;i++){
    for(int j = 1;j<n+1;j++){
      for(int k = 1;k<n+1;k++){
        // puts("a");
        sum += euqlid(i,euqlid(j,k));
      }
    }
  }
  cout << sum << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N) cin >> d[i];
    sort(d.begin(), d.end());
    int left = d[N/2 - 1];
    int right = d[N/2];
    cout << right - left << endl;
    return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint N, K;
    cin >> N >> K;
    vector<lint> A(N, 0);
    rep(i, N) {
        cin >> A[i];
        A[i]--;
    }
    vector<int> path(1, 0);
    set<int> check{0};
    int cn    = 0;
    int start = -1;
    while (true) {
        int nc = A[cn];
        if (check.count(nc)) {
            start = nc;
            break;
        } else {
            path.push_back(nc);
            cn = nc;
            check.insert(nc);
        }
    }
    int x = -1;
    int p = path.size();
    for (int i = 0; i < p; i++) {
        if (path[i] == start) { x = i; }
    }
    if (K < x) {
        cout << path[K] + 1 << endl;
        return 0;
    }
    K -= (lint)x;
    vector<lint> path2(p - x);
    rep(i, path2.size()) { path2[i] = path[i + x]; }
    lint mod = path2.size();
    cout << path2[K % mod] + 1 << endl;
    // dump(path);
    // d(start);
    // dump(path2);
    // d(x);
    return 0;
}


Measured memory_bytes: 14628
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

n, m = map(int, input().split())
c = list(map(int, input().split()))

dp = [[INF] * (n + 10) for _ in range(m + 10)]
for i in range(m+10):
    dp[i][0] = 0
for i in range(1, n + 1):
    if i % c[0] == 0:
        dp[1][i] = i // c[0]
for i in range(2, m + 1):
    for j in range(1, n + 1):
        if j - c[i - 1] >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i][j - c[i - 1]] + 1)
        else:
            dp[i][j] = dp[i-1][j]
print(dp[m][n])


Measured memory_bytes: 50476
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<cmath>
using namespace std;

int main(){
	int n;
	cin >> n;
	printf("ABC%d",n);
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::string s;
    std::cin >> s;
    bool result = true;
    for (int i=0;i<s.length();++i)
    {
        if (i%2 == 0) result &= s[i] != 'L';
        else result &= s[i] != 'R';
    }
    std::cout << (result ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

template<class T>
using Graph = std::vector<std::vector<int>>;

bool dfs(Graph<int> &G, int step, int u, int v,
         std::vector<bool> &visited)
{
    int n = G.size();
    int x = (step < n / 2 ? u : v);
    if (step == n - 1) {
        return true;
    }
    
    bool ret = false;
    for (int next : G[x]) {
        if (!visited[next]) {
            visited[next] = true;

            if (step < n / 2) {
                ret |= dfs(G, step + 1, next, v, visited);
            } else {
                ret |= dfs(G, step + 1, u, next, visited);
            }           
        }        
    }

    return ret;
}

bool solve(Graph<int> &G, int u, int v)
{
    int n = G.size();
    if (n & 1) {
        return false;
    }

    std::vector<bool> visited(n, false);
    visited[u] = visited[v] = true;
    return dfs(G, 1, u, v, visited);
}

int main()
{
    int n, u, v;
    std::cin >> n >> u >> v;
    u--; v--;
    
    Graph<int> G(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        std::cin >> a >> b;
        a--; b--;

        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    std::cout << (solve(G, u, v) ? "Yes" : "No") << std::endl;
    
    return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int n;
    cin >> n;

    int cnt = 0;
    rep(1, n + 1) if (i % 2 != 0) cnt++;

    cout << (double(cnt) / double(n)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int xmax = -100;
  int ymin = 100;

  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (xmax < x) xmax = x;
  }
  for (int i = 0; i < M; i++) {
    int y;
    cin >> y;
    if (y < ymin) ymin = y;
  }

  if (X < ymin and xmax < ymin and xmax < Y) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] HW = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            List<string> checkH = new List<string>(); 
            for(int j = 0; j < HW[0]; j++)
            {
                //横列確認
                string s = Console.ReadLine();
                if (s.IndexOf("#") != -1)
                {
                    //横に1つも#がない列は加えない
                    checkH.Add(s);
                }
            }
            //縦列確認
            List<Boolean> ch = new List<Boolean>();
            //1つずつ見ていく
            for (int q = 0; q < HW[1]; q++)
            {
                int cnt = 0;
                for (int z = 0; z < checkH.Count(); z++)
                {
                    if (checkH[z].Substring(q, 1) != "#")
                    {
                        cnt++;
                    }
                }
                if (cnt == checkH.Count())
                {
                    ch.Add(false);
                }
                else
                {
                    ch.Add(true);
                }
            }
            //出力
            //リスト内falseの桁を弾く
            for(int m=0;m< checkH.Count(); m++)
            {
                int ppp = ch.Count();
                int count = 0;
                for (int d = 0; d < ppp; d++)
                {
                    if (ch[d + count] == false)
                    {
                        //falseの桁を取り除く 
                        checkH[m] = checkH[m].Remove(d, 1);
                        d--;
                        ppp--;
                        count++;
                    }
                }
            }
            for(int f = 0; f < checkH.Count(); f++)
            {
                Console.WriteLine(checkH[f]);
            }
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 28664
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/
 
struct edge {
    int next,to;
};
 
const int maxn=(int)(1e5)+5;
int a[maxn];
int fr[maxn];
edge e[maxn<<1];
int n,m,tote=0;
 
inline void addedge(int u,int v) {
    ++tote;
    e[tote].next=fr[u];fr[u]=tote;e[tote].to=v;
}
 
int res;
int dfs(int x,int f) {
    int now=1;
    RAL(i,x) {
        now=max(now,dfs(e[i].to,x)+1);
    }
    if((now==m && f && f!=1)) {
        now=0;++res;
    } return now;
}
 
int main() {
    read(n);read(m);
    REP(i,1,n) read(a[i]);
    res=(a[1]!=1);
    memset(fr,-1,sizeof(fr));
    REP(i,2,n) addedge(a[i],i);
    dfs(1,0);printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 6528
s=input()
a=int(s)
b=0
if a<10:
  b=a
elif 10<=a<100:
  b=9
elif 100<=a<1000:
  b=a-90
elif 1000<=a<10000:
  b=909
elif 10000<=a<100000:
  b=a-9999+909
elif 100000<=a<1000000:
  b=90909
else:
  b=a-909090
print(b)

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

const int MAXN = 100001;
typedef long long ll;
#define f first
#define s second
const ll mod = 1e9+7;

int main(){
    char s[3001],t[3001];
    scanf("%s %s",s,t);
    int N = strlen(s), M = strlen(t);
    int dp[N+1][M+1];
    pair<int,int> lst[N+1][M+1];
    memset(dp,0,sizeof dp);
    for (int i=0;i<=N;i++){
        for (int j=0;j<=M;j++){
            lst[i][j] = {-1,-1};
        }
    }
    for (int i=1;i<=N;i++){
        for (int j=1;j<=M;j++){
            if (s[i-1]==t[j-1]){
                if (dp[i-1][j-1]+1>dp[i][j]){
                    dp[i][j] = dp[i-1][j-1]+1;
                    lst[i][j] = {i-1,j-1};
                }
            }else{
                if (dp[i-1][j-1]>dp[i][j]){
                    dp[i][j] = dp[i-1][j-1];
                    lst[i][j] = {i-1,j-1};
                }
            }
            if (dp[i-1][j]>dp[i][j]){
                dp[i][j] = dp[i-1][j];
                lst[i][j] = lst[i-1][j];
            }
            if (dp[i][j-1]>dp[i][j]){
                dp[i][j] = dp[i][j-1];
                lst[i][j] = lst[i][j-1];
            }
        }
    }
    pair<int,int> c = {N,M};
    vector<char> ans;
    while (lst[c.f][c.s].f!=-1){
        c = lst[c.f][c.s];
        if (s[c.f]==t[c.s]){
            ans.push_back(s[c.f]);
        }
    }
    for (int i=ans.size()-1;i>=0;i--){
        printf("%c",ans[i]);
    }
    printf("\n");
}


Measured memory_bytes: 105856
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

int main()
{
    int k,x;
    cin >> k >> x;

    for(int i = -k+1; i < k; i++) cout << x+i << " ";
    cout << endl;


    return 0;
}


Measured memory_bytes: 256
#define REP(i,n) for (int i=0;i<(n);i++)
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 25;
typedef pair<int,int> P;

int n;
int v,l;
P p[MAX_N]; //(?¨±??????,???????????????)

void solve(){
	int accum = 0;
	sort(p,p+n);
	REP(i,n){
		accum += p[i].second;
		if (accum <= p[i].first){
			continue;
		}else{
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;
	return;
}

int main(){
	while(1){
	    cin >> n;
	    if (n == 0) break;
		REP(i,n){
			cin >> v >> l;
			p[i] = P(l,v);
		}
		solve();
	}
}

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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)

int main()
{
	int a, b;
	cin >> a >> b;
	a %= 500;
	if (a <= b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

struct triple {
    ll aa;
    ll bb;
    ll cc;
    bool operator<(const triple &tt) {
        if (aa != tt.aa) {
            return (aa < tt.aa);
        }
        if (bb != tt.bb) {
            return (bb < tt.bb);
        }
        return cc < tt.cc;
    }
    bool operator==(const triple &tt) {
        return (aa == tt.aa &&
                bb == tt.bb &&
                cc == tt.cc);
    }
    bool operator>(const triple &tt) { return !(*this == tt) && !(*this < tt); }
    bool operator!=(const triple &tt) { return !(*this == tt); }
    bool operator>=(const triple &tt) { return (*this == tt) || (*this > tt); }
    bool operator<=(const triple &tt) { return (*this == tt) || (*this < tt); }
};

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> RA(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (ll i = 0; i < N; i++) {
        RA[i] = A[N - i - 1];
    }

    ll result = 0;

    map<ll, vector<ll>> party;
    for (ll i = 0; i < N; i++) {
        ll pt = A[i] - i;
        party[pt].push_back(i);
    }
    for (ll i = 0; i < N; i++) {
        ll tgtp = -i - A[i];
        if (!party.count(tgtp)) {
            continue;
        }
        ll cnt = party[tgtp].end() - upper_bound(party[tgtp].begin(), party[tgtp].end(), i);
        //   print(i + 1, cnt);
        result += party[tgtp].end() - upper_bound(party[tgtp].begin(), party[tgtp].end(), i);
    }

    // map<ll, vector<ll>> rparty;
    // for (ll i = 0; i < N; i++) {
    //     ll pt = RA[i] - i;
    //     rparty[pt].push_back(i);
    // }
    // for (ll i = 0; i < N; i++) {
    //     ll tgtp = -i - RA[i];
    //     if (!party.count(tgtp)) {
    //         continue;
    //     }
    //     //result += rparty[tgtp].end() - upper_bound(rparty[tgtp].begin(), rparty[tgtp].end(), i);
    // }
    print(result);
}


Measured memory_bytes: 26672