akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>

template<bool sort, typename T>
auto divisors(T n) -> std::vector<T>
{
	std::vector<T> r;
	T i = 1;
	for (; i * i < n; ++i)
	{
		if (n % i == 0)
		{
			r.emplace_back(i);
			r.emplace_back(n / i);
		}
	}
	if (i * i == n)
	{
		r.emplace_back(i);
	}
	if (sort)
	{
		std::sort(r.begin(), r.end());
	}
	return r;
}

int main()
{
	long long n;
	scanf("%lld", &n);
	long long ans = divisors<false>(n - 1).size() - 1;
	for (auto d : divisors<false>(n))
	{
		if (d == 1)
		{
			continue;
		}
		long long m = n;
		while (m % d == 0)
		{
			m /= d;
		}
		if (m % d == 1)
		{
			ans += 1;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<queue>
using namespace std;

int vis[100009];
typedef pair<int, int> P;


int main()
{
    int k;
    scanf("%d", &k);
    deque<P> q;
    memset(vis, 0, sizeof(vis));
    q.push_back(make_pair(1, 1));
    while(!q.empty())
    {
        P x = q.front(); q.pop_front();
        if(vis[x.first]) continue;
        vis[x.first] = 1;
        if(x.first == 0)
        {
            printf("%d\n", x.second);
            break;
        }
        q.push_front(make_pair(x.first*10 % k, x.second));
        q.push_back(make_pair((x.first+1) % k, x.second+1));

    }
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, D, x;

  cin >> r >> D >> x;

  int sum;

  for(int i = 0; i < 10; i++){
    sum = r * x -D;
    x = sum;
    cout << sum << endl;
  }

  return 0;
}

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

int main(int argc, char const *argv[])
{
    
    vector<char>c;
    string s,s1="";
    cin>>s;
    for(char i:s)
    {
        if(i=='0'||i=='1')
        {
            c.push_back(i);
        }
        else if(i=='B')
        {
          if(!c.empty())
            c.pop_back();
          else
            continue;
        }
    }
    if(c.empty())
    {
          cout<<"";


    }
    else{
      for(int i=0;i<c.size();i++)
    {
        s1+=c[i];
    }
    cout<<s1;

    }

    
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

unordered_map<int, ll> fact(int x) {
    int num = x;
    unordered_map<int, ll> ans;
    int a = 2;
    while (x >= a * a) {
        if (x % a == 0) {
            ans[a]++;
            x /= a;
        }
        else
        {
            a++;
        }
    }
    ans[x]++;
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vint A(N);
    rep(i, N) cin >> A[i];

    bool is_all_one = true;
    rep(i, N) {
        if (A[i] != 1) {
            is_all_one = false;
        }
    }

    if (is_all_one) {
        cout << "pairwise coprime" << endl;
        return 0;
    }
    unordered_map<int, ll> p_cnt;
    ll max_cnt = 0;
    rep(i, N) {
        if (A[i] == 1) {
            //p_cnt[1]++;
            continue;
        }
        auto primes = fact(A[i]);
        for (auto& p : primes) {
            p_cnt[p.first]++;
            max_cnt = max(max_cnt, p_cnt[p.first]);
        }
    }
    if (max_cnt == 1) {
        cout <<"pairwise coprime" << endl;
        return 0;
    }
    for (auto& p : p_cnt) {
        if (p.second == N) {
            cout << "not coprime" << endl;
            return 0;
        }
    }
    cout << "setwise coprime" << endl;
    return 0;
}

Measured memory_bytes: 10384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;


namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var K = cin.nextInt();
            var X = cin.nextInt();

            var l = X - K;
            var r = X + K;

            if(K == 1)
            {
                Console.WriteLine(X);
                return;
            }

            var count = 1;
            var start = 0;
            var hankei = K - 1;
            if (l < -1000000)
            {
                count += Math.Abs(-1000000 - X);
                start = -1000000;
            }
            else
            {
                count += hankei;
                start = X - hankei;
            }

            if(r > 1000000)
            {
                count += Math.Abs(1000000 - X);
            }
            else
            {
                count += hankei;
            }



            for (int i = start; i < (start + count); i++)
            {
                if(i == (start + count) - 1)
                {
                    Console.Write(i);
                }
                else
                {
                    Console.Write(i + " ");
                }
                
            }
        }
    }





    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m;
int a[150],b[150];
int main()
{
    while (~scanf("%d%d",&n,&m)) {
        if (n==0&&m==0) break;
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        for (int i=1;i<=n;i++) {
            int x;
            scanf("%d",&x);
            a[x]++;
        }
        for (int i=1;i<=m;i++) {
            int x;
            scanf("%d",&x);
            b[x]++;
        }
        int ans=0;
        for (int i=1;i<=20;i++) ans+=i*max(a[i],b[i]);
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1172
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<ll, ll>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N; cin >> N;
    ll a[N], b[N];
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    ll cnt1 = 0, cnt2 = 0;
    rep(i, N) {
        if(b[i] < a[i]){
            cnt2 += (a[i] - b[i]);
        } else if(a[i] < b[i]) {
            cnt1 += (b[i] - a[i]) / 2;
        }
    }
    if(cnt2 <= cnt1) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 384
# 初期入力
import sys
import math
input = sys.stdin.readline
N = int(input())
a_max =[] #移動手段の最大乗車人数
num =[0]*5 #各移動機関の稼働回数
for i in range(5):
    x = int(input())
    a_max.append(x)
    num[i] =math.ceil(N /x)

#ボトルネックを過ぎれば、時間は距離に比例
max_value = max(num)
max_index = num.index(max_value)
ans =num[max_index] +6-2
print(ans)

Measured memory_bytes: 9048
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n,x,y;
  cin>>n>>x>>y;
  vector<int> a(n);
  repeat(i,1,n+1) {
    repeat(j,i+1,n+1) {
      int d = j-i;
      d = min(d,abs(x-i)+1+abs(y-j));
      a[d]++;
    }
  }
  //  cout << "hoge" << endl;
  repeat(i,1,n) {
    cout << a[i] << endl;
  }
  return 0;
}


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

using namespace std;

int n, m, sum = 0;
int a[107];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i], sum += a[i];
    }
    sort(a + 1, a + n + 1, greater<int>());
    if ((double)a[m] < (double)sum / (m + m + m + m))
    {
        cout << "No";
    }
    else
    {
        cout << "Yes";
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
S=input()
L='ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans=''
for i in range(len(S)):
  a=S[i]
  index=L.find(a)
  b=L[index+N]
  ans=ans+b
print(ans)

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

int main(){
    int array[6];
    int count[4] = {0,0,0,0}; 
    int Ccount1 = 0, Ccount2 = 0;
    cin >> array[0] >> array[1] >> array[2] >> array[3] >> array[4] >> array[5];
    for(int i = 0;i < 6;i++){
        if(array[i] == 1){
            count[0]++;
        } 
        if(array[i] == 2){
            count[1]++;
        }
        if(array[i] == 3){
            count[2]++;
        }
        if(array[i] == 4){
            count[3]++;
        }
    }
    for(int i = 0;i < 4; i++){
        if(count[i] == 1){
            Ccount1++;
        }
        if(count[i] == 2){
            Ccount2++;
        }
    }
    if(Ccount1 == 2 && Ccount2 == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    
}

Measured memory_bytes: 256
#coding: utf-8

N = int(input())
a = []
for i in range(N):
    a.append(int(input()))

start = 0
count = 0

for i in range(N):
    count += 1
    next = a[start]
    if(next == 2):
        print(count)
        break
    start = next - 1
else:
    print(-1)

Measured memory_bytes: 7084
import sys

n, q = map(int, input().split())
s = input()
commands = [line.rstrip().split() for line in sys.stdin]
commands.reverse()

l, r = 0, n - 1
for t, d in commands:
    if s[l] == t and d == 'L':
        l += 1
    elif 0 < l and s[l - 1] == t and d == 'R':
        l -= 1
    if s[r] == t and d == 'R':
        r -= 1
    elif r < n - 1 and s[r + 1] == t and d == 'L':
        r += 1
    if l > r:
        break

print(r - l + 1)


Measured memory_bytes: 39356
#pragma region header
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
struct UnionFind {
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        }
         else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
signed main() {
    int n,m;cin >> n >> m;
    vi v(n);
    rep(i, n){
        cin >> v[i];
        v[i]--;
    }
    UnionFind uf(n);
    rep(i, m) {
        int a,b;cin >> a >> b;
        a--;b--;
        uf.unite(a,b);
    }
    int count = 0;
    rep(i, n) {
        if(uf.same(v[i],i))count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 5608
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <queue>

using namespace std;

int n;
map<string, string> cnv;
map<string, bool> chk;
vector<string> vec;
string s1, s2;

struct St{
  string str;
  int cnt;

  St() {}
  St(string _str, int _cnt): str(_str), cnt(_cnt) {}
};

string conv(string str, string s)
{
  string res = "";
  int l = s.size(), i = 0;

  while(i < str.size()){
    if(i+l <= str.size() && str.substr(i, l) == s){
      res += cnv[s];
      i += l;
    } else {
      res += str[i++];
    }
  }

  return res;
}

int func()
{
  string s;
  queue<St> que;
  que.push(St(s1, 0));
  chk[s1] = true;

  while(!que.empty()){
    St st = que.front();
    que.pop();
    if(st.str == s2) return st.cnt;

    for(int j = 0; j < n; j++){
      s = conv(st.str, vec[j]);
      if(s.size() <= 10 && !chk[s]){
	chk[s] = true;
	que.push(St(s, st.cnt+1));
      }
    }
  }

  return -1;
}

int main()
{
  while(cin>>n && n){
    while(n--){
      cin >> s1 >> s2;
      cnv[s1] = s2;
      vec.push_back(s1);
    }
    cin >> s1 >> s2;
    n = vec.size();
    cout << func() << endl;

    vec.clear();
    cnv.clear();
    chk.clear();
  }

  return 0;
}

Measured memory_bytes: 1080
import itertools

n = int(input())
dt = input()
l = dt.split()
count = 0
for team in itertools.combinations(l,3):
    team1 = list(team)
    for i in range(3):
        team1[i] = int(team1[i])
        
    if team1[0] != team1[1] and team1[1] != team1[2] and team1[0] != team1[2]:
        if team1[0] + team1[1] > team1[2] and team1[0] + team1[2] > team1[1] and team1[1] + team1[2] > team1[0]:
            count += 1

print(count)


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

int h, w, m;
set <pair <int, int>> s;
int x[300010], y[300010], mx, my;
int qx[300010], tx, qy[300010], ty;

int main() {
	scanf("%d%d%d", &h, &w, &m);
	while (m--) {
		int i, j; scanf("%d%d", &i, &j);
		s.insert(make_pair(i, j));
		++x[i], ++y[j];
		if (x[i] == mx)
			qx[tx++] = i;
		else if (x[i] > mx)
			qx[0] = i, tx = 1, mx = x[i];
		if (y[j] == my)
			qy[ty++] = j;
		else if (y[j] > my)
			qy[0] = j, ty = 1, my = y[j];
	}
	for (int i = 0; i < tx; ++i)
		for (int j = 0; j < ty; ++j)
			if (s.find(make_pair(qx[i], qy[j])) == s.end()) {
				printf("%d\n", mx + my);
				return 0;
			}
	printf("%d\n", mx + my - 1);
	return 0;
}


Measured memory_bytes: 22400
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < n; i++)
#define REP(i,n) for(int i=1;i<=n;i++)

using namespace std;
typedef long long ll;

int main()
{
    const ll MOD = 1000000007;

    // Input
    ll n;
    cin >> n;

    if (n == 1) {
        cout << 0;
        return 0;
    }

    ll ans = 0;

    ll all = 1;
    ll noBoth = 1;
    ll one = 1;

    rep(i, n) {
        all *= 10;
        all %= MOD;

        noBoth *= 8;
        noBoth %= MOD;

        one *= 9;
        one %= MOD;
    }

    ans = all - (one * 2 - noBoth);
    ans %= MOD;

    if (ans < 0) {
        ans += MOD;
    }
    // ans = (ans + MOD) % MOD;

    cout << ans;
    return 0;
}


Measured memory_bytes: 3176
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#include <string>
#include <sstream>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
ull gcd(ull a, ull b){return b? gcd(b, a%b):a;}
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
	ull ans = 0;
	int len = S.size();
    int i_max = 1 << (len-1);
	for (int i = 0; i < i_max; i++) {
		ull sum = 0, cur = 0;
		for (int j = 0; j < len; ++j) {
			if (j > 0 && (i & (1 << (j - 1)))) {
				sum += cur;
				cur = 0;
			}
			cur = cur * 10 + (S[j] - '0');
		}
		sum += cur;
		ans += sum;
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;cin>>n;
    vint a(n+1);rep(i, n)cin>>a[i+1];
    vint b(n+1, -1);
    for(int i = n;i>=1;i--){
        int ac = 0;
        int cou = 0;
        for(int j = 1;j*i <= n;j++){
            if(b[j*i]==-1){
                cou++;
            }else{
                ac += b[j*i];
            }
        }
        b[i] = (a[i]+ac)%2;
    }

    vll ans;
    for(int i = 1;i <= n;i++){
        if(b[i] == 1){
            ans.push_back(i);
        }
    }
    cout << ans.size() << endl;
    rep(i, ans.size()){
        if(i)cout << ' ';
        cout << ans[i];
    }
    return 0;
}


Measured memory_bytes: 3700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();

		String str2 = "";

		String num = "";

		int num2;

		StringBuilder builder = new StringBuilder();

		while (!(str.equals("-"))) {

			num = br.readLine();


			for (int i = 0; i < Integer.parseInt(num); i++) {

				num2 = Integer.parseInt(br.readLine());

				builder.append(str.substring(num2, str.length()));
				builder.append(str.substring(0, num2));

				str = builder.toString();
				builder.setLength(0);
			}
			str2 += str + "\n";
			str = br.readLine();

		}

		System.out.print(str2);
	}

}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int a,b;
    cin >>a>>b;
  
  	if(a%3==0)flag=true;  	
  	if(b%3==0)flag=true;
  	if((a+b)%3==0)flag=true;


    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag)cout << "Possible" <<endl;
    else cout << "Impossible" <<endl;
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin>>a>>b>>c;
	int ans=a;
	if(a==b) ans=c;
	if(a==c) ans=b;
	cout<<ans<<'\n';
	return 0;
}


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

long ansiter = -1, ans = 0;

void solve(int depth, long pre, long k, long *flag, int flag0){
  if(depth==10){
    if(ansiter<k)ansiter++;
    if(ansiter==k){
      rep(i,10){
        ans += flag[9-i]*pow(10,i);
      }
    }
    return;
  }

  if(ansiter==k)return;
  if(flag0==0 && pre==0){
    rep(i,10){
      flag[depth] = i;
      if(ansiter<k && i==0)solve(depth+1,0,k,flag, flag0);
      else if(ansiter<k)solve(depth+1,i,k,flag, 1);
    }
  }else if(pre==0){
    flag0 = 1;
    flag[depth] = 0;
    if(ansiter<k)solve(depth+1,0,k,flag,flag0);
    flag[depth] = 1;
    if(ansiter<k)solve(depth+1,1,k,flag,flag0);
  }else if(pre==9){
    flag0 = 1;
    flag[depth] = 8;
    if(ansiter<k)solve(depth+1,8,k,flag,flag0);
    flag[depth] = 9;
    if(ansiter<k)solve(depth+1,9,k,flag,flag0);
  }else{
    flag0 = 1;
    flag[depth] = pre-1;
    if(ansiter<k)solve(depth+1,pre-1,k,flag,flag0);
    flag[depth] = pre;
    if(ansiter<k)solve(depth+1,pre,k,flag,flag0);
    flag[depth] = pre+1;
    if(ansiter<k)solve(depth+1,pre+1,k,flag,flag0);
  }
}

int main(){
  long k;
  cin >> k;
  long flag[10];
  solve(0,0,k,flag,0);
  cout << ans << endl;
  return 0;
}

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

class UnionFind {
    vector<int> par, rank;
public:
    explicit UnionFind(int n) : par(n), rank(n) {
        for (int i = 0; i < n; i++) { par[i] = i; rank[i] = 0; }
    }

    int find(int i) {
        return (par[i] == i) ? i : (par[i] = find(par[i]));
    }

    void unite(int i, int j) {
        int x = find(i), y = find(j);
        if (x != y) {
            if (rank[x] < rank[y])
                par[x] = y;
            else {
                par[y] = x;
                if (rank[x] == rank[y]) rank[x]++;
            }
        }
    }

    bool same(int i, int j) { return find(i) == find(j); }
};

int main() {
    int n, m, k; cin >> n >> m >> k;
    vector<int> fr[n], bl[n];
    UnionFind u(n);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b; a--; b--;
        u.unite(a, b);
        fr[a].push_back(b);
        fr[b].push_back(a);
    }
    for (int i = 0; i < k; i++) {
        int a, b; cin >> a >> b; a--; b--;
        bl[a].push_back(b);
        bl[b].push_back(a);
    }
    int cnt[n] = {};
    for (int i = 0; i < n; i++) cnt[u.find(i)]++;
    for (int i = 0; i < n; i++) {
        int ans = cnt[u.find(i)] - fr[i].size();
        for (int j : bl[i])
            if (u.same(i, j)) ans--;
        cout << ans-1 << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 13048
import numpy as np
def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U,MOD):
    x = np.arange(U,dtype=np.int64); x[0] = 1
    fact = cumprod(x,MOD)
    x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
    fact_inv = cumprod(x,MOD)[::-1]
    return fact,fact_inv

U = 10**6
MOD = 10**9 + 7
fact, invfact = make_fact(U,MOD)

X, Y = [int(x) for x in input().split()]
if (X+Y) % 3 != 0:
    print(0)
    exit()
r = (X+Y) // 3
k = X - r
if (k < 0 or Y - r < 0):
    print(0)
else:
    print(fact[r] * invfact[r-k] % MOD * invfact[k] % MOD)


Measured memory_bytes: 51520
#include <iostream>
#include <queue>

int main(void) {
    std::priority_queue<u_int> heights;
    //??\???
    for (u_int h, i = 0; i < 10; ++i) {
        std::cin >> h;
        heights.push(h);
    }
	//??????
    for (u_int i = 0; i < 3; ++i) {
        std::cout << heights.top() << std::endl;
        heights.pop();
    }
    return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <stdlib.h>

using namespace std;
#define N_MAX 200000
int N, K;
int A[N_MAX];

int comp(const void * a, const void *b){
	return *(int*)b - *(int*)a;
}

int main(){
	cin >> N >> K;
	for (int i=0; i<N; i++){
		int tmp;
		cin >> tmp;
		A[tmp-1]++;
	}
	qsort((void * )A, N_MAX, sizeof(int), comp);
	int ans = 0;
	for (int i=K; i<N; i++){
		ans += A[i];
	}
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)


#define N 100005

int32_t main()
{



    IOS



    string s,t;
    cin >> s >> t;

    if(t.length() == s.length()+1 and s == t.substr(0,s.length()))
    {
      cout << "Yes";
    }
    else
    {
      cout << "No";
    }


   
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

#define MXN 305
int N, M;
int A[MXN][MXN];
bool de[MXN];
int Ans;
int now[MXN];
int cnt[MXN];

/*
greedy with good amortized complexity
*/

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

    cin>>N>>M;
    FOR(i,1,N)
    {
        FOR(j,1,M)cin>>A[i][j];
        now[i]=1;
    }
    Ans=N;

    FOR(c,1,M-1)
    {
        FOR(i,1,M)cnt[i]=0;
        int mx=0, mxi;
        FOR(i,1,N)
        {
            int ni = A[i][ now[i] ];
            cnt[ni]++;
            if( cnt[ni]>mx )
            {
                mx=cnt[ni];
                mxi=ni;
            }
        }
        Ans=min(Ans,mx);
        de[mxi]=true;
        FOR(i,1,N)
        {
            while( de[ A[i][now[i]] ] )now[i]++;
        }
    }
    cout<<Ans<<'\n';

    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#define MAXN 100000
#define INF 0x3FFFFFFF
using namespace std;
struct node
{
	int to;
	node *next;
}edge[MAXN*2+5];
node *ncnt=&edge[0],*Adj[MAXN+5];
struct point
{
	int val;
	bool vis;
}poi[MAXN+5];
int minval=INF,minid,N,M;
bool visit[MAXN+5];
bool cmp(point a,point b)
{
	return a.val<b.val;
}
void AddEdge(int u,int v)
{
	node *p=++ncnt;
	p->to=v;
	p->next=Adj[u];
	Adj[u]=p;
	
	node *q=++ncnt;
	q->to=u;
	q->next=Adj[v];
	Adj[v]=q;
}
void dfs(int u)
{
	int v;
	visit[u]=true;
	if(poi[u].val<minval)
		minval=poi[u].val,minid=u;
	for(node *p=Adj[u];p!=NULL;p=p->next)
	{
		v=p->to;
		if(visit[v]==false)
			dfs(v);
	}
}
int main()
{
	scanf("%d %d",&N,&M);
	for(int i=0;i<N;i++)
		scanf("%d",&poi[i].val),poi[i].vis=false;
	int x,y;
	for(int i=1;i<=M;i++)
	{
		scanf("%d %d",&x,&y);
		AddEdge(x,y);
	}
	int cnt=0;
	long long ret=0LL;
	for(int i=0;i<N;i++)
		if(visit[i]==false)
		{
			minval=INF;
			cnt++;
			dfs(i);
			poi[minid].vis=true;
			ret+=1LL*minval;
		}
	if(cnt<=1)
	{
		printf("0\n");
		return 0;
	}
	cnt=cnt-2;
	sort(poi,poi+N,cmp);
	for(int i=0;i<N;i++)
	{
		if(cnt<=0)
			break;
		if(poi[i].vis==false)
			ret+=1LL*poi[i].val,cnt--;
	}
	if(cnt>0)
		printf("Impossible\n");
	else
		printf("%lld\n",ret);
	return 0;
}
/*
7 4
1 2 3 4 5 6 7
3 0
4 0
1 2
5 6

*/

Measured memory_bytes: 5120
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val edges = mutableListOf<Pair<Int, Int>>()
    val g = Array(n + 1) { mutableListOf<Int>() }
    repeat(m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        edges.add(a to b)
        g[a].add(b)
        g[b].add(a)
    }

    fun dfs(i: Int): Boolean {
        val (a, b) = edges[i]
        val visited = BooleanArray(n + 1) { false }

        fun rec(u: Int) {
            visited[u] = true
            for (v in g[u]) {
                if (visited[v]) continue
                if (u == a && v == b) continue
                rec(v)
            }
        }

        rec(a)

        return !visited[b]
    }

    println((0 until m).count { dfs(it) })
}

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

int main() {
    
    ll n; cin >> n;
    vector<ll> c(n - 1), s(n - 1), f(n - 1);
    for (ll i = 0; i < n - 1; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }
    for (ll i = 0; i < n - 1; i++) {
        ll time = 0;
        time += s[i];
        time += c[i];
        for (ll j = i + 1; j < n - 1; j++) {            
            if (time % f[j] != 0) {
                ll diff = time % f[j];
                time += f[j] - diff;
            }
            if (s[j] < time) {}
            else { // time <= s[j]
                time = s[j];
            }        
            time += c[j];
        }
        cout << time << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3612
import sys
input=sys.stdin.readline
import bisect

def main():
    N = int(input())
    Q = []
    for _ in range(N):
        Q.append(list(map(int, input().split())))
    Q = sorted(Q, key=lambda x:x[1], reverse=True)
    t = Q[0][1]
    for q in Q:
        if t > q[1]:
            t = q[1]
        t -= q[0]
    if t >= 0:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


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

int main() {
    int d,n;
    cin >> d >> n;
    if(d == 0){
        if(n != 100)cout << n << endl;
        else cout << n+1 << endl;
    }else if (d == 1)
    {
        if(n != 100)cout << n * 100 << endl;
        else cout << n*100 + n << endl;
    }else{
        if(n != 100)cout << n * 10000 << endl;
        else cout << n * 100 * 100 + n*100 << endl;
    }
    
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 998244353
#define pi 3.1415926535897932384

void shuffledget(int x[],int n){
    srand(time(0));
    int i,b[524288],p,c;
    for(i=0;i<n;i++){
        b[i]=i;
    }
    for(i=n;i>=1;i--){
        p=rand()%i;
        c=b[i-1];b[i-1]=b[p];b[p]=c;
    }
    for(i=0;i<n;i++){
        scanf("%d",&x[b[i]]);
    }
}

long long factorial[524288];

void cfact(){
    long long i;
    factorial[0]=1;
    factorial[1]=1;
    for(i=2;i<524288;i++){
        factorial[i]=factorial[i-1]*i;
        factorial[i]%=mod;
    }
}

long long power(long long a, long long b){
	long long x = 1, y = a;
	while (b > 0){
		if(b%2){
			x = (x*y)%mod;
		}
		y = (y*y)%mod;
		b /= 2;
	}
	return x%mod;
}	
 
long long modular_inverse(long long n){
	return power(n, mod-2);
}

long long calcnCr(long long n,long long k){
	return (factorial[n]*(modular_inverse(factorial[k])*modular_inverse(factorial[n-k])%mod))%mod;
}

int main(void){
    cfact();
    long long i,j,n,m,k,a,b,c,w,r=0,l,t;
    double d;
    char s[524288];
    scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
    //l=strlen(s);
    for(i=0;i<=n;i++){
        w=k-(a*i);
        if(w%b!=0){continue;}
        w=w/b;
        if(w<0 || n<w){continue;}
        t=1;
        t*=calcnCr(n,i);t%=mod;
        t*=calcnCr(n,w);t%=mod;
        r+=t;r%=mod;
    }
    //shuffledget(a,n);
    //qsort(a,n,sizeof(int),sortfncsj);
    printf("%lld\n",r);
    return 0;
}

Measured memory_bytes: 4224
import java.util.*;
public class Main {
	static int n, r, p, c;
	static Scanner sc = new Scanner(System.in);
	static int[] Hanafuda, temp;
	
	public static void main(String[] args) {
		while(read()){
			
		}
	}
	static boolean read(){
		/**
		 * ScannerNXÌnextInt()Å®lÌÇÝÝªÅ«Ü·B
		 */
		n = sc.nextInt(); r = sc.nextInt();
		/**
		 * âè¶æèAnÆrªÆàÉ0ÈçfalseðÔµÜ·B@
		 */
		if(n == 0 && r == 0)
			return false;
		/**
		 * ÔDÌzñAHanafudaÆAêIÉDððï³¹ézñ
		 * tempðõµÜ·B¡ñA0 < n <= 50 ÈÌÅ50ÜÅõ·éÆ
		 * âèÍð¯Ü·ªAHanafuda[0]ðg¢½­È¢ÌÅ51ÜÅpÓµÜ·B
		 */
		Hanafuda = new int[51];
		temp = new int[51];
		/**
		 * HanafudazñÌú»B
		 * Hanafuda[n]ÉÍ1AHanafuda[1]ÉÍnðüêÜ·B
		 */
		for(int i = 1; i <= n; i++){
			Hanafuda[i] = n - i + 1;
			temp[i] = 0;
		}
		/**
		 * rñApÆcª±­ÌÅnextInt()ÅÇÝÝÜ·B
		 * pÆcðêñÇÝÞ½ÑÉAVbt·éÌÅA
		 * »Ì½ÑÉsolve()ÖðÄÑÜ·B
		 */
		for(int i = 0; i < r; i++){
			p = sc.nextInt(); c = sc.nextInt();
			solve();
		}
		/**
		 * rñÇÝñÅAVbtµ½ ÆÅAêÔãÌDð\¦µÜ·B
		 */
		System.out.println(Hanafuda[1]);
		/**
		 * ±êÅªIíÁ½ÌÅtrueðÔµÜ·B
		 */
		return true;
	}
	static void solve(){
		/**
		 * HanafudazñÌã©çp-1ÚÜÅðAtempzñÉÞð³¹Ü·B
		 */
		for(int i = 1; i <= p-1; i++)
			temp[i] = Hanafuda[i];
		/**
		 * HanafudazñÌpÚ©çp+c-1ÚÜÅðÚ®µÜ·B
		 */
		for(int i = p; i < p+c; i++)
			Hanafuda[i-p+1] = Hanafuda[i];
		/**
		 * tempzñÉ¦ªµÄ¨¢½J[hðA é×«êÉßµÜ·B
		 * ¼OÌìÆÅHanafuda[c]ÜÅªÜÁÄ¢éÌÅA
		 * ÍHanafuda[c+1]©çÅ·B
		 */
		for(int i = 1; i <= p-1; i++)
			Hanafuda[c+i] = temp[i];
	}

}

Measured memory_bytes: 12000
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<stdlib.h>



int main()

{
    int n,m,k,i;
    scanf("%d %d %d",&n,&m,&k);
    int a[n],b[m];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<m;i++)
    {
        scanf("%d",&b[i]);
    }
    i=0;
    int j=0,count=0,sum=0;
    while(sum+a[i]<=k&&i<n)
    {
        sum=sum+a[i];
        i++;
    }

    while(sum+b[j]<=k&&j<m)
    {
        sum=sum+b[j];
        j++;
    }

    count=i+j;

    while(i>0)
    {
        sum=sum-a[i-1];
        i--;
        while(sum+b[j]<=k&&j<m)
        {
               sum=sum+b[j];
               j++;
        }
        if(i+j>count)
        {count=i+j;}
    }
    printf("%d\n",count);


    return 0;
}


/*
presented by codeRumi
thanks for watching & being here,thank me later... :)
*/



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

int main(void){
	long int n, min=1000000, max=-1000000, sum=0, a;
	cin >>n;
	for(int i=0; i<n; i++){
		cin >>a;
		if(max<a){
			max=a;
		}
		if(min>a){
			min=a;
		}
		sum+=a;
	}
	cout <<min <<" " <<max <<" " <<sum <<endl;
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cmath>
#define MAX_N 10e7
using ll = long long;
using namespace std;
bool isprime(ll x){
	if(x<2)	return false;
	if(x==2)	return true;
	if(x%2==0)	return false;
	for(ll i=3;i*i<=x;i+=2){
		if(x%i==0)	return false;
	}
	return true;
}
int main(){
	ll n,x,ans=0;
	cin >> n;
	for(int i=0;i<n;i++){
			cin >> x;
			if(isprime(x))	ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3092
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
import collections
from collections import deque 

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

N, M = inpl()
graph = [[] for i in range(N+1)]

for i in range(M):
    x, y = inpl()
    graph[x].append(y)

flag = [False] * (N + 1)
dp = [0] * (N + 1)


def f(x):
    if flag[x]:
        return dp[x]
    flag[x] = True
    fans = 0
    for y in graph[x]:
        fans = max(fans, f(y) + 1)
    dp[x] = fans
    return dp[x]

ans = 0
for i in range(1, N + 1):
    ans = max(ans, f(i))
print(ans)


Measured memory_bytes: 190492
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mod = 1e9+7;

int main(){

	int n,k;
	cin>>n>>k;

	k = min(k,n);

	ll a[n];
	for(int i = 0; i < n; i++)
		cin>>a[i];

	ll ans = 0;

	sort(a,a+n);
	reverse(a,a+n);

	for(int i=k; i < n; i++)
		ans += a[i];

	cout<<ans<<"\n";
	return 0;
}

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

int main() {
  vector<int> a(3);
  rep(i,3) cin >> a[i];

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  int ans = 0;
  int diff = a[0] - a[1];
  diff /= 2;
  ans += diff;
  a[1] += diff*2;
  diff = a[0] - a[2];
  diff /= 2;
  ans += diff;
  a[2] += diff*2;
  if (a[0] != a[1] && a[0] != a[2]) {
    ans++;
  } else if (a[0]==a[1] && a[0]==a[2]) {
    ans += 0;
  } else {
    ans += 2;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, h, ok = 0, a, s = 0;
	cin >> h >> num;
	rep(i, num) {
		cin >> a;
		s += a;
	}
	if (s >= h)
		ok = true;
	if (ok)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(true){
    C -= B;
    if(C <= 0) break;
    A -= D;
    if(A <= 0) break;
  }
  if(A > 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3532
#include <stdio.h>

int main()
{
        // 入力用変数
        int N;
        int d[50];

        // 出力用変数
        int point = 0;

        // 入力
        scanf("%d", &N);
        for (int i = 0; i < N; i++) {
                scanf("%d", &d[i]);
        }

        // 計算処理
        for (int i = 0; i < N-1; i++) {
                for (int j = i+1; j < N; j++) {
                        point += d[i] * d[j];
                }
        }

        // 出力処理
        printf("%d\n", point);

        return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

ll solve(ll A, ll B) {
  if (A > B) return solve(B, A);
  ll d = B / A;
  if (B % A == 0) return A * (2 * d - 1);
  return d * 2 * A + solve(A, B - d * A);
}

int main() {
  ll N, X;
  while (cin >> N >> X) {
    cout << solve(X, N - X) + N << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


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

}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(1<<30)-1;
const ll INFl=9223372036854775807;
const int MAX=310;
const ll MOD=1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
ll n,m;
ll a[100010],b[100010];
ll par[100010];
ll ran[100010];
ll chi[100010];
ll ans[100010];

void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		ran[i]=0;
		chi[i]=1;
	}
}

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

void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	
	if(ran[x]<ran[y]){
		par[x]=y;
		chi[y]=chi[y]+chi[x];
	}else{
		par[y]=x;
		chi[x]=chi[x]+chi[y];
		if(ran[x]==ran[y]){
			ran[x]++;
		}
	}
}

bool same(int x,int y){
	return find(x)==find(y);
}
int main(){
	cin>>n>>m;
	REP(i,m)
		cin>>a[i]>>b[i];
	init(n);
	ans[m-1]=n*(n-1)/2;
	for(int i=m-2;i>=0;i--){
		if(find(a[i+1])==find(b[i+1]))
			ans[i]=ans[i+1];
		else{
			ans[i]=ans[i+1]-chi[find(a[i+1])]*chi[find(b[i+1])];
		}
		unite(a[i+1],b[i+1]);
	}
	REP(i,m)
		cout<<ans[i]<<endl;
}

Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define Rrep(i,n) for(int i=n-1;i>0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define P pair<int,int>
#define Pll pair<ll,ll>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main(){
    int h,w; cin >> h >> w;
    string s[h];
    rep(i,h) cin >> s[i];
    int l[h][w],r[h][w],u[h][w],d[h][w];
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.'){
                if(j==0) l[i][j]=1;
                else l[i][j]=l[i][j-1]+1;
            }else{
                l[i][j]=0;
            }
        }
        rrep(j,w){
            if(s[i][j]=='.'){
                if(j==w-1) r[i][j]=1;
                else r[i][j]=r[i][j+1]+1;
            }else{
                r[i][j]=0;
            }
        }
    }
    rep(j,w){
        rep(i,h){
            if(s[i][j]=='.'){
                if(i==0) u[i][j]=1;
                else u[i][j]=u[i-1][j]+1;
            }else{
                u[i][j]=0;
            }
        }
        rrep(i,h){
            if(s[i][j]=='.'){
                if(i==h-1) d[i][j]=1;
                else d[i][j]=d[i+1][j]+1;
            }else{
                d[i][j]=0;
            }
        }
    }
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.'){
                chmax(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 66816
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    println!("{}",if a<=c&&a+b>=c{"YES"}else{"NO"})
}


Measured memory_bytes: 4352