akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "vector"
#include "list"
using namespace std;

void set_min(int &x, list<int> args)
{
	for (auto i : args)
	{
		x = min(x, i);
	}
}

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n + 1);
	for (int i = 1; i <= n; i++)
	{
		cin >> h[i];
	}
	vector<int> dp(n + 1, INT_MAX);
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	for (int i = 3; i <= n; i++)
	{
		for (int j = i - 1; j >= i - k; j--)
		{
			if (j < 1)
			{
				continue;
			}
			set_min(dp[i], {dp[j] + abs(h[i] - h[j])});
		}
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double k=(h*60+m)*5.5*PI/180.0;
    cout<<fixed<<setprecision(15)<<sqrt(a*a+b*b-2*a*b*(1.0-2.0*pow(sin(k/2.0),2)));
}


Measured memory_bytes: 4216
N = int(input())
A = list(map(int,input().split()))
Z = [-1 for i in range(N)]

for j,v in enumerate(A):
    Z[v-1] = j+1

for k,v in enumerate(Z):
    print(v,end="")
    if k < N:
        print(" ",end="")
    else:
        print()

Measured memory_bytes: 13880
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    int n;
    cin >> n;
    
    for (int i=1; i<=n; i++) {
        
        if (i%3==0) {
            cout << " " << i ;
        }
        else if (i%10 == 3) {
            cout << " " << i;
        }
        else if ((i/10)%10== 3){
            cout << " " << i;
            
        }
        else if((i/100)%10 == 3){
            cout << " " << i;
        }
        else if ((i/1000)%10 == 3){
            cout << " " << i;
        }
    }
    cout << endl;
}



Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge{
    int to, cost;
};


// dijikstra
/* int V;
vector<edge> G[10];
int d[10];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + V + 1, INF);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        REP(i, G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
*/

int main(){
    int m;
    cin >> m;
    cout << 48 - m << endl;
}

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

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    long long N;
    cin >> N;
    auto pf = prime_factorize(N);
    long long res = 0;
    for (auto p : pf) {
        long long e = p.second;
        long long tmp = 0, cur = 1;
        while (e >= cur) e -= cur++, ++tmp;
        res += tmp;
    }
    cout << res << endl;
}

Measured memory_bytes: 3608
mod = 10 ** 9 + 7
N, K = map(int, input().split())

ans = 0

lst = [int(i) for i in range(N + 1)]
internal = 1
for i in range(N + 1):
    internal += lst[N - i] - lst[i]
    if i + 1 >= K:
        ans += internal
        ans = ans % mod

print(ans)


Measured memory_bytes: 79196
#include <iostream>
#include <algorithm>
// #include <fstream>

using namespace std;

typedef long long ll;


ll x[100001], v[100001];
ll v_sum_right[100001], v_sum_left[100001];
ll g[100001];
ll g2[100001];

int main() {
    ll N, C;
    ll i;
    ll ans;

    // ifstream cin("input.txt");
    cin >> N >> C;
    for (i = 0; i < N; i++) {
        cin >> x[i] >> v[i];
    }

    v_sum_right[0] = v[0];
    for (i = 1; i < N; i++) {
        v_sum_right[i] = v_sum_right[i - 1] + v[i];
    }

    v_sum_left[N] = 0;
    for (i = N - 1; i >= 0; i--) {
        v_sum_left[i] = v_sum_left[i + 1] + v[i];
    }


    // g計算
    g[0] = 0;
    g2[0] = 0;
    for (i = 1; i <= N; i++) {
        g[i] = max(g[i - 1], v_sum_right[i - 1] - x[i - 1]);
        g2[i] = max(g2[i - 1], v_sum_right[i - 1] - 2 * x[i - 1]);
    }
        
    // 探査
    ans = v_sum_left[0] - C + x[0];
    for (i = 1; i < N; i++) {
        ans = max(ans, v_sum_left[i] + g[i] - 2 * (C +- x[i]));
        ans = max(ans, v_sum_left[i] - C + x[i] + g2[i]);
    }
    ans = max(ans, g[N]);

    
    // ofstream cout("output.txt");
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h> 
#include <ctype.h>
 #include <stdlib.h>
 int main() {
 int a[101][101], b[101], c[101];
 int i, j; 
int n, m; scanf("%d%d", &n, &m);
 for (i = 0; i < n; i++) {
 for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
 }
 for (j = 0; j < m; j++) scanf("%d", &b[j]);
 for (i = 0; i < n; i++) {
 c[i] = 0; for (j = 0; j < m; j++) c[i] += a[i][j] * b[j];
 }
 for (i = 0; i < n; i++) {
 printf("%d\n", c[i]);
 }
 return 0;
 } 


Measured memory_bytes: 2124
program main
   implicit none
   integer(8)::n,m,l
   character(10)::s
   read(*,"(a10)")s
 !  write(*,*)s
   read(s(6:7),*)n
   if(n>=5)then
      print '(a)',"TBD"
   else
      print '(a)',"Heisei"
   endif
   contains

end program main


Measured memory_bytes: 640
from bisect import bisect_left
n,k = map(int, input().split())
v = list(map(int, input().split()))
# 取る回数i
# 取る回数が0なら0だからやらない
ans = 0
for i in range(1, k+1):
    if i > n:
        continue
    toreru = min(k-i, i)
    for left in range(i+1):
        right = i-left
        # left,rightの中から、マイナスのものがk-i個以下なら全部捨てる それ以上なら無視
        #print(left, right, toreru)
        #print(v[:left], v[-1:-right-1:-1])
        now = v[:left] + v[-1:-right-1:-1]
        now.sort()
        ko = bisect_left(now, 0)
        if ko <= toreru:
            ans = max(ans, sum(now[ko:]))
            #print(sum(now[ko:]))
        else:
            ans = max(ans, sum(now[toreru:]))
            #print(sum(now[toreru:]))
print(ans)

Measured memory_bytes: 43240
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long X, Y;
  cin >> X >> Y;
  vector<long> as;

  long i = X;
  while (i <= Y) {
    as.push_back(i);
    i *= 2;
  }

  cout << as.size() << endl;
  return 0;
}

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

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

using ll = long long;

std::vector< ll > divisor(ll n) {
    std::vector< ll > res;
    for (ll i=2; i*i<=n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

int main() {
    ll n;
    ll ans;
    std::cin >> n;
    ans = n - 1;
    for (ll v=2; v*v<=n; ++v) {
        if (n % v == 0) ans = std::min(ans, v + (n / v) - 2);
    }

    std::cout << ans << std::endl;

    return 0;
}


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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 90000000000000000;
int PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

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

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

ll modCON(ll n,ll r,ll m){
   ll res = 1;
   for(int i = 1;i <= n;i++){
      res *= i;
      res %= m;
   }
   for(int i = 1;i <= r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   for(int i = 1;i <= n-r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   return res;
}

long long int fact(int A){
  if(A==0)return 1;
  else return fact(A-1)*A % MOD;
}

int main(){
  ll N,M;cin >> N >> M;
  if(N == M){
    cout << 2 * fact(N) * fact(M) % MOD << endl;
    return 0;
  }else if(abs(N-M) == 1){
    cout << fact(N) * fact(M) % MOD << endl;
    return 0;
  }else{
    cout << 0 << endl;
  }
  
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
int main()
{
	int N;
	cin >> N;

	vector<int> v(N);

	int T, A;
	cin >> T >> A;

	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}

	int k = 0;
	for (int i = 0; i < N; i++) {
		if (abs(A - (T - v.at(k)*0.006)) > abs(A - (T - v.at(i) * 0.006))) {
			k = i;
		}
	}
	
	cout << k + 1 << endl;
}

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  sort(h.rbegin(), h.rend());
  ll ans = 0;
  for (int i = 0; i < min(k, n); ++i) {
    h[i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    ans += h[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main (void){
    int A, B;
    int ans;

    scanf("%d%d", &A, &B);
    ans = (B - 1) / (A - 1);

    if ((B - 1) % (A - 1) == 0)
                        printf("%d", ans);
    else printf("%d", ans + 1);
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=1e6+100,mod=1e9+7;
ll fac[N];
ll fm[N];
ll power(ll n,ll k){
    if (k==0) return 1;
    if (k%2==1){
        ll x=power(n,k/2);
        return x*x%mod*n%mod;
    }
    ll x=power(n,k/2);
    return x*x%mod;
}
ll ent(ll k,ll n){
    if (k<0 || k>n) return 0;
    if (k==0 || k==n) return 1;
    return fac[n]*fm[k]%mod*fm[n-k]%mod;
}
ll dp[N];
int32_t main(){
    fac[0]=1;
    fm[0]=1;
    for (int i=1;i<N;i++){
        fac[i]=fac[i-1]*i%mod;
        fm[i]=power(fac[i],mod-2);
    }
    ll n;
    cin >> n;
    n--;
    for (int i=0;i<=n;i++){
        dp[i]=ent(i,n-i-1)*fac[i]%mod*fac[n-i]%mod;
    }
    ll ans=0;
    for (int i=0;i<N-1;i++){
        dp[i]-=dp[i+1];
        dp[i]+=mod;
        dp[i]%=mod;
        ans+=dp[i]*(n-i)%mod;
        ans%=mod;
    }
    cout << ans << endl;

}


Measured memory_bytes: 27072
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}



//head



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if(s == "SSS") cout << 0 << endl;
	else if(s == "RRR") cout << 3 << endl;
	else if(s == "SRR" or s == "RRS") cout << 2 << endl;
	else cout << 1 << endl;
}

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

int main() {
  int N,K;
  int x;
  int count; //移動距離の総和
  cin >> N >> K;
	
  count = 0;
  for (int i=0;i<N;i++) {
    cin >> x;	//位置の入力
    //タイプAとBどちらのがボールに近いか判定
    if (x > K/2) {
      //タイプBでとる
      count += (K-x)*2;
    }
    else {
      //タイプAでとる
      count += x*2;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;

string ans = "0";

void solve(){
	if(N==0) ans = "1";
}
 
int main(){
	cin >> N;
 
    solve();

	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3136
def resolve():
    S = input()

    ans = "Yes"
    n = len(S)
    for i in range(n):
        if i % 2 != 0: 
            if S[i] == "R":
                ans = "No"
        if i % 2 == 0: 
            if S[i] == "L":
                ans = "No"
    print(ans)
resolve()

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  int N;
  deque<int> V;
  cin>>N;
  if(N%2==0){
    FOR(i,1,N+1){
      int A;
      cin>>A;
      if(i%2==0){
        V.push_front(A);
      }else{
        V.push_back(A);
      }
    }
  }else{
    FOR(i,1,N+1){
      int A;
      cin>>A;
      if(i%2==1){
        V.push_front(A);
      }else{
        V.push_back(A);
      }
    }
  }
  cout<<V.front();
  V.pop_front();
  while(V.size()){
    cout<<" "<<V.front();
    V.pop_front();
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3072
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    elif m==-1 or f==-1:
        print("F")
    else:
        s=m+f
        if s>=80:
            print("A")
        if 65<=s<80:
            print("B")
        if 50<=s<65:
            print("C")
        if 30<=s<50:
            if r>=50:
                print("C")
            else:
                print("D")
        if s<30:
            print("F")


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <algorithm>
#include <string>

using namespace std;
int main() {
    long long N,s{}; cin>>N;
    unordered_map<long long,long long> valCnt{};
    for (int i = 0; i < N; ++ i){
        int v{}; cin>>v;
        s+=v;
        valCnt[v]++;
    }
    long long Q; cin>>Q;
    for (int i = 0; i < Q; ++ i) {
        long long b, c; cin>>b>>c;
        long long cnt = valCnt[b];
        s = s + (cnt * (c-b));
        valCnt[c] += valCnt[b];
        valCnt[b] = 0;
        cout<<s<<endl;
    }

    return 0;
}


Measured memory_bytes: 7120
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    vector<int> A(N), B(N);
    for (auto &a : A) cin >> a;
    for (auto &b : B) cin >> b;
    auto f = [&](Int mask) {
        unsigned char ok[51][51] = {};
        for (int i = 0; i <= 50; i++) {
            ok[i][i] = 1;
            if (mask & (1LL << i)) {
                for (int j = 0; j <= 50; j++) {
                    if (i != 0) ok[j][j%i] = 1;
                }
            }
        }
        for (int k = 0; k <= 50; k++) {
            for (int i = 0; i <= 50; i++) {
                for (int j = 0; j <= 50; j++) {
                    ok[i][j] |= ok[i][k] & ok[k][j];
                }
            }
        }
        for (int i = 0; i < N; i++) {
            if (!ok[A[i]][B[i]]) {
                return false;
            }
        }
        return true;
    };
    Int ans = (1LL << 51) - 2;
    if (!f(ans)) {
        cout << -1 << '\n';
        return 0;
    }
    for (int i = 50; i >= 1; i--) {
        Int n = ans & ~(1LL << i);
        if (f(n)) ans = n;
    }
    cout << ans << '\n';
    return 0;
}


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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " = " << x << endl
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define infll 1e18
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };



//===========================DEBUG======================//
#define XOX 1
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

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



//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=2e5+5;
vi adj[lmt];
int dp[lmt];

void dfs(int p){
	int ans=0;
	for(int c: adj[p]){
		if(!dp[c]) dfs(c);
		ans = max(ans,dp[c]);
	}
	dp[p]=1+ans;
}


int main(){
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
    fast

    ll n,m; cin>>n>>m;
    int u,v;
    loop(i,m){
    	cin>>u>>v;
    	adj[u].pb(v);
    }
    int ans=0;
    loop1(i,n){
    	if(!dp[i])dfs(i);
    	ans = max(ans,dp[i]);
    }
    pt(ans-1);
}


/*


*/





Measured memory_bytes: 14440
from io import StringIO
from collections import *
from functools import *
import sys


def main(inputs):
    # n = int(next(inputs))
    # n, k = map(int, next(inputs).split())
    # xs = list(map(int, next(inputs).split()))
    a, b = map(int, next(inputs).split())
    if a >= 13:
        return b
    if a >= 6:
        return b // 2
    return 0


def gen_inputs(str_=None):
    inputs = StringIO(str_) if str_ else sys.stdin
    while True:
        a = inputs.readline().rstrip()
        yield a
        pass
    pass


if __name__ == "__main__":
    print(main(gen_inputs()))
    pass


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 922337203685477580
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
ll n;
ll dp[3001][3001];
ll a[3005];
ll func(ll start,ll end)
{
	if(dp[start][end]!=-1)
		return dp[start][end];
	ll size=end-start+1;
	ll x=n-size;
	ll ch=x%2;
	ll ans1,ans2;
	if(start==end)
	{
		if(ch==0)
			return dp[start][end]=a[start];
		else
			return dp[start][end]=-1*a[start];
	}
	if(ch==0)
	{
		ans1=a[start]+func(start+1,end);
		ans2=a[end]+func(start,end-1);
		dp[start][end]=max(ans1,ans2);
	}
	else
	{
		ans1=func(start+1,end)-a[start];
		ans2=func(start,end-1)-a[end];
		dp[start][end]=min(ans1,ans2);
	}
	return dp[start][end];
}
int main()
{
	boost
	cin>>n;
	ll i,j;
	for(i=0; i<3001; i++)
		for(j=0; j<3001; j++)
			dp[i][j]=-1;
	for(i=0; i<n; i++)
		cin>>a[i];
	ll ans=func(0,n-1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	string o, e;
	cin >> o >> e;
	
	REP(i, e.size()) printf("%c%c", o[i], e[i]);
	if (o.size() > e.size()) printf("%c", o[o.size() - 1]);
	puts("");
	
	return 0;
}

Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
//In the name of Allah the Most Merciful
//Astagfirullahil laji Rabbi Minkulli Jamio Watubi elai
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define double long double
#define MX 10000008
#define cs int t;cin>>t;while(t--)
int i,j,k;
int r,s;
int main()
 {
    int x;
    cin>>x;
    int p=0;
    for(i=1;i<=9;i++)
    {
        if(x%i==0)
        {
            int k=x/i;
            if(k>=1&&k<=9)
            {
                p=k;

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


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 50;
int n;
int x[MAX_N];
int y[MAX_N];
map<pii,int> s;

struct union_find {
  typedef vector<int> vi;
  vi par,rank,cnt;
  int n;

  union_find(int n) : n(n) {
    par = vi(n); rank = vi(n,0); cnt = vi(n,1);
    for (int i = 0; i < n; i++) par[i] = i;
  }

  int find(int a) {
    if (par[a] == a) return a;
    return par[a] = find(par[a]);
  }

  void unite(int a, int b) {
    a = find(a); b = find(b);

    if (a == b) return;
    if (rank[a] < rank[b]) {
      par[a] = b; cnt[b] += cnt[a];
    } else {
      par[b] = a; cnt[a] += cnt[b];
      if (rank[a] == rank[b]) rank[a]++;
    }
  }

  int count(int a) { return cnt[find(a)]; }

  bool same(int a, int b) { return find(a) == find(b); }
};


int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n;
  forn(i,n) {
    cin >> x[i] >> y[i];
    s[mp(x[i],y[i])] = i;
  }

  ll res = n;
  forn(i,n) {
    for (int j = i+1; j < n; j++) {
      int p = x[j] - x[i];
      int q = y[j] - y[i];
      assert(p != 0 || q != 0);

      union_find uf(n);
      for (int k = 0; k < n; k++) {
        auto it = s.find(mp(x[k]+p,y[k]+q));
        if (it != s.end()) {
          uf.unite(k,it->snd);
        }
      }

      set<int> c;
      forn(i,n) {
        c.insert(uf.find(i));
      }

      //printf("temp=%lld p=%d q=%d\n",temp,p,q);
      chmin(res, (ll)c.size());
    }
  }

  cout << res << endl;

  return 0;
}


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

int main(){
  int n, l, r, k = 0;
  cin >> n;
  rep(i,n){
    cin >> l >> r;
    k += r - l + 1;
  }
  cout << k << endl;
}

Measured memory_bytes: 3516
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

ll mod = 1000000007;

ll
gcd(ll a, ll b) {
  if (a > b)
    return gcd(b, a);

  if (a == 0)
    return b;

  return gcd(b % a, a);
}

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

  ll a, b;
  ll zero = 0;

  vector<ll> pow(n + 1, 0);
  pow[1] = 2;
  for (ll i=2; i<=n; i++) 
    pow[i] = pow[i-1] * 2 % mod;

  map<pair<ll, ll>, pair<ll, ll>> data;
  data[{0, 1}] = {0, 0};
  for (ll i=0; i<n; i++) {
    cin>>a>>b;
    if (a == 0 && b == 0) 
      zero++;
    else if (a == 0) 
      data[{0, 1}].first++;
    else if (b == 0) 
      data[{0, 1}].second++;
    else if ((a>0) == (b>0)) {
      if (a < 0) {
        a = -a;
        b = -b;
      }

      ll g = gcd(a, b);
      a /= g;
      b /= g;
      if (data.find({a, b}) == data.end()) data[{a, b}] = {0, 0};
      data[{a, b}].first++;
    }
    else {
      ll temp = a;
      a = -b;
      b = temp;
      if (a < 0) {
        a = -a;
        b = -b;
      }

      ll g = gcd(a, b);
      a /= g;
      b /= g;
      if (data.find({a, b}) == data.end()) data[{a, b}] = {0, 0};
      data[{a, b}].second++;
    }
  }

  ll ans = 1;
  for (auto p : data) {
    if (p.second.first == 0 && p.second.second == 0) 
      continue;
    if (p.second.first == 0) 
      ans = (ans * pow[p.second.second]) % mod;
    else if (p.second.second == 0) 
      ans = (ans * pow[p.second.first]) % mod;
    else {
      ll now = (pow[p.second.first] + pow[p.second.second] - 1) % mod;
      ans = (ans * now) % mod;
    }

    //cout<<ans<<endl;
  }

  cout<<(ans+zero-1+mod)%mod<<endl;
}

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

  ll t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



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

typedef long long s64;

int main()
{
	//freopen("1.in","r",stdin);
	s64 a,b,c;
	cin>>a>>b>>c;
	cout<<min(min(c%2*a*b,a%2*b*c),b%2*a*c);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;
typedef double ld;
ll xs, xe, ys, ye;
ll n;
ll a[1005], b[1005], c[1005];
ld d[1005][1005];
ld ans = 4e18;

int main()
{
    scanf("%lld%lld%lld%lld%lld", &xs, &ys, &xe, &ye, &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
    }
    for(ll i = 0; i < n; i++)
    {
        for(ll j = 0; j < n; j++)
        {
            if((a[i] - a[j]) * (a[i] - a[j]) + (b[i] - b[j]) * (b[i] - b[j]) < (c[i] + c[j]) * (c[i] + c[j])) d[i][j] = 0;
            else d[i][j] = sqrt((ld)(a[i] - a[j]) * (a[i] - a[j]) + (b[i] - b[j]) * (b[i] - b[j])) - c[i] - c[j];
        }
    }
    for(ll k = 0; k < n; k++)
    {
        for(ll i = 0; i < n; i++)
        {
            for(ll j = 0; j < n; j++)
            {
                if(d[i][k] + d[k][j] < d[i][j]) d[i][j] = d[i][k] + d[k][j];
            }
        }
    }
    for(ll i = 0; i < n; i++)
    {
        for(ll j = 0; j < n; j++)
        {
            ld t1 = 0, t2 = 0;
            t1 = max(sqrt((a[i] - xs) * (a[i] - xs) + (b[i] - ys) * (b[i] - ys)) - c[i], 0.0);
            t2 = max(sqrt((a[j] - xe) * (a[j] - xe) + (b[j] - ye) * (b[j] - ye)) - c[j], 0.0);
            ans = min(ans, t1 + t2 + d[i][j]);
        }
    }
    ans = min(ans, (ld)sqrt((xs - xe) * (xs - xe) + (ys - ye) * (ys - ye)));
    printf("%.12f", ans);
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  if (A >= 13) {
    cout << B << endl;
  } else if (A >= 6) {
    cout << B/2 << endl;
  } else {
    cout << 0 << endl;
  }
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 100000;
int n;
string s;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> s;
  int wb = 0;
  forn (i,s.size()) {
    if ((i%2 == 0 && s[i] == '0') || (i%2 == 1 && s[i] == '1'))
      wb++;
  }

  int bw = 0;
  forn (i,s.size()) {
    if ((i%2 == 0 && s[i] == '1') || (i%2 == 1 && s[i] == '0'))
      bw++;
  }

  cout << min(wb,bw) << endl;


  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long x;
    scanf("%lld",&x);
    int i;
    long long t=100;
    for(i=1;;i++){
        t=t*1.01;
        if(t>=x)
            break;
    }
    printf("%d",i);


    return 0;
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

typedef pair<double,int32> P;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 xs,ys,xt,yt;
  cin >> xs >> ys >> xt >> yt;
  int32 n;
  cin >> n;
  vector<tuple<int32,int32,int32>> xyr;
  xyr.emplace_back(xs,ys,0);
  REP(i,n){
    int32 x,y,r;
    cin >> x >> y >> r;
    xyr.emplace_back(x,y,r);
  }
  xyr.emplace_back(xt,yt,0);
  priority_queue<P,vector<P>,greater<P>> que;
  que.emplace(0,0);
  vector<double> dist(n+2,llinf);
  dist[0] = 0;
  while(!que.empty()){
    auto [d,v] = que.top();que.pop();
    if(dist[v] < d)continue;
    REP(u,n+2){
      if(v == u)continue;
      auto dd = [&](){
        int64 dx = get<0>(xyr[v]) - get<0>(xyr[u]);
        int64 dy = get<1>(xyr[v]) - get<1>(xyr[u]);
        double res = sqrt(dy * dy  + dx * dx);
        res -= get<2>(xyr[v]);
        res -= get<2>(xyr[u]);
        if(res < 0)res = 0;
        return res;
      };
      double nd = d + dd();
      if(chmin(dist[u],nd)){
        que.emplace(nd,u);
      }
    }
  }
  cout << fixed << setprecision(10);
  ANS(dist[n+1]);
  return 0;
}

Measured memory_bytes: 7400
N=int(input())
dp=[[0,0,0] for i in range(N+1)]
for i in range(1,N+1):
    a,b,c=map(int,input().split())
    dp[i][0]=max(dp[i-1][1]+a,dp[i-1][2]+a)
    dp[i][1]=max(dp[i-1][0]+b,dp[i-1][2]+b)
    dp[i][2]=max(dp[i-1][0]+c,dp[i-1][1]+c)
print(max(dp[N]))

Measured memory_bytes: 22816
#include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<long double> vld;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846
#define sqr(a) ((a) * (a))
#define len(V) (int)V.size()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define fix(a) fixed << setprecision(a)
#define readv(x) for(auto &_ : (x)) {cin >> _;}
#define printv(x) for(auto &_ : (x)) {cout << _ << ' ';} cout << endl
#define EPS 1e-6
#define MAXN 100047

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int s; cin >> s;
	vi was; was.pb(s);
	
	int res = 1;
	while(true){
		int fn;
		if(was.back() % 2 == 1)
			fn = 3*was.back() + 1;
		else
			fn = was.back() / 2;
		
		for(auto el : was)
			if (el == fn){
				cout << res + 1<< endl;
				return 0;
			}
		res++;
		was.pb(fn);
		debug() << imie(was);
	}
	
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define getbit(x, i) (((x) >> (i)) & 1)
using namespace std;
typedef pair<int, int> pii;
#define hashset unordered_set
#define hashmap unordered_map
#define unify(arr) arr.resize(unique(arr.begin(), arr.end()) - arr.begin())
#define getbit(x, i) (((x) >> (i)) & 1)

template <typename T>
vector<T> readvector(size_t size) {
    vector<T> res(size);
    for (size_t i = 0; i < size; ++i) {
        cin >> res[i];
    }
    return res;
}
template <typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
    std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, " "));
    return out;
}

int mylog(int n) {
    return 63 - __builtin_clzll(n);
}

inline int binPow(int x, int deg, int mod) {
    int ans = 1;
    for (int i = sizeof(deg) * CHAR_BIT - 1; i >= 0; i--) {
        ans *= ans;
        ans %= mod;
        if (getbit(deg, i)) ans *= x;
        ans %= mod;
    }
    return ans;
}

// ====================== END ======================
const int MAXN = 1e6 + 10;
const int MOD = 1e9 + 7;
const int INF = 1e18;

int L[MAXN];
int W[MAXN];
int H[MAXN];

void solve() {
    string S;
    cin >> S;
    int ans = 0;
    for (int l = 1; l <= S.size(); ++l) {
        for (int start = 0; start <= S.size() - l; ++start) {
            if (S.substr(start, l) == string(l, 'R')) ans = max(ans, l);
        }
    }
    cout << ans << endl;
}

signed main() {
    // ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
  int N = 0;
  int copyN =0;
  int sn = 0;
  cin >> N;
  copyN = N;
  do
    {
      sn = sn+(N%10);
    } while ((N/=10) != 0);


  if ((copyN%sn) == 0) {
    cout << "Yes" << "\n";
  }else {
    cout << "No" << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 256
fun main(array: Array<String>) {
    val (a, b, k) = readLine()!!.split(" ").map { it.toInt() }
    val list = mutableListOf<Int>()
    var cnt = 0
    for(i in a..b) {
        list.add(i)
        cnt++
        if(cnt < k) {
            continue
        }
        else {
            break
        }
    }
    cnt = 0
    loop@for(j in b downTo 1) {
        while (j >= a) {
            list.add(j)
            cnt++
            if(cnt < k) {
                continue@loop
            }
            else {
                break@loop
            }
        }
    }
    val ansList = list.toSet().toList().sorted()
    for(num in ansList) {
        println(num)
    }
}


Measured memory_bytes: 35900
# include <iostream>
# include <cstdio>
# include <algorithm>
# include <queue>
# include <map>
# include <cmath>
# include <sstream>
# include <vector>
# include <string>
# include <cstring>
# include <set>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
int main ()
{
    string s1, s2;
    while (cin >> s1 >> s2)
    {
        int i =0;
        int flag = 0;
        if (s1.size() > s2.size ())
        {
            cout << "GREATER" << endl;
        }
        else if (s1.size() < s2.size ())
        {
            cout << "LESS" << endl;
        }
        else
        {
            for (i=0; i<s1.size (); ++i)
            {
                if (s1[i] > s2[i])
                {
                    flag  = 1;
                    cout << "GREATER" << endl;
                    break;
                }
                else if (s1[i] < s2[i])
                {
                    flag = 1;
                    cout << "LESS" << endl;
                    break;
                }
            }
            if (!flag)
            {
                cout << "EQUAL" << endl;
            }
        }
    }

    return 0;
}



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

string A, B, C;

char ans(char c, int i, int j, int k) {
  if (c == 'a') {
    if (i + 1 >= A.length()) return 'A';
    return ans(A[i+1], i+1, j, k);
  }
  else if (c == 'b') {
    if (j + 1 >= B.length()) return 'B';
    return ans(B[j+1], i, j+1, k);
  }
  else {
    if (k + 1 >= C.length()) return 'C';
    return ans(C[k+1], i, j, k+1);
  }
}

int main() {
  cin >> A >> B >> C;
  cout << ans('a', -1, -1, -1) << "\n";
  return 0;
}



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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int k;
    cin >> s >> k;
    int n=s.size();
    vector<string> slist;
    for(int i = 1; i <= min(k,n); i++) {
        for(int j = 0; j < n-i+1; j++) {
            string tmp;
            tmp=s.substr(j,i);
            slist.emplace_back(tmp);
        }
    }
    sort(slist.begin(),slist.end());

//    for(int i = 0; i < slist.size(); i++) {
//        cout << slist[i] << "\n";
//    }

    string ref=slist[0];
    int idx=1;
    int count=1;
    while(count<k) {
        if(ref!=slist[idx]){
            count++;
            ref=slist[idx];
        }
        idx++;
    }
    cout << ref << "\n";
    return 0;
}

Measured memory_bytes: 1660
N,K=input().split()
N=int(N)
K=int(K)
j=0
A=[]
for j in range(K):
    d=int(input())
    B=[int(x) for x in input().split()]
    k=0
    for k in range(d):
        A.append(B[k])
        k+=1
    A=list(set(A))
    j+=1
A=set(A)
a=len(A)
b=N-a
print(b)

Measured memory_bytes: 9196
N = gets.to_i
A = 2.times.map { gets.split.map(&:to_i) }

queue = [[0, 0, A[0][0]]]

counter = Array.new(2) { Array.new(N, -1) }
ans = 0

until queue.empty?
  y, x, cnt = queue.shift

  next if counter[y][x] > cnt
  counter[y][x] = cnt
  ans = cnt if ans < cnt

  if y == 0
    queue << [y + 1, x, cnt + A[y + 1][x]]
  end

  if x < N - 1
    queue << [y, x + 1, cnt + A[y][x + 1]]
  end
end

puts ans


Measured memory_bytes: 1788
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S;
	cin >> S;

	if (SZ(S) % 2 == 1)
	{
		cout << "No" << endl;
		return 0;
	}

	bool ok = true;
	rep(i, 0, SZ(S) / 2)
	{
		if (S[2 * i] == 'h'&&S[2 * i + 1] == 'i')continue;
		ok = false;
	}

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

	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
  char S[11],T[11];
  bool x = true;
  int a = 0;
  int b = 0;
  cin >> S >> T;
  while(S[a]) a++;
  while(T[b]) b++;
  if(b != a + 1) x = false;
  for(int i=0;i<=a-1;i++)
    if(S[i] != T[i]) x = false;
  if(x) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

struct segtree{
    int n;
    vector<int> dat,sum; //????????????,?????????????§?????¶?????????????
    segtree(int size,int x){
        n=1;
        while(n<size) n*=2;
        dat.assign(2*n-1,x);
        sum.assign(2*n-1,x);
    }
    void add(int a,int b,int x){ add(a,b,x,0,0,n); }
    int add(int a,int b,int x,int k,int l,int r){
        if(b<=l or r<=a) return dat[k];
        if(a<=l and r<=b){
            sum[k]+=x;
            return dat[k]+=x*(r-l);
        }
        int m=(l+r)/2;
        return dat[k]=add(a,b,x,2*k+1,l,m)+add(a,b,x,2*k+2,m,r);
    }
    int query(int a,int b){ return query(a,b,0,0,n); }
    int query(int a,int b,int k,int l,int r){
        if(b<=l or r<=a) return 0;
        if(a<=l and r<=b) return dat[k];
        int m=(l+r)/2;
        return query(a,b,2*k+1,l,m)+query(a,b,2*k+2,m,r)+sum[k]*(min(r,b)-max(l,a));
    }
};

void solve(){
    int n,q;
    cin >> n >> q;
    segtree seg(n,0);
    rep(i,0,q){
        int com,x,y;
        cin >> com >> x >> y;
        if(com==0) seg.add(x-1,x,y);
        if(com==1) cout << seg.query(x-1,y) << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 4848
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a, b = MAP()

print(sum(range(1, b-a+1))-b)

Measured memory_bytes: 3884
def extract_num(n):
    n_set.add(n)


A, B, K = map(int, input().rstrip().split())
n_set = set()

cnt = 0
for n in range(A, B+1):

    extract_num(n)

    cnt += 1
    if cnt >= K:
        break

cnt = 0
for n in range(B, A-1, -1):

    extract_num(n)

    cnt += 1
    if cnt >= K:
        break

n_set = sorted(n_set)

for n in n_set:
    print(n)
    

Measured memory_bytes: 3064