akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int c = 0;  //count prime numbers

void pri_num(int a);

int main () {
    int a,times,i; 
    
    scanf ("%d",&times); //how many times
    for (i = 0;i < times;i ++) {
        scanf ("%d",&a); 
        pri_num(a);
    }
    
    printf ("%d\n",c);
    
    return 0;
}
    
void pri_num(int a) {
    int i;
    
    if  (a == 2) {
        c ++;
    }
    if (a % 2 != 0 && a > 2) {
        for (i = 3;i * i <= a;i += 2) { //i < a 
        //i=1とやると事故る
            if (a % i == 0) { //if i=0 floating point exception
                c --;
                break;
            }
        }
        c ++;
    }
    
}


Measured memory_bytes: 2124
#include<stdio.h>
int main (void)
{
    int N,M,i,c=0;
    scanf("%d %d",&N,&M);
    int A[N];
    long S=0;
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
        S+=A[i];
    }
    for(i=0;i<N;i++){
        if(S<=A[i]*4*M)c++;
    }
    if(c>=M)puts("Yes");
    else puts("No");
    return 0;
}

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

string S;

int main() {
    cin >> S;

    int ans = 0;
    int i = 0;
    int j = S.length() - 1;
    while (i < j) {
        if (S[i] == S[j]) {
            i++;
            j--;
        }
        else {
            if (S[i] == 'x') {
                ans++;
                i++;
            }
            else if (S[j] == 'x') {
                ans++;
                j--;
            }
            else {
                ans = -1;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int x = log10(N) + 1;
  if(x == 1)
    cout << N << endl;
  else if(x == 2)
    cout << 9 << endl;
  else if(x == 3)
    cout << 9 + N - 99 << endl;
  else if(x == 4)
    cout << 909 << endl;
  else if(x == 5)
    cout << 909 + N - 9999 << endl;
  else
    cout << 90909 << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
  int A[100][100];
  int n, i, j, k, u, v;

  scanf("%d", &n);

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

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

  for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
      printf("%d", A[i][j]);
      if(j != n-1)
        printf(" ");
    }
    putchar('\n');
  }

  return 0;
}

Measured memory_bytes: 1820
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  string s;
  cin >> s;
  ll ans=700;
  for(ll i=0;i<3;i++)if(s[i]=='o')ans+=100;
  cout << ans << endl;

}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

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

const ll mod = 1e9 +7;

int main() {
    
    
    ll n;
    cin >> n;
    
    vector<ll> l(n);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> l[i];
    }
    
    sort(l.begin(), l.end());
    
    ll ret = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = i + 1; j < n; ++j)
        {
            ll pos1 = upper_bound(l.begin(), l.end(), l[i] - l[j]) - l.begin();
            ll pos2 = lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
            
            pos1 = max((int)pos1, j + 1);
            ret += (pos2 - pos1);
        }
    }
    
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int h,w;
	int x,y;
	while(1){
	scanf("%d",&h);
	scanf("%d",&w);
	if(h==0 && w==0){
		break;
	}
	for(y=0;y<h;y++){
		for(x=0;x<w;x++){
			if(y==0||y==h-1||x==0||x==w-1){
				printf("#");
			}else{
				printf(".");
			}
		}
		printf("\n");
	}
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 568
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll 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] % INF) % INF;
}
///////////////////////////////////////

int main() {
	string s; cin >> s;
	bool ok = true;
	if (s[2] != s[3])ok = false;
	if (s[4] != s[5])ok = false;
	if (ok)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

using int64 = long long;

const int mod = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  std::vector<int> x(n), inv(n, 1);
  for (int i = 0; i < n; ++i) scanf("%d", &x[i]);
  for (int i = 2; i < n; ++i) {
    inv[i] = int64(mod - mod / i) * inv[mod % i] % mod;
  }
  int64 ret = 0, sum = 0;
  for (int i = 0; i + 1 < n; ++i) {
    sum += inv[i + 1];
    sum %= mod;
    ret += (x[i + 1] - x[i]) * sum % mod;
  }
  ret %= mod;
  for (int i = 1; i < n; ++i) ret = ret * i % mod;
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define sll            set<ll int>
#define msll        multiset<ll int>
#define io    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main()
{
    io
    ll i,j,a[6],k;
    for(i=0;i<5;i++) cin>>a[i];
    cin>>k;
    if((*max_element(a,a+5))-(*min_element(a,a+5))>k) cout<<":(";
    else cout<<"Yay!";

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		long m = saori.saori_hayami();
		Map<Integer,Long> num = new HashMap<>();
		for(int i = 0;i < n;i++){
			int a = saori.saori_hayami();
			long b = saori.saori_hayami();
			if(num.containsKey(a)){
				long value = num.get(a);
				value += b;
				num.put(a, value);
			} else {
				num.put(a, b);
			}
		}
		Object[] mapkey = num.keySet().toArray();
		Arrays.sort(mapkey);
		long ans = 0;
		for(Object obj : mapkey){
			String objStr = obj.toString();
			int key= new Integer(objStr);
			long value = num.get(key);
			if(m <= 0)break;
			if(value < m){
				m -= value;
				ans += (value*key);
			} else {
				ans += (m*key);
				m = 0;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 46460
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;

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

    ll n, m, s;
    cin >> n >> m >> s;
    s = min(s, MAX - 1);

    vector<vector<P>> edge(n * MAX);
    for (int i = 0; i < m; i++) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        for (int j = a; j < MAX; j++) {
            edge[u * MAX + j].push_back({v * MAX + j - a, b});
            edge[v * MAX + j].push_back({u * MAX + j - a, b});
        }
    }

    for (int i = 0; i < n; i++) {
        ll c, d;
        cin >> c >> d;
        for (int j = 0; j < MAX; j++) {
            edge[i * MAX + j].push_back({i * MAX + min(j + c, MAX - 1), d});
        }
    }

    vector <ll> ans(n * MAX, 1LL << 60);
    priority_queue <P, vector<P>, greater<P>> q;
    ans[s] = 0;
    q.push({0, s});

    while (!q.empty()) {
        P p = q.top();
        q.pop();
        ll time = p.first;
        int cur = p.second;
        if (ans[cur] < time) continue;
        for (P nxt : edge[cur]) {
            int next_node = nxt.first;
            ll total_time = time + nxt.second;
            if (ans[next_node] > total_time) {
                ans[next_node] = total_time;
                q.push({total_time, next_node});
            }
        }
    }

    for (int i = 1; i < n; i++) {
        ll mn = 1LL << 60;
        for (int j = 0; j < MAX; j++) mn = min(mn, ans[i * MAX + j]);
        cout << mn << '\n';
    }
    return 0;
}


Measured memory_bytes: 23932
#include <iostream>
#include <cstdlib>
#include <string>

void alphabetCase(char &moji); 
void change(std::string &str); 

int main(void) {
    std::string target;
    std::getline(std::cin, target);
    change(target);
    std::cout << target << std::endl;

    return EXIT_SUCCESS;
}

void alphabetCase(char &c) {
    int ascii = (int)(c);
    int diff = int('a') - int('A');
    if (ascii >= int('A') && ascii <= int('Z')) {
        ascii += diff;
    } else if (ascii >= ('a') && ascii <= ('z')) {
        ascii -= int('a') - int('A');
    }
    c = (char)(ascii);
    return; 
}

void change(std::string &str) {
    int size = (int)(str.size());
    for (int loop = 0; loop < size; loop++) {
        alphabetCase(str[loop]);     
    }
    return;
}

Measured memory_bytes: 3156
// AOJ 2494 Sliding GCD
// 2018.3.18 bal4u

#include <stdio.h>

//#define putchar_unlocked(x)  putchar(x)

void out(int n)
{
	int rev, c;
    if (!n) { putchar_unlocked('0'); return ; }
	c = 0, rev = n;
	while (!(rev % 10)) c++, rev /= 10;
	rev = 0;
	while (n) rev = 10*rev + n % 10, n /= 10;
	while (rev) putchar_unlocked(rev % 10 + '0'), rev /= 10;
    while (c--) putchar_unlocked('0');
}

#define MAX   100000
#define DMAX     130	// max 126

int   t[MAX+1][DMAX+1]; short w[MAX+1];
short c[MAX+1];

void divisor_tble(int N)
{
	int i, k, n = (N>>1)+1;
	for (i = 2; i <= n; i++) {
		for (k = i<<1; k <= N; k += i) t[k][w[k]++] = i;
	}
}

int main()
{
	int  N, W, nw;
	int i, k, lo, hi, ans;

	scanf("%d%d", &N, &W), nw = N-W+1;
	if (W == 1) {
		putchar_unlocked('1');
		for (k = 2; k <= nw; k++) putchar_unlocked(' '), putchar_unlocked('1');
		putchar_unlocked('\n');
		return 0;
	}

	divisor_tble(N);

	out(W);
	ans = 1;
	for (k = 1; k <= W; k++) {
		c[k] += 2; ans++;
		for (i = 0; i < w[k]; i++) if (++c[t[k][i]] == 2) ans++;
	}

	lo = 1, hi = W;
	for (k = 2; k <= nw; k++) {
		for (i = 0; i < w[lo]; i++) if (--c[t[lo][i]] == 1) ans--;
		c[lo] -= 2; if (c[lo] < 2) ans--;
		lo++, hi++;
		c[hi] += 2; if (c[hi] == 2) ans++;
		for (i = 0; i < w[hi]; i++) if (++c[t[hi][i]] == 2) ans++;
		putchar_unlocked(' '), out(ans);
	}
	putchar_unlocked('\n');
	return 0;
}


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

#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define endl        '\n'
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

namespace InOp{
template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
}
using namespace InOp;

namespace ModOp{
template<class x,class y,class z> z add(x a,y b,z m){return (a+b)%m;}
template<class x,class y,class z> z sub(x a,y b,z m){return (a-b+m)%m;}
template<class x,class y,class z> z mul(x a,y b,z m){return ((ll)a*b)%m;}
template<class y,class z> z expo(ll b,y e,z m){ll a=1;b%=m;while(e!=0){if((e&1)==1){a=a*b;a=a%m;}b=b*b;b%=m;e>>=1;}return a%m;}
template<class x,class z> z inv(x b,z m){return expo(b,m-2,m);}
template<class x,class y> x invGeneral(x a,y b){if(a==0)return b==1?0:-1;x m=invGeneral(b%a,a);return m==-1?-1:((1-(ll)b*m)/a+b)%b;}
template<class x,class y,class z> z div(x a,y b,z m){ll c=inv(b,m);return mul(a,c,m);}
}
using namespace ModOp;

namespace Debug{
template<class x> void deb(x a){cerr<<"a"<<": "<<a<<endl;}
template<class x,class y> void deb(x a,y b){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<endl;}
template<class x,class y,class z> void deb(x a,y b,z c){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<endl;}
template<class x,class y,class z,class xy> void deb(x a,y b,z c,xy d){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<" | "<<"d"<<": "<<d<<endl;}
}
using namespace Debug;

#define N  1000005

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,r,x,y,m,n;
    	string s;
    	cin>>x>>s;
    	y=s[0]-'0';
    	ll ans=x*y;
    	m=0;
    	m=s[2]-'0';
    	m=m*10;
    	m+=s[3]-'0';
    	// cout<<m<<endl;
    	n=x*m;
    	n/=100;
    	ans+=n;
    	cout<<ans;
    }
    return 0;
}

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

int main() {
  int n;
  bool f=false;
  string ans="No";

  cin >> n;

  for(int i=0;i<3;i++) {
    if(n%10==7) {f=true;break;}
    n/=10;
  }

  if(f) ans="Yes";

  cout <<ans<<  endl;

  return 0;
}


Measured memory_bytes: 3624
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int K,N;cin>>K>>N;
  int A[K+10];
  int B[K+10];
  REP(i,N) {
    cin>>A[i];
  }
  B[0]=0;
  for(int i=1;i<N;++i) {
    B[i]=A[i]-A[i-1];
  }
  B[N] = K - A[N-1] + A[0];
  int max_b = 0;
  REP(i,N+1) {
   if(max_b < B[i]) max_b = B[i];
  }
  p(K-max_b);
  return 0;
}



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

#define lint long long


signed main() {
    int c[3][3];

    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            cin >> c[i][j];
        }
    }

    bool flag = true;

    for(int i = 0; i < 2; ++i){
        int tmp = c[i + 1][0] - c[i][0];
        for(int j = 1; j < 3; ++j){
            if(c[i + 1][j] - c[i][j] != tmp){
                flag = false;
            }
        }
    }

    if(flag){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
using System;class A{static void Main(){var p = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);int N = p[0];int M = p[1];int K = p[2];for(var i = 0; i <= N; i++) { for(var j = 0; j <= M; j++) { if (K == (i * M + j * N - 2 * i * j)) { Console.WriteLine("Yes");return; } } }Console.WriteLine("No");}}



Measured memory_bytes: 13140
N,M=map(int,input().split())
X=list(map(int,input().split()))

if N>=M:
  print(0)
  exit()

X = sorted(X)

diff=[]
for i in range(1,M):
  diff.append(X[i]-X[i-1])

diff = sorted(diff)
print(sum(diff[:M-N]))

Measured memory_bytes: 20488
using System;

namespace pro
{



    class MainClass
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] h = new int[n];
            for(int i = 0; i < n; i++)
            {
                h[i] = int.Parse(str[i]);
            }

            int tmpcount = 0;
            int count = 0;
          
            for (int i = 0; i < n - 1; i++)
            {


                if (h[i] >= h[i + 1])
                {
                    tmpcount++;
                }
                else
                {
                    tmpcount = 0;
                }
                if (count <= tmpcount)
                {
                    count = tmpcount;
                }


                
                
              

            }



                Console.WriteLine(count);

        }

    }


}

Measured memory_bytes: 27100
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll M,K; cin >> M >> K;
    ll Max = 1LL<<M;
    if(Max <= K) return vector<ll>{-1};
    ll N = 1LL<<(M+1);
    res.resize(N);
    if(K == 0){
        for(ll i = 0; i < N;i+=2){
            res[i] = res[i+1] = i/2;
        }
    }else{
        res[0] = K;
        res[N/2] = K;
        
        ll XOR = 0;
        for(ll n = 0; n < Max; n++){
            if(n == K) continue;
            XOR ^= n;
        }
        if(XOR != K) return vector<ll>{-1};
        ll cnt = 0;
        for(ll n = 0; n < Max; n++){
            if(n == K) continue;
            res[cnt+1]  = res[N-1-cnt] = n;
            cnt++;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<vector<ll>>() << endl;
    return 0;
}


Measured memory_bytes: 3840
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll a[51];
int main()
{
	ll n;
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	ll dap = 0;
	while (1)
	{
		int check = 0;
		ll ch = 0;
		for (int i = 1; i <= n; i++)
		{
			ch += (a[i] / n);
			if (a[i] < n)
				check++;
		}
		if (check == n)break;
		dap += ch;
		for (int i = 1; i <= n; i++)
		{
			a[i] = ch - (a[i] / n)+(a[i]%n);
		}
	}
	printf("%lld\n", dap);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long int i,n,a,m,g,b[100000];
int main(void)
{
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		m=0;
		g=0;
		for(i=0;i<n;i++){
			scanf("%d",&a);
			m+=a;
		}
		for(i=0;i<n-1;i++){
			scanf("%d",&b[i]);
		}
		sort(b,b+(n-1));
		b[n-1]=0;
		for(i=n-1;i>=0;i--){
			if(g<(m+b[i])*(i+1)){
				g=(m+b[i])*(i+1);
			}
			m+=b[i];
		}
		printf("%lld\n",g);
	}
	return 0;
}


Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<deque>
 
using namespace std;
typedef long long ll;
 
int main(void)
{
    ll N;
    cin >> N;

    map<ll, vector<ll>> B_A;

    for(ll i = 0; i < N; i++)
    {
        ll _A, _B;
        cin >> _A >> _B;
        
        if(B_A.count(_B) == 0)
        {
            vector<ll> A{_A};
            B_A.insert(make_pair(_B, A));
        }
        else
        {
            B_A[_B].push_back(_A);
        }
    }

    ll current_time = 0;

    for(auto iterator : B_A)
    {
        vector<ll> A = iterator.second;
        sort(A.begin(), A.end());

        for(auto _A : A)
        {
            current_time += _A;
            if(current_time > iterator.first)
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;



    // multimap<ll, ll> B_A;

    // for(ll i = 0; i < N; i++)
    // {
    //     ll _A, _B;
    //     cin >> _A >> _B;
    //     B_A.insert(make_pair(_B, _A));
    // }

    // map<ll, ll> B_count;
    // vector<ll> sorted_A;
    // vector<ll> sorted_B;

    // for(auto iterator : B_A)
    // {
    //     sorted_A.push_back(iterator.second);

    //     if(B_count.count(iterator.first) == 0)
    //     {
    //         B_count.insert(make_pair(iterator.first, 1));
    //         sorted_B.push_back(iterator.first);
    //     }
    //     else
    //     {
    //         B_count[iterator.first]++;
    //     }
    // }

    // sort(sorted_A.begin(), sorted_A.end());

    // ll current_time = 0;
    // ll i_A = 0;

    // for(ll _B : sorted_B)
    // {
    //     for(ll i = 0; i < B_count[_B]; i++)
    //     {
    //         current_time += sorted_A[i_A++];
    //         if(current_time > _B)
    //         {
    //             cout << "No" << endl;
    //             return 0;
    //         }
    //     }
    // }

    // cout << "Yes" << endl;
}

Measured memory_bytes: 22144
# coding:utf-8
n = input()
R = []
for i in range(n):
    R.append(input())
minv = R[0]
maxv = -999999999
for j in range(1,n):
    maxv = max(maxv,R[j]-minv)
    minv = min(minv,R[j])
print maxv

Measured memory_bytes: 17284
#include<iostream>
#include<vector>
#include<algorithm>


using namespace std;

template<typename input_Integer>
vector<input_Integer> is_Prime(input_Integer N){


    vector<input_Integer> Prime;
    vector<bool> check(N+1,true);
    check[0]=false;
    check[1]=false;


    for(input_Integer i = 2; i * i <= N; ++i){
        if(check[i]){
            for(input_Integer k = i * 2; k < N; k += i){
                check[k] = false;
            }
        }
    }
    for (int i = 0; i < check.size(); i++){
    	if (check[i]) Prime.push_back(i);
    }


    return Prime;
}


int main(){
    int Q;
    cin>>Q;
    vector<int> Prime;
    Prime=is_Prime(100000);
    vector<bool> check(100005);

    for(int x :Prime){
        check[x]=true;
    }

    for(int i=check.size()-1;i>=0;--i){
        if(check[i]){
            check[i]=check[(i+1)/2];
        }
    }
    
    vector<int> niteru;

    for(int i=0;i<check.size();++i){
        if(check[i]){
            niteru.emplace_back(i);
        }
    }

    int l,r;
    for(int i=0;i<Q;++i){
        cin>>l>>r;
        int ans=upper_bound(niteru.begin(),niteru.end(),r)-lower_bound(niteru.begin(),niteru.end(),l);

    cout<<ans<<endl;

    }

}


Measured memory_bytes: 768
#include<iostream>

using namespace std;

int main(){
  int a[6];
  int mx=0,t=0;
  for(int i=0;i<5;i++){
    cin>>a[i];
    if(10-(a[i]%10)>10-(a[mx]%10) && a[i]%10!=0) mx=i;
  }
  for(int i=0;i<5;i++){
    if(i==mx) continue;
    if(a[i]%10==0) t+=a[i];
    else t+=10-(a[i]%10)+a[i];
  }
  cout<<t+a[mx]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#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 REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=5005,mod=1e9+7;
int f[N][N][2],g[N][N],h[N],n,A,B;

void add(int &x,int y){
	x=(x+y>=mod?x+y-mod:x+y);
}

int main(){
	read(n),read(A),read(B);
	if(A<B) swap(A,B);

	add(f[1][1][0],1);
	rep(i,1,n){
		if(i<B) add(f[i][0][1],1);
		else add(f[i][i][1],1);
	}

	rep(i,1,n){
		add(h[i],h[i-1]);
		add(f[i][0][1],h[i]);

		add(f[i+1][1][0],f[i][0][1]);
		
		rep(j,1,A-1){
			add(g[i][j],g[i-1][j-1]);
			add(f[i][j][1],g[i][j]);

			add(h[i+1],f[i][j][0]);
			add(h[min(n+1,i+B)],mod-f[i][j][0]);
			add(f[i+1][j+1][0],f[i][j][0]);
			if(i+B<=n){
				add(g[i+B][j+B],f[i][j][0]);
			}
						
			add(f[i+1][j+1][0],f[i][j][1]);
		}
	}

	int ans=0,tot=1;
	rep(i,1,n){
		tot=2ll*tot%mod;
	}
	rep(j,0,A-1){
		add(ans,f[n][j][0]);
		add(ans,f[n][j][1]);
	}
	ans=((tot+mod-ans)%mod+mod)%mod;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 296872
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def get_all_members(self):
        pare_d = {}
        for i in range(self.n):
            parent = self.find(i)
            pare_d.setdefault(parent,[])
            pare_d[parent].append(i)
        return list(pare_d.values())

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())



def main():
    n,m = map(int, input().split())
    al = list(map(int, input().split()))    
    uf = UnionFind(n)
    for _ in range(m):
        x,y = map(int, input().split())
        uf.union(x,y)

    first_mins = []
    other_vals = []
    
    all_members = uf.get_all_members()
    if len(all_members) == 1:
        print(0)
        exit()

    for members in all_members:
        vs = []
        for m in members:
            vs.append(al[m])
        vs.sort()
        first_mins.append(vs[0])
        for i,v in enumerate(vs[1:]):
            # if i > 0:
            other_vals.append(v)

    # print(first_mins)
    ans = 0
    ans += sum(first_mins)
    rem = len(all_members)-2
    if len(other_vals) < rem:
        print('Impossible')
        exit()
    other_vals.sort()
    ans += sum(other_vals[:rem])
    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 109552
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
 
public class Main {
	
	public static class Score implements Comparable<Score> {
		long point;
		int dir, pos;
		
		public Score(long point, int dir, int pos){
			this.point = point;
			this.dir = dir;
			this.pos = pos;
		}

		@Override
		public int compareTo(Score o) {
			return Long.compare(this.point, o.point);
		}
	}
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int W = sc.nextInt();
		final int H = sc.nextInt();
		
		long[] ps = new long[W];
		long[] qs = new long[H];
		for(int i = 0; i < W; i++){
			ps[i] = sc.nextLong();
		}
		for(int i = 0; i < H; i++){
			qs[i] = sc.nextLong();
		}
		//System.out.println(Arrays.toString(ps) + " " + Arrays.toString(qs));
		PriorityQueue<Score> queue = new PriorityQueue<Score>();
		
		for(int i = 0; i < W; i++){
			queue.add(new Score(ps[i], 0, i));
		}
		for(int j = 0; j < H; j++){
			queue.add(new Score(qs[j], 1, j));
		}
		
		long answer = 0;
		int w_count = 0, h_count = 0;
		
		while(!queue.isEmpty()){
			final Score score = queue.poll();
			
			if(score.dir == 0){
				answer += score.point * ((H + 1) - h_count);
				w_count++;
			}else{
				answer += score.point * ((W + 1) - w_count);
				h_count++;
			}
			
			//System.out.println(score.point + " " + score.dir + " " + answer);
		}
		
		System.out.println(answer);
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}	
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 37076
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli x;
	cin >> x;
	for (int a = -1000; a<1000; ++a){
		lli a5 = 1;
		rep(i,5) a5*=a;
		for(int b = -1000; b < 1000; ++b){
			lli b5 = 1;
			rep(i,5) b5*=b;
			if(a5 - b5 == x){
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
using P=pair<int,int>;

#define _ cin.tie(0);ios::sync_with_stdio(false);
int MAXN=100111;

int main(){_
  
  int n,ans;
  ans=0;
  cin>>n;
  
  for(int i=0;i<n;i++){
    int l,r;
    cin>>l>>r;
    ans+=r-l+1;
  }
  cout<<ans<<endl;
    
    
  return 0;
}
  



  

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

using namespace std;

int main() {
    string str;
    cin >> str;
    
    vector<int> dir;
    vector<int> dir_cnt;
    
    bool ans=true, flag;
    
    for(int i=0; i<4; i++) {
        int tmp=str[i];
        // cout << "tmp = " << tmp << endl;
        if(i==0) {
            dir.push_back(tmp);
            dir_cnt.push_back(1);
        } else {
            int dir_size=dir.size();
            // cout << "dir size = " << dir_size << endl;
            flag = false;
            for(int j=0; j<dir_size; j++) {
                // cout << "cmp dir & tmp : dir = " << dir[i] << ", tmp = " << tmp << endl;
                if(dir[j]==tmp) {
                    // cout << "dir_cnt[" << i << "] = " << dir_cnt[i] << " -> " << dir_cnt[i]+1\
                    << endl;
                    dir_cnt[j]++;
                    flag = true;
                }
            }
            if(flag) {
                continue;
            } else {
                dir.push_back(tmp);
                dir_cnt.push_back(1);
            }
        }
    }

    
    if(dir.size()!=2) {
        ans = false;
    } else {
        if(dir_cnt[0]==1 || dir_cnt[0]==3) {
            ans = false;
        }
    }

    if(ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
    
}

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

using namespace std;

int main(){
  	int x;
  	int sum = 0;
   for(int i=0;i<5;i++){
     cin>>x;
     sum+=x;
   }
  sum = 15 -sum;
  cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define MOD 1000000007

using namespace std;



int main() {

	int n; cin >> n;
	vector<int> p(n);

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

	int ans = 0;
	if (p[0] == 1) {
		swap(p[0],p[1]);
		ans++;
	}
	for (int i = 1; i < n-1; i++) {
		if (p[i] == i+1 and p[i+1] == i+2) {
			swap(p[i],p[i+1]);
			ans++;
		}else if (p[i] == i+1) {
			swap(p[i],p[i-1]);
			ans++;	
		}
	}
	if (p[n-1] == n) {
		swap(p[n-1],p[n-2]);
		ans++;
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
typedef vector<int> vi;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n; cin >> n;
    vi recording(100010, 0);
    vi a(n); rep(i,n) cin >> a[i];
    for(int i : a){
        recording[i]++;
        recording[i+1]++;
      	if(i!=0) recording[i-1]++;
    }
    
    cout << *max_element(recording.begin(), recording.end()) <<'\n';
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


ll h;
void solve() {
    cin >> h;

    ll ans = 0;
    ll cnt = 1;
    while (h != 0) {
        ans += cnt;
        cnt *= 2;
        h /= 2;
    }

    cout << ans << endn;

}

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


Measured memory_bytes: 256
def isPrime(x):
    if x > 2 and x % 2 == 0:
        return False
    if x == 1:
        return True
    for a in range(3,round(x**(1/2))+1,2):
        if x % a == 0:
            return False
    return True

n = int(input())

R= []
for a in range(n):
    R.append(int(input()))


# pattern1
min_R = []
min = 10**9
for a in R:
    if a < min:
        min = a
    min_R.append(min)
#print(min_R)
#print(R)
R.pop(0)
calculated = [a-b for (a,b) in zip(R,min_R)]

print(max(calculated))
'''
minv = 999999999999
maxv = R[1]-R[0]
for a in range(len(R)):
    maxv = max(maxv, R[a]-minv)
    minv = min(minv, R[a])
    # print(f'{maxv} {minv}')
print(maxv)
'''




Measured memory_bytes: 23116
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

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

	int cnt = 0;

	rep(pass, 1000) {
		int c[3];
		c[0] = pass/100;
		c[1] = (pass-c[0]*100)/10;
		c[2] = pass%10;
		int j = 0;
		
		rep(i, N) {
			if(c[j] == S[i]-'0') {
				j++;
				if(j==3) {
					cnt++;
					break;
				}
			}
		}

	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [0] + A

Root = []
Visited = [0 for _ in range(N+1)]

now = 1
after = A[now]
while Visited[now] == 0:
    Root.append(now)
    Visited[now] = 1
    now = after
    after = A[now]
ind = Root.index(now)
Init = Root[:ind]
Loop = Root[ind:]

if K <= len(Init)-1:
    print(Init[K])
else:
    print(Loop[(K-len(Init))%len(Loop)])

Measured memory_bytes: 117028
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#define pb push_back
using namespace std;

struct rec{
  int t,n,m,s;
  rec(int a,int b,int c,int d){t=a;n=b;m=c;s=d;}
};
struct query{
  int ts,te,m;
  query(int a,int b,int c){ts=a;te=b;m=c;}
};
int main(void){
  int N,M;
  int r,q;
  int t,n,m,s,ts,te;
  vector<rec> R;
  vector<query> Q;
  int t1,t2,rogin;
  int i,j,k;
  int res;
  while(scanf("%d %d",&N,&M),N|M){
    R.clear();
    scanf("%d",&r);
    for(i=0;i<r;i++){
      scanf("%d %d %d %d",&t,&n,&m,&s);
      R.pb(rec(t,n,m,s));
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
      scanf("%d %d %d",&ts,&te,&m);
      //Q.pb(query(ts,te,m));
      res=rogin=t1=0;
      for(j=0;j<r;j++){
        if(R[j].t>te) break;
        if(R[j].m==m){
          //printf("%d ??????\n",j);
          if(rogin==0) t1=max(R[j].t,ts),rogin++;
          else if(R[j].s==1) rogin++;
          else if(R[j].s==0) rogin--;
          if(rogin==0&&R[j].s==0) res+=max(0,R[j].t-t1);
        }
      }
      if(rogin>0){
        res+=te-t1;
      }
      printf("%d\n",res);
    }
    
  }
  return 0;
}

Measured memory_bytes: 3140
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let a_s = buf.split_whitespace()
        .map(|x| x.parse::<usize>().unwrap())
        .collect::<Vec<_>>();

    let mut has_ans = false;
    let mut ans = 0usize;
    let mut i = 1usize;

    for a in a_s.iter() {
        if *a == i {
            i += 1;
            has_ans = true;
        } else {
            ans += 1;
        }
    }

    if has_ans {
        println!("{}", ans);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 10492
sx,sy,tx,ty = map(int,input().split())
dx=tx-sx
dy=ty-sy

ans=""

ans+="R"*dx
ans+="U"*dy

ans+="L"*dx
ans+="D"*dy

ans+="D"
ans+="R"*(dx+1)
ans+="U"*(dy+1)
ans+="L"

ans+="U"
ans+="L"*(dx+1)
ans+="D"*(dy+1)
ans+="R"

print(ans)


Measured memory_bytes: 3064
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int y = sc.nextInt();
        for(int i = 0; i <= n; i++){
        	for(int j = 0; j <= n - i; j++){
            	int x = n - i - j;
                int sum = 10000 * i + 5000 * j + 1000 * x;
                if(sum == y){
                	System.out.println(i + " " + j + " " + x);
                    return;
                }
            }
        }
        System.out.println(-1 + " " + -1 + " " + -1);
    }
}

Measured memory_bytes: 39152
# -*- coding: utf-8 -*-
# ヒープキューを使う

import math
import sys
import itertools
import numpy as np
import heapq
 
# なんこか入力
x,y,z,k = map(int, input().split())
 
# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

a.sort()
b.sort()
c.sort()

h = [] # heap
g = set() #使用済み

heapq.heappush(h,(-(a[x-1]+b[y-1]+c[z-1]),x-1,y-1,z-1))
g.add((x-1,y-1,z-1))

#print(h)

for i in range(k):
#    heapq.heapify(h)
    temp =[]
    temp = heapq.heappop(h)
    print(-temp[0])
    for j in range(3):
        if temp[j+1]==0:
            continue
        if j == 0:
            temp2 = (-(a[temp[1]-1]+b[temp[2]]+c[temp[3]]),temp[1]-1,temp[2],temp[3])
        elif j == 1:
            temp2 = (-(a[temp[1]]+b[temp[2]-1]+c[temp[3]]),temp[1],temp[2]-1,temp[3])
        else:
            temp2 = (-(a[temp[1]]+b[temp[2]]+c[temp[3]-1]),temp[1],temp[2],temp[3]-1)
        if (temp2[1],temp2[2],temp2[3]) in g:
            continue
        heapq.heappush(h,temp2)
        g.add((temp2[1],temp2[2],temp2[3]))


Measured memory_bytes: 14116
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int NIL = -1;

struct Node {
    int parent;     //・節点 u の親ノード
    int left;       //・節点 u の最も左の子(left)
    int right;      //・節点 u のすぐ右の兄弟(right)
    int end;        //・節点 u 子の一番右の兄弟
}node;

vector<struct Node> T;  // ノード入れ

void GetChildren(int u,vector<vector<int>> &CL){    // CLが子のリスト
    int c;
    if(T[u].left != NIL)c = T[u].left;
    else return;
    while(c != NIL){
        CL[u].push_back(c); 
        c = T[c].right;
    }
    return;
}

///////////////////////////////// O(N)　のはず

int main(){
    int N,Q;cin >> N >> Q;
    T.resize(N+1);

    rep(i,N+1)T[i].parent = T[i].left = T[i].right = NIL; // 初期化

    int tmp1,tmp2; // tmp1 は親、tmp2　は追加される子

    rep(i,N-1){     //  ノードの入力
        cin >> tmp1 >> tmp2;
        if(T[tmp1].left == NIL)T[tmp1].left = T[tmp1].end = tmp2;
        else{
            int c = T[tmp1].end;
            T[c].right = tmp2;
            T[tmp1].end = tmp2;
        }
        T[tmp2].parent = tmp1;  //　親登録
    }

    vector<vector<int>> CL; //子リスト
    CL.resize(N+1);
    for(int i = 1;i < N+1;i++)GetChildren(i,CL);  //子リスト取得


    vector<LL> ct(N+1);   // カウンター配列

    int p,x;
    rep(i,Q){
        cin >> p >> x;
        ct[p] += x;
    }
    /*
    for(int i = 2;i < N+1;i++){
        ct[i] += ct[T[i].parent];
    }
*/
    for(int i = 1;i < N+1;i++){
        for(auto j : CL[i]){
            ct[j] += ct[i];
        }
    }
    rep(i,N)cout << ct[i+1] << " ";

} 


//　答えはあってるけど　TLE
// TLE 解消

// TLE の原因は47行目から始まるノード入力の際に、T[c].rightの右隣りを.rightでwhlieループで無理やり探索し続けたことだった、
// なので、rightの末端をメモするために、・子の右端にあるノード　を　.end として構造体に追加した。
// これを利用することで、そもそもwhile ループを使わなくて済むようになりAC。

// 以下に用済みになった者たちを記す。

// 70行目の最後の累積和のところ。
// 下のは子のリストをループすることで作ってる。
// しかし、純粋に親の内容を足し続けるのと同じなので、簡便をとるのとなんとなく二重ループが嫌なので上のように表記。
/*
    for(int i = 1;i < N+1;i++){
        for(auto j : CL[i]){
            ct[j] += ct[i];
        }
    }
*/


// TLE の原因となったループ。
// 47行目から始まるノード入力の途中。
/*
            while(true){
                if(T[c].right == NIL){
                    T[c].right = tmp2;
                    break;
                }
                else{
                    c = T[c].right;
                }
            }
*/

Measured memory_bytes: 18048