akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int from, to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };

int dx[] ={-1, 0, 0, 1};
int dy[] ={0, -1, 1, 0};

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

//int dp[SIZE][3];
#define A 0
#define B 1
#define C 2

int main(void){
	static int dp[SIZE][3];
	int n; cin >> n;
	vint a(n), b(n), c(n);
	rep(i, n){
		cin >> a[i] >> b[i] >> c[i];
	}

	dp[0][A] = a[0];
	dp[0][B] = b[0];
	dp[0][C] = c[0];

	rep2(i, 0, n-1){
		dp[i+1][A] = max(dp[i+1][A], dp[i][B] + a[i+1]);
		dp[i+1][A] = max(dp[i+1][A], dp[i][C] + a[i+1]);

		dp[i+1][B] = max(dp[i+1][B], dp[i][A] + b[i+1]);
		dp[i+1][B] = max(dp[i+1][B], dp[i][C] + b[i+1]);

		dp[i+1][C] = max(dp[i+1][C], dp[i][A] + c[i+1]);
		dp[i+1][C] = max(dp[i+1][C], dp[i][B] + c[i+1]);
	}

	int ans = 0;
	rep(i, 3){
		//cout << dp[n-1][i] << endl;
		ans = max(ans, dp[n-1][i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int H; 
  cin >> H;

  int ans = 0;
  int p = 1;
  while(H > 0){
    H /= 2;
    ans += p;
    p *= 2;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val alist = readLine()!!.split(' ').map(String::toInt)

    var count = 0
    val map = alist.groupBy { it }
    for (key in map.keys) {
        val filtered = map[key]!!.size
        if (filtered > key) {
            count += filtered - key
        } else if (filtered < key) {
            count += filtered
        }
    }
    println(count)
}

Measured memory_bytes: 59548
#include <bits/stdc++.h>
//#include <boost/algorithm/string.hpp>
using namespace std;


void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}


#define Vec(a) vector<a>

#define ll long long
#define ld long double
#define ull unsigned long long
#define ull unsigned long long
#define mod 1000000007
#define pi (3.1415926)

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

#define scd(a)  scanf("%lld",&a)
#define scdd(a,b)	scanf("%lld%lld",&a,&b)
#define scddd(a,b,c)	scanf("%lld%lld%lld",&a,&b,&c)
#define ptab(a)	printf("%lld ",a)
#define pdn(a)	printf("%lld\n",a)
#define pddn(a,b)	printf("%lld %lld\n",a,b)
#define pdddn(a,b,c)	printf("%lld %lld %lld\n",a,b,c)

#define Filein(N) freopen("N", "r", stdin);
#define Fileout(N) freopen("N", "w", stdout);

#define forr(n) for(ll i=0;i<n;i++)
#define rev(n) for(ll i=n-1;i>=0;i--)
#define forp(x, y) for(ll i=x;i<y;i++)
#define loop( j, k, in) for (ll i=j ; i<k ; i+=in)

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define eps 1.0E-14
#define l length()
#define preci(x) cout << fixed<<setprecision(x)
#define inf LONG_LONG_MAX
#define ninf LONG_LONG_MIN


void odd(int n)
    {
    bool b=1;
        int x = sqrt(n);
    for (int i=2 ; i<=x ; ++i)

    {
        if(n%i == 0) {cout << "NO" << sp; b = 0;  break;}
    }
    if (b)
    cout << "Yes" << sp;
    b=1;
    }

ll sum (int n ){return ((n*(n+1)) / 2) ;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int a[4];

int main()
{
    init();

    short a , b ; cin>>a>>b;

    if (a>b) cout << "safe";
    else cout << "unsafe";
}



Measured memory_bytes: 3696
n = int(input())
A = list(map(int, input().split()))
flag = True
count = 0

while flag:
    flag = False
    for i in range(n-1):
        if A[i] > A[i+1]:
            v = A[i]
            A[i] = A[i+1]
            A[i+1] = v
            flag = True
            count += 1
print(" ".join(map(str, A)))
print(count)


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

typedef unsigned long long  ULL;
typedef long long LL;

#define pb push_back
#define mp make_pair
#define reset(a, b) memset(a, b, sizeof(a))
#define rep(i,b) for(int i=0; i<b; i++)
#define F first 
#define S second

 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int T;
//    cin>>T;
    T=1;
    while(T--){
       
       int k;
       cin>>k;
       ULL sum=0;
       for(int i=1; i<=k; i++){
           for(int j=1; j<=k; j++){
               for(int t=1; t<=k; t++){
                   sum+=__gcd(__gcd(i,j),t);
               }
           }
       }
       
       cout<<sum;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

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 F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

struct Widget
{
    int A;
    int B;
    bool operator<( const Widget& rhs ) const
    {
        return ( A + B ) < ( rhs.A + rhs.B );
    }
};

int main()
{
    int N;
    cin >> N;
    Widget W[ N ];
    REP( i, N )
    {
        int A, B;
        cin >> A >> B;
        W[ i ].A = A;
        W[ i ].B = B;
    }
    sort( W, W + N );
    LL ans = 0;
    REP( i, N )
    {
        if( i % 2 == 0 )
        {
            ans += W[ N - i - 1 ].A;
        }
        else
        {
            ans -= W[ N - i - 1 ].B;
        }
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import heapq
import itertools
def evaluate(siki):
    return lambda a,b,c,d:eval(siki.replace("-","-~"))%2
def changenum(siki):
    res=0
    for seq in itertools.product(range(2),repeat=4):
        a,b,c,d=seq
        if evaluate(siki)(a,b,c,d)==1:
            res+=2**(a+2*b+4*c+8*d)
    return res
D=dict()
def dget(m):
    if m in D:
        return D[m]
    else:
        return 17
q=[]
heapq.heappush(q,(1,changenum("a")))
heapq.heappush(q,(1,changenum("b")))
heapq.heappush(q,(1,changenum("c")))
heapq.heappush(q,(1,changenum("d")))
heapq.heappush(q,(1,changenum("0")))
heapq.heappush(q,(1,changenum("1")))
D[changenum("a")]=1
D[changenum("b")]=1
D[changenum("c")]=1
D[changenum("d")]=1
D[changenum("0")]=1
D[changenum("1")]=1
while(len(q)>0):
    le,n=heapq.heappop(q)
    #print(le,n,dget(240),dget(255))
    if D[n]<le:
        continue
    D[n]=min(D[n],le)
    cost=1
    if dget(65535^n)>D[n]+cost and D[n]+cost<=16:
        D[65535^n]=D[n]+cost
        heapq.heappush(q,(D[65535^n],65535^n))
    tmp=dict()
    for k in D:
        if dget(n^k)>D[n]+D[k]+3 and D[n]+D[k]+3<=16:
            tmp[n^k]=D[n]+D[k]+3
            heapq.heappush(q,(tmp[n^k],n^k))
        if dget(n&k)>D[n]+D[k]+3 and D[n]+D[k]+3<=16:
            tmp[n&k]=D[n]+D[k]+3
            heapq.heappush(q,(tmp[n&k],n&k))
    for k in tmp:
        D[k]=tmp[k]
while(True):
    S=input()
    if S==".":
        break
    print(D[changenum(S)])


Measured memory_bytes: 6044
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int[] s = new int[n+1];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }

        int q = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < q; i++) {
            int t = sc.nextInt();
            if (search(s, n, t) >= 0)
                ans++;
        }

        System.out.println(ans);
    }

    // 線形探索
    static int search(int[] a, int n, int key) {
        int i = 0;
        a[n] = key;
        while (a[i] != key) i++;
        if (i != n)
            return i;
        else
            return -1;
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


ll gcd(ll m, ll n){
  if(m == 0) return 0;
  if(n == 0) return 0;
	
	while(m != n){
		if(m > n) m = m - n;
		else    n = n - m;
	}
	return m;
}

int main(){
  ll a, b;
  cin >> a >> b;

  if(b < a) swap(a, b);

  ll g = gcd(a, b);

  ll cnt = 1;
  if(2 <= g && g%2 == 0){
    while(0 < g && g%2 == 0) g /= 2;
    cnt++;
  }
  for(ll i = 3; i <= sqrt(g); i += 2){
    if(g%i == 0){
      while(0 < g && g%i == 0) g /= i;
      cnt++;
    }
  }

  if(2 <= g) cnt++;
  
  cout << cnt << endl;


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {

    int x;
    int b, s, ans;

    scanf("%d", &x);

    b = x / 500;
    s = (x - b * 500) / 5;

    ans = b * 1000 + s * 5;

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <map>
#include <set>
using namespace std;

int main() {
    bool insertLinefeed = false;
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        multimap<int, string> teams;
        set<int> scores;
        for (int i = 0; i < n; i++) {
            string team;
            int win, lose, draw;
            cin >> team >> win >> lose >> draw;
            teams.insert(make_pair(3 * win + draw, team));
            scores.insert(3 * win + draw);
        }
        if (insertLinefeed) {
            cout << endl;
        } else {
            insertLinefeed = true;
        }
        for (set<int>::reverse_iterator sit = scores.rbegin(); sit != scores.rend(); sit++) {
            for (multimap<int, string>::iterator it = teams.lower_bound(*sit); it != teams.upper_bound(*sit); it++) {
                cout << it->second << "," << it->first << endl;
            }
        }
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[32][100010];
ll b[100010];
int main() {
	ll n,c;
	cin>>n>>c;
	for(int i=0;i<n;i++){
		ll x,y,z;
		cin>>x>>y>>z;
		z--;
		a[z][x]++;
		a[z][y]--;
	}
	for(int i=0;i<c;i++){
		for(int j=0;j<100010;j++){
			a[i][j+1]=a[i][j]+a[i][j+1];
		}
	}
	for(int i=0;i<100010;i++){
		ll now=0;
		for(int j=0;j<c;j++){
			if(a[j][i]==0&&a[j][i+1]==1){
				now++;
				continue;
			}
			now+=a[j][i];
		}
		b[i]=now;
	}
	ll ans=0;
	for(int i=0;i<100010;i++){
		ans=max(ans,b[i]);
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 24832
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
		ll gcd( ll a, ll b )
		{
			if(b==0)
			{
			     return a;
			}
			else
			{
			     return gcd( b, a%b );
			}
		}
		ll lcm (ll a, ll b)
		{
			return (a*b)/gcd(a,b);
		}
	void solve()
	{
		ll x;cin>>x;

		cout<<lcm(360,x)/x<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	char S[4];
	cin>>S;
	sort(S,S+4);
	if(S[0]==S[1]&&S[2]==S[3]&&S[1]!=S[2])cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import static java.util.Comparator.comparing;

import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
    final long INF = 100000000000000000L;
    int H, N;
    int[] A, B;
    long[] memo = new long[10010];
    long calc(int zan) {
    	if(zan <= 0)			return 0;
    	if(memo[zan] != -1)		return memo[zan];
    	long ans = INF;
    	for (int i = 0; i < N; i++) {
			ans = Math.min(ans, calc(zan - A[i]) + B[i]);
		}
    	return memo[zan] = ans;
    }
    public void solve() {
    	H = ni();
    	N = ni();
    	A = new int[N];
    	B = new int[N];
    	for (int i = 0; i < N; i++) {
			A[i] = ni();
			B[i] = ni();
		}
    	Arrays.fill(memo, -1);
    	out.println(calc(H));
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 28764
from math import gcd


def eratosthenes(n):
    prime = []
    data = [i for i in range(2, n + 1)]
    while True:
        p = data[0]
        if n <= p ** 2:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return data


def factorize(N):  # 素因数分解
    prime = set()
    for p in prime_list:
        if p * p > N:
            break
        while N % p == 0:
            N //= p
            prime.add(p)
    if N > 1:
        prime.add(N)
    return prime


n = int(input())
a = list(map(int, input().split()))

ans = 0
for ai in a:
    ans = gcd(ans, ai)
if ans != 1:
    print('not coprime')
    exit()

prime_list = eratosthenes(10 ** 6)
num = set()
for ai in a:
    prime = factorize(ai)
    if len(prime & num) > 0:
        print('setwise coprime')
        break
    num |= prime
else:
    print('pairwise coprime')


Measured memory_bytes: 250916
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

int main () {
   int n; std::cin >> n;
   int t, a; std::cin >> t >> a;

   std::vector<int> h (n);
   std::vector<double> av (n);

   for(int i = 0; i < n; i++) {
      std::cin >> h[i];
      av[i] = std::abs((t - h[i]*0.006) - a);
   }

   int ans = 1;

   double min = 100000;
   for(int i = 0; i < n; i++) {
      if(min > av[i]) {
         min = av[i];
         ans = i + 1;
      }
   }

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


   


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

int main() {
    const int num[3] = {3, 5, 7};
    int64_t n, ans = 0;
    cin >> n;
    queue<pair<int64_t, vector<bool>>> q;
    for (auto i = 0; i < 3; i++) {
        vector<bool> tmp(3, false);
        tmp[i] = true;
        q.emplace(num[i], tmp);
    }
    while (not q.empty()) {
        auto p = q.front();
        q.pop();
        if (p.first > n) continue;
        for (auto i = 0; i < 3; i++) {
            auto tmp = p;
            tmp.first = tmp.first * 10 + num[i];
            tmp.second[i] = true;
            if (tmp.first > n) continue;
            auto flg = true;
            for (auto j = 0; j < 3; j++)
                flg &= tmp.second[j];
            if (flg) ans++;
            q.push(tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5124
// Vivek Rai
// Blazer_007

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/detail/standard_policies.hpp>

#define fastio 		ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp	     make_pair
#define inf         0x3f3f3f3f
//#define INF         0x3f3f3f3f3f3f3f3fLL
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define ppi	    pair<ll,pii>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define see(x)	    cout<<x<<endl;
#define see2(x,y)   cout<<x<<" "<<y<<endl;
#define see3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define bit(x, y)   (((x)>>(y))&1)
#define bpt(x)      (__builtin_popcount(x))
#define bptl(x)     (__builtin_popcountll(x))
#define loop(i,a,b)  for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define N 2000010

using namespace std;
//using namespace __gnu_pbds;

//typedef priority_queue<int> maxHeap;
//typedef priority_queue<int,vector<int>,greater<int>()) minHeap;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// find_by_order(index) -> value at given index or Kth smallest element in set
// order_of_key(X) -> number of elements strictly less than X
//typedef tree<pii , null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

vector<int> graph[100001];
int dp[100001];

int solve(int src){
    if(dp[src]!=-1)
        return dp[src];
    int cur_ans = 0;
    bool leaf = true;
    for(auto child:graph[src]){
        leaf = false;
        cur_ans = max(cur_ans,solve(child));
    }
    if(leaf)
        return dp[src] = 0;
    return dp[src] = 1 + cur_ans;
}

void solution(){
    int n,m,u,v;
    cin >> n >> m;
    memset(dp,-1,sizeof dp);
    loop(i,0,m){
        cin >> u >> v;
        graph[u].pb(v);
    }
    int ans = 0;
    loop(i,1,n+1)
        ans = max(ans,solve(i));
    cout << ans << endl;
}

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

    ll t=1;
    // cin>>t;
    loop(i,1,t+1){
    	//cout<<"Case #"<<i<<": ";
    	solution();
    }
}




Measured memory_bytes: 7808
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
#define M 1000000007
int main(void){
	int i,j,k,lent,lenb,sum;
	char t[1001],b[1001];
	cin>>t>>b;
	lent=strlen(t); lenb=strlen(b);
	int dp[lenb][lent];
	for(i=0;i<lenb;i++){
		for(j=0;j<lent;j++) dp[i][j]=0;
	}
	for(i=0;i<lent;i++){
		if(b[0]==t[i])dp[0][i]=1;
	}
	for(i=0;i<lenb-1;i++){
		for(j=0;j<lent;j++){
			if(dp[i][j]!=0){
				for(k=j+1;k<lent;k++){
					if(b[i+1]==t[k]){
						dp[i+1][k]+=dp[i][j];
						dp[i+1][k]%=M;
					}
				}
			}
		}
	}
	sum=0;
	for(i=0;i<lent;i++){
		sum+=dp[lenb-1][i];
		sum%=M;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 7028
def main():
    import sys
    input = sys.stdin.buffer.readline
    Q = int(input())

    def Eratosthenes(sup: int) -> set:
        primes = [True for i in range(sup+1)]
        primes[0] = False
        primes[1] = False
        for i in range(2, sup+1):
            if sup < i*i:
                break
            if primes[i]:
                mul = 2
                while i*mul <= sup:
                    primes[i*mul] = False
                    mul += 1
        return {i for i in range(sup+1) if primes[i]}
    primes = Eratosthenes(10**5)
    S = [0]*(10**5+1)
    for a in range(2, 10**5+1):
        if a in primes and (a+1)//2 in primes:
            S[a] = 1
        S[a] += S[a-1]

    for _ in range(Q):
        le, ri = (int(i) for i in input().split())
        print(S[ri] - S[le-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 80380
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
 int t;
int arr[101];
scanf("%d",&t);
for(int i=0;i<t;i++)
{
 scanf("%d",&arr[i]);
}
sort(arr,arr+t);
printf("%d\n",arr[t-1]-arr[0]);
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n - 1; i++) {
    if (a[i] == a[i + 1]) {
      cout << "NO" << '\n';
      return 0;
    }
  }
  cout << "YES" << '\n';
  return 0;
}

Measured memory_bytes: 3984
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;


int main() {
	char s[20];
	cin >> s;
	int ans=0;
	int i;
	for (i = 0; s[i] != '\0'; i++) {
		if (s[i] == 'o')ans++;
	}
	if (ans+ 15-i>= 8)cout << "YES";
	else cout << "NO";
}


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

int main(){
    int a,b;
    string s,t,u;
    cin >> s >> t >> a >> b >> u;
    if (s == u){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
#define pi 3.1415926535
using namespace std;
int main(){
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double theta;
  theta=abs(30*h-(11*m)/2.0);
  theta=pi*(theta/180.0);
  double ans=0.0;
  ans=sqrt(a*a+b*b-2*a*b*cos(theta));
  cout << fixed << setprecision(15) << ans << endl;
}


Measured memory_bytes: 4228
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    K=I()
    if K%2==0 or K%5==0:
        print(-1)
        exit()
    a=7
    ans=1
    for i in range(1000000):
        if a%K==0:
            break
        else:
            a=(a*10+7)%K
            ans+=1
            
    print(ans)
    

main()


Measured memory_bytes: 62952
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	int N, ans = 0,a,mae=-1;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a;
		if (mae == a) {
			ans++;
			mae = -1;
		}
		else mae = a;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    int cnt = 0;
    for (int i = 0; i < n - 2; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            for (int k = j + 1; k < n; k++) {
                if (l[i] + l[j] <= l[k]) break;
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ull unsigned long long
#define mp make_pair
#define F first
#define S second
#define mod 1000000007

double dp[3005];

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

    double p;
    dp[0] = 1;
    for(int i=1; i<=n; i++)
    {
        cin >> p;
        for(int j = i; j>=0; j--)
        {
            dp[j] = (j == 0 ? 0 : dp[j-1]*p) + dp[j]*(1-p); 
            
        }
    }

    //dp[j]: j tane tura gelme olasılığı
    double ans = 0;
    for(int i=0; i<=n; i++)
    {
        if(i > n-i)
        {
            ans += dp[i];
        }
    }

    printf("%.10lf\n", ans);
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define ull              unsigned long long
#define f                first
#define s                second
#define sqr(x)           (x)*(x)
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define intlim           2147483648
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
#define mk(x1,y1) make_pair(x1, y1)
#define maxi 1000010
#define psz 20
using namespace std;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdin);

//ios_base::sync_with_stdio(false);
//cin.tie(NULL);



int main(){
    string s;
    int w;
    cin>>s>>w;
    int i=0,f=0;
    string res = "";

    while(i<s.size()){
        res+=s[i];
        i+=(w+f);
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

struct minco_flow{
	struct edge{
		int to,cap,co,p;
	};
	vector<edge> vs[105];
	
	void adde(int fr,int to,int cap,int co){
		vs[fr].push_back((edge){to,cap,co,vs[to].size()});
		vs[to].push_back((edge){fr,0,-co,vs[fr].size()-1});
	}
	
	int pv[105];
	int pe[105];
	int h[105];
	int dist[105];
	
	int inf;
	int n;
	minco_flow(int in){ inf=IINF; n=in; }
	
	int get_minco_flow(int st,int gl,int f){
		int res=0;
		memset(h,0,sizeof(h));
		while(f>0){
			pque(mp) que;
			fill(dist,dist+105,inf);
			dist[st]=0;
			que.push(mp(0,st));
			while(!que.empty()){
				mp pa=que.top();
				que.pop();
				int no=pa.sec,
					nd=pa.fir;
				if(dist[no] < nd)continue;
				rep(i,vs[no].size()){
					edge& e = vs[no][i];
					int td=nd + e.co + h[no] - h[e.to];
					if(e.cap<=0 || dist[e.to]<=td)continue;
					dist[e.to] = td;
					pv[e.to] = no;
					pe[e.to] = i;
					que.push(mp(td,e.to));
				}
			}
			if(dist[gl]==inf)return -1;
			
			rep(i,n){
				//printf("%d %d %d\n",i,h[i],dist[i]);
				h[i] += dist[i];
			}
			
			int tf=f;
			for(int no=gl; no!=st; no=pv[no]){
				tf = min(tf,vs[pv[no]][pe[no]].cap);
			}
			f -= tf;
			//printf("%d %d\n",tf,h[gl]);
			res += tf * h[gl];
			for(int no=gl; no!=st; no=pv[no]){
				edge& e = vs[pv[no]][pe[no]];
				e.cap -= tf;
				vs[e.to][e.p].cap += tf;
			}
		}
		
		return res;
	}
};



int main(void){
	int n,m,f;
	scanf("%d%d%d",&n,&m,&f);
	minco_flow flow(n);
	rep(i,m){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		flow.adde(a,b,c,d);
	}
	printf("%d\n",flow.get_minco_flow(0,n-1,f));
	return 0;
}

Measured memory_bytes: 3296
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var line = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
			WriteLine(line[0] * line[1]);
		}
	}
}


Measured memory_bytes: 19044
#include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int 
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
const int twx=5e3+100;
const int inf=0x3f3f3f3f;
ll read()
{
    ll sum=0;
    ll flag=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            flag=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=((sum*10)+c-'0');
        c=getchar();
    }
    return sum*flag;
}
int n;
int xs[twx];
struct LV
{
    int y;
    int Next;
}a[twx];
int Link[twx];
int len;
int asd[twx];
int qwe[2][twx];
void Insert(int x,int y)
{
    a[++len].y=y;
    a[len].Next=Link[x];
    Link[x]=len;
}
void dfs(int x)
{
    f3(Link[x],a[i].Next,i)
    {
        int y=a[i].y;
        dfs(y);
    }
    memset(qwe[0],0x3f,sizeof qwe[0]);
    int tmp=0;
    qwe[tmp][0]=0;
    f3(Link[x],a[i].Next,i)
    {
        int y=a[i].y;
        tmp=1-tmp;
        memset(qwe[tmp],0x3f,sizeof qwe[tmp]);
        f1(0,xs[x],j)
        {
            if(j-xs[y]>=0)
            {
                qwe[tmp][j]=min(qwe[tmp][j],qwe[1-tmp][j-xs[y]]+asd[y]);
            }
            if(j-asd[y]>=0)
            {
                qwe[tmp][j]=min(qwe[tmp][j],qwe[1-tmp][j-asd[y]]+xs[y]);
            }
        }
    }
    f1(0,xs[x],i)
    {
        asd[x]=min(asd[x],qwe[tmp][i]);
    }
}
void init()
{
	n=read();
    f1(2,n,i)
    {
        int p=read();
        Insert(p,i);
    }
    f1(1,n,i)
    {
        xs[i]=read();
    }
    memset(asd,0x3f,sizeof asd);
    dfs(1);
    if(asd[1]!=inf)
    {
        puts("POSSIBLE");
    }
    else
    {
        puts("IMPOSSIBLE");
    }
}
int main()
{
    init();
	return 0;
}


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

using namespace std;

#define ll long long int
#define get(a) ll a; cin >> a;
#define show(a) cout << a << endl;
#define full(p) p.begin(), p.end()
#define sz(a) (ll)(a.size())
#define pb push_back

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
	////////////////////////////////
	string s;
	cin >> s;

	for (int i = 0; i < sz(s); ++i)
		{
			if(s[i] == 'A')
				cout << 'T' ;
			else if(s[i] == 'T')
				cout << 'A';
			else if(s[i] == 'G')
				cout << 'C';
			else if(s[i] == 'C')
				cout << "G";
		}	
	cout << endl;
	return 0;
}

Measured memory_bytes: 3616
#!/usr/bin/env pypy3

def main():
    N = int(input())
    L = list(map(int, input().split()))
    count = 0
    for i in range(0, N-2):
        for j in range(i+1, N-1):
            for k in range(j+1, N):
                if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
                    continue
                if abs(L[j] - L[k]) < L[i] and L[i] < L[j] + L[k]:
                    count = count + 1
    print(count)


main()


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

int main(){
    int n;
    cin >> n;
    double ans;
    if (n%2==0){
        printf("%.10f",0.5000000000);
        printf("\n");
    }else if(n==1){
        printf("%.10f",1.0000000000);
        printf("\n");
    }else{
        ans = (double)(n/2+1)/n;
        printf("%.10f",ans);
        printf("\n");
    }
    

}

Measured memory_bytes: 256
#
#at coder beginner contest165 a we love golf
#
import math

input1 = input()
kbai= int(input1)
 
input2=input().split(" ")
mins= int(input2[0])
maxs= int(input2[1])
flg=0
ans=0
tmp=0

tmp=math.floor(mins/kbai)
ans=tmp*kbai
#print(tmp)

while ans <= maxs:
  if ans >= mins and ans <= maxs:
    flg=1
  ans=ans+kbai

if flg ==1:
  print("OK")
  #print(ans,maxs,mins,flg)
else:
  print("NG")
  #print(ans,maxs,mins,flg)


Measured memory_bytes: 9128
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class UnionFind:
    # Reference: https://note.nkmk.me/python-union-find/
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

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

        if x == y:
            return

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

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

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


def main():
    N, M = map(int, readline().split())
    P = [int(s) - 1 for s in readline().split()]
    XY = map(int, read().split())

    uf = UnionFind(N)
    for x, y in zip(*[iter(XY)] * 2):
        uf.union(x - 1, y - 1)

    Q = [0] * N
    for i, p in enumerate(P):
        Q[p] = i

    ans = 0
    for i, p in enumerate(P):
        if i == p or uf.same(i, Q[i]):
            ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 30356
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int ma[1010][1010]; 
int main()
{
	int h,w,i,j,a,b;
	scanf("%d%d%d%d",&h,&w,&a,&b);
	for(i=1;i<=b;i++)
	{
		for(j=1;j<=a;j++)
			ma[i][j]=0;
		for(j=a+1;j<=w;j++)
			ma[i][j]=1;
	}
	for(i=b+1;i<=h;i++)
	{
		for(j=1;j<=a;j++)
			ma[i][j]=1;
		for(j=a+1;j<=w;j++)
			ma[i][j]=0; 
	}
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
			printf("%d",ma[i][j]);
		printf("\n"); 
	}
	return 0;
}


Measured memory_bytes: 5248
#include <cstdio>

int main() {
  int x, y;
  while(1){
    scanf("%d %d", &x, &y);
    if(x == 0 && y == 0) break;
    else if(x < y){
      printf("%d %d\n", x, y);
    }
    else{
      printf("%d %d\n", y, x);
    }
  }

  return 0;
}

Measured memory_bytes: 2580
#include <iostream>
using namespace std;
int main(void){
    string s, t;
    cin >> s >> t;
    
    int sum = 0;
    for (int i = 0; i < 3; i++) {
      if (s[i] == t[i]) sum++;
    }
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9

vector<ll> daikus(vector<vector<mp> > &g,int s){
	priority_queue<mp,vector<mp>,greater<mp> > q;
	ll n = g.size();
	vector<bool> used(n,false);
	vector<ll> cost(n,(ll)1e10);
	q.push(mp(0,s) );
	while(!q.empty()){
		mp now = q.top();
		q.pop();
		ll nn = now.second;
		ll c = now.first;
		if(used[nn] ) continue;
		used[nn] = true;
		cost[nn] = c;
		for(int i=0;i<g[nn].size();i++){
			ll next = g[nn][i].second;
			ll nc = g[nn][i].first;
			if(used[next])continue;
			q.push(mp(c+nc,next) );
		}
	}
	return cost;
}

int main(){
	ll n,r;
	cin>>n>>r;
	vector<vector<mp> > g(n);
	for(int i=0;i<r;i++){
		ll a,b,d;
		cin>>a>>b>>d;
		a--,b--;
		g[a].push_back(mp(d,b) );
		g[b].push_back(mp(d,a) );
	}

	vector<vector<ll> > dis(n);
	for(int i=0;i<n;i++) dis[i] = daikus(g,i);
	vector<mp> sai;
	ll ma = 0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ma = max(ma,dis[i][j]);
		}
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(ma==dis[i][j]){
				sai.push_back(mp(i,j) );
			}
		}
	}
	vector<bool> used(n,false);
	vector<int> ans;
	for(int i=0;i<sai.size();i++){
	    		int s = sai[i].first;
			int t = sai[i].second;
			for(int j=0;j<n;j++){
			    	if(used[j])continue;
				if(dis[s][t] == dis[s][j] + dis[j][t] ){
					used[j] = true;
				}
			}

	}
	for(int i=0;i<n;i++){
		if(!used[i])ans.push_back(i+1);
	}
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++){
	cout<<ans[i]<<endl;
	}

	return 0;
}



Measured memory_bytes: 53704
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep (i, n) cin >> a[i];

  ll sum = 0, minus = 0;
  rep (i, n) {
    if (i % 2 == 0) {
      sum += a[i];
    } else {
      minus += a[i];
    }
  }

  ll x = (sum - minus);
  x /= 2;
  cout << x * 2 << " ";
  for (int i = 0; i < n - 1; i++) {
    if (a[i] - x == 0) {
      cout << "0" << " ";
      x = 0;
    } else {
      cout << (a[i] - x) * 2 << " ";
      x = (a[i] - x);
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3764
# -*- coding: utf-8 -*-

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 ** 18
MOD = 10 ** 9 + 7

def bfs(nodes, src):
    """ BFS(一般グラフ、重みなし) """
    from collections import deque

    N = len(nodes)
    que = deque([(src, 0)])
    dist = [INF] * N
    while que:
        u, c = que.popleft()
        if dist[u] != INF:
            continue
        dist[u] = c
        for v in nodes[u]:
            que.append((v, c+1))
    return dist

N, x, y = MAP()
x -= 1; y -= 1

nodes = [[] for i in range(N)]
for i in range(N-1):
    nodes[i].append(i+1)
    nodes[i+1].append(i)
nodes[x].append(y)
nodes[y].append(x)

distx = bfs(nodes, x)
disty = bfs(nodes, y)

G = list2d(N, N, 0)
for i in range(N):
    for j in range(i+1, N):
        G[i][j] = min(j - i, distx[i] + disty[j] + 1, distx[j] + disty[i] + 1)
ans = [0] * N
for i in range(N):
    for j in range(i+1, N):
        ans[G[i][j]] += 1
[print(a) for a in ans[1:]]


Measured memory_bytes: 84004
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Deque;
 
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        int count = 1;
        
        long gcdab = gcd(a,b);

        for(int i = 2; i <= Math.sqrt(gcdab); i++){
            if(gcdab % i == 0)
                count += 1;
            while(gcdab % i == 0){
                gcdab /= i;
            }
        }
        if(gcdab != 1)
            count += 1;

        System.out.println(count);
    }

    private static long gcd(long a,long b){
        if(b == 0)
            return a;
        else
            return gcd(b,a % b);
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;
public class Main {
 public static void main(String[] args){
	 Scanner sc = new Scanner(System.in);
	 int a = sc.nextInt();
	 int b = sc.nextInt();
	 int area = a*b;
	 int length = (a+b)*2;
	 System.out.println(area +" "+ length);
 }
}

Measured memory_bytes: 26084
#include "bits/stdc++.h"
// Custom Header <<<
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;
// >>>

struct FastIO {
    FastIO() { cin.tie(nullptr); ios::sync_with_stdio(false); }
} fastIO_ydk ;

constexpr i64 modPow(i64 n, i64 p, const int mod = MOD)
{
    i64 ret = 1;
    while(p) {
        if (p & 1) ret = (ret * n) % mod;
        n = (n * n) % mod;
        p >>= 1;
    }
    return ret;
}

template<int MOD> class ModInt {
private:
    long long n;
    using T = ModInt<MOD>;
public:
    constexpr inline ModInt(long long n_) : n(n_ % MOD) {}
    template<class Int> constexpr explicit inline operator Int() const { return n; }
    friend ostream& operator<<(ostream &os, T m) { os << m.n; return os; }
    constexpr inline T operator~() const { return modPow(n, MOD-2, MOD); }
    constexpr inline T& operator+=(T o) { n = (n + o.n) % MOD; return *this; }
    constexpr inline T& operator-=(T o) { n = (n - o.n + MOD) % MOD; return *this; }
    constexpr inline T& operator*=(T o) { n = (n * o.n) % MOD; return *this; }
    constexpr inline T& operator/=(T o) { n = (n * (~o).n) % MOD; return *this; }
};
using Mint = ModInt<MOD>;
Mint operator+(Mint a, Mint b) { return Mint(a) += b; }
Mint operator-(Mint a, Mint b) { return Mint(a) -= b; }
Mint operator*(Mint a, Mint b) { return Mint(a) *= b; }
Mint operator/(Mint a, Mint b) { return Mint(a) /= b; }

template<size_t N> struct Factrial {
    i64 a[N];
    constexpr inline Factrial() : a{1} { for (int i = 1; i < N; ++i) a[i] = (a[i-1] * i) % MOD; }
    constexpr inline Mint operator[] (size_t i) const { return a[i]; }
};

Factrial<100010> fact;

Mint comb(i64 n, i64 r) {
    if (n < r) return 0;
    if (r <= 0) return 1;
    return fact[n] / (fact[r] * fact[n-r]);
}

Mint perm(i64 n, i64 r) {
    if (n < r) return 0;
    if (r <= 0) return 1;
    return fact[n] / fact[r];
}

signed main()
{
    int N;
    int a[100010];
    bool exist[100010] {};
    int twice;

    cin >> N;
    rep(i, 0, N+1) {
        cin >> a[i];
        if (exist[a[i]]) {
            twice = a[i];
        } else {
            exist[a[i]] = true;
        }
    }

    int l, r;
    for (l = 0; a[l] != twice; ++l);
    for (r = N; a[r] != twice; --r);

    const int M = N - (r - l);

    for (int k = 1; k <= N+1; ++k) {
        cout << comb(N+1, k) - comb(M, k-1) << endl;
    }
}

/* vim:set foldmethod=marker foldmarker=<<<,>>> : */


Measured memory_bytes: 1664