akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/14  Problem: 067_arc_a / Link: https://abc052.contest.atcoder.jp/tasks/arc067_a?lang=en  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */


void dividenum(int n, VI&a) {
	for (int i = 2; i*i <= n; i++) {
		while (n%i == 0) {
			n /= i;
			a[i]++;
		}
	}
	if (n > 1)a[n]++;
}
LL N;

LL ans = 0LL;

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

	cin >> N;
	ans = 1;
	VI a(1001,0);
	FOR(i, 2, N + 1) {
		dividenum(i, a);
	}
	FOR(i, 2, N + 1) {
		if (a[i])
			ans *= (a[i] + 1);
		ans %= MOD;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
    int a,b,i,j;
    while(1){
        scanf("%d %d",&a,&b);
        if(a==0&&b==0)
        break;
        for(i=0;i<a;i++){
            for(j=0;j<b;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int N,X,T;cin>>N>>X>>T;
    if(N%X==0){
        cout<<T*(N/X)<<endl;
    }
    else{
        cout<<T*(N/X+1)<<endl;
    }
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
  int n;
  cin>>n;
  vi a(n,0);
  vector<vector<pii>> t(n,vector<pii>());
  FOR(i,0,n){
    cin>>a[i];
    FOR(j,0,a[i]){
      int aa,aaa;
      cin>>aa>>aaa;
      aa--;
      t[i].PB(MP(aa,aaa));
    }
  }
  int ans=0;
  FOR(i,0,(1<<n)){
    int tmp=0;
    FOR(j,0,n){
      if(i&(1<<j)){
        tmp++;
        FOR(k,0,a[j]){
          int tt=(i>>t[j][k].ST)&1;
          if(tt!=t[j][k].ND)goto LB;
        }
      }
    }
    ans=max(ans,tmp);
    LB:ans=ans;
  }
  cout<<ans;
}


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

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

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

    sort(a,a+n);

    for(int i=0;i<n;++i) cout<<a[i];
}





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(void){
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n) cin >> vec.at(i);

    sort(vec.begin(),vec.end());
    int temp = 0;
    int count = 0;
    rep(i,n){
        if(temp < vec.at(i)){
            temp = vec.at(i);
            count++;
        }
    }

    cout << count << endl;
}

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

using int64 = long long;
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int n;
   string s;
   cin >> n >> s;
   int ans = 0;
   set<char> cs;
   for (int i = 0; i < s.size()-1; i++) {
      cs.insert(s[i]);
      set<char> ts;
      for (int j = i+1; j < s.size(); j++) {
         ts.insert(s[j]);
      }
      int cnt = 0;
      for (char c : cs) {
         if (ts.find(c) != ts.end()) {
            cnt++;
         }
      }
      chmax(ans, cnt);
   }

   cout << ans << endl;

   return 0;
}

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

using namespace std;

typedef long long ll;

bool reversecompare(int a, int b)
{
    return a > b;
}

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

    ll a, b, c;

    cin >> a >> b;
    c = a*b;

    if (c%2 == 0)
        cout << "Even" << endl;
    else
        cout << "Odd" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int A[33], N;
int main(){
  while (cin >> N && N){
    A[0] = 1;
    for (int i=1; i<=32; ++i){
      A[i] = A[i-1];
      if (i>1){
	A[i] += A[i-2];
      }
      if (i>2){
	A[i] += A[i-3];
      }
    }
    cout << A[N] / 3650 + 1 << endl;
  }
}



Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    cout << ceil((double)(N - 1) / (K - 1)) << '\n';
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 1; i < (int)c; i++)
#define debug(x) cout << #x << " is " << endl

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

    ll ans = 0;
    rep(a, K + 1)
    {
        rep(b, K + 1)
        {
            rep(c, K + 1)
            {
                // cout << __gcd(__gcd(a, b), c) << endl;
                ans += __gcd(__gcd(a, b), c);
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<30)
typedef pair< int , int > P;
typedef pair< int , P > Pi;
int m,n,k,d;
vector<int> cal;
struct Edge {
  int to,cost;
  Edge(){}
  Edge(int to,int cost):to(to),cost(cost){};
};
vector< Edge > Graph[110];
int min_cost[110][1<<6];
int Bellman_Ford(){
  int ret = INF;
  fill_n(*min_cost,110*(1<<6),INF);
  min_cost[0][(1<<m)-1] = true;
  queue<Pi> que;
  que.push(Pi(0,P(0,(1<<m)-1)));
  while(!que.empty()){
    Pi p = que.front();
    que.pop();
    int cost = p.first;
    int now = p.second.first;
    int bit = p.second.second;
    if(now == 1) ret = min(ret,cost);
    if(min_cost[now][bit] < cost) continue;
    for(int i=0;i<Graph[now].size();i++){
      Edge e = Graph[now][i];
      int nc = cost + e.cost*k;
      int nbit = bit;
      if(e.to >= 2 && e.to < 2 + m){
	if((nbit >> (e.to-2)) & 1){
	  nc -= cal[e.to-2];
	  nbit &= ~(1 << (e.to-2));
	} else continue;
      }
      if(nc < min_cost[e.to][nbit]){
	que.push(Pi(nc,P(e.to,nbit)));
	min_cost[e.to][nbit] = nc;
      }
    }
  }
  return ret;
}

int judge(string s){
  if(s == "H") return 0;
  else if(s == "D") return 1;
  else if(s[0] == 'C') return atoi(s.substr(1).c_str())+1;
  else if(s[0] == 'L') return atoi(s.substr(1).c_str())+m+1;
}

int main(){
  while(cin >> m >> n >> k >> d , m){
    cal.resize(m);
    for(int i=0;i<m;i++) cin >> cal[i];
    for(int i=0;i<d;i++){
      string s1,s2; int dis;
      cin >> s1 >> s2 >> dis;
      Graph[judge(s1)].push_back(Edge(judge(s2),dis));
      Graph[judge(s2)].push_back(Edge(judge(s1),dis));
    }
    cout << Bellman_Ford() << endl;
    for(int i=0;i<110;i++) Graph[i].clear();
  }
}

Measured memory_bytes: 1344
n,k=map(int,input().split())
s=input()
f=int(s[0])
d=[0]
if f==0: d.append(0)
t=s[0]
for i in s:
    if i==t:
        d[-1]+=1
    else:
        d.append(1)
        t=i
if s[-1]=="0": d.append(0)
ans=chk=0
for i in range(len(d)):
    chk+=d[i]
    if i>=(2*k+1):
        chk-=d[i-(2*k+1)]
    if i%2==0:
        ans=max(ans,chk)
print(ans)


Measured memory_bytes: 4212
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 5000 + 20 , mod = 1e9 + 7 ;
int n ;
vector <int> g[N] ;

int save[N] ;
int sz[N] , dp[N][N][2] ;

inline void add (int &a , int b) {
	a += b ;
	if (a >= mod) a -= mod ;
}

void dfs (int v , int par = -1) {
	sz[v] = 1 ;

	dp[v][0][0] = 1 ;

	for (int u : g[v]) {
		if (u == par) continue ;

		dfs(u , v) ;

		for (int i = sz[v] ; i >= 0 ; i --)
			for (int j = sz[u] ; j >= 0 ; j --) {
				if (j) {
					for (int k1 : {0 , 1})
						for (int k2 : {0 , 1})
							add(dp[v][i + j][k1 ^ k2] , 1ll * dp[v][i][k1] * dp[u][j][k2] % mod) ;
				}
				else {
					int d0 = dp[v][i][0] , d1 = dp[v][i][1] ;

					dp[v][i][0] = 1ll * d0 * dp[u][0][0] % mod ;
					dp[v][i][1] = 1ll * d1 * dp[u][0][0] % mod ;
				}
			}

		sz[v] += sz[u] ;
	}

	if (sz[v] % 2 == 0) {
		for (int i = 0 ; i < sz[v] ; i ++)
			for (int k : {0 , 1})
				add(dp[v][sz[v]][k] , 1ll * dp[v][i][k ^ 1] * save[sz[v] - i] % mod) ;
	}
}

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

	cin >> n ;

	save[0] = 1 ;
	for (int i = 2 ; i <= n ; i += 2)
		save[i] = 1ll * save[i - 2] * (i - 1) % mod ;

	for (int i = 0 , u , v ; i < n - 1 ; i ++) {
		cin >> u >> v ;
		u -- , v -- ;
		g[u].push_back(v) ;
		g[v].push_back(u) ;
	}

	dfs(0) ;

	cout << (dp[0][n][1] - dp[0][n][0] + mod) % mod << '\n' ;
}

Measured memory_bytes: 196736
# coding:utf-8

# 要素数取得
a = int(raw_input())
#print a
a0 = a
a1 = a/100 #100の位
a = a%100
a2 = a/10  #10の位
a = a%10
a3 = a     #1の位

if a1*111 >= a0:
    print a1*111
else:
    print (a1+1)*111

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, Ma, Mb; cin >> N >> Ma >> Mb;
    int A[41], B[41], C[41];
    rep(i,N) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        A[i] = a;
        B[i] = b;
        C[i] = c;
    }
    int H1 = N / 2;
    int H2 = N - H1;
    int mi = INT32_MAX;

    // (MbA0−MaB0)+(MbA1−MaB1)=0
    // MbA0 - MaB0 = MaB1 - MbA1
    
    map<int,int> M1;
    for (int bit = 1; bit < pow(2,H1); bit++) {
        int a = 0, b = 0, c = 0;
        for (int i = 0; i < H1; i++) {
            if (bit & (1 << i)) {
                a += A[i];
                b += B[i];
                c += C[i];
            }
        }
        int s = Mb * a - Ma * b;
        if (M1[s] == 0) M1[s] = c; // Can't be zero
        else M1[s] = min(M1[s], c);
        if (s == 0) mi = min(mi, c);
    }

    map<int,int> M2;
    for (int bit = 1; bit < pow(2,H2); bit++) {
        int a = 0, b = 0, c = 0;
        for (int i = 0; i < H2; i++) {
            if (bit & (1 << i)) {
                a += A[H1 + i];
                b += B[H1 + i];
                c += C[H1 + i];
            }
        }
        int s = Ma * b - Mb * a;
        if (M2[s] == 0) M2[s] = c;
        else M2[s] = min(M2[s], c);
        if (s == 0) mi = min(mi, c);
    }

    for (auto x : M1) {
        if (M2.count(x.first) > 0) {
            mi = min(mi, x.second + M2[x.first]);
        }
    }

    if (mi == INT32_MAX) {
        cout << -1 << endl;
    } else {
        cout << mi << endl;
    }
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}

int ab[100010];

int main()
{
	ios_base::sync_with_stdio(false);
	ll n;
	string a, b;
	cin >> n >> a >> b;
	ll ans = 1,m = mod;
	rep(i, n) {
		if (i == 0) {
			if (a[i] == b[i]) ans = 3;
			else {
				ans = 6;
				i++;
			}
			continue;
		}
		if (a[i] == b[i]) {
			if (a[i - 1] == b[i - 1]) ans *= 2;
		}
		else {
			if (a[i - 1] == b[i - 1]) ans *= 2;
			else ans *= 3;
			i++;
		}
		ans %= m;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int INF=1e9;

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

    long long n,c;
    cin>>n>>c;

    vector<pair<long long,long long>> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first>>v[i].second;
    }

    long long ans=0;

    vector<long long> sum1(n+1),sum2(n+1);
    sum1[0]=0;sum2[0]=0;

    for(int i=0;i<n;i++)sum1[i+1]=v[i].second;
    for(int i=0;i<n;i++)sum1[i+1]+=sum1[i];
    for(int i=0;i<n;i++)sum2[i+1]=v[n-i-1].second;
    for(int i=0;i<n;i++)sum2[i+1]+=sum2[i];

    vector<long long> f1(n+1),f2(n+1);
    f1[0]=0;f2[0]=0;

    for(int i=1;i<=n;i++){
        f1[i]=sum1[i]-v[i-1].first;
        f2[i]=sum2[i]-(c-v[n-i].first);
    }

    vector<long long> g1(n+1),g2(n+1);
    g1[0]=0;g2[0]=0;

    for(int i=1;i<=n;i++){
        g1[i]=max(g1[i-1],f1[i]);
        g2[i]=max(g2[i-1],f2[i]);
    }

    for(int i=1;i<=n;i++){
        f1[i]-=v[i-1].first;
        f2[i]-=(c-v[n-i].first);
    }

    for(int i=0;i<=n;i++){
        ans=max(ans,f2[i]+g1[n-i]);
        ans=max(ans,f1[i]+g2[n-i]);
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
using namespace std;
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 4010
class CS{
  public:
  ll cs[N];
  void init(ll a[]){
    cs[0]=0;
    for(int i=0;i<N-1;i++){
      cs[i+1]=cs[i]+a[i];
    }
  }
  ll qry(ll l,ll r){
    return (cs[r+1]-cs[l])%mod;
  }
};CS cs;

ll f[N][N],n,m,k;
int main(){
    cin>>n>>m>>k;
    for(int i=0;i<N;i++)f[0][i]=0; f[0][0]=1;
    for(int i=1;i<N;i++){
      cs.init(f[i-1]);
      for(int j=0;j<N;j++){
	f[i][j]=cs.qry(max(0LL,j-k+1),j);
      }
    }
    ll ans=0;
    for(;n>0;n-=(k-1)){
      ll s=(n+m-1)/(k-1);
      //cout<<s<<" "<<n<<" "<<f[s][n]<<endl;
      ans=(ans+f[s][n])%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 125952
#include<iostream>
using namespace std;
int main()
{
    int i=0,m,n,l;
    cin>>n;
    l=n/100;
    m=n%100;
    //cout<<l<< " "<<m;
    if(l>=1&&l<=12)
    {
        if(m>=1&&m<=12)cout<<"AMBIGUOUS\n";
        else cout<<"MMYY\n";
    }
    else if(m>=1&&m<=12)cout<<"YYMM\n";
    else cout<<"NA\n";
    return 0;
}


Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N = INT()

ans = -N % 1000
print(ans)


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 2e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

int main()
{
	int n;
	cin>>n;
	vector<ll> v;
	rep(i, 0, n)
	{
		ll x;
		cin>>x;
		v.pb(x);
	}
	std::vector<ll> s(n+1, 0);
	rep(i, 0, n)
	{
		s[i+1] = v[i] + s[i];
	}
	vector<ll> ss(n+1, 0);
	ll minn = LONG_MAX;
	repb(i, n, 1)
	{
		ss[i-1] = ss[i] + v[i-1];
	}
	repn(i,0 , n)
		chmin(minn, abs(s[i] - ss[i]));
	cout<<minn<<endl;
}


Measured memory_bytes: 5104
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func scanInt() int {
	scanner.Scan()
	txt := scanner.Text()
	n, _ := strconv.Atoi(txt)
	return n
}

type Pair struct {
	First  int
	Second int
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := scanInt()
	vs := make([]int, 0, n)
	for i := 0; i < n; i++ {
		vs = append(vs, scanInt())
	}

	areAllSame := true
	for i := 0; i < n; i++ {
		if vs[i] != vs[0] {
			areAllSame = false
			break
		}
	}
	if areAllSame {
		fmt.Println(n / 2)
		return
	}

	oddMap := map[int]int{}
	evenMap := map[int]int{}

	for i := 0; i < n; i++ {
		if i%2 != 0 {
			oddMap[vs[i]]++
		} else {
			evenMap[vs[i]]++
		}
	}

	odd1, odd2 := Pair{}, Pair{}
	even1, even2 := Pair{}, Pair{}

	for key, count := range oddMap {
		if count > odd1.Second {
			odd1.First = key
			odd1.Second = count
		}
	}
	delete(oddMap, odd1.First)
	for key, count := range oddMap {
		if count > odd2.Second {
			odd2.First = key
			odd2.Second = count
		}
	}

	for key, count := range evenMap {
		if count > even1.Second {
			even1.First = key
			even1.Second = count
		}
	}
	delete(evenMap, even1.First)
	for key, count := range evenMap {
		if count > even2.Second {
			even2.First = key
			even2.Second = count
		}
	}

	if odd1.First != even1.First {
		fmt.Println(n - odd1.Second - even1.Second)
		return
	}

	if odd1.Second+even2.Second > odd2.Second+even1.Second {
		fmt.Println(n - odd1.Second - even2.Second)
	} else {
		fmt.Println(n - odd2.Second - even1.Second)
	}
}


Measured memory_bytes: 8852
#include <stdio.h>
#define N 100
int main()
{
  int A[N],n,i,j,count=0;

  scanf("%d",&n);
  for( i = 0; i < n; i++ ){
    scanf("%d",&A[i]);
  }
  for(i = 0; i < n; i++){
    for(j = n-1; j > i; j--){
      if(A[j] < A[j-1]){
	A[n] = A[j];
	A[j] = A[j-1];
	A[j-1] = A[n];
	count++;
      }
    }
  }
 for(i = 0; i < n; i++){
   if(i == n-1){
     printf("%d",A[i]);
     break;
   }
   printf("%d ",A[i]);
 }
 printf("\n%d\n",count);
 return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long int n,k,q,m;
cin>>n>>k>>q;

long long int a[n+1]={0};


for(int i=0;i<q;i++){
  cin>>m;
  a[m-1]++;
}

for(int i=0;i<n;i++){
  //cout<<a[i]<<endl;
  if(k-(q-a[i])>0){
    cout<<"Yes"<<endl;
  }
  else {cout<<"No"<<endl;
}
}

    return 0;
}


Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[]) {
        FastReader sc = new FastReader();
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a <= b && b <= a + w || a <= b + w && b <= a)
            System.out.println(0);
        else if (a < b)
            System.out.println(b - a - w);
        else
            System.out.println(a - b - w);
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21204
#D
import math

n = int(input())
a = list(map(int,input().split()))
numli = [0] * (n+1)
for i in range(n):
    numli[a[i]] += 1
numli2 = numli.copy()
numli2.sort(reverse=True)    
i = 0
ans = 0
while numli2[i] > 1:
    ans += numli2[i] * (numli2[i]-1) / 2
    i += 1

ansli = [0] * n
for k in range(n):
    nb = numli[a[k]]
    anssub = nb * (nb - 1) / 2
    anssub = (nb-1) * (nb - 2) / 2
    ansli[k] = int(ans - (nb - 1))
    print(ansli[k])


Measured memory_bytes: 26140
#include<stdio.h>
#include<string.h>
int main(void){
    char a[1000];
    while(scanf("%s",a)!=EOF){
        int i,j,s,c,d=0,e,f,g;
        char b[1000]={0};
        for(i=0;a[i]!='\0';i++){
            if(a[i]=='@'){
                c=a[i+1]-'0';
                for(j=c;j>0;j--){
                    b[d++]=a[i+2];
                }
                i+=2;
            }
            else {
                b[d++]=a[i];
            }
        }

        for(e=0;e<d;e++)printf("%c",b[e]);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 524
public class Main {

  private static void solve() {
    int n = ni();
    System.out.println((n + 1) / 2);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 22740
import java.util.*;

public class Main {

    public static void main(String[] args) {
		new Main().run();
    }

    void run() {
      Scanner sc = new Scanner(System.in);
      int H=sc.nextInt();
      int W=sc.nextInt();
      char[][] a=new char[H][W];
      for(int i=0;i<H;++i){
          a[i]=sc.next().toCharArray();
      }
      long[][] dp=new long[H+1][W+1];
      long mo=1_000_000_000+7;
      dp[0][0]=1;
      for(int sum=0;sum<=H+W-2;++sum){
          for(int i=0;i<=sum;++i){
          int j=sum-i;
          if(i>=H||j>=W)continue;
          if(a[i][j]=='#'){
              dp[i][j]=0;
              continue;
          }
            dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mo;
            dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mo;
          }
      }
      System.out.println(dp[H-1][W-1]);
    }

    void tr(Object...objects){
		System.out.println(Arrays.deepToString(objects));
    }
}


Measured memory_bytes: 51048
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n

for i in range(1, n):
    hi = h[i]
    s = max(i-k,0)
    dp[i] = min(dpj + abs(hi - hj) for dpj, hj in zip(dp[s:i], h[s:i]))
    
print(dp[-1])


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

#define pll pair<long long, long long>

class UnionFind {
public:
	vector <long long> par; // 各元の親を表す配列
	vector <long long> siz; // 素集合のサイズを表す配列(1 で初期化)

	// Constructor
	UnionFind(long long sz_): par(sz_), siz(sz_, 1LL)
	{
		for (long long i = 0; i < sz_; ++i) {
			par[i] = i; // 初期では親は自分自身
		}
	}
	void init(long long sz_)
	{
		siz.assign(sz_, 1LL);  // assign: 再代入
		par.resize(sz_);  // resize: 再確保
		for (long long i = 0; i < sz_; ++i) {
			par[i] = i; // 初期では親は自分自身
		}
	}

	// Member Function
	// Find
	long long root(long long x)
	{
		// 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(long long x, long long y)
	{
		x = root(x);
		y = root(y);
		if (x == y) {
			return false;
		}
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) {
			swap(x, y);
		}
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	// 連結判定
	bool issame(long long x, long long y)
	{
		return root(x) == root(y);
	}

	// 素集合のサイズ
    long long size(long long x)
	{
        return siz[root(x)];
    }
};

int main()
{
	long long N, M;
	long long node1, node2;
	cin >> N >> M;

	vector<pll> A(M);
	for (long long loop = 0; loop < M; ++loop) {
		cin >> node1 >> node2; --node1, --node2;
		A[loop].first = node1;
		A[loop].second = node2;
	}

	vector<long long> ans(M);
	ans[M-1] = (N*(N-1))/2;

	UnionFind uf(N);
	for (long long loop = M - 1; loop >= 1; --loop) {
		node1 = A[loop].first, node2 = A[loop].second;
		if (uf.issame(node1, node2)) {
			ans[loop - 1] = ans[loop];
		} else {
			ans[loop - 1] = ans[loop] - (uf.size(node1) * uf.size(node2));
			uf.merge(node1, node2);
		}
	}

	for (int loop = 0; loop < M; ++loop) {
		cout << ans[loop] << "\n";
	}

    return 0;
}


Measured memory_bytes: 7168
N=int(input())
T=list(map(int,input().split()))
M=int(input())

PX=[list(map(int,input().split())) for _ in range(M)]

for p,x in PX:
  p-=1
  tmp=T[p]
  T[p]=x
  print(sum(T))
  T[p]=tmp
  

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void){
    ll n;
    cin >> n;
    vector<ll> a;
    for(ll i = 0; i < n; i++){
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    
    sort(a.begin(), a.end());
    
    ll counter = 0;
    for(ll i = 0; i < a.size(); i++){
        ll count = 1;
        while(a[i] == a[i + 1]){
            count++;
            i++;
        }
        if(count > 0 && count % 2 != 0){
            counter++;
        }
    }
    cout << counter << endl;
}



Measured memory_bytes: 1400
#include<stdio.h>
#define mod 1000000007ll
#define inf 2147483647ll
#define ll long long
struct edge{ int to,nex; }e[3000010];
int c[200010],h[200010],pos[200010],cnt[200010],tot;
ll w[200010],fac[200010],rfac[200010],min[200010];
bool v[200010];
ll pow(ll a,ll b){ ll ans=1,base=a; while(b){ if(b&1)ans=(ans*base)%mod; base=(base*base)%mod; b>>=1; } return ans; }
ll C(ll n,ll k){ return(((fac[n]*rfac[n-k])%mod)*rfac[k])%mod; }
void add(int a,int b){ tot++; e[tot].to=b; e[tot].nex=h[a]; h[a]=tot; }
void dfs(int x){ v[x]=1; for(int i=h[x];i;i=e[i].nex){ if(!v[e[i].to])dfs(e[i].to); } }
int main(){
    int n,i,fir,sec=0; ll X,Y,min1,min2,tot,ans; scanf("%d%lld%lld",&n,&X,&Y); fac[0]=1; for(i=1;i<=n;i++){ scanf("%d%lld",c+i,w+i); fac[i]=(i*fac[i-1])%mod; min[i]=inf; }
    rfac[n]=pow(fac[n],mod-2); for(i=n;i>0;i--)rfac[i-1]=(i*rfac[i])%mod;
    for(i=1;i<=n;i++){ if(w[i]<min[c[i]]){ min[c[i]]=w[i]; pos[c[i]]=i; } }
    for(i=1;i<=n;i++){ if(i!=pos[c[i]]&&w[i]+min[c[i]]<=X){ add(i,pos[c[i]]); add(pos[c[i]],i); } }
    min1=min2=inf; for(i=1;i<=n;i++){ if(w[i]<min1){ min1=w[i]; fir=i; } }
    for(i=1;i<=n;i++){ if(w[i]<=min2&&c[i]!=c[fir]){ min2=w[i]; sec=i; } }
    for(i=1;i<=n;i++){
        if(i==fir)continue;
        if(c[i]!=c[fir]&&w[i]+w[fir]<=Y){ add(i,fir); add(fir,i); }
        if(sec&&c[i]!=c[sec]&&w[i]+w[sec]<=Y){ add(i,sec); add(sec,i); }
    }
    dfs(fir);
    tot=0; for(i=1;i<=n;i++){ if(v[i]){ tot++; cnt[c[i]]++; } }
    ans=1; for(i=1;i<=n;i++){ if(cnt[i]){ ans=(ans*C(tot,cnt[i]))%mod; tot-=cnt[i]; } }
    printf("%lld",ans);
}

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

int main() {
    int n,cnt=0;
    cin>>n;
    long long a[105];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    if(n<3)
        cout<<"0\n";
    else{
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(a[i]==a[j])
                    continue;
                for(int k=j+1;k<n;k++){
                    if(a[i]==a[k]||a[j]==a[k])
                        continue;
                    else if(a[i]+a[j]>a[k]&&a[k]-a[j]<a[i])
                        cnt++;
                }
            }
        }
        cout<<cnt<<endl;
    }
}


Measured memory_bytes: 3644
#!/usr/bin/env python3

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

edges = []
graph = [ [] for _ in range(n) ]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1;
    edges.append( (a, b) )
    graph[a].append(b)
    graph[b].append(a)

def dfs(cur, u, v):
    is_visited[cur] = True
    for adj in graph[cur]:
        if is_visited[adj]: continue
        if cur == u and adj == v: continue
        if cur == v and adj == u: continue
        
        dfs(adj, u, v)

ans = 0
for u, v in edges:
    is_visited = [False]*n
    dfs(0, u, v)
    if not all(is_visited):
        ans += 1

print(ans)


Measured memory_bytes: 3064
<?php

fscanf(STDIN, "%s", $s);
fscanf(STDIN, "%s", $t);

$s1 = str_split($s);
$s2 = [];
foreach ($s1 as $sx) {
    if (!isset($s2[$sx])) {
        $s2[$sx] = 1;
        continue;
    }
    ++$s2[$sx];
}
sort($s2);


$t1 = str_split($t);
$t2 = [];
foreach ($t1 as $tx) {
    if (!isset($t2[$tx])) {
        $t2[$tx] = 1;
        continue;
    }
    ++$t2[$tx];
}
sort($t2);

if (count($s2) !== count($t2)) {
    echo 'No';
} else {
    $flg = true;
    $cnt = count($s2);
    for ($i = 0; $i < $cnt; ++$i) {
        if ($s2[$i] !== $t2[$i]) {
            $flg = false;
            break;
        }
    }

    echo $flg ? 'Yes' : 'No';
}


Measured memory_bytes: 33272
def main():
    n, q = [int(e) for e in input().split()]
    s = input()
    LR = [[int(e) for e in input().split()] for i in range(q)]

    CNT = []
    cnt = 0
    for i in range(n - 1):
        if s[i] == 'A' and s[i + 1] == 'C':
            cnt += 1

        CNT.append(cnt)

    CNT.append(0)
    for lr in LR:
        print(CNT[lr[1] - 2] - CNT[lr[0] - 2])

if __name__ == "__main__":
    main()


Measured memory_bytes: 68568
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 100005;

int N, C, K;
int t[MAXN];

void load() {
	scanf("%d%d%d", &N, &C, &K);
	for (int i = 0; i < N; i++)
		scanf("%d", t + i);
}

int solve() {
	sort(t, t + N);
	int sol = 0, curr = 0, cnt = 0;
	for (int i = 0; i < N; i++) {
		if (t[i] > curr || !cnt) {
			curr = t[i] + K;
			cnt = C;
			sol++;
		}
		cnt--;
	}
	return sol;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);
typedef complex<long double> cm;
typedef vector<cm> vcm;

const double pi = acos(-1);

void make_zeta(int n, vcm &zeta){
    rep(i, n + 1){
        zeta[i] = polar(1.0, 2.0 * pi * i / n);
    }
}

vcm dft(int n, vcm f, bool inv, vcm &zeta){
    if(n == 1) return f;
    int n2 = n / 2;
    vcm f1(n2), f2(n2);
    rep(i,n) (!(i & 1) ? f1[i/2] : f2[i/2]) = f[i];
    f1 = dft(n2, f1, inv, zeta);
    f2 = dft(n2, f2, inv, zeta);
    int zeta_mul = (zeta.size() - 1) / n;
    rep(i, n){
        f[i] = f1[i % n2] + zeta[zeta_mul * (inv ? n - i : i)] * f2[i % n2];
    }
    return f;
}

vcm convolution(vcm g,vcm h){
    int sz = g.size() + h.size() - 1, n = 1;
    while(sz > n) n *= 2;
    g.resize(n);
    h.resize(n);
    vcm zeta(n + 1);
    make_zeta(n, zeta);
    vcm g_hat = dft(n, g, false, zeta), h_hat = dft(n, h, false, zeta);
    vcm gh_hat(n);
    rep(i,n) gh_hat[i] = g_hat[i] * h_hat[i];
    vcm gh = dft(n, gh_hat, true, zeta);
    rep(i, n) gh[i] /= cm(n);
    return gh;
}
int main(){
    cin>>N;
    const int p = 200003;
    vec in(N), log_two(p, 0), pow_two(p);
    ll temp = 1;
    rep(i, p - 1){
        log_two[temp] = i;
        pow_two[i] = temp;
        (temp *= 2)%=p;
    }
    vcm a(p, cm(0.0, 0.0)), b(p, cm(0.0, 0.0));
    cm one(1.0, 0.0);
    rep(i,N){
        cin>>in[i];
        if(in[i] != 0) {
            a[log_two[in[i]]] += one;
            b[log_two[in[i]]] += one;
        }
    }
    vcm fftresult = convolution(a, b);
    ll res = 0;
    /*
    rep(i,p * 2){
        if(fftresult[i].real() > 0.1) cout<<i<<' '<<fftresult[i].real()<<endl;
    }
     */
    rep(i,p - 1){
        res += pow_two[i] * (ll(fftresult[i].real() + 0.5) + ll(fftresult[i + p - 1].real() + 0.5));
    }
    rep(i,N) res -= (in[i] * in[i]) % p;
    cout<<res / 2<<endl;
}


Measured memory_bytes: 184704
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = (n) - 1; i >= 0; i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define all(ar) ar.begin(), ar.end()
#define rall(ar) ar.rbegin(), ar.rend()
#define sz(x) ((long long)x.size())
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
 
auto clk=clock();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll INF = 1e18L+5;
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
 
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<int> vint;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<bool> vb;

const ll N_MAX = 100005;
vvi adj(N_MAX);
vb vis(N_MAX);
vi dp(N_MAX);

void dfs(ll v){
    vis[v] = true;
    for(ll u : adj[v]){
        if(!vis[u])
            dfs(u);
        dp[v] = max(dp[v],dp[u]+1);
    }
}

void solve(){
    rep(i,N_MAX){
        adj[i].clear();
        vis[i] = false;
        dp[i] = 0;
    }

	ll n,m;
    cin>>n>>m;
    rep(i,m){
        ll x,y;
        cin>>x>>y;
        adj[x].pb(y);
    }

    fr(i,1,n)
        if(!vis[i])
            dfs(i);
    ll ans = *max_element(all(dp));
    cout<<ans;
}
 
int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<setprecision(11);
 
    ll t = 1;
    // cin>>t;
    while(t--)
        solve();
 
    // cout<<endl<<endl<<"Time elapsed: "<<((double)(clock()-clk)/CLOCKS_PER_SEC)*1000<<"ms"<<endl;
    return 0;
}

Measured memory_bytes: 12120
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define ss second
#define ff first 
#define ub upper_bound
#define lb lower_bound
// #define mp make_pair
const ll M=1000000007;
ll power(ll x,ll n){if(n==0)return 1;else if(n%2==0)return (power((x*x)%M,n/2))%M;else return ((x%M)*power(x,n-1)%M);}
ll ncr(int n,int r){if(r>n)return 0;if(r > n - r) r = n - r;ll ans = 1;
int i;for(i = 1; i <= r; i++){ans *= n - r + i;ans /= i;}return ans;}
ll nCrModpDP(ll n, ll r, ll p){ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
    C[0] = 1;
    for (ll i = 1; i <= n; i++){ 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
ll ncrmod(ll n, ll r, ll p){ 
   if (r==0) 
      return 1; 
   ll ni = n%p, ri = r%p; 
   return (ncrmod(n/p, r/p, p) * 
           nCrModpDP(ni, ri, p)) % p;  
} 
ll modInverse(ll a,ll m) 
{ 
   ll m0 = m; 
   ll y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
       ll q = a / m; 
       ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 
ll fun(ll num[],ll sum,ll n){
map<ll,ll>mp;
for(int i=0; i<n; i++){
mp[num[i]]++;
}
ll ans=0;
for(int i=0; i<n; i++){
if(mp[sum-num[i]]>0&&(sum-num[i]!=num[i])&&(mp[num[i]]>0)){
ans+=1,mp[sum-num[i]]--,mp[num[i]]--;
}
else if(mp[sum-num[i]]>=2&&(sum-num[i]==num[i])){
ans+=1,mp[sum-num[i]]-=2;
}
}
return ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string str;
cin>>str;
int n=str.length();
int paper=0,won=0,lose=0;
for(int i=0; i<n; i++){
if(str[i]=='g'){
if(paper>0)
paper-=1,won+=1;
else
paper+=1;
}else{
if(paper>0)
paper-=1;
else
paper+=1,lose+=1;
}
}
cout<<won-lose;
return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

int main(){
  int a, b;
  int n;
  while(cin >> n, n){
    int A, B;
    A = B = 0;
    for(int i = 0  ;i < n ; i++){
      cin >> a >> b;
      if(a > b) A += a+b;
      else if(a < b) B += a+b;
      else A += a, B += b;
    }
    cout << A << ' ' << B << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

int N=105;

char inter(string s){
    LL n = stol(s);
    if(N<=n&&to_string(N)<=to_string(n))return 'Y';
    if(N>n&&to_string(N)>to_string(n))return 'Y';
    return 'N';
}

bool ask(string s){
    cout<<"? "<<s<<endl;
    cout.flush();
    char res;cin>>res;
    return (res=='Y');
}

void ans(string s){
    cout<<"! "<<s<<endl;
    cout.flush();
}

int main(){

    string num="";
    while(true){
        int left=-1,right=9;
        while(true){
            //YESならそれ以下、NOならそれより大きい
            int center=(left+right)/2;
            if(num.size()==0&&center==0){
                num="1";
                break;
            }
            string nine="";
            REP(i,17-num.size())nine+="9";
            if(!ask(num + to_string(center)+nine))left=center;
            else{
                if(center==0){
                    //0でYの場合
                    string _s =to_string(stoi(num)*10-1);
                    if(!ask(_s)^_s.size()==num.size()){
                        ans(num);
                        return 0;
                    }
                }
                right =center;
            }
            if(center==(left+right)/2){
                num+=to_string(right);
                break;
            }
        }
    }

}

Measured memory_bytes: 596
#include<stdio.h>
void fibonacci(int n);
int F[44];
int main(){
  int n;
  scanf("%d",&n);
  fibonacci(n);
  printf("%d\n",F[n]);
  return 0;
}

void fibonacci(int n){
  int i;
  F[0]=F[1]=1;
  for(i=2;i<=n;i++)
    F[i]=F[i-2]+F[i-1];
}

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

int main() {
  int n;
  cin >> n;
  cout << ceil((double)n / 1000) * 1000 - n << endl;
  return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,line;
    int n,a,x,i,b,c,arr[26];

    for(i=0;i<26;i++)
    {
        arr[i]=0;
    }

while(getline(cin,line))
{
    if(line.empty())
        break;

    s +=  line;
}



     n=s.size();

    for(i=0;i<n;i++)
        {


        if(s[i]>='A'&&s[i]<='Z')
                s[i]+='a'-'A';

        }

     for(i=0;i<n;i++)
     {
       x=s[i]-'a';

       arr[x]=arr[x]+1;
     }

     a='a';

     for(i=0;i<26;i++)
    {
        cout<<char(a+i)<<" : "<<arr[i]<<endl;
    }

}



Measured memory_bytes: 3152
#include <iostream>

using namespace std;

int main()
{
	int a, b, c, d,r1,r2;
	cin >> a>>b>>c>>d;

	if (a >= 1 && a <= 10000 && b >= 1 && b <= 10000 && c >= 1 && c <= 10000 && d >= 1 && d <= 10000) {
		r1 = a * b;
		r2 = c * d;
		if (r1 >= r2) {
			cout << r1 << endl;
		}
		else
		{
			cout << r2 << endl;
		}


	}

}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
#define int long long

int next_combination(int bit) {
    int x = bit & -bit, y = bit + x;
    return (((bit & ~y) / x) >> 1) | y;
} /*(1<<k)-1から列挙*/

signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int cost = 1e17;
    for (int i = (1<<k) - 1; i < (1<<n); i = next_combination(i)) {
        int tmp = 0;
        int height = 0;
        for (int j = 0; j < n; ++j) {
            if(i & (1<<j)){
                if(height < a[j]){
                    height = a[j];
                    continue;
                }
                else{
                    tmp += height - a[j] + 1;
                    height++;
                    continue;
                }
            }
            height = max(height, a[j]);
        }
        cost = min(cost, tmp);
    }
    cout << cost << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class StringsWithTheSameLength
{
    static void Main(string[] args)
    {
        var number = int.Parse(Console.ReadLine());

        var words = Console.ReadLine().Split(' ');

        string first = words[0];
        string second = words[1];

        char[] wordList = new char[number * 2];

        for(var i = 0;i < number; i++)
        {
  
            wordList[ 2 * i] = first[i];
            wordList[2 * i + 1] = second[i];
        }

        foreach (var c in wordList) {
            Console.Write(c);

        }


    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define all(a) (a).begin(), (a).end()

#define equal equalll
#define less lesss
const int N = -1;
const long long INF = 1e9 + 19;


void read() {
	string s;
	cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;

}

void solve() {

}

void stress() {

}

int main(){
#ifdef MY_DEBUG
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif
    if (1) {
        int k = 1;
        for (int tt = 0; tt < k; tt++) {
            read();
            solve();
        }
    }
    else {
        stress();
    }

    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<queue>
#define int long long
#define mod 1000000007
using namespace std;

signed main() {
	int a; scanf("%lld", &a);
	int s = 1;
	for (int b = 1; b <= a; b++) {
		s = s*b%mod;
	}
	printf("%lld\n", s);
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a=0,b=0,n,i;
    char c,st[101]="";
    scanf("%d",&n);
    getchar();
    for(i=0;i<n;i++){
        scanf("%c",&c);
        st[i]=c;
        if(c=='('){
            a++;
        }
        else{
            if(a>0){
                a--;
            }
            else{
                b++;
            }
        }
    }
    for(i=0;i<b;i++){
        printf("(");
    }
    printf("%s",st);
    for(i=0;i<a;i++){
        printf(")");
    }
}

Measured memory_bytes: 128