akhauriyash/Code-Regression huggingface dataset:
import sys
from itertools import product

input = sys.stdin.readline


def main():
    N, A, B, C = map(int, input().split())
    L = [0] * N
    for i in range(N):
        L[i] = int(input())

    ans = float("inf")
    for comb in product(range(4), repeat=N):
        mp = -30
        a = b = c = 0
        for i, j in enumerate(comb):
            if j == 0:
                continue
            elif j == 1:
                a += L[i]
            elif j == 2:
                b += L[i]
            elif j == 3:
                c += L[i]
            mp += 10

        if min(a, b, c) == 0:
            continue

        mp += abs(A - a) + abs(B - b) + abs(C - c)
        if mp < ans:
            ans = mp

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
#include <iostream>

using namespace std;

#define MAX_N 100000

int N;
int A[MAX_N + 1];

int main(void) {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        A[a]++;
    }

    int odd_cnt = 0;
    int even_cnt = 0;
    for (int i = 1; i < MAX_N + 1; ++i) {
        if (A[i] != 0) {
            if (A[i] % 2 == 1) {
                odd_cnt++;
            } else {
                even_cnt++;
            }
        }
    }

    int ans;
    if (even_cnt % 2 == 0) {
        ans = odd_cnt + even_cnt;
    } else {
        ans = odd_cnt + even_cnt - 1;
    }

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

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

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int i = 0, w = 0;
	string s;
	cin >> s;
	for (i = 0; i < s.size(); i++) {
		if (s[i] == 'o')
			w++;
	}
	if (w + (15 - s.size()) >= 8)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

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

int main() {
    int h , w;
    cin >> h >> w;

    char c[103];
    memset(c, '#', w + 2);
    c[w + 2] = 0;
    cout << c << '\n';
    for (int i = 0; i < h; i++) {
        cin >> c;
        cout << '#' << c << "#\n";
    }
    memset(c, '#', w + 2);
    c[w + 2] = 0;
    cout << c << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#include<cstdio>
#include<cmath>
#define INF 500000000
using namespace std;

typedef pair<int,int> P;

int n,m,k;
int l[100100],a[100100],b[100100];
vector<P> g[5000];
int d[5000],w[5000];
bool s[5000];

int main(){
  cin >> n >> m >> k;
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i] >> l[i];
    a[i]--; b[i]--;
    g[a[i]].push_back(P(l[i],b[i]));
    g[b[i]].push_back(P(l[i],a[i]));
  }

  for(int i=0;i<n;i++)s[i] = false;

  int tmp;
  for(int i=0;i<k;i++){
    cin >> tmp;
    s[tmp-1] = true;
  }

  for(int i=0;i<n;i++)w[i] = INF;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)d[j] = INF;
    d[i] = 0;
    priority_queue<P,vector<P>,greater<P> > q;
    q.push(P(0,i));
    while(q.size()){
      P p = q.top(); q.pop();
      int cost = p.first, pos = p.second;

      if(s[pos]){
	w[i] = cost;
	break;
      }
      for(int j=0;j<(int)g[pos].size();j++){
	int dis = cost + g[pos][j].first;
	int next = g[pos][j].second;

	if(dis<d[next]){
	  d[next] = dis;
	  q.push(P(dis,next));
	}
      }
    }
  }

  double ans = 0.0;
  for(int i=0;i<m;i++){
    if(fabs(w[a[i]] - w[b[i]]) >= l[i]){
      ans = max(ans,(double)max(w[a[i]],w[b[i]]));
    }else{
      ans = max(ans,(double)(l[i]+w[a[i]]+w[b[i]])/2);
    }
  }
  cout << (int)(ans+1e-9+0.5) << endl;
}
  

Measured memory_bytes: 4352
#include<iostream>
#include<iomanip>
#include<memory>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
  int dx[13] = {0, 1, 0, -1, 0, 1, -1, -1, 1, 2, 0, -2, 0};
  int dy[13] = {0, 0, 1, 0, -1, 1, 1, -1, -1, 0, 2, 0, -2};
  int loop[4] = {0, 5, 9, 13};

  int map[10][10];
  int x, y, size;
  char c;
  int cnt = 0, d = 0;
  
  for ( int i = 0; i < 10; ++i )
    for ( int j = 0; j < 10; ++j )
      map[i][j] = 0;

  while( cin >> x >> c >> y >> c >> size )
    {
      for ( int i = 0; i < loop[size]; ++i )
        if ( x+dx[i] >= 0 && x+dx[i] < 10 && y+dy[i] >= 0 && y+dy[i] < 10 )
          map[x+dx[i]][y+dy[i]] += 1;
    }

  for ( int i = 0; i < 10; ++i )
    for ( int j = 0; j < 10; ++j )
      {
        if ( map[i][j] == 0 )
          ++cnt;
        d = max( d, map[i][j] );
      }

  cout << cnt << endl;
  cout << d << endl;
  
  return 0;
}

Measured memory_bytes: 1160
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール
ld powld(ld x, ll n) {
    if (n < 0) return powld(1.L/x, -n);
    if (n == 0) return 0;
    if (n == 1) return x;
    ld temp = powld(x, n/2);
    if (n % 2) {
        return temp * temp * x;
    } else {
        return temp * temp;
    }
}

// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n, m, d; cin >> n >> m >> d;

    ll t = max(0LL, n - d) * (1 + !!d);
    ld ans = (ld)t / n / n * (m-1);
    cout << fixed << setprecision(30) << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001, M = 1000000007;
int n, k, md[N+100];

int main(){
    scanf("%d%d", &n, &k);
    for(int i = 1; i<=n; ++i)++md[i % k];
    ll an = 0;
    for(int i = 0; i<k; ++i){
       int a = md[i], bv = (k-i)%k;
       int b = md[bv], cv = (k-bv)%k;
       int c = (cv != bv? 0: md[cv]); 
       ll ad = (1ll * a * b * c);
       an += ad; 
    }
    printf("%lld\n", an);
}

Measured memory_bytes: 640
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn f(b: u64, n: u64) -> u64 {
    let mut nn = n;
    let mut sum = 0;
    while nn >= 1 {
        sum += nn % b;
        nn /= b;
    }
    sum
}

fn main() {
    input! {
        n: u64,
        s: u64,
    }

    if s == n {
        println!("{}", s + 1);
        return;
    }

    if s > n {
        println!("-1");
        return;
    }

    let rn = (n as f64).sqrt() as u64;
    for b in 2..rn + 1 {
        let ans = f(b, n);
        if ans == s {
            println!("{}", b);
            return;
        }
    }

    for p in (1..rn + 1).rev() {
        if (n - s) % p != 0 {
            continue;
        }
        let b = (n - s) / p + 1;
        let ans = f(b, n);
        if ans == s {
            println!("{}", b);
            return;
        }
    }

    println!("-1");
    return;
}


Measured memory_bytes: 4352
/* HEADERS & NAMESPACES */
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;

/* MACROS */
#define fastIO() ios_base:: sync_with_stdio(false); cin.tie(NULL)
#define fill(v, x) memset(v, x, sizeof(v))
#define rep(i, a, b) for(__typeof(b) i = (a)-((a)>(b)); i != (b)-((a)>(b)); i += 1-2*((a)>(b)))
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define int long long
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl;
#define CHK(x, y) cerr << "\n" << #x << "=" << (x) << ", " << #y << "=" << (y) << "\n"
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define INF (1ll)<<60
#define MOD 1000000007
#define N 200005

/* TEMPLATES */
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v: V) os << v << " ";
    return os << "]\n";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.ff << ", " << P.ss << ")\n";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for(auto s: S) os << s << " ";
    return os << "}\n";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for(auto m: M) os << "(" << m.ff << ":" << m.ss << ") ";
    return os << "}\n";
}

/* GLOBAL */
/* FUNCTIONS */

void solve() {
    double s;
    cin >> s;
    cout << setprecision(10);
    cout << (s * s * s) / 27;
}

signed main() {
    fastIO();
    solve();
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = [0] * N
    for i in range(N):
        if i % 2 == 0:
            x[0] += A[i]
        else:
            x[0] -= A[i]
    for i in range(N-1):
        x[i+1] = 2 * A[i] - x[i]

    print(*x)

if __name__ == "__main__":
    main()

Measured memory_bytes: 64484
import java.util.Scanner;

public class Main {
	static Scanner scn = new Scanner(System.in);

	public static void main(String[] args) {
		String str = scn.next();
		boolean Fp = ispalindrome(str);
		if (Fp) {
			boolean Sp = ispalindrome(str.substring(0, str.length() / 2));
			if (Sp) {
				boolean Tp = ispalindrome(str.substring((str.length()) / 2 + 1));
				if (Tp)
					System.out.println("Yes");
				else
					System.out.println("No");
			} else
				System.out.println("No");
		} else
			System.out.println("No");

	}

	public static boolean ispalindrome(String str) {
		for (int i = 0; i < str.length() / 2; i++) {
			if (str.charAt(i) != str.charAt(str.length() - 1 - i))
				return false;
		}
		return true;
	}
}


Measured memory_bytes: 23636
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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 bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int n, m; cin >> n >> m;
	vector<string> s, t;
	rep(i, n) {
		string f; cin >> f; s.push_back(f);
	}
	rep(i, m) {
		string f; cin >> f; t.push_back(f);
	}
	rep(i, 100){
		s.push_back("");
		while(s[i].size() < 100) s[i].push_back('a');
	}
	bool ans = false;
	rep(i, n) rep(j, n){
		bool ok = true;
		rep(p, m) rep(q, m){
			if(s[i+p][j+q] != t[p][q]) ok = false;
		}
		if(ok) ans = true;
	}
	if(ans){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


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

using namespace std;

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	vector<long long> s(n);
	for(long long i=0;i<n;i++) cin>>s.at(i);
	long long q;
	cin>>q;
	vector<long long> t(q);
	for(long long i=0;i<q;i++) cin>>t.at(i);

	long long cnt=0;
	sort(s.begin(),s.end());

	for(auto a:t){
		long long l=0,r=n;
		while(r-l>1){
			long long mid=(l+r)/2;

			if(s.at(mid)<=a){
				l=mid;
			}else{
				r=mid;
			}
		}

		if(s.at(l)==a) cnt++;
	}

	cout<<cnt<<endl;

	return 0;
}



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

const int MAX_N = 15;
const int INF = 1<<28;

int main() {
  int n, m;
  int b[MAX_N], a[MAX_N];
  int dp[1<<MAX_N], space[1<<MAX_N], need[1<<MAX_N];
  while(cin >> n >> m && (n|m)) {
    for(int i = 0; i < n; ++i) {
      cin >> b[i] >> a[i];
    }

    for(int s = 0; s < (1<<n); ++s) {
      space[s] = m;
      need[s] = 0;
      for(int i = 0; i < n; ++i) {
        if(s & (1<<i)) {
          space[s] += b[i] - a[i];
          need[s] += a[i];
        }
      }
    }

    fill(dp,dp+(1<<n),INF);
    dp[0] = 0;
    for(int s = 0; s < (1<<n); ++s) {
      int rs = s ^ ((1<<n)-1);
      int sub = rs;
      do {
        sub = (sub-1) & rs;
        if(space[s] >= need[sub]) {
          dp[s|sub] = min(dp[s|sub], dp[s] + 1);
        }
      } while(sub != rs);
    }

    if(dp[(1<<n)-1] == INF)
      cout << "Impossible" << endl;
    else
      cout << dp[(1<<n)-1] << endl;

  }
  return 0;
}

Measured memory_bytes: 1068
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

void solve(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<string>s(h);
    vector<pair<int,int>>v;
    vector<vector<int>>ans(h,vector<int>(w));
    int pos=0;
    rep(i,h){
        cin>>s[i];
        rep(j,w)if(s[i][j]=='#'){
            v.eb(i,j);
            ans[i][j]=++pos;
        }
    }
    rep(i,k){
        int cnt=1;
        while(v[i].first+cnt<h&&ans[v[i].first+cnt][v[i].second]==0){
            ans[cnt+v[i].first][v[i].second]=ans[v[i].first][v[i].second];
            ++cnt;
        }
        cnt=1;
        while(v[i].first-cnt>=0&&ans[v[i].first-cnt][v[i].second]==0){
            ans[v[i].first-cnt][v[i].second]=ans[v[i].first][v[i].second];
            ++cnt;
        }
    }

        rep(j,w){
            if(ans[0][j]==0){
                int p=-1;
                for(int l=j-1;l>=0;--l){
                    if(ans[0][l]!=0){
                        p=l;
                        break;
                    }
                }
                if(p==-1){
                    for(int l=j+1;j<w;++l){
                        if(ans[0][l]!=0){
                            p=l;
                            break;
                        }
                    }
                }
                rep(r,h){
                    ans[r][j]=ans[r][p];
                }
            
        }
    }
    rep(i,h){
        rep(j,w){
            if(j)cout<<" ";
            cout<<ans[i][j];
        }
        cout<<"\n";
    }
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
void comb(vector<vector <long long> > &v){
  for(int i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <v.size();k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j])%mod;
    }
  }
}

// int main(){
//   int N,K;
//   cin >> N >>K;
//   vector<vector<long long int> > v(N+1,vector<long long int>(N+1,0));
//   comb(v);
//   cout << v[N][K];
//   return 0;
// }


int main(){
    int  N, K;
    cin >> N >> K;
    vector<vector<long long> > v(2000,vector<long long>(2000,0));
    vector<int> ans(4000);    
    int left = N-K+1, right;
    comb(v);

    for(int i=1; i<K+1; i++){
	ans[i]= (v[left][i]* v[K-1][i-1])%mod;
    }

    for(int i=1; i<K+1; i++){
	cout << ans[i]<<endl;
    }
	
    
//     cout << ans << endl;
}



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

#define all(x) x.begin(),x.end()
#define LB(V,x) lower_bound(all(V),x)-V.begin()

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using pi = pair<int32, int32>;
using pll = pair<int64, int64>;
using vi = vector<int32>;
using vll = vector<int64>;
using ll = int64;

void Main(){
    int32 N, ans, A;
    cin >> N >> ans;
    while(--N){
        cin >> A;
        ans = __gcd(ans,A);
    }
    cout << ans << endl;
}

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

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MAX = 999999;
const static int MOD = 1000000007;
const static int IINF = INT_MAX;
const static llong LINF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}
template<typename T> T my_lcm(T a, T b){
    return a * b / my_gcd(a, b);    
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> P(n);
    rep(i, n) cin >> P[i];

    int tmp = P[0];
    vector<int> CM(n);
    rep(i, n) {
        tmp = min(tmp, P[i]);
        CM[i] = tmp;
    }

    int ans = 0;
    rep(i, n) if (CM[i] == P[i]) ++ans;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

void fib();

void risu();

void kannon();

void fir();

int main(){

// 	fib();
// 	risu();
// 	kannon();
	fir();


	return 0;
}

void fir(){
	int n;
	int i,j;
	int count=0;

	scanf("%d",&n);

	int a[n];

	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}

	unsigned long long int x[21][n];

	for(i=0;i<21;i++){
		for(j=0;j<n;j++){
			x[i][j]=0;
		}
	}

	int b;

	x[a[0]][0]=1;
	for(i=1;i<n-1;i++){
		for(j=0;j<21;j++){
			if(x[j][i-1]!=0){
				b=j-a[i];
				if(0<=b && b<=20){
					x[b][i]+=x[j][i-1];
				}
				b=j+a[i];
				if(0<=b && b<=20){
					x[b][i]+=x[j][i-1];
				}
			}
		}
	}

// 	printf("a[n-1]+1=%d, n-1=%d,a[0]=%d \n",a[n-1]+1,n-1,a[0]);

	unsigned long long int ans=x[a[n-1]][n-2];

/* 	for(i=0;i<n-1;i++){
		for(j=0;j<21;j++){
			printf("%llu ",x[j][i]);

		}
		printf("\n");


	}
*/
	printf("%llu\n",ans);


}

void kannon(){

	int i,j;

	int n[100];

	int count=0;

	for(i=0;i<100;i++){
		scanf("%d",&n[i]);
		if(n[i]==0)	break;
		count++;
	}

	for(j=0;j<count;j++){

		int f[n[j]+1];

		f[0]=1;
		f[1]=1;
		f[2]=2;

		for(i=3;i<=n[j];i++){
			f[i]=f[i-3]+f[i-2]+f[i-1];
		}
		
		int d=f[n[j]]/10;
		int y=d/365+1;
	

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

	}

}

void risu(){
	int i,j,n;
	scanf("%d",&n);

	int rs[n];	// risu high
	int rr[n];	// risu rank

	int max=0;

	int flag=0;	// 自分より大きいのがあるかないか、あれば１
/*
	typedef struct{
		int h;	// 高さ
		int r;	// 順位
	}rs[n];
*/
	for(i=0;i<n;i++){
		scanf("%d",&rs[i]);
		rr[i]=1;
	}

	for(i=1;i<n;i++){
		for(j=i-1;j>=0;j--){
			if(rs[i]>rs[j]){
				
			}

		
		}

// 		if(rr[i]>max)	max=rr[i];

	}

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




}


void fib(){
	int i,n;
	scanf("%d",&n);
	
	int f[n];

	f[0]=0;
	f[1]=1;

	for(i=2;i<=n;i++){
		f[i]=f[i-1]+f[i-2];
	}

	printf("%d\n",f[n]);
}

Measured memory_bytes: 620
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s = input.next();
        String t = input.next();
        long counter = 0;
        for(int i = 0; i < s.length(); i ++) {
            if(s.charAt(i) != t.charAt(i)) {
                counter ++;
            }
        }
        System.out.println(counter);
    }

}

Measured memory_bytes: 41096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
int main(int argc, char* argv[]) {
	long long n, k; cin >> n >> k;
	vector<pair<int, int>> v;
	for(int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;
		v.push_back(make_pair(a, b));
	}
	sort(v.begin(), v.end(),
			[](pair<int, int> v0, pair<int, int> v1) {
			return v0.first < v1.first;
			});
	for(int i = 0; i < n; i++) {
		k -= v[i].second;
		if (k <= 0) {
			cout << v[i].first << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
inline long long read(){
	register long long x=0;
	register bool f=0;
	register char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') f=1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+c-48;
		c=getchar();
	}
	return f?-x:x;
}
char cr[200];int tt;
inline void print(register long long x,register char k='\n') {
    if(!x) putchar('0');
    if(x < 0) putchar('-'),x=-x;
    while(x) cr[++tt]=x%10+'0',x/=10;
    while(tt) putchar(cr[tt--]);
    putchar(k);
}
long long n;
int cnt=1,sqr1;
int main(){
	n=read();
	for(int i=1;1ll*i*i<=n;i++){
		if(1ll*i*i<(n-1)&&(n-1)%i==0) cnt++;
		if(i==1) continue;
		long long tmp=n;
		while(tmp%i==0){
			tmp/=i;
		}
		cnt+=(tmp%i==1);
	}
	print(cnt);
	return 0;
}


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

int main()
{
    int n, m, i, j;
    cin>>n>>m;
    int p;
    string s;
    bool mark[n+1]= {};
    int wcnt[n+1]= {};
    for(i=0; i<m; i++)
    {
        cin>>p>>s;
        if(s=="AC")
            mark[p]=1;
        else if(mark[p]==0)
            wcnt[p]++;
    }
    int cor=0, pen=0;
    for(i=1; i<=n; i++)
    {
        if(mark[i]==1)
        {
            cor++;
            pen+=wcnt[i];
        }
    }
    cout<<cor<<' '<<pen;
}


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

int main(){
    int n;
    cin>>n;
    int ans=0;
    int init=-1;
    while(n--){
        int x;
        cin>>x;
        if(x>=init){
            init=x;
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string s, t;
  cin >> s >> t;
  int r = 0;
  F0R(i, s.size()) {
    if (s[i] == t[i]) r++;
  }
  cout << r;
}
#endif


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

 bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }

 signed main(){
 int x;
 cin>>x;
 int p=x;
 while(!is_prime(p)) p++;
 cout<<p<<endl;
 return 0;
 }

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

int main() {
  
  int h,w;
  cin >> h >> w;
  
  vector<string> s(h+2);
  
  for ( int i = 1; i < h+2-1; i++){
    cin >> s[i];
    s[i] = ' ' + s[i] + ' ';
  }
  
  int count;
 
  for ( int i = 1; i < h+1; i++){
    for ( int j = 1; j < w+1; j++){
      count = 0;
      for ( int k = -1; k < 2; k++){
        for ( int l = -1; l < 2; l++){
          if ( s[i+k][j+l] == '#' ){
            count++;
          }
        }
      }
      if ( s[i][j] == '#' ){
        cout << '#';
      }else{
        cout << count;
      }
    }
    cout << endl;
  }

}

Measured memory_bytes: 256
N,M = map(int,input().split())
num_list = []
for i in range(N):
    num_list.append(list(map(int,input().split())))
#print(N,M,num_list)

'''
[x,y,z]としてx+y+z,x-y+z,x+y-z,x-y-z,-x+y+z,-x-y+z,-x+y-z,-x-y-zの8パターン
を計算してソート
'''
list_xyz1 = []
list_xyz2 = []
list_xyz3 = []
list_xyz4 = []
list_xyz5 = []
list_xyz6 = []
list_xyz7 = []
list_xyz8 = []

for i in range(N):
    list_xyz1.append(num_list[i][0] + num_list[i][1] + num_list[i][2])
    list_xyz2.append(num_list[i][0] - num_list[i][1] + num_list[i][2])
    list_xyz3.append(num_list[i][0] + num_list[i][1] - num_list[i][2])
    list_xyz4.append(num_list[i][0] - num_list[i][1] - num_list[i][2])
    list_xyz5.append(-num_list[i][0] + num_list[i][1] + num_list[i][2])
    list_xyz6.append(-num_list[i][0] - num_list[i][1] + num_list[i][2])
    list_xyz7.append(-num_list[i][0] + num_list[i][1] - num_list[i][2])
    list_xyz8.append(-num_list[i][0] - num_list[i][1] - num_list[i][2])

list_xyz1.sort(reverse=True)
list_xyz2.sort(reverse=True)
list_xyz3.sort(reverse=True)
list_xyz4.sort(reverse=True)
list_xyz5.sort(reverse=True)
list_xyz6.sort(reverse=True)
list_xyz7.sort(reverse=True)
list_xyz8.sort(reverse=True)

xyz1 = 0
xyz2 = 0
xyz3 = 0
xyz4 = 0
xyz5 = 0
xyz6 = 0
xyz7 = 0
xyz8 = 0

for i in range(M):
    xyz1 += list_xyz1[i]
    xyz2 += list_xyz2[i]
    xyz3 += list_xyz3[i]
    xyz4 += list_xyz4[i]
    xyz5 += list_xyz5[i]
    xyz6 += list_xyz6[i]
    xyz7 += list_xyz7[i]
    xyz8 += list_xyz8[i]

#print(list_xyz1)
print(max(xyz1,xyz2,xyz3,xyz4,xyz5,xyz6,xyz7,xyz8))

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

int main() {
    string op;
    priority_queue<int> que;
    while(cin >> op, op != "end") {
        if(op == "insert") {
            int x;
            cin >> x;
            que.push(x);
        } else if(op == "extract") {
            cout << que.top() << endl;
            que.pop();
        }
    }
}


Measured memory_bytes: 7096
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 2020
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int f[N][N],minn[N][N];
int siz[N];
int n,k;
struct edge
{
	int next,to;
}e[N<<1];
int head[N],cnt,dist[N],g[N],ans=inf;
inline void add_edge(int from,int to){e[++cnt]=(edge){head[from],to};head[from]=cnt;}
void dfs(int now,int father)
{
	siz[now]=1;int flag=0;
	for(register int i=head[now];i;i=e[i].next)
	{
		if(e[i].to==father)continue;
		dfs(e[i].to,now);flag=1;
		siz[now]+=siz[e[i].to];dist[now]=max(dist[now],dist[e[i].to]+1);
		for(register int j=1;j<=k+1;j++)f[now][j]+=f[e[i].to][j];
	}
	for(register int j=0;j<=k+1;j++)g[j]=0;
	for(register int i=head[now];i;i=e[i].next)
	{
		if(e[i].to==father)continue;
		for(register int j=0;j<=k+1;j++)g[j]+=f[e[i].to][j];
	}
	f[now][0]=siz[now];
	if(!flag){for(register int i=1;i<=k+1;i++)f[now][i]=0;return ;}
	for(register int j=1;j<=k+1;j++)
	{
		f[now][j]=inf;
		for(register int i=head[now];i;i=e[i].next)
		{
			if(e[i].to==father)continue;
//			cout<<"???:"<<now<<" "<<e[i].to<<" "<<j<<" "<<min(j-1,k-(j-1))<<" "<<f[e[i].to][j-1]<<" "<<g[min(j-1,k-(j-1))]-f[e[i].to][min(j-1,k-(j-1))]<<endl;
			if(min(j-1,k-(j-1))<0)continue;
			f[now][j]=min(f[now][j],f[e[i].to][j-1]+g[min(j-1,k-(j-1))]-f[e[i].to][min(j-1,k-(j-1))]);
		}
	}
	for(register int j=1;j<=k+1;j++)f[now][j]=min(f[now][j],f[now][j-1]);
	ans=min(ans,f[now][k+1]+(n-siz[now]));
//	cout<<"WTF:"<<now<<" "<<dist[now]<<endl;
//	for(register int j=0;j<=k+1;j++)cout<<f[now][j]<<" ";cout<<endl;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),k=read();
	for(register int i=1;i<n;i++)
	{
		int x=read(),y=read();
		add_edge(x,y);add_edge(y,x);
	}
	dfs(1,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 19568
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e7
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

int main(){
    int n,k;cin>>n>>k;k--;
    string s;cin>>s;
    if(s[k] == 'A')s.replace(k,1,"a");
    if(s[k] == 'B')s.replace(k,1,"b");
    if(s[k] == 'C')s.replace(k,1,"c");
    cout<<s;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n';

using namespace std;

int n, m, k, a, t;

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

    map<int, int> ma;

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

    for(int i = 1; i < ma.size()+1; i++){
        if(ma[i] == n){
            t++;
        }
    }

    cout << t;




}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

// char** arr = new char*[r];
// for(long long i = 0; i < r; i++) arr[i] = new char[c];

Measured memory_bytes: 256
import java.util.*;
public class Main {
   public static void main(String[] args) {  
      Scanner sc = new Scanner(System.in);
      long n = sc.nextLong();
      long m = sc.nextLong();
      
      long ans = (1900*m + 100*(n-m))*(long)Math.pow(2,m);
      System.out.println(ans);
   }
}

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

int main() {
    int h, n;
    cin >> h >> n;
    int *a = new int[n];
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    string ans = "Yes";
    if (sum < h) {
        ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3880
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,sum;
  cin >>n;
  sum =0;
  for(int i=0;i<n;i++)
    {
      int a;
      cin >> a;
      sum += (a - 1);
    }
  cout << sum << endl ;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define endl '\n'

void solvetask(){
    string s; cin >> s;
    if (s.back() == 's') s += "es";
    else s += "s";
    cout << s << endl;
}
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1; //cin >> t;
    while(t--) solvetask();
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<bitset>
#include<random>
#include<time.h>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

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

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

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



// Main Code
int x, y;
bool dp[8010][8010];

bool findans(vector<int> v, int d)
{
  memset(dp, 0, sizeof(dp));
  d = abs(d);
  int n = v.size();
  int sum = 0;
  for(int a: v) sum += a;
  if(sum == d) return true;
  repn(i, 0, n)
    dp[i][0] = 1;
  repn(i, 1, n)
  {
    repn(j, 1, sum)
    {
      dp[i][j] = dp[i-1][j];
      if(v[i-1] <= j) dp[i][j] |= dp[i-1][j-(v[i-1])];
      int a = j;
      int b = sum - j;
      if(dp[i][j] == 1 && d == abs(a - b)) return true;
    }
  }
  return false;
}

int main()
{
  vector<int> xv, yv;
  string s;
  cin>>s;
  xv.pb(0);yv.pb(0);
  cin>>x>>y;
  int n = s.length();
  int cnt = 0;
  int j = 0;
  rep(i, 0, n)
  {
    j++;
    if(s[i] == 'T') break;
    cnt++;
  }
  x = x - cnt;
  bool flag = true;
  cnt = 0;
  while(j < n)
  {
    if(s[j] == 'F') cnt++;
    else
    {
      if(flag)
      {
        yv.pb(cnt);
        cnt = 0;
        flag = false;
      }
      else
      {
        xv.pb(cnt);
        cnt = 0;
        flag = true;
      }
    }
    j++;
  }
  if(flag)
  {
    yv.pb(cnt);
    cnt = 0;
    flag = false;
  }
  else
  {
    xv.pb(cnt);
    cnt = 0;
    flag = true;
  }
  if(findans(xv, x) && findans(yv, y)) puts("Yes");
  else puts("No");
}


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

int main() {
	int n;
	cin >> n;
	string c;
	cin >> c;
	int ans = 0;
	int f = 0, e = n-1;
	while(c[f] == 'R') f++;
	while(c[e] == 'W') e--;
	while(f < e) {
		f++;
		e--;
		ans++;
		while(c[f] == 'R') f++;
		while(c[e] == 'W') e--;
		// cout << f << " " << e << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>

using namespace std;


int main() {
	string N;
	cin >> N;

	int length = N.length();
	for (int i = 0; i < length; i++) {
		if (N[i] == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}




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

using namespace std;

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

//#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define cl(x, v) memset((x), (v), sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) int(x.size())
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (( (a)/__gcd((a), (b)) )*(b))

vector<int> adj[100010];
int memo[100010];
int n, m;

int dfs(int u){
	int r = 0;
	
	if(memo[u] != -1)	
		return memo[u];
	
	for(int v: adj[u]){
		r = max(r, 1 + dfs(v));
	}
	
	return memo[u] = r;
}

int main() {
	
	memset(memo, -1, sizeof(memo));
	
	cin.sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	
	for(int i=0; i<m; i++){
		int a, b;
		cin >> a >> b;
		
		adj[a].PB(b);		
	}
	
	int r = 0;
	for(int i=1; i<=n; i++)
		r = max(r, dfs(i));

	cout << r << endl;

	return 0;	
}


Measured memory_bytes: 8192
while True:
    n = int(raw_input())
    if n == 0:
        break

    a = [[] for i in range(n + 1)]

    for i in range(n + 1):
        if i < n:
            a[i] = map(int, raw_input().split())
            a[i].append(sum(a[i]))
        else:
            a[i] = [sum([a[j][k] for j in range(n)]) for k in range(n + 1)]

    s = ""
    for i in range(n + 1):
        for j in range(n + 1):
            s += "{0:5d}".format(a[i][j])
        s += "\n"
    print s,

Measured memory_bytes: 4256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll floor(ll a,ll b){
    return a/b;
}

int main(){
    fast_io
    
    ll a, b, n;
    cin>>a>>b>>n;
    ll x;
    if(n>=b){
        x=b-1;
    }
    else{
        x=n;
    }
    ll ans=floor(a*x, b)-a*floor(x, b);
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(){
  int a,b,c,d;
  int cnt, num;
  while(scanf("%d", &num) != EOF){
    cnt = 0;
    if(num <= 36){
      for(a=0;a<=9;a++){
	for(b=0;b<=9;b++){
	  for(c=0;c<=9;c++){
	    for(d=0;d<=9;d++){
	      if(a+b+c+d == num){
		cnt++;
	      }
	    }
	  }
	}
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}
      

Measured memory_bytes: 596
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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


    int N, K; cin >> N >> K;

    double ans = 0;
    int cnt = 0;
    FOR(i,1,N+1) {
        int n = ceil(log2(((double)K) / i));
        //cerr << n << endl;
        if (n == 0) break;
        ans += pow(0.5, n);
        cnt++;
    }    
    ans += N - cnt;
    ans /= N;

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

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>

using ll = long long;

int main(){
    ll n;
    std::cin >> n;
    std::map<ll, ll, std::greater<ll>> mp;
    for(int i = 0; i < n; i++){
        ll a;
        std::cin >> a;
        mp[a]++;
    }

    std::vector<ll> ans;
    for(auto m : mp){
        if(m.second >= 4 && ans.size() == 0){
            std::cout << m.first * m.first << std::endl;
            return 0;
        }else if(m.second >= 2 && ans.size() == 1){
            std::cout << ans[0] * m.first << std::endl;
            return 0;
        }else if(m.second >= 2){
            ans.push_back(m.first);
        }
    }

    std::cout << 0 << std::endl;

    return 0;
}


Measured memory_bytes: 6528
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 20:58:59 2020

@author: H_Hoshigi
"""

N = int(input())

FizzBuzz_sum_list = [0,1,3,3,7,7,7,14,22,22,22,33,33,46,60]
FizzBuzz_num_list = [0,1,2,2,3,3,3,4,5,5,5,6,6,7,8]

answer = 60*pow(N//15, 2) + FizzBuzz_sum_list[N%15] + 15*(N//15)*FizzBuzz_num_list[N%15]

print(answer)



Measured memory_bytes: 9200
# n = int(input())
# a, b = map(str, input().split())
# a = list(map(str, input().split()))
s = input()

if s == "hi" or s == "hihi" or s == "hihihi" or s == "hihihihi" or s == "hihihihihi":
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
/*
 * =====================================================================================
 *
 *       Filename:  main.cpp
 *
 *    Description:  standard template
 *
 *        Version:  1.0
 *        Created:  30/07/2019 16:17:02
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Luigi Berducci (), berducci.1647887@studenti.uniroma1.it
 *        Company:  University of Rome La Sapienza
 *
 * =====================================================================================
 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <set>
#include <string>

using namespace std;

int K, X;
int main ( int argc, char *argv[] ) {
    cin >> K >> X;
    for(int i=X-(K-1); i<=X+(K-1); i++){
        cout << i << " ";
    }
    cout << endl;
    return EXIT_SUCCESS;
}				/* ----------  end of function main  ---------- */


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int count = 0;
		for (int i = 1; i <= n; i++) {
			int keta = 0;
			int tmp = i;
			while (tmp > 0) {
				tmp /= 10;
				keta++;
			}
			if (keta % 2 == 1) {
				count++;
			}
		}
		System.out.println(count);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

int main() {
  
  int n;
  cin >> n;
  
  vector<vector<vector<int>>> A(4,vector<vector<int>>(3,vector<int>(10,0)));
  
  for(int i=0; i<n; i++) {
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    A.at(b-1).at(f-1).at(r-1) += v;
  }
  
  for(int i=0; i<4; i++) {
    for(int j=0; j<3; j++) {
	  for(int k=0; k<10; k++) {
		cout << ' ' << A.at(i).at(j).at(k);
      }
      cout << endl;
    }
    if(i != 3)
    cout << "####################" << endl;
  }
  
  return 0;
}



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

using namespace std;

long long gcd(long long a, long long b);
long long lcm(long long a, long long b);


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

	vector<long long> t(n);
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	
	long long ans = 1;
	for (int i = 0; i < n; i++) {
		if (t[i] % ans == 0) {
			ans = t[i];
		} else if (ans % t[i] != 0) {
			ans = lcm(ans, t[i]);
		}
	}
	cout << ans << endl;

	return 0;
}

long long gcd(long long a, long long b)
{
	if (a < b) {
		long long t = a;
		a = b;
		b = t;
	}

	long long r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long lcm(long long a, long long b)
{
	return a / gcd(a, b) * b;
}

Measured memory_bytes: 256