akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18


int main(){
    int N;cin >> N;
    vector<int> h(N);
    rep(i,N) cin >> h[i];
    vector<int> dp(N);
    dp[1] = abs(h[1] - h[0]);
    int ans = 0;
    if(N == 2) ans = abs(h[1] - h[0]);
    else{
        rep(i,N-2){
            dp[i+2] = min(abs(h[i+2] - h[i+1]) + dp[i+1],abs(h[i+2] - h[i]) + dp[i]);
        }
        ans = dp[N-1];
    }
    cout << ans << endl;
}

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    int cnt = 0;

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

    for(int i = 0; i < n; i++){
        for(int j = n - 1; j >= i + 1; j--){
            if(a[j] < a[j - 1]){
                int tmp = a[j];
                a[j] = a[j - 1];
                a[j - 1] = tmp;
                cnt++;
            }
        }
    }
    
    for(int i = 0; i < n; i++){
        if(i < n - 1){
            cout << a[i] << ' ';
        }else{
            cout << a[i] << endl;
        }
    }
    cout << cnt << endl;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  if (a == b){
    cout << "a == b\n";
  }
   else if (a > b){
    cout << "a > b\n";
  } 
  else if (a < b){
    cout << "a < b\n";
  }
  return 0;
}


Measured memory_bytes: 3088
n, m = map(int, input().split())
lp, ls = [0] * m, [0] * m
for i in range(m):
    lp[i], ls[i] = input().split()

lpu = list(set(lp))
lac = [0] * n
lwa = [0] * n

for j in range(m):
    p = int(lp[j]) - 1
    if lac[p] == 0:
        if ls[j] == 'AC':
            lac[p] = 1
        else:
            lwa[p] += 1
    else:
        continue

print(sum(lac), sum(x * y for x, y in zip(lac, lwa)))

Measured memory_bytes: 21868
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  int n,m;

  cin >> n >> m;

  cout <<  (n*(n-1))/2 + (m*(m-1))/2 << endl;

  return 0;
}


Measured memory_bytes: 3580
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#","# => r#" "#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }

    let ab = a * b;
    let cd = c * d;

    if ab >  cd {
        ab
    } else {
        cd
    }.to_string()
}

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

#if debug
#include "printer.hpp"
#define dump(a) cerr << #a << "(" << __LINE__ << ") = " << a << endl;
#else
#define dump(...)
#endif

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a, b) for (int i = (b)-1; i >= a; i--)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
const ll mod = 1000000007;

ll pow(ll x, ll y) {
  ll ret = 1, tmp = x;
  while (y) {
    if (y % 2) ret = ret * tmp % mod;
    tmp = tmp * tmp % mod;
    y /= 2;
  }
  return ret;
}

ll inverse(ll x) { return pow(x, mod - 2); }

pair<bool, pair<double, double>> solve(ll a1, ll b1, ll c1, ll a2, ll b2,
                                       ll c2) {
  if (a1 == 0) {
    double y = double(c1) / double(b1);
    if (a2 == 0) {
      return {false, {0, 0}};
    }
    double x = (double(c2) - y * b2) / double(a2);
    return {true, {x, y}};
  }
  if (a2 == 0) {
    double y = double(c2) / double(b2);
    double x = (double(c1) - y * b1) / double(a1);
    return {true, {x, y}};
  }
  ll a = a1 * a2 / __gcd(a1, a2);
  b1 *= a / a1;
  c1 *= a / a1;
  b2 *= a / a2;
  c2 *= a / a2;
  a1 = a2 = a;
  if (b1 == b2) {
    return {false, {0, 0}};
  }
  double y = double(c1 - c2) / double(b1 - b2);
  double x = (double(c1) - double(b1) * y) / double(a1);
  return {true, {x, y}};
}

int main() {
  ll N;
  cin >> N;
  vector<double> x(N), y(N);
  rep(i, 0, N) cin >> x[i] >> y[i];
  double ans = double(1ll << 30);
  auto square = [](double d) { return d * d; };
  rep(i, 0, N) {
    rep(j, 0, N) {
      double u = 0;
      pair<double, double> center = {double(x[i] + x[j]) / 2,
                                     double(y[i] + y[j]) / 2};
      rep(l, 0, N) {
        u = max(u, sqrt(square(center.first - x[l]) +
                        square(center.second - y[l])));
      }
      ans = min(ans, u);

      rep(k, 0, N) {
        if (i == j || i == k || j == k) continue;
        ll a1 = 2 * (x[j] - x[i]);
        ll b1 = 2 * (y[j] - y[i]);
        ll c1 = x[j] * x[j] - x[i] * x[i] + y[j] * y[j] - y[i] * y[i];

        ll a2 = 2 * (x[k] - x[i]);
        ll b2 = 2 * (y[k] - y[i]);
        ll c2 = x[k] * x[k] - x[i] * x[i] + y[k] * y[k] - y[i] * y[i];

        auto solution = solve(a1, b1, c1, a2, b2, c2);
        if (solution.first) {
          auto center = solution.second;
          double u = 0;
          rep(l, 0, N) {
            u = max(u, sqrt(square(center.first - x[l]) +
                            square(center.second - y[l])));
          }
          ans = min(ans, u);
        }
      }
    }
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int N=2e5+5;
const double eps=1e-4;
typedef long long ll;
typedef pair<int,int> pii;
int a[N];
int vis[N];
vector<int>g[N];
int main()
{
    int n;
    scanf("%d",&n);
    a[0]=1;
    for(int i=1;i<=n;i++)
    {
        int b;
        scanf("%d",&b);
        a[i]=a[i-1];
        if(vis[b]&&vis[b]<i-1)
            a[i]=(a[i]+a[vis[b]])%mod;
        vis[b]=i;
    }
    printf("%d\n",a[n]);
    return 0;
}



Measured memory_bytes: 6528
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
#include <atcoder/mincostflow>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()


const long long BIG = 1'000'000'000;

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

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

    /**
     * generate (s -> row -> column -> t) graph
     * i-th row correspond to vertex i
     * i-th col correspond to vertex n + i
     **/
    atcoder::mcf_graph<int, long long> g(2 * n + 2);
    int s = 2 * n, t = 2 * n + 1;

    // we can "waste" the flow
    g.add_edge(s, t, n * k, BIG);

    for (int i = 0; i < n; i++) {
        g.add_edge(s, i, k, 0);
        g.add_edge(n + i, t, k, 0);
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            long long a;
            cin >> a;
            g.add_edge(i, n + j, 1, BIG - a);
        }
    }

    auto result = g.flow(s, t, n * k);
    cout << 1LL * n * k * BIG - result.second << endl;

    vector<string> grid(n, string(n, '.'));
    auto edges = g.edges();
    for (auto e : edges) {
        if (e.from == s || e.to == t || e.flow == 0) continue;

        grid[e.from][e.to - n] = 'X';
    }

    for (int i = 0; i < n; i++) {
        cout << grid[i] << endl;
    }

	return 0;
}


Measured memory_bytes: 3908
try:
   while True:
      cards = input()
      if cards == "-": break
      m = int(input()) #シャッフルの回数
      
      for i in range(m):
         h = int(input()) #シャッフルするカードの枚数
         neworder = cards[h:len(cards)]
         #print("#1", neworder)
         for j in range(h):
            #print("+", cards[j])
            neworder += cards[j]
            #print("#", neworder)
         cards = neworder
         #print("#2", cards)
   
      print(cards)

except EOFError:
   pass



Measured memory_bytes: 5600
import itertools

n,m,r = map(int, input().split())
v = list(map(int, input().split()))

inf = float('inf')
l = [[inf for i in range(n)] for j in range(n)]

for i in range(m):
    a,b,c = map(int, input().split())
    l[a-1][b-1]=c
    l[b-1][a-1]=c

for i in range(n):
    l[i][i]=0

for k in range(n):
    for i in range(n):
        for j in range(n):
            l[i][j] = min(l[i][j], l[i][k]+l[k][j])

ans = inf

for i in range(r):
    v[i]-=1

s = list(itertools.permutations(v))

for i in range(len(s)):
    a = 0
    for j in range(r-1):
        a += l[s[i][j]][s[i][j+1]]
    ans = min(ans, a)

print(ans)

Measured memory_bytes: 78552
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	o, _ := strconv.Atoi(s[0:2])
	t, _ := strconv.Atoi(s[2:4])
	if (o > 12 || o == 0) && t <= 12 && t > 0 {
		fmt.Println("YYMM")
		return
	}
	if (t > 12 || t == 0) && o <= 12 && o > 0 {
		fmt.Println("MMYY")
		return
	}
	if t == 0 && o == 0 {
		fmt.Println("NA")
		return
	}
	if t <= 12 && o <= 12 {
		fmt.Println("AMBIGUOUS")
		return
	}
	fmt.Println("NA")
}


Measured memory_bytes: 512
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            if (n == 0 && m == 0) break;
            var suisen = new int[m + 1];
            for (int i = 0; i < n; i++)
            {
                string[] line2 = Console.ReadLine().Trim().Split(' ');
                var a = int.Parse(line2[0]);
                var b = int.Parse(line2[1]);
                if (b > suisen[a]) suisen[a] = b;
            }
            Console.WriteLine(suisen.Sum());
        }
    }
}

Measured memory_bytes: 9564
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
char str[maxn];
int dp[maxn];
int ans=0;

int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
	scanf("%s",str);
	int n=strlen(str);
	repd(i,0,n-1)
	{
		if(str[i]=='A'||str[i]=='C'||str[i]=='G'||str[i]=='T')
		{
			dp[i]=dp[i-1]+1;
		}
		ans=max(ans,dp[i]);
	}	
	printf("%d\n",ans);
	
	
	
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 2304
#include <cstdio>
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(void) {

	int x = 0, max = 1;
	int tmp = 1;

	cin >> x;

	for (int i = 1; i <= 1000; i++) {
		for (int j = 2; j <= 1000; j++) {
			tmp = (int)pow((double)i, (double)j);
			if (max < tmp && tmp <= x) {
				max = tmp;
			}
		}
	}

	cout << max << endl;


	return 0;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
int main()
{
    ll i=1;
    while(1)
    {
        ll a; cin>>a;
        if(a==0)
        {
            cout<<i;
            break;
        }
        else i++;
    }
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int h, w, n;
int sr, sc;
string s, t;

bool solve() {
    int lft = 0, rgt = w - 1;
    int top = 0, btm = h - 1;

    for (int i = n - 1; i >= 0; i--) {
        if (t[i] == 'L')
            rgt = min(rgt + 1, w - 1);
        else if (t[i] == 'R')
            lft = max(lft - 1, 0);
        else if (t[i] == 'U')
            btm = min(btm + 1, h - 1);
        else if (t[i] == 'D')
            top = max(top - 1, 0);

        if (s[i] == 'L')
            lft++;
        else if (s[i] == 'R')
            rgt--;
        else if (s[i] == 'U')
            top++;
        else if (s[i] == 'D')
            btm--;

        if (lft > rgt || top > btm) return false;
    }

    if (lft <= sc && sc <= rgt && top <= sr && sr <= btm) {
        return true;
    } else {
        return false;
    }
}

int main(void) {
    cin >> h >> w >> n;
    cin >> sr >> sc;
    sr--, sc--;
    cin >> s >> t;

    if (solve()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

#define ll long long
#define ld long double

const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

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

string s;
int main() {
    INIT();
    cin >> s;
    for(char c : s) {
        if(c == '?') {
            cout << 'D';
        } else {
            cout << c;
        }
    }
    return 0;
}

Measured memory_bytes: 3756
N,x=map(int,input().split())

if x==1 or x==2*N-1:
  print('No')
  exit()

print('Yes')

r=[x-1,x,x+1]
tmp=list(range(1,x-1))+list(range(x+2,2*N))

ans=tmp[:N-2]+r+tmp[N-2:]

for a in ans:
  print(a)

Measured memory_bytes: 15348
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			while(a % 2 == 0) {
				count++;
				a /=2;
			}
		}
		System.out.println(count);
	}
}

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

int main(){
    long long N;//Nの素因数を求めてから、そのかけ合わせでできるうちのFの最小値を求める
    cin>>N;
    vector<pair<long long,long long>> F;
    int c=0;
    /*if(N==1) {
        cout<< 1 << endl;
        return 0;
    } */
    for(long long i=1;i<=sqrt(N);i++){
        if(N%i==0) {
            F.push_back(make_pair(i,N/i));
            c++;
    }
    }
    F.resize(c);
    /* for(int i=0;i<c;i++){
    cout<<F[i].first<<" "<<F[i].second<<endl;
    }*/
    vector<pair<string,string>> f(c);
    vector<int> s(c);
    for(int i=0;i<c;i++){
        f[i].first=to_string(F[i].first);
        f[i].second=to_string(F[i].second);
        s[i]=max(f[i].first.size(),f[i].second.size());
    }
    sort(s.begin(),s.end());
    cout<<s[0]<<endl;
    return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

long N;
VL C, S, F;
int main() {
    std::cin >> N;
    C.resize(N-1), S.resize(N-1), F.resize(N-1);
    REP(i, N-1) {
        std::cin >> C[i] >> S[i] >> F[i];
    }

    REP(i, N) {
        long t = 0;
        for(long j=i; j<N-1; ++j) {
            while(true) {
                if(t < S[j]) {
                    ;
                } else if(t == S[j]) {
                    break;
                } else if(t % F[j] == 0) {
                    break;
                }
                t++;
            }
            t += C[j];
        }
        std::cout << t << std::endl;
    }
}

Measured memory_bytes: 256
/*
[dp] G - Longest Path
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 1e5;
const int MAX_M = 1e5;

int N, M;
int x[MAX_M], y[MAX_M];
vector<int> g[MAX_N];
int dep[MAX_N];
bool visited[MAX_N];

int dfs(int u) {
    if (visited[u]) {
        return dep[u];
    }
    visited[u] = true;

    dep[u] = 0;
    for (int v : g[u]) {
        dep[u] = max(dep[u], dfs(v) + 1);
    }

    return dep[u];
}

ll solve() {
    for (int i = 0; i < M; i++) {
        g[x[i]].push_back(y[i]);
    }
    for (int i = 0; i < N; i++) {
        dfs(i);
    }

    return *max_element(dep, dep + N);
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 8320
/**
 *    author:  tourist
 *    created: 13.06.2020 15:18:47       
**/
#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, s, t;
  cin >> n >> k >> s >> t;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if ((t & s) != s) {
    cout << 0 << '\n';
    return 0;
  }
  vector<vector<long long>> C(n + 1, vector<long long>(n + 1));
  for (int i = 0; i <= n; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
    }
  }
  vector<long long> ways(n + 1);
  for (int i = 0; i <= n; i++) {
    for (int j = 1; j <= min(i, k); j++) {
      ways[i] += C[i][j];
    }
  }
  vector<int> b;
  long long ans = 0;
  for (int mask = 0; mask < (1 << 18); mask++) {
    if ((mask & (t ^ s)) != mask) {
      continue;
    }
    int sign = (__builtin_popcount(mask) % 2 == 0 ? 1 : -1);
    b.clear();
    for (int i = 0; i < n; i++) {
      if ((a[i] & s) != s) {
        continue;
      }
      if ((a[i] | t) != t) {
        continue;
      }
      b.push_back(a[i] & mask);
    }
    sort(b.begin(), b.end());
    int beg = 0;
    while (beg < (int) b.size()) {
      int end = beg;
      while (end + 1 < (int) b.size() && b[end + 1] == b[end]) {
        ++end;
      }
      ans += sign * ways[end - beg + 1];
      beg = end + 1;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3680
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		sc.close();

		Arrays.sort(h);
		int ans = Integer.MAX_VALUE;
		for (int i = k - 1; i < n; i++) {
			int d = h[i] - h[i - k + 1];
			ans = Math.min(ans, d);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 49592
n = int(input())
cards = {}
for i in range(n):
    card = input()
    cards[card] = 1
    
#print(cards)

for c in ['S', 'H', 'C', 'D']:
    for n in range(1, 14):
        key = c + ' ' + str(n)
        if not key in cards:
            print(key)



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

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll M;

void solve(){
    cout << 48 - M << endl;
}

int main(){
    cin >> M;

    solve();
}

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

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			int count = int.Parse(Console.ReadLine());
			var restaurants = new List<Restaurant>(count);
			for (int i = 0; i < count; i++)
			{
				var input = Console.ReadLine().Split(' ');
				restaurants.Add(new Restaurant(input[0], int.Parse(input[1]), i + 1));
			}
			restaurants.Sort();
			for (int i = 0; i < count; i++)
			{
				Console.WriteLine(restaurants[i].Number);
			}
		}
	}

	public class Restaurant : IComparable<Restaurant>
	{
		private string mCity;
		private int mPoint;
		private int mNumber;

		public Restaurant(string city, int point, int number)
		{
			mCity = city;
			mPoint = point;
			mNumber = number;
		}

		public string City { get { return mCity; } }
		public int Point { get { return mPoint; } }
		public int Number { get { return mNumber; } }

		public int CompareTo(Restaurant other)
		{
			int compare = this.City.CompareTo(other.City);
			if (compare == 0)
			{
				return other.Point - this.Point;
			}
			else
			{
				return compare;
			}
		}
	}
}


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

int main(){
    int n;
    cin >> n;
    bool ok=true;
    string s,tmp;
    map<string,int> Map;
    for(int i=0;i<n;i++){
        //cout << i << endl;
        cin >> s;
        if(Map[s]==0)Map[s]++;
        else{ok=false;}
        if(i==0)tmp=s;
        else{
            if(tmp[tmp.size()-1]==s[0]){tmp=s;}
            else{ok=false;tmp=s;}
        }
        //cout << tmp.size() << " " << s << endl;
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<cstring>
#define inf 2147483647
#define For(i,a,b) for(long long i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar()
#define N 1000100
//2018.10.25;6:37
using namespace std;
long long n,t[N<<4],a[N<<4],l,r,mid,cnt,b[N<<4];
void in(long long &x){
    long long y=1;
    char c=g();x=0;
    while(c<'0'||c>'9'){
        if(c=='-')y=-1;
        c=g();
    }
    while(c<='9'&&c>='0'){
        x=(x<<1)+(x<<3)+c-'0';c=g();
    }
    x*=y;
}
void o(long long x){
    if(x<0){
        p('-');
        x=-x;
    }
    if(x>9)o(x/10);
    p(x%10+'0');
}

void modify(long long k){
    for(;k<=N<<1;k+=k&(-k))
        t[k]++;
}

long long get(long long k){
    long long ans=0;
    for(;k;k-=k&(-k))
        ans+=t[k];
    return ans;
}

bool check(long long x){
    For(i,1,n)
    b[i]=b[i-1]+(a[i]>=x?1:-1);
    cnt=0;
    memset(t, 0, sizeof(t));
    For(i,0,n){
        cnt+=get(b[i]+N);
        modify(b[i]+N);
    }
    return cnt>=n*(n+1)/4;
}

int main(){
//	freopen("t.in","r",stdin); 
    in(n);
    For(i, 1, n)in(a[i]);
    if(n==1){
    	o(a[1]);
    	return 0;
	}
	if(n==2){
		o(max(a[1],a[2]));
		return 0;
	}
    r=10000000000;
    while(l<r){
        mid=(l+r)>>1;
        if(check(mid))l=mid+1;
        else
            r=mid;
    }
    o(l-1);
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;
typedef long long ll;

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

    int ans = 0;
    rep(i, n){
        if(s[i] != s[i + 1]) ans++;
    }
    OP(ans);
}


Measured memory_bytes: 512
def solve():
    N, M = map(int, input().split())
    L = []
    R = []
    for _ in range(M):
        tmp = input().split()
        L.append(int(tmp[0]))
        R.append(int(tmp[1]))
    ans = min(R) - max(L) + 1
    ans = ans if ans >= 0 else 0
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 11012
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x1 = sc.nextInt();
    int y1 = sc.nextInt();
    int x2= sc.nextInt();
    int y2= sc.nextInt();

    int dx = x2-x1;
    int dy = y2-y1;
    int addx = -dy;
    int addy = dx;

    int x3 = x2+addx;
    int y3 = y2+addy;
    int x4 = x3-dx;
    int y4 = y3-dy;


    System.out.print(x3);
    System.out.print(" ");
    System.out.print(y3);
    System.out.print(" ");
    System.out.print(x4);
    System.out.print(" ");
    System.out.println(y4);
  }
}


Measured memory_bytes: 22608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

int main() 
{

 fast();
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt","w",stdout);
  // #endif
  ll n;
  cin >> n;
  vec q(n-1);
  f(i,0,n){
    cin >> q[i];
  }
  ll s=q[0];
  f(i,1,n-1){
    s+=min(q[i],q[i-1]);
  }

  // if(n==2)
  // s+=q[n-2]+q[n-2];
  // else
    s+=q[n-2];
  cout<<s;
  cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int n,i;
    char s[100000];
    scanf("%d",&n);
    scanf("%s",s);
    for(i=0;i<strlen(s);i++){
        int x=s[i]-65;
        int y=(x+n)%26;
        printf("%c",y+65);
    }
    return 0;
}

Measured memory_bytes: 256
use v5.18;
use warnings;
use Data::Dumper;
use List::Util qw( min );
sub line { chomp(my $str = <STDIN>); $str }
sub split_line { split / /, line }
my ($train_nomal, $train_unlimit, $bus_nomal, $bus_unlimit) = map { line } 0 .. 3;
say min($train_nomal, $train_unlimit) + min($bus_nomal, $bus_unlimit);

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

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var x = new long[N];
        var y = new long[N];
        for (int i = 0; i < N; i++)
        {
            var xy = ReadLine().Split().Select(long.Parse).ToArray();
            x[i] = xy[0];
            y[i] = xy[1];
        }

        if (N == 1)
        {
            WriteLine(1);
            return;
        }

        var ans = int.MaxValue;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                if (i == j) continue;
                var a = x[i] - x[j];
                var b = y[i] - y[j];

                var uf = new UnionFind(N);
                for (int k = 0; k < N; k++)
                {
                    for (int l = 0; l < N; l++)
                    {
                        if (k == l) continue;
                        if (x[k] - x[l] == a && y[k] - y[l] == b)
                        {
                            uf.Unite(k, l);
                        }
                    }
                }
                ans = Min(ans, uf.Count);
            }
        }
        WriteLine(ans);
    }
}

public class UnionFind
{
    int[] parent;
    int count;
    public int Count => count;

    public UnionFind(int length)
    {
        parent = new int[length];
        for (int i = 0; i < parent.Length; i++)
        {
            parent[i] = -1;
        }
        count = length;
    }

    int Root(int x) => parent[x] < 0 ? x : parent[x] = Root(parent[x]);

    public bool Same(int x, int y) => Root(x) == Root(y);

    public bool Unite(int x, int y)
    {
        x = Root(x);
        y = Root(y);
        if (x == y) return false;
        count--;
        if (parent[x] < parent[y])
        {
            parent[x] += parent[y];
            parent[y] = x;
        }
        else
        {
            parent[y] += parent[x];
            parent[x] = y;
        }
        return true;
    }

    public int Size(int x) => -parent[Root(x)];
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
long long int dp[51][51][2501];
int main(){
  int n,a;
  cin >>n >>a;
  int x[n+1];
  for(int i=1;i<=n;i++)cin>>x[i];
  x[0]=51;
  dp[0][0][0]=1;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      for(int k=0;k<=n*a;k++){
        if(i>=1 && x[i]>k)dp[i][j][k]=dp[i-1][j][k];
        else if(i>=1 && j>=1 && k>=x[i])dp[i][j][k]=dp[i-1][j-1][k-x[i]]+dp[i-1][j][k];
        else if(i==0 && j==0 && k==0)dp[i][j][k]=1;
      }
    }
  }
  long long int ans=0;
  for(int i=1;i<=n;i++){ans+=dp[n][i][i*a];
                       cerr<<dp[n][i][i*a];}
  cout << ans <<endl;
  
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N; cin >> N;
	vll A(N); cin >> A;

	int cnt = 0;	
	for (int i = 0; i < N; i++) {
		if (A[i]&1) cnt++;
	}

	if (cnt == 0) cout << "second" << endl;
	else cout << "first" << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#define MOD 1000000007

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const int INF=1e9;
const double eps=0.0000000001;


int main(){
  ll n;
  cin >> n;
  ll i=1,ans=0;
  while(1){
    if((n-i)/i<=i)break;
    if((n-i)%i==0 && (n-i)/i!=0){
      ans+=(n-i)/i;
    }
    i++;
    
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
    int N;
    int x[8];
    int y[8];
    int i;
    int c;
    double total_length;

    cin >> N;
    for(i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    vector<int> order(N);
    for(i = 0; i < N; i++) {
        order[i] = i;
    }

    c = 0;
    total_length = 0;
    do {
        for(i = 0; i < N-1; i++) {
            total_length += sqrt(pow(x[order[i+1]]-x[order[i]], 2) + pow(y[order[i+1]]-y[order[i]], 2));
        }
        c++;
    } while (next_permutation(order.begin(), order.end()));

    //cout << total_length /  (double)c << endl;
    cout << fixed << std::setprecision(10) << total_length/c << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <set>
#include <sstream>
#include <map>
#include <iomanip>
using namespace std;

const int MAX_N = 2e5 + 5;
int a[MAX_N];

int main()
{
	int N;
	cin >> N;
	int ans = -1;
	for (int i = 0; i < N; i++) {
		int d;
		cin >> d;
		a[d] = a[d - 1] + 1;
		ans = max(ans, a[d]);
	}
	cout << N - ans;
	return 0;
}

Measured memory_bytes: 1152
a[1<<20];
n=1<<20;
main(i,c){
	*a=a[1]=1;
	for(;++i<n;)
		if(!a[i])
			for(c=2;c*i<n;)
				a[i*c++]=1;
	for(;scanf("%d",&n),n;printf("%d\n",c)){
		c=0;
		for(i=n;++i<=2*n;)
			a[i]||c++;
	}
	0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>

using namespace std;

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

	std::vector<int> count(N, 0);

	for (int i = 0; i < M; i++) {
		int a,b;
		cin >> a >> b;

		count[a-1]++;
		count[b-1]++;
	}

	for (int i = 0; i < N; i++) {
		cout << count[i] << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    int lcm = n * m / __gcd(n, m);
    int ans = 0;
    rep(i, 0, lcm / m){
        int MAX = 0, MIN = INF;
        rep(j, 0, m){
            int id = (i * m + j) % n;
            chmin(MIN, a[id]);
            chmax(MAX, a[id]);
        }
        ans += MAX - MIN;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int n;
	cin>>n;
	int a[n+1],b[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		b[a[i]]=i;
	}
	for(int i=1;i<=n;i++){
		cout<<b[i]<<" ";
	}

}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int A[1005][1005];
int INDEX[1005];
int B[1005];
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    queue<i_i> que;
    cin >> N;
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j < N; j++) {
            cin >> A[i][j];
        }
    }
    for(int i = 1; i <= N; i++) {
        INDEX[i] = 1;
        int enemy = A[i][1];
        if(enemy > i && A[enemy][1] == i) {
            que.push({i, enemy});
        }
    }
    while(!que.empty()) {
        i_i now = que.front();
        int day = max(B[now.first], B[now.second]) + 1;
        int s = now.first;
        int t = now.second;
        que.pop();
        B[now.first] = day;
        B[now.second] = day;
        INDEX[now.first]++;
        INDEX[now.second]++;
        if(INDEX[now.first] < N) {
            int enemy = A[s][INDEX[s]];
            if(A[enemy][INDEX[enemy]] == s) {
                que.push({s, enemy});
            }
        }
        if(INDEX[t] < N) {
            int enemy = A[t][INDEX[t]];
            if(A[enemy][INDEX[enemy]] == t) {
                que.push({t, enemy});
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= N; i++) {
        if(INDEX[i] < N) {
            cout << -1 << endl;
            return 0;
        }
        chmax(ans, B[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
fun main(arg: Array<String>) {
    val INF = 1001001001
    var (N, X, Y) = listOfInt(0, -1, -1)
    val ans = IntArray(N)
    for (st in 0 until N) {
        val V = IntArray(N) { INF }
        val Q = Queue<Int>()
        fun push(v: Int, d: Int) {
            if (v !in 0 until N) return
            if (V[v] != INF) return
            V[v] = d
            Q.enqueue(v)
        }
        push(st, 0)
        while (!Q.isEmpty()) {
            val v = Q.dequeue()!!
            val d = V[v]
            push(v - 1, d + 1)
            push(v + 1, d + 1)
            if (v == X) push(Y, d + 1)
            if (v == Y) push(X, d + 1)
        }
        repeat(N) { n-> ans[V[n]] += 1 } 
    }
    println(ans.drop(1).map { it / 2 }.joinToString("\n"))
}

class Queue<T> {
    val elements = mutableListOf<T>()
    fun isEmpty() = elements.isEmpty()
    fun count() = elements.size
    fun enqueue(t: T) = elements.add(t)
    fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null
    fun peek() = if (!isEmpty()) elements[0] else null
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map(String::toDouble)
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }
fun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }
fun listOfLong(vararg offset: Long) = listOfString().map { java.lang.Long.parseLong(it) }.mapIndexed { index, long -> long + offset[index % offset.size] }
fun listOfDouble(delta: Double = 0.0) = listOfString().map { java.lang.Double.parseDouble(it) + delta }
fun pairIntLong() = listOfLong().let { Pair(it[0].toInt(), it[1]) }
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }
fun tripleIntLongLong() = listOfLong().let { Triple(it[0].toInt(), it[1], it[2]) }
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }
fun tripleIntIntLong(offset: Triple<Int, Int, Long> = Triple(0, 0, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1].toInt() + offset.second, it[2] + offset.third) }
fun tripleIntLongLong(offset: Triple<Int, Long, Long> = Triple(0, 0L, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1] + offset.second, it[2] + offset.third) }



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

#define INT_MAX 2147483647
#define SQ_TWO 1.41421356

int sg(double x) {
    return (int)(x < 0.0 ? x-0.5 : x+0.5 );
}

int main(void){
    int x1, x2, y1, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

    double x = (double)(x2 - x1);
    double y = (double)(y2 - y1);
    double x4 = -y + (double)x1;
    double y4 = x + (double)y1;

    double X = (double)(x2 - x1) * SQ_TWO;
    double Y = (double)(y2 - y1) * SQ_TWO;

    double x3 = X / SQ_TWO - Y / SQ_TWO + (double)x1;
    double y3 = X / SQ_TWO + Y / SQ_TWO + (double)y1;

    printf("%d %d %d %d\n", sg(x3), sg(y3), sg(x4), sg(y4));

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define infi 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////
signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int k;
	cin>>k;
	int a,b;
	cin>>a>>b;
	if((a-1)/k==b/k)
	{
		cout<<"NG";
	}
	else
		cout<<"OK";
	#ifdef ANIKET_GOYAL
		cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
} 

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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[])
{
	int a;
	scanf("%d",&a);
	printf("%d\n",a+a*a+a*a*a);
	return 0;
}

Measured memory_bytes: 3808
using System;

class Program
{
	static void Main(string[] args)
	{
		int count = 0;

		int n = int.Parse(Console.ReadLine());
		for(int i=0; i<n; i++)
		{
			int x = int.Parse(Console.ReadLine());
			if(IsPrime(x))
			{
				count++;
			}
		}

		Console.WriteLine(count);
	}

	static bool IsPrime(int x)
	{
		int p = (int)Math.Sqrt(x);
		bool is_prime = true;
		for (int i=2; i<=p; i+=(i==2)?1:2)
		{
			if (x%i == 0)
			{
				is_prime = false;
				break;
			}
		}
		if (is_prime)
		{
			return true;
		}

		return false;
	}
}

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

int main() {
    int n;
    cin >> n;
    int answer = 50001;
    for(int i = 1; i <= 50000; i++){
        if(n == floor(i*1.08)){
            answer = i;
            break;
        } 
    }
    if(answer == 50001){
        cout << ":(";
    } else {
        cout << answer;
    }
}

Measured memory_bytes: 256
from queue import Queue

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

grafo = [[] for i in range(n)]

for x in range(m):
    a,b = map(int,input().split())
    grafo[a-1].append(b)
    grafo[b-1].append(a)


placas = [0] * (n)

def bfs(a):
    q = Queue(maxsize = n)
    placas[0] = 1
    q.put(a)
    while not q.empty():
        popado = q.get()
        for adj in grafo[popado-1]:
            if not placas[adj-1]:
                placas[adj-1] = popado
                q.put(adj)

    if placas.count(0) == 0:
        print("Yes")
        for x in placas[1::]:
            print(x)
    else:
        print("No")

bfs(1)


Measured memory_bytes: 35124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll a,b,k;
  cin>>a>>b>>k;
  for(int i=0;i<k;i++){
    if(i%2==0){
      b+=a/2;
      a/=2;
    }else{
      a+=b/2;
      b/=2;
    }
  }
  cout<<a<<" "<<b;
}

Measured memory_bytes: 256