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

char divide(int math, int english, int japanese);
char grade;

int main(void)
{
    int dataset;
    int math, english, japanese;

    while (1){
        scanf("%d", &dataset);
        if (dataset == 0){
            break;
        } else {
            while (dataset--){
                scanf("%d %d %d", &math, &english, &japanese);
                grade = divide(math, english, japanese);
                printf("%c\n", grade);
            }
        }
    }

    return 0;
}

char divide(int math, int english, int japanese)
{
    int sum = math + english + japanese;

    if (math == 100 || english == 100 || japanese == 100){
        grade = 'A';
    } else if (math + english >= 90 * 2){
        grade = 'A';
    } else if (sum >= 80 * 3){
        grade = 'A';
    } else if (sum >= 70 * 3){
        grade = 'B';
    } else if (sum >= 50 * 3 && (math >= 80 || english >= 80)){
        grade = 'B';
    } else {
        grade = 'C';
    }

    return grade;
}

Measured memory_bytes: 1028
import sys
from collections import Counter
import random
import numpy as np
import time


alph="abcdefghijklmnopqrstuvwxyz"
s=input()
l=len(s)
k=int(input())
cou=[s.count(alph[i]) for i in range(len(alph))]
keep=[]
for c in range(len(cou)):
    if(cou[c]==0):continue
    ind=[i for i, x in enumerate(s) if x == alph[c]]
    for i in ind:
        for j in range(1,6):
            if(i+j<=l):
                t=s[i:i+j]
                if(t not in keep):keep.append(s[i:i+j])
    if(len(keep)>=5):break

keep.sort()
print(keep[k-1])

Measured memory_bytes: 14204
<?php
  	fscanf(STDIN, '%d %d', $switch_num, $light_num);
	for($i = 0; $i < $light_num; $i++){
      	$input = rtrim(fgets(STDIN));
      	$input_arr = explode(' ', $input);
      	$connect_num[$i] = $input_arr[0];
      	$connect[$i] = array_slice($input_arr, 1);
    }
	$input = rtrim(fgets(STDIN));
	$on = explode(' ', $input);

	$cnt = 0;
	for($i = 0; $i < 2 ** $switch_num; $i++){
		$status = $i;
      	//switchのon/off状態に変換
      	for($j = 1; $j <= $switch_num; $j++){
          	$switch[$j] = $status % 2;
          	$status = (int) ($status / 2);
        }
      	//各lightのon/off判別
      	for($j = 0; $j < $light_num; $j++){
          	$sum = 0;
          	foreach($connect[$j] as $value){
              	$sum += $switch[$value];
            }
          	if($sum % 2 == $on[$j]){
              	$light[$j] = 1;
            }else{
              	$light[$j] = 0;
            }
        }
      	//全部onなら
      	if(array_sum($light) == (int)$light_num){
          	$cnt++;
        }
    }
	echo $cnt;

Measured memory_bytes: 4604
#include<bits/stdc++.h>
//今日も20分で解けなかったので、他の方のプログラムで勉強させていただきました。
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  int num_max,num_min;
  for(int i = 0; i < M; i++){
    if(i ==0 ){
      cin >> num_max >> num_min;
    }else{
      int a,b;
      cin >> a >> b;
      if(num_max < a){num_max = a;}
      if(num_min > b){num_min = b;}
    }
  }
  if((num_min-num_max) < 0){
   cout << 0;
  }else{
    cout << num_min-num_max+1;
  }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll MOD = 1000000007;
const double PI = 3.141592653589793238463;
const ll N=2e5+9;
int main()
{
    FASTINOUT;
    int x,money;
    cin>>x>>money;
    int mn=1e9,sum=0;
    int y[x];
    for (int i=0;i<x;i++){
        cin>>y[i];
        sum+=y[i];
        mn=min(y[i],mn);
    }
    cout<<x+(money-sum)/mn<<endl;
    return 0;
}


Measured memory_bytes: 256
<?php
$input=explode(' ',trim(fgets(STDIN))); // // 1 2 3 ……
//print_r($input);
 
if ($input[0]>2 and $input[1]>2) {
    echo( ($input[0]-2) * ($input[1]-2) );
    exit();
}elseif ($input[0]==2 or $input[1]==2) {
    exit("0");
}elseif ($input[0]==1 and $input[1]>2) {
    echo($input[1]-2);
    exit();
}elseif ($input[0]>2 and $input[1]==1) {
    echo($input[0]-2);
    exit();
}else {
    exit("1");
}
?>

Measured memory_bytes: 3828
N,A,B = map(int, input().split())

if (B-A)%2 == 0:
    #真ん中で会う
    ans = (B-A)//2
else:
    if N-B < A-1:
        #まずBがNへ行く
        temp_ans = N-B
        A += N-B
        ans = temp_ans + 1 + (N-A)//2
    else:
        #まずAが1へ行く
        temp_ans = A-1
        B -= A-1
        ans = temp_ans + 1 + (B-1)//2
print(ans)

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};
  
struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};
  
constexpr ran rn0(const i64 e) noexcept { return ran(e); }
constexpr ran rn0(const i64 b, const i64 e) noexcept { return ran(b, e); }
constexpr ran rn1(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rn1(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }
  
i64 pow_(i64 x, i64 p) {
  i64 ans = 1;
  while(p) {
    if(p & 1) ans *= x;
    x = x * x;
    p >>= 1;
  }
  return ans;
}
  
i64 calc(i64 x) {
  i64 ans = 0;
  while(x) {
    ans += x % 10;
    x /= 10;
  }
  return ans;
}
  
int main() {
  i64 a, n, m;
  cin >> a >> n >> m;
  i64 ans = 0;
  for(i64 z = 1;pow_(z, n) <= m;z++) {
    i64 x = pow_(z, n);
    i64 y = z - a;
    if(calc(x) == y) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3108
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<random>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
short gh[2][4] = { {0,0,-1,1},{-1,1,0,0} };
struct P {
ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
ll to, cost;
};
struct S {//辺の情報を入れる変数
int from, to, cost;
};
struct H {
int x, y;
};
bool operator<(H a, H b) {
if (a.x != b.x) return a.x < b.x;
return a.y < b.y;
}
ll gcm(ll i, ll j) {//最大公約数
if (i > j) swap(i, j);
if (i == 0) return j;
return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
if (b <= c || d <= a) return 0;
return 1;
}//[a,b),[c,d)
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int b[10],c[10];
bool solve(int x,int y){
	if(x==4&&y==1){
		return 1;
	}
	bool ans=0;
	if(x<4){
		for(int i=1;i<=7;i++){
			if(c[i]&&c[i+1]&&c[i+2]){
				c[i]--;c[i+1]--;c[i+2]--;
				ans=ans||solve(x+1,y);
				c[i]++;c[i+1]++;c[i+2]++;
			}
		}
		for(int i=1;i<=9;i++){
			if(c[i]>=3){
				c[i]-=3;
				ans=ans||solve(x+1,y);
				c[i]+=3;
			}
		}
	}
	if(y<1){
		for(int i=1;i<10;i++){
			if(c[i]>=2){
				c[i]-=2;
				ans=ans||solve(x,y+1);
				c[i]+=2;
			}
		}
	}
	return ans;
}
signed main() {
	string s;
	while(cin>>s){
		for(int i=0;i<10;i++)
			b[i]=0;
		vector<int>a;
		for(int i=0;i<13;i++){
			b[(int)s[i]-'0']++;
		}
		for(int i=1;i<=9;i++){
			if(b[i]>=5){
				cout<<0<<endl;
				return 0;
			}
			if(b[i]==4){
				continue;
			}
			for(int j=0;j<10;j++)
				c[j]=b[j];
			c[i]++;
			if(solve(0,0)){
				a.push_back(i);
			}
		}
		if(a.size()==0){
			cout<<0<<endl;
		}
		else{
			for(int i=0;i<a.size();i++){
				if(i==0) cout<<a[i];
				else cout<<" "<<a[i];
			}
			cout<<endl;
		}
	}
	getchar(); getchar();
}



Measured memory_bytes: 3048
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

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

    int l,r; cin >> l >> r;
    if(r-l>=2019) cout << 0 << endl;
    else {
        int ans=3000;
        rng(i,l,r+1){
            rng(j,i+1,r+1){
                chmin(ans,(i*j)%2019);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
//Name-Deepesh Bhatt
//Institute-IIT Dhanbad

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

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 power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
ll combination(ll x)
{
    if(x==0||x==1)
        return 0;
    return (x*(x-1))/2;
}
int main()
{
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(NULL);
    int x;
    cin>>x;
    int count=0;
    int fh=x/500;
    int f=(x-fh*500)/5;
    cout<<fh*1000+f*5;
    return 0;
}

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

using ll = long long;

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

        ll n, a, b;
        cin >> n >> a >> b;
        ll ans = (n / (a+b)) * a + min(a, n % (a + b));
        cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <algorithm>

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)

int n,m;
vector<pii> tmp[125252];
pii ranges[353531];   // sort by first, [left, right]
pii ranges2[353531];  // sort by second, [right, id]

int ans[125252];

const int B = 400;
const int C = 300;

// pointer struct
struct data{
  // id, position, in-iterator, out-iterator
  int id,pos,in,out;
};
data pts[C];
int cnt[353531];

int main(){
  // input
  scanf("%d%d",&n,&m);
  REP(i,n){
    int l,r;
    scanf("%d%d",&l,&r);
    ranges[i] = pii(l,r);
  }
  
  // d small
  FOR(d,1,min(B,m+1)){
    int tmp = 0;
    REP(i,n){
      int x = (ranges[i].first+d-1)/d;
      if(x*d<=ranges[i].second)tmp++;
    }
    ans[d]=tmp;
  }

  // d large
  // sort
  {
    REP(i,n)tmp[ranges[i].first].push_back(ranges[i]);
    int it = 0;
    REP(i,m+1){
      for(pii P : tmp[i]){
        ranges[it++] = P;
      }
      tmp[i].clear();
    }
  }
  {
    REP(i,n)tmp[ranges[i].second].push_back(pii(ranges[i].second, i));
    int it = 0;
    REP(i,m+1)for(pii P : tmp[i]){
      ranges2[it++] = P;
    }
  }

  // pointer init
  data yo;
  yo.id=0; yo.pos=0; yo.in=0; yo.out=0;
  set<int> S;
  int tmp = 0;
  FOR(i,1,m+1){
    yo.pos++;
    while(yo.in<n && ranges[yo.in].first==yo.pos){
      S.insert(yo.in);
      yo.in++;
    }
    while(yo.out<n && ranges2[yo.out].first<yo.pos){
      S.erase(S.find(ranges2[yo.out].second));
      yo.out++;
    }
    if(i%B==0){
      // pts
      pts[yo.id] = yo;
      yo.id++;
      for(int x : S){
        if(cnt[x]==0)tmp++;
        cnt[x]++;
      }
    }
  }

  int pts_len = yo.id;
  FOR(d,min(B,m+1),m+1){
    ans[d] = tmp;
    if(d==m)break;
    REP(i,pts_len){
      if(pts[i].pos > m)break;
      // step pts[i]
      pts[i].pos += i+1;
      while(pts[i].in<n && ranges[pts[i].in].first<=pts[i].pos){
        if(cnt[pts[i].in]==0)tmp++;
        cnt[pts[i].in]++;
        pts[i].in++;
      }
      while(pts[i].out<n && ranges2[pts[i].out].first<pts[i].pos){
        int id = ranges2[pts[i].out].second;
        cnt[id]--;
        if(cnt[id]==0)tmp--;
        pts[i].out++;
      }
    }
  }
  FOR(d,1,m+1)printf("%d\n",ans[d]);
  return 0;
}


Measured memory_bytes: 29564
n = int(input())
s_t = list(list(input().split()) for _ in range(n))
x = input()

for r in s_t:
    r[1] = int(r[1])

sum = 0
wk = 0
for i in range(n):
    sum += s_t[i][1]
    if x == s_t[i][0]:
        wk = sum
print(sum - wk)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  long long A, B, N; cin >> A >> B >> N;
  long long ans = 0;
  long long NN = min(B-1, N);
  long long C = A*NN;
  long long D = C/B;
  long long E = NN/B;
  ans = D-A*E;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A&lang=ja
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    n = int(readline())
    n_ = n

    d = {}
    i = 2
    while i * i <= n:
        if n % i == 0:
            d[i] = 1
            n //= i
            while n % i == 0:
                n //= i
                d[i] += 1
        i += 1

    if n > 1:
        d[n] = 1
    
    ans = ["{}:".format(n_)]
    for k, v in d.items():
        for _ in range(v):
            ans .append(str(k))

    print(" ".join(ans))


if __name__ == "__main__":
    main()


Measured memory_bytes: 5604
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int T=scanner.nextInt();
        int t[]=new int[n];
        for(int i=0;i<n;i++){
            t[i]=scanner.nextInt();
        }
        int sum=0;
        for(int i=0;i<n-1;i++){
            if(t[i+1]-t[i]>=T){
                sum=sum+T;
            }else{
                sum=sum+(t[i+1]-t[i]);
            }
        }
        sum=sum+T;
        System.out.println(sum);
    }
}


Measured memory_bytes: 62576
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

const int maxn = 2e3 + 10;
typedef long long int ll;
int dis[maxn];
void solved(){
	int n,x,y;cin>>n>>x>>y;
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			int di = min(abs(i - j) ,abs(i - x) + 1 + abs(j - y));
			di = min(di,abs(x - j) + 1 + abs(i - y));
			dis[di]++;
		}
	}
	for(int i = 1; i< n; i++){
		cout<<dis[i]<<endl;
	}
}
int main(){
	solved();
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,cnt=0;
    cin>>a>>b>>c;
    while(1)
    {
        if(a%2!=0||b%2!=0||c%2!=0)
            {cout<<cnt<<endl;return 0;}
        if(a==b&&b==c)
            {cout<<"-1"<<endl;return 0;}
        ll t1,t2,t3;
        t1=a/2;
        t2=b/2;
        t3=c/2;
        a+=t2+t3;
        b+=t1+t3;
        c+=t1+t2;
        cnt++;
    }
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long fac[200020], finv[200020], inv[200020];
long long mod = 1000000007;
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 200020; 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(long long n, long long 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 co[100010] = { 0 };
int main() {
	COMinit();
	long long n;
	long long e;
	cin >> n;
	for (int i = 1; i <= n + 1; i++) {
		int a;
		cin >> a;
		if (co[a] != 0) {
			e = (co[a] - 1) + (n - i + 1);
		}
		co[a] = i;
	}
	cout << n << endl;
	for (long long i = 2; i <= n + 1; i++) {
		long long ans = COM(n + 1, i) - COM(e, i - 1);
		while (ans < 0) {
			ans += 1000000007;
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 9004
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MAX=200005;
const int mod=1e9+7;
//ll a[MAX],x[MAX],b[MAX];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   bool flag = false;
	string s;cin>>s;
	string t = s;
	int len = s.size();
	reverse(t.begin(),t.end());
	if(s==t){
		string q = s.substr(0,(len-1)/2);
		//cout<<q<<'\n';
		t = q;
		reverse(t.begin(),t.end());
		if(q==t){
			q = s.substr((len+3)/2-1);
			//cout<<q<<'\n';
			t =q;
			reverse(t.begin(),t.end());
			if(q==t)flag = true;
		}
	}
	if(flag)cout<<"Yes\n";
	else cout<<"No\n";
}



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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c, d, n, m, x, y, h, w;
    string s, t;


    auto Yes = [&](bool t){
        cout << (t ? "Yes" : "No") << endl;
    };
    auto YES = [&](bool t){
        cout << (t ? "YES" : "NO") << endl;
    };
    auto tri = [&](bool t, string a, string b){
        cout << (t ? a : b) << endl;
    };


    i64 aa, bb, xx;
    cin >> aa >> bb >> xx;

    cout << bb / xx - (aa ? (aa - 1) / xx : -1) << endl;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string s;
  cin >> s;

  if(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi"){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
N=gets.to_i
h = gets.chomp.split.map(&:to_i)
dp = Array.new(N)

dp[0] = 0
dp[1] = (h[1]-h[0]).abs
2.upto(N-1) do |i|
  dp[i] = [dp[i-1] + (h[i] - h[i-1]).abs, dp[i-2] + (h[i] - h[i-2]).abs].min
end
puts dp[N-1]

Measured memory_bytes: 11780
program V803;
 var
  a,c:array[0..100001] of longint;
  b:array[0..100001] of int64;
  i,j,m,n:longint;
  sum,max:int64;
 begin
  readln(n,m);
  for i:=1 to n do
   read(a[i]);
  readln;
  fillchar(b,sizeof(b),0);
  fillchar(c,sizeof(c),0);
  sum:=0;
  for i:=2 to n do
   if a[i]>a[i-1] then
    begin
     inc(sum,a[i]-a[i-1]);
     inc(b[a[i-1]+1],a[i-1]+1);
     dec(b[a[i]+1],a[i-1]+1);
     inc(c[a[i-1]+1]);
     dec(c[a[i]+1]);
    end
                  else
    begin
     inc(sum,m-a[i-1]+a[i]);
     inc(b[a[i-1]+1],a[i-1]+1);
     inc(b[1],a[i-1]+1-m);
     dec(b[a[i]+1],a[i-1]+1-m);
     inc(c[a[i-1]+1]);
     inc(c[1]);
     dec(c[a[i]+1]);
    end;
  for i:=2 to m do
   begin
    inc(b[i],b[i-1]);
    inc(c[i],c[i-1]);
   end;
  max:=0;
  for i:=1 to m do
   if i*c[i]-b[i]>max then max:=c[i]*i-b[i];
  writeln(sum-max);
 end.


Measured memory_bytes: 1664
n,i;
ea[2<<17],eb[2<<17],next[2<<17],first[1<<17];
long M,dp1[1<<17],dp2[1<<17],L[2<<17],R[2<<17]={1};
dfs1(u,p,id)
{
	dp1[u]=1;
	id=first[u];
	while(id)
	{
		if(eb[id]!=p)
		{
			dfs1(eb[id],u);
			dp1[u]=dp1[u]*-~dp1[eb[id]]%M;
		}
		id=next[id];
	}
}
make();
dfs2(u,p,x,id)
{
	dp2[u]=dp1[u]*x%M;
	make(first[u],p,x);
	id=first[u];
	while(id)
	{
		if(eb[id]!=p)
		{
			dfs2(eb[id],u,L[id]*R[next[id]]%M+1);
		}
		id=next[id];
	}
}
make(i,p,x,t)
{
	if(i)
	{
		L[i]=x;
		t=eb[i]!=p?-~dp1[eb[i]]:1;
		make(next[i],p,t%M*x%M);
		R[i]=R[next[i]]*t%M;
	}
}
main(u,v)
{
	scanf("%d%d",&n,&M);
	for(i=0;~scanf("%d%d",&u,&v);)
	{
		i++;
		ea[i]=u;
		eb[i]=v;
		i++;
		ea[i]=v;
		eb[i]=u;
	}
	for(;i;i--)
	{
		next[i]=first[ea[i]];
		first[ea[i]]=i;
	}
	dfs1(1,0);
	dfs2(1,0,1);
	for(i=1;i<=n;i++)printf("%d\n",dp2[i]);
}

Measured memory_bytes: 13056
def main():
    lst = []
    lst += list(map(int,input().split()))
    lst += list(map(int,input().split()))
    lst += list(map(int,input().split()))
    n = int(input())


    for _ in range(n):
        temp = int(input())
        if temp in lst:
            i = lst.index(temp)
            lst[i] = False
    answer = "No"
    if (all((not lst[0],not lst[1],not lst[2]))) or (all(( not lst[3],not lst[4],not lst[5]))) or (all((not lst[6],not lst[7],not lst[8]))):
        answer = "Yes"
    if (all((not lst[0],not lst[3], not lst[6]))) or (all((not lst[1],not lst[4],not lst[7]))) or (all((not lst[2],not lst[5],not lst[8]))):
        answer = "Yes"
    if (all((not lst[0],not lst[4],not lst[8]))) or (all((not lst[2],not lst[4],not lst[6]))):
        answer = "Yes"
    print(answer)










if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int L[200005];
int R[200005];
int D[200005];

vector<pair<int,int> >E[100005];
vector<pair<int,int> >EE[100005];

int visit[100005];
int x[100005];

void dfs(int pos,int value){
	if(visit[pos]==1){return;}

	visit[pos]=1;
	x[pos]=value;

	int i;

	for(i=0;i<E[pos].size();i++){
		dfs(E[pos][i].first,value+E[pos][i].second);
	}
	for(i=0;i<EE[pos].size();i++){
		dfs(EE[pos][i].first,value+EE[pos][i].second);
	}
}

int main() {

	int N,M;
	scanf("%d %d",&N,&M);

	int i;

	for(i=0;i<M;i++){
	scanf("%d %d %d",&L[i],&R[i],&D[i]);
	E[L[i]].push_back(make_pair(R[i],D[i]));
	EE[R[i]].push_back(make_pair(L[i],-D[i]));
	}

	for(i=0;i<M;i++){
	dfs(L[i],0);
	}
	for(i=0;i<M;i++){
		if(x[R[i]]-x[L[i]]!=D[i]){
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}

Measured memory_bytes: 18048
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
    int N;
    cin >> N;

    vector <long int> Pin(N);
    rep(i,N){
        cin >> Pin.at(i);
    }

    long int min = 1000000000000;
    int cnt = 0;
    rep(i,N){
        if(Pin.at(i) <= min){
            min = Pin.at(i);
            cnt++;
        }
    }

    cout << cnt << endl;

}

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

#define inf (1<<30)-1
#define INF (1LL<<62)-1
#define MOD 1000000007LL
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define PI acos(-1)
#define MEM(x,y) memset(x,y,sizeof (x))
#define debug cout<<"A"<<'\n'
#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 REPL(i,a,b) for (LL i=(a); i<=(b); i++)
#define PERL(i,a,b) for (LL i=(a); i>=(b); i--)
#define print(x) cout<<x<<'\n'
#define dprint(a,x) cout<<setprecision(x)<<fixed<<a<<'\n'
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int>PII;
typedef pair<LL,LL>PLL;
typedef set<int> SI;
typedef set<LL> SL;
typedef set<string> SS;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef map<int,int> MII;
typedef map<LL,LL> MLL;
typedef queue<int> QI;

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

template <class T> inline T bigmod(T p,T e,T M)
{
    T ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

inline LL power(LL a, LL b)
{
    LL multiply=1;
    REP(i,1,b)
    {
        multiply*=a;
    }
    return multiply;
}
inline LL ABS(LL a){return (a>=0)?a:-a;}

/*end of header*/
int n,a[1003];
VI v;

bool valid(int x)
{
    VI temp;
    while(x>0)
    {
        temp.PB(x%10);
        x/=10;
    }
    REP(i,1,temp.size()-1)
    {
        if(temp[i]!=temp[i-1]-1)return 0;
    }
    return 1;
}

int main()
{
    //freopen("input_file_name.in","r",stdin);
    //freopen("output_file_name.out","w",stdout);
    scanf("%d",&n);
    REP(i,1,n)scanf("%d",&a[i]);
    if(n==1)
    {
        print(-1);
        return 0;
    }
    REP(i,1,n)
    {
        REP(j,i+1,n)v.PB(a[i]*a[j]);
    }
    sort(ALL(v));
    reverse(ALL(v));
    REP(i,0,v.size()-1)
    {
        if(valid(v[i]))
        {
            print(v[i]);
            return 0;
        }
    }
    print(-1);
    return 0;
}

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

ll a[20],x[20][20],y[20][20];

int main(){
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		for(int j=0;j<a[i];j++)cin>>x[i][j]>>y[i][j];
	}
	ll ans=0;
	for(int i=0;i<(1ll<<n);i++){
		bool f=1;
		ll cnt=0;
		for(int j=0;j<n;j++){
			ll num=1ll<<j;
			if(num&i){
				cnt++;
				for(int k=0;k<a[j];k++){
					ll che=1ll<<(x[j][k]-1);
					if((i&che)&&!y[j][k])f=0;
					if(!(i&che)&&y[j][k])f=0;
				}
			}
		}
		if(f)ans=max(ans,cnt);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def cmb(n, r, p):
  a=1
  for i in range(r):
    a*=n
    a%=mod
    n-=1
  b=1
  for i in range(1,r+1):
    b*=i
    b%=mod

  inv_b=mod_inv(b,mod)
  # print(a,inv_b)
  return a*inv_b

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
            K%=mod
        x *= x
        n //= 2
        x%=mod

    return (K * x)%mod

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def main():
  n,a,b=LI()
  if n==2:
    if a!=b:
      return 0
    else:
      return 1

  ans=pow_k(2,n)

  ans-=(cmb(n,a,mod)%mod)
  ans-=(cmb(n,b,mod)%mod)

  ans-=1
  ans%=mod

  if ans<0:
    ans+=mod

  return ans

# main()
print(main())


Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }

int main(){
    ll A, B, K;
    cin >> A >> B >> K;
    ll c = 1;
    FOR(i, A, B+1) {
        if (c<=K || B+1-i<=K) cout << i << "\n";
        c++;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

//#define int long long

using namespace std;

void Main()
{
	string s;
	cin >> s;

	int anum = 0;
	int bnum = 0;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A') anum++;
		if (s[i] == 'B') bnum++;
	}
	
	if (anum == 3 || bnum == 3) {
		cout << "No" << endl;
		return;
	}

	cout << "Yes" << endl;
}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, C: int, D: "List[List[int]]", c: "List[List[int]]"):
    """
    (x+y)%3が等しければ色も等しいので良いグリッドには色は3色しかない。
    これを利用して30C3種類全探索。
    """
    t = [[0 for _ in range(30)] for _ in range(3)]
    for i in range(N):
        for j in range(N):
            t[(i+j)%3][c[i][j]-1] += 1

    res = 1 << 30
    for i in range(C):
        for j in range(C):
            if i != j:
                for k in range(C):
                    if i != k and j != k:
                        tt = 0
                        for l in range(C):
                            tt += D[l][i] * t[0][l]
                        for l in range(C):
                            tt += D[l][j] * t[1][l]
                        for l in range(C):
                            tt += D[l][k] * t[2][l]
                        if tt < res:
                            res = tt
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = [ [ int(next(tokens)) for _ in range(C) ] for _ in range(C) ]  # type: "List[List[int]]"
    c = [ [ int(next(tokens)) for _ in range(N) ] for _ in range(N) ]  # type: "List[List[int]]"
    solve(N, C, D, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7636
#include<iostream>
using namespace std;

static const int  MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
int M[MAX][MAX];

int prim()
{
  int u,minv;
  int d[MAX], p[MAX],color[MAX];
  int i,v;

  
  for(i = 0; i < n; i++)
    {
      d[i] = INFTY;
      p[i] = -1;
      color[i] = WHITE;
    }

  d[0] = 0;

  while(1)
    {
      minv = INFTY;

      u = -1;

      for(i = 0; i < n; i++)
	{
	  if(minv > d[i] && color[i] != BLACK)
	    {
	      u = i;
	      minv = d[i];
	    }
	}

      if(u == -1) break;
      color[u] = BLACK;

      for(v = 0; v < n; v++)
	{
	  if(color[v] != BLACK && M[u][v] != INFTY)
	    {
	      if(d[v] > M[u][v])
		{
		  d[v] = M[u][v];
		  p[v] = u;
		  color[v] = GRAY;
		}
	    }
	}
    }
  int sum =0;
  for(i = 0; i < n;i++)
    {
      if(p[i] != -1)
	{
	 
	  sum+=M[i][p[i]];
	}
    }

  return sum;

}


int main()
{
  int e;
  int i,j;
  
 cin >>n;

  for(i = 0; i < n;i++)
    {
      for(j = 0; j < n; j++)
	{
	 
	  cin >> e;
	 M[i][j] = (e == -1) ? INFTY : e;
        }
    }

 cout << prim() << endl;
  return 0;
  
}



Measured memory_bytes: 3136
using System;

class Program
{
    static void Main()
    {
            int i, j, x;
            int[,,] to = new int[4, 3, 10];
            for (x = 0; x < 4; x++)
            {
                for (i = 0; i < 3; i++)
                {
                    for (j = 0; j < 10; j++)
                    {
                        to[x, i, j] = 0;
                    }
                }
            }
            string len = Console.ReadLine();
            for (i = 0; i < int.Parse(len); i++)
            {
                string inp = Console.ReadLine();
                string[] data = inp.Split(' ');
                to[int.Parse(data[0]) - 1, int.Parse(data[1]) - 1, int.Parse(data[2]) - 1] += int.Parse(data[3]);
            }
            for (x = 0; x < 4; x++)
            {
                if (x != 0)
                {
                    Console.WriteLine("####################");
                }
                for (i = 0; i < 3; i++)
                {
                    for (j = 0; j < 10; j++)
                    {
                            Console.Write(" {0}", to[x, i, j]);

                    }
                    Console.Write("\n");
                }
            }
    }
}


Measured memory_bytes: 9280
#!/usr/bin/env python3
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
l = 1
for x in a:
    l = l * x // gcd(l, x)
ans = sum(l // x for x in a) % MOD
print(ans)


Measured memory_bytes: 6072
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<std::vector<int> > g(n),rg(n);
	rep(i,m) {
		int a,b;
		std::cin >> a >> b;
		a--;b--;
		g[a].emplace_back(b);
		rg[b].emplace_back(a);
	}
	std::vector<double> dp(n,0);
	auto dfs = [&] (auto f, int i) -> double {
		if(i==n-1) return 0;
		if(dp[i]!=0) return dp[i];
		double ev=0;
		for(int to:g[i]) {
			ev+=f(f,to);
		}
		return dp[i]=ev/g[i].size()+1;
	};
	dfs(dfs,0);
	debug(dp);
	double min=dp[0];
	rep(ci,n) {
		if(g[ci].size()<2) continue;
		double max=0; int mi;
		for(int to:g[ci]) if(dp[to]>max) mi=to,max=dp[to];
		std::vector<double> d(n);
		auto dfs = [&] (auto f, int i) -> double {
			if(i==n-1) return 0;
			if(d[i]!=0) return d[i];
			int sz=0;
			double ev=0;
			for(int to:g[i]) {
				if(i==ci && to==mi) continue;
				ev+=f(f,to);
				sz++;
			}
			return d[i]=ev/sz+1;
		};
		dfs(dfs,0);
		min=std::min(min,d[0]);
		debug(ci,mi,d);
	}
	std::cout << std::setprecision(10) << min << EL;

	return 0;
}


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

int main() {
    int A, B, cnt = 0;
    cin >> A >> B;

    for(int i = A; i <= B; i++){
        if(((i / 10000) == (i % 10)) && ((i / 1000 % 10) == (i / 10 % 10))) cnt++;
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    string S;
    cin>>S;
    if(S[0]==S[1] || S[1]==S[2] || S[2]==S[3]) cout<<"Bad"<<endl;
    else cout<<"Good"<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
a, b, x = map(int, input().split())

v = a * a * b
if v / 2 < x:
    print(90-math.asin(a/((2*(v-x)/a/a)**2+a**2)**0.5)/math.pi*180)
else:
    print(math.asin(b/((2*x/a/b)**2+b**2)**0.5)/math.pi*180)


Measured memory_bytes: 38544
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n;
  cin >> n;
  vector<string> s;
  rep(i,n){
    string x;
    cin >> x;
    s.push_back(x);
  }
  rep(i,n){
    sort(s[i].begin(),s[i].end());
  }
  
  sort(s.begin(),s.end());
  ll ans = 0;
  ll count = 1;
  string temp = s[0];
  for(int i = 1; i<n; i++){
    if(temp == s[i]){
      count++;
    } else {
      ans += count*(count-1)/2;
      temp = s[i];
      count = 1;
    }
  }
  ans += count*(count-1)/2;
    
  cout << ans;
  return 0;
}

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

#define lli long long int
#define endl "\n"
#define debug(n) cout<<n<<endl
#define debug2(a, b) cout<<a<<" "<<b<<endl;
#define forn(i, in, fin) for(int i = in; i<fin; i++)
#define all(v) v.begin(), v.end()
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

vector< vector<lli> > adj;
vector< lli > dp(100010, 0);


lli dfs(lli index)
{
    if(dp[index]!= 0)  return dp[index];
    for(auto v: adj[index])
    {
        dp[index] = max(dp[index], 1 + dfs(v) );
    }
    return dp[index];
}




int main()
{
    fastIO();
    lli n, m; cin>>n>>m;
    adj.resize(n);
    forn(i, 0, m)
    {
        lli x, y; cin>>x>>y;
        x--,y--;
        adj[x].push_back(y);
    }

    for(int i = 0; i<n; i++)
    {
        dfs(i);
    }
    lli res = 0;
    forn(i, 0, n)
        res = max(res, dp[i]);
        //cout<<dp[i]<<" ";
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

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

int main(void){
    int k;
    cin >>k;
    ll ans=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int o=1;o<=k;o++){
                ans+=gcd(gcd(i,j),o);
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3596
def main():
    N  = int(input())
    H = list(map(int,input().split()))
    ans = 0
    pre = H[0]
    temp = 0
    for h in H[1:]:
        if pre >= h:
            temp += 1
        else:
            temp = 0
        if temp > ans:
            ans = temp
        pre = h
    print(ans)
    return
main()



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

class Combination{
    private:
    vector<ll>fact, inv;
    ll mod;
    
    public:
    ll modpow(ll x, ll n){
        ll res = 1;
        while(n > 0){
            if(n & 1)res = res * x % mod;
            x = x * x % mod;
            n >>= 1;
        }
        return res;
    }
    ll modinv(ll x){
        ll y = mod, u = 1, v = 0;
        while(y){
            ll t = x / y;
            x -= t * y; swap(x, y);
            u -= t * v; swap(u, v);
        }
        u %= mod;
        if(u < 0)u += mod;
        return u;
    }
    Combination(ll num, ll _mod = 1000000007){
        fact = vector<ll>(2 * num + 10);
        inv = vector<ll>(2 * num + 10);
        mod = _mod;
        fact[0] = 1;
        inv[0] = modinv(fact[0]);
        for(ll i = 1; i < fact.size(); i++){
            fact[i] = fact[i - 1] * i % mod;
            inv[i] = modinv(fact[i]);
        }
    }
    ll factrial(ll n){
        return fact[n];
    }
    ll nPk(ll n, ll k){
        return fact[n] * inv[n - k] % mod;
    }
    ll nCk(ll n, ll k){
        return nPk(n, k) * inv[k] % mod;
    }
    ll nHk(ll n, ll k){
        return nCk(n+k-1, k);
    }
};

const ll MOD = 1000000007;
ll N, M;

int main(){
    ll N, M;
    cin >> N >> M;
    Combination cmb(N, MOD);
    map<ll, ll>cnt;
    for(ll i = 2; M > 1; i++){
        while(M % i == 0){
            cnt[i]++;
            M /= i;
        }
    }
    ll ans = 1;
    for(map<ll, ll>::iterator it = cnt.begin(); it != cnt.end(); it++){
        ll x = (*it).second;
        ans *= cmb.nHk(N, x);
        ans %= MOD;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
vector<pl> vec(0);

class SegmentTree
{
public:
    vector<ll> seg;
    ll len;
   SegmentTree(ll n){
       len = n;
       seg.resize(2 * n);
   }
    void add(ll ind,ll x){//1indexed
        ind += len;
        seg[ind] += x;
        while(true){
            ind /= 2;
            if(ind == 0)break;
            seg[ind] = seg[ind*2] + seg[ind*2+1];
			seg[ind] %= 998244353;
        }
	}
    ll get_sum(ll l,ll r){//1indexed
        ll ans=0;
        l += len; r += len;
        while(l < r){
            if(l%2 == 1){
                ans += seg[l];
                l++;
            }
            l /= 2;
            if(r%2 == 1){
                ans += seg[r-1];
                --r;
            }
            r /= 2;
        }
        return ans;
    }    
};


signed main(){
	//cout << fixed << setprecision(10);
    ll n,k; cin >> n >> k;
	SegmentTree s(200200);
	s.add(1 , 1);
	rep(i,0,k){
		ll a,b; cin >> a >> b;
		vec.push_back(pl(a,b));
	}
	rep(i,1,n+1){
		ll sum = 0;
		rep(j,0,k){
			if(i - vec[j].first < 1)continue;
			ll l = max((ll)1 , i - vec[j].second);
			ll r = i - vec[j].first + 1;
			sum += s.get_sum(l , r);
			sum %= 998244353;
		}
		s.add(i , sum);
	}
	cout << s.get_sum(n , n+1) << endl;

	return 0;
}

Measured memory_bytes: 6424
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<ctype.h>
#define ll long long 
using namespace std;
const int maxn=102333;
struct node{
	ll to,next,weight;
}e[maxn*2];
ll cnt;
ll last[maxn];
ll dist[maxn];
bool inq[maxn];
ll q[maxn*5];
ll read(){
	ll x=0;
	char ch=getchar();
	while (!isdigit(ch)) ch=getchar();
	while (isdigit(ch)) {
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x;
}
void insert(ll u,ll v,ll w){
	e[++cnt].to=v;
	e[cnt].weight=w;
	e[cnt].next=last[u];
	last[u]=cnt;
}
void spfa(ll root){
	memset(dist,127/3,sizeof(dist));
	memset(inq,0,sizeof(inq));
	ll head=0,tail=1;
	q[head]=root;inq[root]=1;dist[root]=0;
	while (head<tail){
		ll now=q[head++];
		ll i=last[now];
		while (i){
			ll s=dist[now]+e[i].weight;
			if (s<dist[e[i].to]){
				dist[e[i].to]=s;
				if (!inq[e[i].to]){
					inq[e[i].to]=1;
				    q[tail++]=e[i].to;	
				}
			}
			i=e[i].next;
		}
		inq[now]=0;
	}
}
int main(){
	ll n=read();
	for (ll i=1;i<n;i++){
		ll u=read(),v=read(),w=read();
		insert(u,v,w);insert(v,u,w);
	}
	ll k=read(),root=read();
	spfa(root);
	for (ll i=1;i<=k;i++){
		ll u=read(),v=read();
		printf("%lld\n",dist[u]+dist[v]);
	}
	return 0;
}

Measured memory_bytes: 10880
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
using namespace std;
int main(){
  int N, D, X;
  cin >> N >> D >> X;
  int p[D][N];
  for(int i = 0; i < D; ++i)
    for(int j = 0; j < N; ++j)
      cin >> p[i][j];
  int val;
  for(int d = 1; d < D; ++d){
    val = 0;
    int dp[N+1][X+1];
    for(int i = 0; i <= N;++i)
      fill(dp[i],dp[i]+X+1,0);

    for(int i = 1; i <= N; ++i){
      for(int j = 0; j <= X; ++j){
	dp[i][j] = max(dp[i-1][j],dp[i][j]);
	if(j >= p[d-1][i-1]) dp[i][j] = max(dp[i][j],dp[i][j-p[d-1][i-1]]+p[d][i-1]);
      }
    }

    for(int i = 0; i <= X; ++i){
      val = max(val,dp[N][i]+X-i);
    }

    X = val;
  }
  cout << val << endl;
  return 0;
}

Measured memory_bytes: 4272
// C - Pyramid
#include <bits/stdc++.h>
using namespace std;
using TP = tuple<int,int,int>;//<x,y,h>
using VT = vector<TP>;//[i]<x,y,h>
#define rp(i,n) for(int i=0;i<(n);i++)
#define eb(x,y,h) emplace_back((x),(y),(h))
#define manhattan(x1,y1,x2,y2) abs((x1)-(x2))+abs((y1)-(y2))
#define XMAX 100
#define YMAX 100

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

	VT A;//h!=0
	VT B;//h==0
	VT C;//center candidate

	rp(i, N){
		int x,y,h; cin>>x>>y>>h;
		if(h!=0) A.eb(x,y,h);
		else B.eb(x,y,h);
	}

	rp(y0, YMAX+1){
		rp(x0, XMAX+1){
			bool exist = true;
			int x,y,h;
			tie(x,y,h) = A[0];
			int h0 = h + manhattan(x0,y0, x,y);//h0: hight of center candidate

			for(int i=1; i<A.size(); ++i){
				tie(x,y,h) = A[i];
				if(h0 != h + manhattan(x0,y0, x,y)){
					exist = false;
					break;
				}
			}

			if(exist) C.eb(x0,y0,h0);//set center candidate
		}
	}

	for(auto c:C){// hight zero check & output
		int x0,y0,h0; tie(x0,y0,h0) = c;

		bool exist = true;
		for(auto b:B){
			int x,y,h; tie(x,y,h) = b;

			int m = abs(y0 - y) + abs(x0 - x);
			int hi = max(0, h0 - m);
			if(hi != h){
				exist = false;
				break;
			}

		}

		if(exist) cout<<x0<<" "<<y0<<" "<<h0<<"\n";
	}

}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n; cin >> n;
  vii xy(n);
  map<pii, int> diff;
  rep(i,n) {
    cin >> xy[i].ff >> xy[i].ss;
  }
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  vii dxy;
  rep(i,n) {
    rep(j,n) {
      pii p = mp(xy[i].ff-xy[j].ff, xy[i].ss-xy[j].ss);
      if (diff.find(p) == diff.end()) {
        diff[p] = 1;
      } else {
        diff[p]++;
      }
    }
  }
  int ans = INF;
  for (auto d : diff) {
    int p = d.ff.ff, q = d.ff.ss, c = d.ss;
    if (p==0 && q==0) continue;
    ans = min(ans, n-c);
    // cout << p << ", " << q << ", " << c << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384