akhauriyash/Code-Regression huggingface dataset:
N=int(input())
from itertools import combinations

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

import math 
n=int(math.sqrt(N))
k=n
divisors = []
if (n ** 2) == N:
    k = 2 * (n-1)
else:
    divisors = make_divisors(N)
    center = (len(divisors) // 2) - 1
    k = divisors[center] - 1 + divisors[center+1] - 1

print(k)





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

int main(){
	int N,D;
	cin >> N >> D;
	
	int ans = 0;
	while(N > 0){
		N -= 2*D + 1;
		ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

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

  string S;
  cin >> S;
  int N = S.size();
  int ans{};
  for(int i=1;i<N;i++){
    if(S[i-1] != S[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <map>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <set>
#include <stack>
#include <list>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <sstream>
#include <stdexcept>
#include <cstdlib>
#include <typeinfo>

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

using namespace std;
// using ll = long long;
// using P = pair<int, int>;

int main(){
    
    string str;
    cin >> str;
    while(str[0] != '0'){
        int j = 0;
        rep(i, str.size()){
            j += str[i] - '0';
        }
        cout << j << endl;
        cin >> str;
    }

    return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;


int main()
{
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    vll ushiro(n,-1);
    rep(i,n){
        int idx = lower_bound(all(ushiro), a[i]) - ushiro.begin();
        ushiro[idx - 1] = a[i];
    }
    ll ans = 0;
    rep(i,n){
        if (ushiro[i]>-1)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;

ll inf=1e18;
struct segtree{
	static const int N=1<<17;
	ll seg[N*2];
	segtree(){
		rep(i,N*2) seg[i]=inf;
	}

	void update(int x,ll v){
		x+=N;
		seg[x]=v;
		x/=2;
		while(x){
			seg[x]=min(seg[x*2],seg[x*2+1]);
			x/=2;
		}
	}
	ll getmin(int a,int b,int l=0,int r=N,int k=1){
		if(b<=l||r<=a) return inf;
		if(a<=l&&r<=b) return seg[k];
		return min(getmin(a,b,l,(l+r)/2,k*2),getmin(a,b,(l+r)/2,r,k*2+1));
	}
}seg1,seg2;

int N;
const int MN=100010;
ll E,T;
ll x[MN];
int get2(int id){
	int lb=-1,ub=id;
	while(ub-lb>1){
		int m=(ub+lb)/2;
		if((x[id]-x[m])*2>=T) lb=m;
		else ub=m;
	}
	return ub;
}

int main(){
	cin>>N>>E>>T;
	rep(i,N) cin>>x[i];
	x[N]=E;
	seg1.update(0,-2*x[0]);
	seg2.update(0,0);
	for(int i=1;i<=N;i++){
		int t=get2(i-1);
		ll val = min(seg1.getmin(0,t)+3*x[i-1],seg2.getmin(t,i)+x[i-1]+T)+(x[i]-x[i-1]);
		// show(t);
		// show(val);
		if(i==N){
			cout<<val<<endl;
			return 0;
		}
		seg1.update(i,val-3*x[i]);
		seg2.update(i,val-x[i]);
	}
}


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

int dig(char c){ return '0'<=c && c<='9'; }
int main(){
int a,b;
string s;
cin>>a>>b>>s;
int yes = 1;
if(s.length() == a+b+1){
for(int i=0;i<a;++i) if(!dig(s[i])) yes=0;
if(s[a]!= '-') yes=0;
for(int i=a+1;i<a+b+1;++i) if(!dig(s[i])) yes=0;
}else{ yes = 0;}
cout<< (yes==1? "Yes" : "No") << endl;
return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        n: usize, k: usize,
        a: [usize; n]
    }

    let mut dp = vec![false;k+1];
    for i in 0..dp.len() {
        for j in 0..n {
            if i >= a[j] {
                dp[i] |= !dp[i - a[j]];
            }
        }
    }
    println!("{}", if dp[k] {"First"} else {"Second"});
}

Measured memory_bytes: 4352
//ABC095C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	long long int ans = 1e9;
	long long int m = 2*max(x,y);
	for(int i=0;i<=m;i+=2){
		long long p = i*c+max(0,x-i/2)*a+max(0,(y-i/2)*b);
		ans = min(ans,p);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  ll N, K; cin >> N >> K;

  cout << min(abs(N-K*(N/K)),abs(N-K*(N/K+1))) << endl;

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n){
        int a;
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());

    int ans = 0, j = 0;
    while(j < n){
        int c = v[j], tmp = 0;
        while(j < n && v[j] == c){
            tmp ++;
            j ++;
        }
        ans += tmp % 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  char a[n+1];
  char b[n+1];
  scanf("%s",a);
  scanf("%s",b);
  for(int i=0;i<n;i++){
    printf("%c%c",a[i],b[i]);
  }
}

Measured memory_bytes: 1716
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();
        string t = sc.Next();

        bool ok = false;
        if (t.StartsWith(s))
        {
            ok = true;
        }

        string answer = ok ? "Yes" : "No";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int n; string s;
    cin>>n>>s;
    //後ろからEを数える
    vector<int> be(n,0);
    if(s.at(n-1)=='E')be[n-1]=1;
    //前からWを数える
    vector<int> fw(n,0);
    if(s.at(0)=='W')fw[0]=1;


    for(int i=1;i<n;i++){if(s.at(i)=='W')fw[i]=fw[i-1]+1;else fw[i]=fw[i-1];}
    for(int i=n-2;i>=0;i--){if(s.at(i)=='E')be[i]=be[i+1]+1; else be[i]=be[i+1];}
    ll min=INF;
    rep(i,n){
        if(i==0)chmin(min,(ll)be[1]);
        else if(i==n-1)chmin(min,(ll)fw[n-2]);
        else{
            chmin(min,(ll)(fw[i-1]+be[i+1]));
        }
    }
    cout<<min<<endl;
    return 0;
}




Measured memory_bytes: 3076
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

use std::cmp::max;

fn main() {
    input! {
        n: u32,
        a: [i64; n]
    }
    // 負の数の個数をカウント
    let mut cnt = 0;
    for val_a in a.clone().into_iter() {
        if val_a < 0 {
            cnt += 1;
        }
    }
    let sum = a.clone().into_iter().map(|a_val| a_val.abs()).sum::<i64>();
    if cnt % 2 == 0 {
        // もし偶数なら全部正の値にできる
        println!("{}", sum);
    } else {
        // もし奇数なら一個だけ負の値になる. 絶対値最小のやつを負の値にすればいい
        let min_val = a.iter().map(|a_val| a_val.abs()).min().unwrap();
        // min_valが正の想定でsumをもとめたから、もし負なら -2 * min_val
        println!("{}", sum - (2 * min_val));
    }
}


Measured memory_bytes: 6396
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
ll id(char C) {
	if (C >= 'A') return (ll)C - 'A' + 26;
	else return (ll) C - 'a';
}
int main() {
	cin >> N;
	vl P(N);
	for (i = 0; i < N; i++) cin >> P[i];
	ll count = 0;
	for (i = 0; i < N; i++) {
		if (P[i] == i + 1) {
			count++;
		}
		else {
			ans += (count + 1) / 2;
			count = 0;
		}
	}
	ans += (count + 1) / 2;
	count = 0;
	cout << ans;
}

Measured memory_bytes: 1024
#!/usr/bin/env php
<?php
if (basename(__FILE__) == basename($_SERVER['PHP_SELF'])) {

  $a = 0;
  $b = 0;
  $c = 0;

  while ($line = fgets(STDIN)) {
    $tokens = explode(' ', $line);
    $a = $tokens[0];
    $b = $tokens[1];
    $c = $tokens[2];
  }

  if ($a == 1) {
  	echo ('YES');
  } else if ($a == $b && $c != 0) {
    echo ('NO');
  } else if ($a > $b && $a % $b == 0 && $c != 0) {
    echo ('NO');
  } else if ($a > $b && $a % $b == 0 && $c == 0) {
    echo ('YES');
  } else if ($b > $a && $b % $a == 0 && $c != 0) {
  	echo ('NO');
  } else if ($b > $a && $b % $a == 0 && $c == 0) {
  	echo ('YES');
  } else {
  	$arr = [];
  	array_push($arr, $a % $b);
  	$a2 = $a + $a;
  	while (true) {
  		$c2 = $a2 % $b;
  		if ($c2 == $c) {
			echo ('YES');
  			break;
  		}
  		$isNO = false;
  		foreach  ($arr as $val) {
  			if ($val == $c2) {
  				echo ('NO');
  				$isNO = true;
  				break;
  			}
  		}
  		if ($isNO) {
  			break;
  		}
  		array_push($arr, $c2);
  		$a2 += $a;
  	}
  }
}
?>

Measured memory_bytes: 4604
import sys
input = sys.stdin.readline
from operator import itemgetter

ANS=1<<100

N=int(input())
L=[]
R=[]
U=[]
D=[]

for i in range(N):
    x,y,c=input().split()
    if c=="L":
        L.append((int(x),int(y)))

    if c=="R":
        R.append((int(x),int(y)))

    if c=="U":
        U.append((int(x),int(y)))

    if c=="D":
        D.append((int(x),int(y)))

L.sort(key=itemgetter(0))
R.sort(key=itemgetter(0))
L.sort(key=itemgetter(1))
R.sort(key=itemgetter(1))

indr=0
for indl in range(len(L)):
    while indr<len(R) and R[indr][1]<L[indl][1]:
        indr+=1

    while indr<len(R) and R[indr][1]==L[indl][1] and R[indr][0]<L[indl][0]:
        ANS=min(ANS,(L[indl][0]-R[indr][0])*5)
        indr+=1
        
U.sort(key=itemgetter(1),reverse=True)
D.sort(key=itemgetter(1),reverse=True)
U.sort(key=itemgetter(0))
D.sort(key=itemgetter(0))

indd=0
for indu in range(len(U)):
    while indd<len(D) and D[indd][0]<U[indu][0]:
        indd+=1
        
    while indd<len(D) and U[indu][0]==D[indd][0] and U[indu][1]<D[indd][1]:
        ANS=min(ANS,(D[indd][1]-U[indu][1])*5)
        indd+=1

U.sort(key=itemgetter(0))
R.sort(key=itemgetter(0))
U.sort(key=lambda x:x[0]+x[1])
R.sort(key=lambda x:x[0]+x[1])

indr=0
for indu in range(len(U)):
    while indr<len(R) and R[indr][0]+R[indr][1]<U[indu][0]+U[indu][1]:
        indr+=1
    while indr<len(R) and R[indr][0]+R[indr][1]==U[indu][0]+U[indu][1] and R[indr][0]<U[indu][0]:
        ANS=min(ANS,(U[indu][0]-R[indr][0])*10)
        indr+=1

U.sort(key=itemgetter(0),reverse=True)
L.sort(key=itemgetter(0),reverse=True)
U.sort(key=lambda x:x[0]-x[1])
L.sort(key=lambda x:x[0]-x[1])

indl=0
for indu in range(len(U)):
    while indl<len(L) and L[indl][0]-L[indl][1]<U[indu][0]-U[indu][1]:
        indl+=1
    while indl<len(L) and L[indl][0]-L[indl][1]==U[indu][0]-U[indu][1] and L[indl][0]>U[indu][0]:
        ANS=min(ANS,(L[indl][0]-U[indu][0])*10)
        indl+=1

D.sort(key=itemgetter(0))
R.sort(key=itemgetter(0))
D.sort(key=lambda x:x[0]-x[1])
R.sort(key=lambda x:x[0]-x[1])

indr=0
for indd in range(len(D)):
    while indr<len(R) and R[indr][0]-R[indr][1]<D[indd][0]-D[indd][1]:
        indr+=1
    while indr<len(R) and R[indr][0]-R[indr][1]==D[indd][0]-D[indd][1] and R[indr][0]<D[indd][0]:
        ANS=min(ANS,(D[indd][0]-R[indr][0])*10)
        indr+=1

D.sort(key=itemgetter(0),reverse=True)
L.sort(key=itemgetter(0),reverse=True)
D.sort(key=lambda x:x[0]+x[1])
L.sort(key=lambda x:x[0]+x[1])

indl=0
for indd in range(len(D)):
    while indl<len(L) and L[indl][0]+L[indl][1]<D[indd][0]+D[indd][1]:
        indl+=1
    while indl<len(L) and L[indl][0]+L[indl][1]==D[indd][0]+D[indd][1] and L[indl][0]>D[indd][0]:
        ANS=min(ANS,(L[indl][0]-D[indd][0])*10)
        indl+=1


if ANS==1<<100:
    print("SAFE")
else:
    print(ANS)

Measured memory_bytes: 43476
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int a, b, c, n;
        cin >> a >> b >> c >> n;
        if(a == 0)
            return 0;

        vector<vector<int> > check(n, vector<int>(4));
        for(int i=0; i<n; ++i){
            for(int j=0; j<4; ++j)
                cin >> check[i][j];
        }

        vector<int> quality(a+b+c+1, 2);
        for(int i=0; i<n; ++i){
            if(check[i][3] == 1){
                quality[check[i][0]] = 1;
                quality[check[i][1]] = 1;
                quality[check[i][2]] = 1;
            }
        }
        for(int i=0; i<n; ++i){
            if(check[i][3] == 0){
                if(quality[check[i][0]] == 1 && quality[check[i][1]] == 1)
                    quality[check[i][2]] = 0;
                if(quality[check[i][1]] == 1 && quality[check[i][2]] == 1)
                    quality[check[i][0]] = 0;
                if(quality[check[i][2]] == 1 && quality[check[i][0]] == 1)
                    quality[check[i][1]] = 0;
            }
        }

        for(int i=1; i<=a+b+c; ++i)
            cout << quality[i] << endl;
    }
}

Measured memory_bytes: 0
require 'bigdecimal'
require 'bigdecimal/util'
a, v = gets.chomp.split(" ").map(&:to_i)
b, w = gets.chomp.split(" ").map(&:to_i)
t = gets.chomp.to_i

if v - w <= 0 || a == b
  puts "NO"
  return
end

if (a - b).abs <= t * (v - w).to_d
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 14308
#include<iostream>
#include<algorithm>
using namespace std;
int n,s;
long long memo[20][1010][110];
long long dp(int num,int sum,int cnt){
    if(num == n){
        if(sum == s) return 1;
        return 0;
    }
    if(memo[num][sum][cnt] != -1) return memo[num][sum][cnt];
    long long ret = 0;
    for(int i=cnt;i<=100;i++){
        if(sum+i > s) continue;
        ret += dp(num+1,sum+i,i+1);
    }
    return memo[num][sum][cnt] = ret;
}
int main(){
    
    while(cin >> n >> s,n!=0||s!=0){
        fill_n(**memo,20*1010*110,-1);
        cout << dp(0,0,0) << endl;
    }
    
    return(0);
}


Measured memory_bytes: 20456
import collections
n=int(input())
s=[]
for i in range(n):
    s.append(input())
c=collections.Counter(s)
v=dict(c).values()
mx=max(v)
l=[]
for k,v in dict(c).items():
    if v==mx:
        l.append(k)

for i in sorted(l):
    print(i)




Measured memory_bytes: 54000
//just for test
#include <cstdio>
#include <set>
#include <queue>
#include <map>
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef set<int> si;
typedef set<int>::iterator sit;
const int N=100005;
int n;
int bl[N];
si s[N];
queue<pii> q;
map<ll,int> g;
inline void swap(int &x,int &y){
	x^=y^=x^=y;
}   
int find(int u){
	return bl[u]==u?u:(bl[u]=find(bl[u]));
}
inline ll getID(int x,int y){
	if(x>y) swap(x,y);
	return 1ll*n*y+x;
}
void addEdge(int u,int v){
	s[u].insert(v);
	s[v].insert(u);
	ll eid=getID(u,v);
	int t=g[eid]+1;
	g[eid]++;
	if(t==2)
		q.push(mp(u,v));
}
void removeEdge(int u,int v){
	s[u].erase(v);
	s[v].erase(u);
	g.erase(getID(u,v));
}
void readData(){
	scanf("%d",&n);
	int u,v;
	for(int i=1;i<=(n-1)<<1;i++){
		scanf("%d%d",&u,&v);
		addEdge(u,v);
	}
}
bool solve(){
	for(int i=1;i<=n;i++) bl[i]=i;
	for(int i=1;i<n;i++){
		int u,v;
		if(q.empty())
			return false;
		u=q.front().first;
		v=q.front().second;
		q.pop();
		u=find(u); 
		v=find(v);
		if(s[u].size()>s[v].size())
			swap(u,v);
		bl[u]=v;
		removeEdge(u,v);
		for(sit i=s[u].begin(),j;i!=s[u].end();i=j){
			j=i;
			j++;
			int x=*i;
			x=find(x);
			removeEdge(u,x);
			addEdge(v,x);
		}
	}
	return true;
}
int main(){
	//freopen("a.in","r",stdin);
	readData();
	puts(solve()?"YES":"NO");
	return 0;
}

Measured memory_bytes: 36608
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int count = 0;
    for (int i = 0, n = sc.nextInt(); i < n; i++)
      if (sc.nextInt() != i + 1)
        count++;
    System.out.println(count == 0 || count == 2 ? "YES" : "NO");
  }
}

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

using namespace std;

long long knapsack(int n, int bag, vector<vector<int>> item){
    long long dp[n+1][bag+1];
    for(int i = 0; i <= bag; i++){
        dp[n][i] = 0;
    }
    for(int i = n-1; i >= 0; i--){
        dp[i][0] = 0;
        int j;
        for(j = 1; j < item[i][0]; j++){
            dp[i][j] = dp[i+1][j];
        }
        for(; j <= bag; j++){
            dp[i][j] = max(dp[i+1][j-item[i][0]] + item[i][1], dp[i+1][j]);
        }
    }
    return dp[0][bag];
}

int main(){
    int n, bag;
    scanf("%d %d\n", &n, &bag);
    vector<vector<int>> item(n, vector<int>(2));
    for(int i = 0; i < n; i++){
        scanf("%d %d\n", &item[i][0], &item[i][1]);
    }
    cout<<knapsack(n, bag, item);
}




Measured memory_bytes: 82516
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>
#include <math.h>

using namespace std;
typedef long long ll;
///定義場所///
int i, j, k, l, m, n;
int N, M, K;
ll MOD = 1000000007;
int ans = 0;
int H, W;
vector<string> S(2000);

//関数リスト//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
//(注)pairの型・比較する場所(first/second)は毎回変えて使用する
bool pairCompare(const pair<int ,int> firstElof, pair<int,int> secondElof)
{
	return firstElof.second > secondElof.second;
}
int Keta(ll F) {
	int keta = 1;
	while (F/10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
//////////////

void dfs(int Hb, int Wb) {
	int res = 1;
	int h = Hb; int w = Wb;
	while (h>0) {
		if (S[h - 1][w] == '.') {
			h--;
			res++;
		}
		else {
			h = 0;
		}
	}
	h = Hb; w = Wb;
	while (h < H-1) {
		if (S[h + 1][w] == '.') {
			h++;
			res++;
		}
		else {
			h = H - 1;
		}
	}
	h = Hb; w = Wb;
	while (w > 0) {
		if (S[h][w-1] == '.') {
			w--;
			res++;
		}
		else {
			w = 0;
		}
	}
	h = Hb; w = Wb;
	while (w < W-1) {
		if (S[h][w + 1] == '.') {
			w++;
			res++;
		}
		else {
			w = W - 1;
		}
	}
	ans = max(res, ans);
}
int main()
{
	cin >> H >> W;
	for (i = 0; i < H; i++) {
		cin >> S[i];
	}
	vector<vector<int>> left(H, vector<int>(W, 0));
	vector<vector<int>> right(H, vector<int>(W, 0));
	vector<vector<int>> up(H, vector<int>(W, 0));
	vector<vector<int>> down(H, vector<int>(W, 0));
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			left[i][j] = 0;
			right[i][j] = 0;
			up[i][j] = 0;
			down[i][j] = 0;
		}
	}
	//右隣に見たとき
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (j == 0) {
				left[i][j] = 0;
			}
			else if (S[i][j - 1] == '.') {
				left[i][j] = left[i][j - 1] + 1;
			}
			else {
				left[i][j] = 0;
			}
		}
	}
	for (i = 0; i < H; i++) {
		for (j = W-1; j >= 0; j--) {
			if (j == W-1) {
				right[i][j] = 0;
			}
			else if (S[i][j + 1] == '.') {
				right[i][j] = right[i][j + 1] + 1;
			}
			else {
				right[i][j] = 0;
			}
		}
	}
	for (j = 0; j < W; j++) {
		for (i = 0; i < H; i++) {
			if (i == 0) {
				up[i][j] = 0;
			}
			else if (S[i-1][j] == '.') {
				up[i][j] = up[i-1][j] + 1;
			}
			else {
				up[i][j] = 0;
			}
		}
	}
	for (j = 0; j < W; j++) {
		for (i = H-1; i >= 0; i--) {
			if (i == H-1) {
				down[i][j] = 0;
			}
			else if (S[i + 1][j] == '.') {
				down[i][j] = down[i + 1][j] + 1;
			}
			else {
				down[i][j] = 0;
			}
		}
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (S[i][j] == '.') {
				ans = max(ans, left[i][j] + right[i][j] + up[i][j] + down[i][j] + 1);
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 67200
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ac=0,wa=0,tle=0,re=0;
    for(int i = 0;i<n;i++){
      String s = sc.next();
      if(s.equals("AC")){
        ac++;
      }else if(s.equals("WA")){
        wa++;
      }else if(s.equals("TLE")){
        tle++;
      }else{
        re++;
      }
    }
    System.out.println("AC x "+ac);
    System.out.println("WA x "+wa);
    System.out.println("TLE x "+tle);
    System.out.println("RE x "+re);

  }
}


Measured memory_bytes: 58568
import java.util.*;

public class Main{

    Scanner sc = new Scanner(System.in);

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

    void run() {

        long a = sc.nextLong();
        long b = sc.nextLong();
        long n = sc.nextLong();

        long ans = 0;

        if (n < b) {
            ans = (a*n)/b - a*(n/b);
            System.out.println(ans);
            return;
        }

        ans = a*(b-1)/b - a*((b-1)/b);

        System.out.println(ans);


    }
}


Measured memory_bytes: 35696
#include <stdio.h>
#include <math.h>
  
double f(double x){
    return x*x*x;
}
double df(double x){
    return 3.0*x*x;
}

double newton(double x,double q){
   return  x - (x * x * x - (double)q) / (3.0 * x * x);
}

int main(void){
    int q;
    double x;
    while(1){
        scanf("%d", &q);
        if(q==-1) break;
                
	x=(double)q/2.0;
        while(1){
            
	if(fabs(x*x*x-(double)q)<0.00001*(double)q) break;
            x = newton(x,q);
        }
        printf("%f\n",x);
    }
    return 0;
}


Measured memory_bytes: 1980
#include <stdio.h>
int main(void){
    int i,n,tmp;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n/2;i++){
        tmp =a[i];
        a[i]    =a[n-1-i];
        a[n-1-i]  =tmp;
    }
    for ( i = 0; i < n; i++ ){
    if ( i ) printf(" "); 
    printf("%d", a[i]);
    }
    printf("\n");
return 0;
    
}



Measured memory_bytes: 2104
from decimal import *

k_str = input()
k = Decimal(k_str)
n = 50

A = [0] * (n)
pl = k // n

amari = k % n
kakanai = n - amari
start = (n + 1 - amari) % (n+1)
ind = 0

print(n)
for i in range(n+1):
    if start != kakanai:
        A[ind] = start + pl
        ind += 1
    start = (start + 1) % (n+1)

print(" ".join(map(str, A)))

Measured memory_bytes: 61616
function Main(input) {
  input = input.split("\n");
  const S = input[0].split("");
  const T = input[1].split("");

  var def = 0;

  for(var i = 0; i <= S.length - T.length; i++){
    var tmp = S.slice(i, i + T.length);
    
    var count = 0; //一致数
    for(var j = 0; j < tmp.length; j++){
      if(tmp[j] == T[j]){
        count++
      }
    }
    
    if(count > def){
      def = count;
    }
  }
  
  console.log(T.length - def);
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 33340
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, g, b;
  cin >> r >> g >> b;
  
  if ((10 *g + b )% 4 == 0) {
  	cout << "YES" << endl;
  }
  else {
  	cout << "NO" << endl;
  }
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x >= y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x <= y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  i64 n; cin >> n;
  i64 ans = 0;
  reps(i, 1000010) {
    i64 nn = n - i;
    if (nn % i == 0 && nn / i > i) {
      ans += nn / i;
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 100000000000
#define int long long int
#define hell (int)(1e9+7)

using namespace std;

vector <int> helper(int n){
    vector <int> f;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            if(i*i==n)
                f.push_back(i);
            else{
                f.push_back(i);
                f.push_back(n/i);
            }
        }
    }
    if(n!=1)
        f.push_back(n);
    return f;
}

void solve(){
    int n;
    cin>>n;
    int ans=0;
    vector <int> a,b;
    a=helper(n-1);
    //cout<<a.size()<<"\n";
    ans+=a.size();
    b=helper(n);
    for(int x:b){
        int on=n;
        while(on%x==0)
            on/=x;
        ans+=on%x==1;
    }
    cout<<ans<<"\n";
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N, K;
vector<ll> A, F;

bool Check(ll n) {
    DBG("check: %lld\n", n);
    ll k = K;
    REP(i, N) {
        DBG("i: %lld A[i]: %lld F[i]: %lld\n", i, A[i], F[i]);
        if(A[i] * F[i] > n) {
            ll use = A[i] - n / F[i];
            if(k - use < 0) { return false; }
            k -= use;
            DBG("use: %lld k: %lld\n", use, k);
        }
    }
    return true;
}

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

    cin >> N >> K;
    A.resize(N);
    F.resize(N);
    REP(i, N) {
        cin >> A[i];
    }
    REP(i, N) {
        cin >> F[i];
    }
    SORT(A);
    SORT(F);
    reverse(F.begin(), F.end());

    ll lb = 0LL, ub = 1000000000005LL;
    while(ub - lb > 1) {
        ll mid = (lb + ub) / 2;
        if(Check(mid)) { ub = mid; }
        else { lb = mid; }
    }

    ll ans = Check(lb) ? lb : ub;
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int W = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());

		System.out.println(Math.max(Math.abs(a-b)-W, 0));
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int k;
	cin >> k;
	queue<ll> q;
	for(int i = 1; i < 10; i++)	
		q.push(i);
	ll prev;
	while(k--) {
		ll t = q.front();
		prev = t;
		q.pop();
		if(t%10!=0) q.push(10*t+(t%10)-1);
		q.push(10*t + t%10);
		if(t%10!=9) q.push(10*t + t%10 +1);
	}
	cout << prev << endl;
	return 0;
}



Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    cout << "square1001" << endl;
}



Measured memory_bytes: 3092
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int sum = 0;
        int x = 0;

        for (int y=0; y<2; y++){
            
            if(A<B){
                x = B;
                B = B-1;
                sum = sum + x;
            }
            else{
                x = A;
                A = A - 1;
                sum = sum + x;
            }
        }
            System.out.println(sum);
    }
}


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

using namespace std;

const int maxN = 1e5 + 10;
std::vector<int> adj_list[maxN];
int inFlux[maxN];
int n, m;

int dp[maxN];
int visited[maxN];

void dfs(int n1)
{
	for (const auto n2 : adj_list[n1])
	{
		dp[n2] = max(dp[n2], dp[n1] + 1);
		visited[n2]++;
		if (visited[n2] == inFlux[n2])
		{
			dfs(n2);
		}
	}
}

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

	int n1, n2;
	for (int i = 0; i < m; ++i)
	{
		cin >> n1 >> n2;
		adj_list[n1].push_back(n2);
		inFlux[n2]++;
	}

	for (int i = 1; i <= n; ++i)
	{
		visited[i] = 0;
		dp[i] = -1;
	}

	for (int i = 1; i <= n; ++i)
	{
		if (visited[i] == 0 && inFlux[i] == 0)
		{
			visited[i] = 1;
			dp[i] = 0;
			dfs(i);
		}
	}

	int maxPath = *max_element(&dp[1], &dp[1] + n);

	cout << maxPath << endl;
	return 0;
}

Measured memory_bytes: 9984
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;


class P
{
    static void Main()
    {
        var nabc = Console.ReadLine().Split().Select(int.Parse).ToList();
        var l = Enumerable.Repeat(0, nabc[0]).Select(_ => int.Parse(Console.ReadLine())).ToList();
        var min = int.MaxValue;
        for (int i = 0; i < 1 << (nabc[0] * 2); i++)
        {
            int mp = 0;
            int a = 0;
            int b = 0;
            int c = 0;
            for (int j = 0; j < nabc[0]; j++)
            {
                var state = i >> (j * 2) & 3;
                if (state == 1)
                {
                    if (a != 0) mp += 10;
                    a += l[j];
                }
                if (state == 2)
                {
                    if (b != 0) mp += 10;
                    b += l[j];
                }
                if (state == 3)
                {
                    if (c != 0) mp += 10;
                    c += l[j];
                }
            }
            if (a == 0 || b == 0 || c == 0) continue;
            mp += Abs(nabc[1] - a);
            mp += Abs(nabc[2] - b);
            mp += Abs(nabc[3] - c);
            min = Min(min, mp);
        }
        Console.WriteLine(min);
    }
}


Measured memory_bytes: 13396
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cassert>

using namespace std;

typedef long long LL;

static const LL MOD = 1000000007;

struct modll {
	long long x;
	modll() { }
	modll(long long _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(const modll& r) { return (x + r.x) % MOD; }
	modll operator+=(const modll & r) { return x = (x + r.x) % MOD; }
	modll operator-(const modll & r) { return (x + MOD - r.x) % MOD; }
	modll operator-=(const modll & r) { return x = (x + MOD - r.x) % MOD; }
	modll operator*(const modll & r) { return (x * r.x) % MOD; }
	modll operator*(int r) { return (x * r) % MOD; }
	modll operator*=(const modll & r) { return x = (x * r.x) % MOD; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

LL n;
LL k;
modll ans;
vector<vector<int>> edges;
vector<int> vis;

void dfs(int node, int cnt) {
	vis[node] = 1;
	ans *= (k - cnt);
	cnt = cnt > 0;
	for (int next : edges[node]) {
		if (!vis[next]) {
			dfs(next, ++cnt);
		}
	}
}

int main(int argc, char *argv[]) {
	ans = 1;
	cin >> n >> k;
	edges.clear();
	edges.resize(n);
	vis = vector<int>(n);
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	dfs(0, 0);
	cout << ans << endl;
	return 0;
}


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


Measured memory_bytes: 1664
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

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

	N := getInt()
	a := make([]int, N)
	b := make([]int, N)

	mi := 1001001001
	mipos := -1
	for i := 0; i < N; i++ {
		a[i], b[i] = getInt(), getInt()
		if b[i] < mi {
			mi = b[i]
			mipos = a[i]
		}
	}

	ans := mipos + mi
	out(ans)
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX
int main(){
    long long n,m;
    cin>>n>>m;
    int c=n/2;
    if (n%2!=0){
        rep(i,m){
            cout<<c-i<<" "<<c+1+i<<endl;
            }
        }
    else{
        int ki=(m+1)/2;
        for(int i=0; i<ki; i++){
            cout<<c-i<<" "<<c+1+i<<endl;
        }
        for(int i=ki; i<m; i++){
            cout<<c-i<<" "<<c+i+2<<endl;
        }
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N),Y(N);
  for(int i=0; i<N; i++) cin >> X[i] >> Y[i];
  double d=0.0;
  for(int i=0; i<N; i++) {
  	for(int j=i+1; j<N; j++) {
    	double lx = X[i] - X[j], ly = Y[i] - Y[j];
        d += sqrt(lx*lx + ly*ly);
    }
  }
  cout << setprecision(12) << d/(0.5*N) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int x;
    double p;
    cin >> x >> p;
    x = (x+1)/2;
    printf("%.10f\n", x/(p/100));
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
int a[10];
for(int i=0;i<10;i++)cin >> a[i];
sort(a,a+10);
for(int i=9;i>=7;i--){
cout << a[i] << "\n";
}
return 0;
}

Measured memory_bytes: 1176
n = int(input())

count = 0
for i in range(1, n + 1):
    if i % 2 == 0:
        continue

    divisor_count = 0
    for j in range(2, i // 2):
        if i % j == 0:
            divisor_count += 1
    if divisor_count == 6:
        count += 1

print(count)
    

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

int main() {
    int n, temp;
    cin >> n;
    set<int> st;
    rep(i, n) {
        cin >> temp;
        st.insert(temp);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 256
n = int(input())
prob = list(map(float, input().split()))


dp = [[0 for i in range(n+1)] for j in range(n+1)]

dp[0][0] = 1.0

for i in range(1, n+1):
    for j in range(n+1):
        if j == 0:
            dp[i][j] = dp[i-1][j] * (1.0 - prob[i-1])
        else:
            dp[i][j] = prob[i-1] * dp[i-1][j-1] + (1.0 - prob[i-1]) * dp[i-1][j]

ans = 0
for i in range(n//2+1, n+1):
    ans += dp[n][i]

print(ans)

Measured memory_bytes: 259848
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<int> a(n*3);
    REP(i,n*3){
        cin >> a[i];
    }
    sort(all(a),greater<>());
    ll res = 0;
    REP(i,n){
        res += a[i*2+1];
    }
    put(res);
    return 0;
}


Measured memory_bytes: 1536