akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    map<int,int> a,b;
    rep(i,n){
        int x; cin >> x;
        if(i%2 == 0) a[x]++;
        else b[x]++;
    }
    vector<pair<int,int>> c,d;
    for(auto p:a) c.push_back({p.second,p.first});
    for(auto p:b) d.push_back({p.second,p.first});
    sort(all(c),greater<pair<int,int>>());
    sort(all(d),greater<pair<int,int>>());
    int ans;
    n /= 2;
    c.push_back({0,0});
    d.push_back({0,0});
    if (c[0].second == d[0].second) ans = min(n-c[0].first + n-d[1].first , n-c[1].first + n-d[0].first);
    else ans= n-c[0].first + n-d[0].first;
    ANS;

    return 0;
}



Measured memory_bytes: 8824
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
 
int dx[] = {0, -1, -1, 0, 1, 1};
int dy[] = {-1, -1, 0, 1, 1, 0};

typedef pair<int, int> P; 

vector<P> move(int d, vector<int> m){
  int x = 0, y = 0;
  int mx = 0, my = 0;
  vector<P> path;
  path.push_back(P(0, 0));
  for(int i = 0 ; i < (int)m.size() ; i++){
    x += dx[ (m[i]+d)%6 ] ,y += dy[ (m[i]+d)%6 ];
    mx = min(mx, x), my = min(my, y);
    path.push_back(P(x, y));
  }
  sort(path.begin(), path.end());
  for(int i = 0 ; i < (int)path.size() ; i++){
    path[i].first -= mx, path[i].second -= my;
  }
  return path;
}

bool solve(vector<int> m1, vector<int> m2){
  vector<P> path1 = move(0, m1);
  
  for(int i = 0 ; i < 6 ; i++){
    vector<P> path2 = move(i, m2);
    if(path1 == path2) return true;
  }
  return false;
}
int main(){
  int n;
  cin >> n;
  cin.ignore();
  string s1, s2, tmp;
  for(int i = 0 ; i < n ; i++){
    getline(cin, s1);
    getline(cin, s2);
    getline(cin, tmp);
 
    vector<int> m1, m2;
    for(int i = 0 ; i < (int)s1.size() ; i++) m1.push_back(s1[i]-'a');
    for(int i = 0 ; i < (int)s2.size() ; i++) m2.push_back(s2[i]-'a');
    
    if(solve(m1, m2)) cout << "true" << endl;
    else cout << "false" << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
package main

import (
	"fmt"
	"io"
	"os"
)

func main() {
	sc := NewScanner(os.Stdin)
	n, m, x := sc.Int(), sc.Int(), sc.Int()
	c := make([]int, n)
	a := make([][]int, n)

	for i := 0; i < n; i++ {
		c[i] = sc.Int()
		a[i] = sc.Ints(m)
	}

	min := 1 << 29
	overX := false

	for bit := 0; bit < (1 << n); bit++ {
		val := 0
		exp := make([]int, m)

		for i := 0; i < n; i++ {
			if bit&(1<<i) != 0 {
				val += c[i]
				for j, ex := range a[i] {
					exp[j] += ex
				}
			}
		}

		skip := false
		for _, ex := range exp {
			if ex < x {
				skip = true
				break
			}
		}
		if skip {
			continue
		}

		overX = true
		min = Min(min, val)
	}

	if !overX {
		fmt.Println(-1)
		return
	}
	fmt.Println(min)
}

// generated by https://github.com/murosan/gollect

func ParseInt(b []byte) (n int) {
	var i int
	if b[0] == '-' {
		i++
	}
	for ; i < len(b); i++ {
		n *= 10
		n += int(b[i] - '0')
	}
	if b[0] == '-' {
		return -n
	}
	return
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

type Scanner struct {
	r     io.Reader
	buf   []byte
	delim byte
	size, eof,
	start, end int
}

func NewScanner(r io.Reader) *Scanner { return NewScannerSize(r, 4096) }
func NewScannerSize(r io.Reader, size int) *Scanner {
	return &Scanner{
		r:     r,
		buf:   make([]byte, size),
		delim: ' ',
		size:  size, start: size, end: size,
	}
}

func (s *Scanner) Int() int { return ParseInt(s.bytes()) }

func (s *Scanner) Ints(len int) []int {
	a := make([]int, len)
	for i := 0; i < len; i++ {
		a[i] = s.Int()
	}
	return a
}

func (s *Scanner) bytes() []byte { b, _ := s.next(); return b }
func (s *Scanner) next() (b []byte, size int) {
	for n := 0; ; {
		for i := s.end; i < s.size; i++ {
			if s.buf[i] == s.delim || s.buf[i] == '\n' || i == s.eof {
				b, size = s.buf[s.start:i], i-s.start
				s.start, s.end = i+1, i+1
				return
			}
		}
		s.end = s.size
		if n++; n == 2 {
			panic("lack of buffer size")
		}
		s.read()
	}
}
func (s *Scanner) read() {
	copy(s.buf, s.buf[s.start:s.end])
	s.end -= s.start
	s.start = 0
	n, _ := s.r.Read(s.buf[s.end:])
	s.eof = s.end + n
}


Measured memory_bytes: 2164
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 760
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////




int main(){fastio
    ll n,k;cin>>n>>k;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll ans=inf;
    rep(i,0,n-k){
        ll b=a[i],c=a[i+k-1];
        if(b<=0&&0<=c){
            chmin(ans,c*2+abs(b));
            chmin(ans,abs(b)*2+c);
        }else if(c<=0){
            chmin(ans,abs(b));
        }else{
            chmin(ans,c);
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {

    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

    if(a == b && b == c){
        printf("1");
    }

    else if(a == b && b != c){
        printf("2");
    }

    else if(a != b && b == c){
        printf("2");
    }

    else if(a != b && a != c){
        printf("3");
    }


    else if(a != b && a == c){
        printf("2");
    }

    return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var A, B, C, D int
	var ans string
	fmt.Scan(&A, &B, &C, &D)

	if A+B > C+D {
		ans = "Left"
	} else if A+B < C+D {
		ans = "Right"
	} else {
		ans = "Balanced"
	}

	fmt.Println(ans)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define pb push_back
#define fi first
#define se second
 
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
const int maxm = 3e5 + 10;
const double PI = acos(-1.0);
const int inf = 1e9;



int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b;
    cin >> a >> b;
    if(a >= 1 && a <= 9 && b >= 1 && b <= 9) {
        cout << a * b;
    }else
    {
        cout << -1;
    };
    return 0;
}

Measured memory_bytes: 256
/*
[agc029] B - Powers of two
*/

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

const int MAX_N = 2e5;

int N;
int A[MAX_N];

ll bits_msb(ll v) {
    for (unsigned int i = 1; i < sizeof(v) * 8; i <<= 1) {
        v = v | (v >> i);
    }
    return v ^ (v >> 1);
}

ll solve() {
    multiset<ll> s;
    for (int i = 0; i < N; i++) {
        s.insert(A[i]);
    }

    ll ans = 0;
    while (!s.empty()) {
        ll a = *s.rbegin();
        s.erase(--s.end());
        auto iter = s.find((bits_msb(a) << 1) - a);
        if (iter != s.end()) {
            ans++;
            s.erase(iter);
        }
    }

    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " << #x << " -> " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" -> ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

const int MAXS = 3000;

struct edge{
    int to;
    ll cost;
};

vector<ll> dijkstra(vector<edge> g[], int s, int V) {

    vector<ll> dist(V, LINF);

    priority_queue<pll, vector<pll>, greater<pll>> que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    while(!que.empty()) {
        ll cost;
        int idx;
        tie(cost, idx) = que.top();
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e: g[idx]) {
            auto next_cost = cost + e.cost;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

int en(int v, int s) {
    return v * MAXS + s;
}

void solve() {
    int n, m, s;
    cin >> n >> m >> s;
    chmin(s, MAXS - 1);
    vector<edge> G[n * MAXS];
    rep(i, m) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        rep(j, MAXS) {
            if (j - a < 0) continue;
            G[en(u, j)].pb({en(v, j - a), b});
            G[en(v, j)].pb({en(u, j - a), b});
        }
    }
    rep(i, n) {
        int c, d;
        cin >> c >> d;
        rep(j, MAXS) {
            G[en(i, j)].pb({en(i, min(MAXS - 1, j + c)), d});
        }
    }
    auto dist = dijkstra(G, en(0, s), n * MAXS);
    REP(i, 1, n) {
        ll ans = LINF;
        rep(j, MAXS) {
            chmin(ans, dist[en(i, j)]);
        }
        cout << ans << endl;
    }
}

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


Measured memory_bytes: 27344
n,x = map(int,input().split())
a = list(map(int,input().split()))
b = [a[i] + a[i+1] for i in range(n-1)] + [0]
 
ans = max(0, a[0] - x)
b[0] -= ans
 
for i in range(n-1):
  diff = max(0, b[i] - x)
  ans += diff
  b[i] -= diff
  b[i+1] -= diff
print(ans)

Measured memory_bytes: 14060
<?php   
    fscanf(STDIN,"%d",$n);
		            
     $s_li = array();
for($i=0;$i<$n;$i++){
  $s_li[]=trim(fgets(STDIN));
       
}

$categ = array();
                        
foreach($s_li as $s){
	  $categ[$s] = 1;
}
           

echo count($categ)."\n";


Measured memory_bytes: 40612
#include <cstdio>
#include <cstring>
#include <iostream>

const int MAXN = 200000;

using namespace std;

int N, K;
char s[MAXN];

int main() {
    scanf("%s", s);
    scanf("%d", &K);

    N = strlen(s);

    for (int i = 0; i < N; ++i) {
        if (s[i] > 'a' && 'z' - s[i] + 1 <= K) {
            K -= ('z' - s[i] + 1);
            s[i] = 'a';
        }
    }

    K %= 26;

    s[N-1] += K;

    printf("%s\n", s);

    return 0;
}


Measured memory_bytes: 384
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int64_t> hs(n);
    for (auto& h : hs)
    {
        cin >> h;
    }

    vector<int64_t> dp(n, 1000000000000ll);
    dp[0] = 0;

    for (int i = 1; i < n; i++)
    {
        for (int j = max(0, i - k); j < i; j++)
        {
            dp[i] = min(dp[i], dp[j] + abs(hs[j] - hs[i]));
        }
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template <class T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define eFOR(i, a, n) for (int i = (a); i <= (n); ++i)
#define rFOR(i, a, n) for (int i = (n)-1; i >= (a); --i)
#define erFOR(i, a, n) for (int i = (n); i >= (a); --i)
#define each(i, a) for (auto &i : a)
#define SORT(a) sort(a.begin(), a.end())
#define rSORT(a) sort(a.rbegin(), a.rend())
#define fSORT(a, f) sort(a.begin(), a.end(), f)
#define all(a) a.begin(), a.end()
#define out(y, x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define tp(a, i) get<i>(a)
#define line cout << "-----------------------------\n"
#define ENDL(i, n) ((i) == (n)-1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template <class T>
inline bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
inline void init()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
template <class T>
inline istream &operator>>(istream &is, vector<T> &v)
{
    for (auto &a : v)
        is >> a;
    return is;
}
template <class T>
inline istream &operator>>(istream &is, deque<T> &v)
{
    for (auto &a : v)
        is >> a;
    return is;
}
template <class T, class U>
inline istream &operator>>(istream &is, pair<T, U> &p)
{
    is >> p.first >> p.second;
    return is;
}
template <class T>
inline vector<T> vec(size_t a) { return vector<T>(a); }
template <class T>
inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template <class T, class... Ts>
inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template <class T, class... Ts>
inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template <class T>
inline void print(const T &a) { cout << a << "\n"; }
template <class T, class... Ts>
inline void print(const T &a, const Ts &... ts)
{
    cout << a << " ";
    print(ts...);
}
template <class T>
inline void print(const vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
        cout << v[i] << (i == v.size() - 1 ? "\n" : " ");
}
template <class T>
inline void print(const vector<vector<T>> &v)
{
    for (auto &a : v)
        print(a);
}
inline string reversed(const string &s)
{
    string t = s;
    reverse(all(t));
    return t;
}

int main()
{
    init();
    int n, l;
    cin >> n >> l;
    string text('x', l);
    VS s(n, text);
    FOR(i, 0, n)
    cin >> s[i];
    sort(s.begin(), s.end());
    cout << endl;
    FOR(i, 0, n)
    cout << s[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 3676
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        //入力の受け取り
        string[] input = Console.ReadLine().Split(' ');
        int num1 = int.Parse(input[0]);
        int num2 = int.Parse(input[1]);
        int numK = int.Parse(input[2]);

        //num1を割れる数
        List<int> num1List = new List<int>();
        for(int ii = 1; ii <= num1; ii++)
        {
            if(num1 % ii == 0)
            {
                num1List.Add(ii);
            }
        }

        //num2を割れる数
        List<int> num2List = new List<int>();
        for(int jj = 1; jj <= num2; jj++)
        {
            if(num2 % jj == 0)
            {
                num2List.Add(jj);
            }
        }

        //共通する数を得る
        List<int> numCommon = new List<int>();
        foreach(int kk in num1List)
        {
            for(int ll = 0; ll < num2List.Count; ll++)
            {
                if(kk == num2List[ll])
                {
                    numCommon.Add(kk);
                }
            }
        }

        numCommon.Reverse();
        Console.WriteLine(numCommon[numK - 1]);

    }
}

Measured memory_bytes: 13268
n=int(input())
a=list(map(int,input().split()))
a.sort()
s=[]
#print(a[-1]-a[0])
for i in range(a[0],a[-1]+1):
    b=0
    #print(i)
    for j in range(len(a)):
        b+=(a[j]-i)**2
    s.append(b)
#print(s)
print(min(s))

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int v[maxn], c[maxn];

int main() {
    int n, res = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &v[i]);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &c[i]);
        if (v[i] > c[i]) res += v[i] - c[i];
    }
    printf("%d\n", res);
	return 0;
}


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

int main() {
  int N;
  int cnt = 0;

  cin >> N;

  int max_cnt = -1;
  int ans = -1;

  rep(1, N+1) {
    int cnt = 0;
    int y = i;

    while (y%2 == 0) {
      y /= 2;
      ++cnt;
    }

    if (max_cnt < cnt) {
      max_cnt = cnt;
      ans = i;
    }
  }

  cout << ans << endl;

  return 0;
}

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

int dp[1000100][2];

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    s += "0";
    int n = s.size();
    rep(i, n + 1) {
        rep(j, 2) {
            dp[i][j] = 1e9;
        }
    }
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, 2) {
            int x = s[i] - '0';
            x += j;
            rep(a, 10) {
                int nj = 0;
                int b = a - x;
                if (b < 0) {
                    nj = 1;
                    b += 10;
                }
                dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + (int)a + b);
            }
        }
    }
    cout << dp[n][0] << endl;
}


Measured memory_bytes: 12084
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(0);
        String res0 = sc.next();
        if (res0.equals("Vacant")) {
            return;
        }

        int left = 0;
        int right = N;
        String evenKey = res0; 

        // binary search
        while (left < right) {
            int mid = (left+right)/2;
            System.out.println(mid);
            String resm = sc.next();
            if (resm.equals("Vacant")) {
                return;
            }
            if ((mid%2 == 0 && !resm.equals(evenKey))
                || (mid%2 == 1 && resm.equals(evenKey))) {
                right = mid;
            } else {
                left = mid;
            }
        }
    }
}


Measured memory_bytes: 24228
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int x, y, z;
	scanf("%d%d%d", &x, &y, &z);
	printf("%d\n", (x - z) / (y + z));
}

Measured memory_bytes: 256
unittest
{
	assert( [ "5", "7.5", "2.4", "17.000000001", "17", "16.000000000" ].solve == 3 );
	assert( [ "11", "0.9", "1", "1", "1.25", "2.30000", "5", "70", "0.000000001", "9999.999999999", "0.999999999", "1.000000001" ].solve == 8 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto as = new long[ n ];
	foreach( ref a; as )
	{
		input.popFront;
		auto b = input.front.split( "." );
		a = b[ 0 ].to!( long ) * 10L ^^ 9;		// 全体に10^^9の補正を掛けて整数にする
		if( 1 < b.length ) a += b[ 1 ].to!( long ) * 10L ^^ ( 9 - b[ 1 ].length.signed );
	}
	
	// 素因数2と5が含まれる数ごとに分類
	const M = 18;
	auto dss = new long[][]( 1 + M, 1 + M );
	foreach( a; as )
	{
		auto d2 = 0L;
		auto d5 = 0L;
		for( ; d2 < M && a % 2 == 0; a /= 2 ) d2++;
		for( ; d5 < M && a % 5 == 0; a /= 5 ) d5++;
		dss[ d2 ][ d5 ]++;
	}
	
	// 素因数2と5がそれぞれ18個以上になる（10^^9の補正を打ち消した状態で整数になる）ペアをカウント
	auto ans = 0L;
	foreach( a2; 0L .. M + 1 )
	{
		foreach( a5; 0L .. M + 1 )
		{
			if( dss[ a2 ][ a5 ] == 0 ) continue;
			foreach( b2; M - a2 .. M + 1 )
			{
				foreach( b5; M - a5 .. M + 1 )
				{
					if( dss[ b2 ][ b5 ] == 0 ) continue;
					ans += dss[ a2 ][ a5 ] * ( dss[ b2 ][ b5 ] - ( a2 == b2 && a5 == b5 ) );
				}
			}
		}
	}
	ans /= 2;
	return ans;
}


Measured memory_bytes: 5276
n = int(input())
A = list(map(int,input().split()))

p,q,r = 0,0,0

for i in range(n):
    if A[i]%4 == 0:
        p += 1
    elif A[i]%2 == 0:
        q += 1
    else:
        r += 1

prev = 2
for i in range(n):
  if prev == 0:
    if p > 0:
      prev = 2
      p -= 1
    else:
      print('No')
      exit()
  elif prev == 1:
    if q > 0:
      prev = 1
      q -= 1
    elif p > 0:
      prev = 2
      p -= 1
    else:
      print('No')
      exit()
  else:
    if r > 0:
      prev = 0
      r -= 1
    elif q > 0:
      prev = 1
      q -= 1
    else:
      prev = 2
      p -= 1
print('Yes')
  

Measured memory_bytes: 14480
//I Guds namn
#include <iostream>

using namespace std;

int dp[10 + 13], bp[10 + 13];

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n; cin >> n;
	for(int i = 0;i < n;i++)
	{
		int a; cin >> a;
		for(int j = 0;j < 10;j++)
			if(dp[j] or !j)
				bp[(j + a) % 10] = dp[j] + a;
		for(int j = 0;j < 10;j++)
			dp[j] = max(dp[j], bp[j]);
	}
	int ans = 0;
	for(int i = 1;i < 10;i++)
		ans = max(ans, dp[i]);
	cout << ans << endl;
	return 0;
}

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

int selectionSort(int a[], int N){
    int minj;
    int sw = 0;
    for(int i = 0; i < N-1; i++){
        minj = i;
        for(int j = i + 1; j < N; j++){
            if(a[j] < a[minj]){
                minj = j;
            }
        }
        if(i != minj){
            swap(a[i], a[minj]);
            sw++;
        }
    }
    return sw;
}

int main(){
    int N, ans, a[100];
    cin >> N;
    rep(i, N){
        cin >> a[i];
    }

    ans = selectionSort(a, N);

    rep(i, N){
        if(i){
            cout << " ";
        }
        cout << a[i];
    }
    cout << endl;
    cout << ans << endl;
}


Measured memory_bytes: 3084
use proconio;

#[proconio::fastout]
fn main() {
    proconio::input! {
        x1: usize,
        x2: usize,
        x3: usize,
        x4: usize,
        x5: usize,
    }

    let result = if x1 == 0 {
        1
    } else if x2 == 0 {
        2
    } else if x3 == 0 {
        3
    } else if x4 == 0 {
        4
    } else {
        5
    };
    println!("{}", result);
}


Measured memory_bytes: 2088
#pragma GCC optimize ("O2") // "Ofast" for REAL FAST
// #pragma GCC optimization ("unroll-loops")

// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#include <bits/stdc++.h>
#define DEBUG 1

using namespace std;

#define rep(i, a, b) for (i = (a); i < (b); i++)
#define trav(a, x) for (auto & a : x)
#define all(x) (x).begin (), (x).end ()
#define rall(x) (x).rbegin (), (x).rend ()
#define sz(x) (int) (x).size ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;

typedef pair <int, int> pii;
#define f first
#define s second
#define mp(x, y) make_pair (x, y)

typedef vector <int> vi;
#define pb(x) push_back (x)

#define ddcout if (DEBUG) cout
#define ddprintf(fmt, ...) if (DEBUG) printf (fmt, ##__VA_ARGS__)

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x3f3f3f3f3f3f3f3f;
const int  INFi  =  0x3f3f3f3f;
const ll   MAXN  =  1e+6+7; // UPDATE

int main ()
{
    int i, j, a, f;
    cin >> a;
    for (i = a; true; i++)
    {
        f = 1;
        for (j = 2; j*j <= i; j++)
            f = f && i%j;
        if (f)
        {
            cout << i << "\n";
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void sort(int *a);

int main(void)
{
	int n, m, s, l;
	int d[4];
	int i;
	int cnt;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		cnt = 0;
		while (n != 6174){
			cnt++;

			for (i = 3; i >= 0; i--){
				d[i] = n % 10;
				n /= 10;
			}

			sort(d);

            s = d[3] * 1000 + d[2] * 100 + d[1] * 10 + d[0];
			l = d[0] * 1000 + d[1] * 100 + d[2] * 10 + d[3];
			n = l -  s;
			if (n == 0){
				cnt = -1;
				break;
			}
		}
		if (cnt != -1){
			printf("%d\n", cnt);
		}
		else {
			printf("NA\n");
		}
	}
	return (0);
}

void sort(int *a)
{
	int i, j;
	int tmp;
	
	for (i = 0; i < 4; i++){
		for (j = 0; j < 3; j++){
			if (a[j] < a[j + 1]){
				tmp = a[j];
				a[j] = a[j + 1];
				a[j + 1] = tmp;
			}
		}
	}
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;


int main() {

    int n;
    ll v;
    cin >> n >> v;

    vector<vector<ll>> coins(4, vector<ll>(n, 0));
    rep(b, 4) rep(i, n) cin >> coins[b][i];

    map<ll, ll> pair1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ll now = coins[0][i] + coins[1][j];
            pair1[now]++;
        }
    }

    map<ll, ll> pair2;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ll now = coins[2][i] + coins[3][j];
            pair2[now]++;
        }
    }

    ll ans = 0;
    for (auto e : pair1) {
        ll nokori = v - e.first;
        ll now = pair2[nokori] * e.second;
        ans += now;
    }
    cout << ans << endl;
}





Measured memory_bytes: 190624
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int > vi;
typedef pair<int ,int > pii;
typedef vector<pii> vii;
const int inf=0x3f3f3f3f, maxn=100007, mod=1e9+7;
const ll linf=0x3f3f3f3f3f3f3f3fLL;
const ll P=19260817;
int fa[100007];
int n;
inline int find(int x){
	return x==fa[x]? x: fa[x]=find(fa[x]);
}
struct node{
	int x,y,id;
}a[100007];
inline bool cmp1(const node& a,const node& b){
	return a.x<b.x;
}
inline bool cmp2(const node& a,const node& b){
	return a.y<b.y;
}
struct edge{
	int x,y,val;
}e[100005<<2];
inline bool cmp3(const edge& a,const edge &b){
	return a.val<b.val;
}
int cnt;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].y),a[i].id=i;
	sort(a+1,a+n+1,cmp1);
	for(int i=1;i<n;i++){
		e[++cnt].x=a[i].id;
		e[cnt].y=a[i+1].id;
		e[cnt].val=abs(a[i].x-a[i+1].x);
	}
	sort(a+1,a+n+1,cmp2);
	for(int i=1;i<n;i++){
		e[++cnt].x=a[i].id;
		e[cnt].y=a[i+1].id;
		e[cnt].val=abs(a[i].y-a[i+1].y);
	}
	sort(e+1,e+cnt+1,cmp3);
	int p=0;
	ll ans=0;
	for(int i=1;i<=cnt;i++){
		int fx=find(e[i].x);
		int fy=find(e[i].y);
		if(fx==fy)continue;
		fa[fx]=fy;
		ans+=e[i].val;
		p++;
		if(p==n-1)break;
	}
	printf("%lld",ans);
    return 0;
}


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

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    vector<int> m(n), a(n), b(n);
    for (int i = 0; i < n; ++i)
      cin >> m[i] >> a[i] >> b[i];

    bool ok = true;
    for (int i = 0; i < n; ++i) {
      int sum = m[i];
      for (int j = 0; j < n; ++j) {
	if (i == j)
	  continue;

	if (a[j] <= a[i] && a[i] < b[j])
	  sum += m[j];
      }

      if (sum > 150)
	ok = false;
    }

    if (ok)
      cout << "OK" << endl;
    else
      cout << "NG" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#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 s;
  cin >> s;
  vector<ll> a(s.size() + 1);
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '<') a[i + 1] = max(a[i + 1], a[i] + 1);
  }
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == '>') a[i] = max(a[i], a[i + 1] + 1);
  }

  ll ans = 0;
  for (auto v : a) {
    ans += v;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N, sum = 0;
  cin >> N;

  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
    sum += L.at(i);
  }

  sort(L.begin(), L.end());

  if (2 * L.at(N - 1) - sum < 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}


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

    cout << nCr(n,2)+nCr(m,2) << endl ;
    return 0;
}


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

int main() {
	int n, a[100], memory, i = 0, flag = 1, b = 0;

	cin >> n;

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

	i = 0;

	while (flag) {
		flag = 0;

		for (int j = n - 1; j >= i + 1; j--) {

			if (a[j] < a[j - 1]) {
				memory = a[j];

				a[j] = a[j - 1];

				a[j - 1] = memory;

				flag = 1;

				b += 1;
			}
		}

		i++;
	}

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

		if (i == n - 1) cout << endl;

		else cout << " ";
	}

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

	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	while (true) {
		int N;
		cin >> N;
		if (N == 0)break;
		vector<int> r(N);
		vector<int> w(N);
		for (int i = 0; i < N; i++) {
			cin >> r[i] >> w[i];
		}
		int sum = 0;
		int sum2 = 0;
		int mx = -1;
		int mxi = -1;
		for (int i = 0; i < N; i++) {
			sum += r[i];
			sum2 += w[i];
			if (mx < r[i]) {
				mx = r[i];
				mxi = i;
			}
		}
		//cerr << sum << " " << mxi << endl;
		if (mx * 2 > sum) {
			int t = mx - (sum - mx);
			//cerr << t << endl;
			int res;
			vector<int> X(t + 1, 0);
			X[0] = 1;
			for (int i = 0; i < N; i++) {
				if (mxi != i) {
					for (int j = t - w[i]; j >= 0; j--) {
						if (X[j] == 1) {
							X[j + w[i]] = 1;
						}
					}
				}
			}
			for (int i = t; i >= 0; i--) {
				if (X[i] == 1) {
					//cerr << i << endl;
					res = 2 * mx + sum2 - i;
					break;
				}
			}
			cout << res << endl;

		}
		else {
			cout << sum + sum2 << endl;
		}
	}
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000
vector<int>G[MAX];
list<int>out;
bool V[MAX];
int N;
int indog[MAX];
void bfs(int s){
  queue<int>q;
  q.push(s);
  V[s]=true;
  while(!q.empty()){
    int u=q.front(); q.pop();
    out.push_back(u);
    for(int i=0;i<G[u].size();i++){
      int v=G[u][i];
      indog[v]--;
      if(indog[v]==0&&!V[v]){
	V[v]=true;
	q.push(v);
      }
    }
  }
}
void tsort(){
  for(int i=0;i<N;i++){
    indog[i]=0;
  }
  for(int u=0;u<N;u++){
    for(int i=0;i<G[u].size();i++){
      int V=G[u][i];
      indog[V]++;
    }
  }
  for(int u=0;u<N;u++){
    if(indog[u]==0&&!V[u]){
      bfs(u);
    }
  }
  for(list<int>::iterator it=out.begin();it!=out.end();it++){
    cout<<*it<<endl;
  }
}
int main(){
  int s,t,M;
  cin>>N>>M;
  for(int i=0;i<N;i++){
    V[i]=false;
  }
  for(int i=0;i<M;i++){
    cin>>s>>t;
    G[s].push_back(t);
  }
  tsort();
  return(0);
}



Measured memory_bytes: 27212
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
#include<numeric>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
#define mkp(a,b) make_pair(a,b)
using namespace std;

inline int mex(unordered_set<int> st)
{
	int m = 0;
	while (st.find(m) != st.end())
	{
		m += 1;
	}
	return m;
}
inline int calculateGrundy(int n)
{
	if (n == 1)
		return 0;
	unordered_set<int> mexi;
	for (int i = 1; i <= sqrt(n); i += 1)
	{
		if (n % i == 0)
		{
			if (n / i != n)
				mexi.insert(calculateGrundy(n / i));
			mexi.insert(calculateGrundy(i));
		}
	}
	return mex(mexi);
}
inline ll gcd(ll a, ll b)
{
	// This is code taken from geeksforgeek
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
ll power(ll x, ll y)
{
	// This is code taken from geeksforgeek
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
/*ll power(ll x, ll y, ll p)
{
	ll res = 1;

	x = x % p;

	while (y > 0)
	{

		if (y & 1)
			res = (res * x) % p;

		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

*/
ll modInverse(ll n, ll p)
{
	return power(n, p - 2);
}

ll nCrModPFermat(ll n, ll r, ll p)
{
	if (r == 0)
		return 1;

	vector<ll> fac(n + 1, 0);
	fac[0] = 1;
	for (ll i = 1; i <= n; i++)
		fac[i] = fac[i - 1] * i % p;

	return (fac[n] * modInverse(fac[r], p) % p *
		modInverse(fac[n - r], p) % p) % p;
}

bool check(ll a)
{
	ll count = 0;
	while (a % 2 == 0)
	{
		a /= 2;
		count += 1;
	}
	if (count > 1)
		return false;
	bool flag = true;
	for (ll i = 3; i <= sqrt(a); i += 2)
	{
		if (a % i == 0)
		{
			flag = false;
			break;
		}
	}
	return flag;
}
ll sum(ll n)
{
	return (n * (n + 1)) / 2;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	vector<ll> arr(n, 0);
	unordered_map<ll, ll> count;
	ll sum = 0;
	f(i, 0, n)
	{
		cin >> arr[i];
		sum += arr[i];
		if (count.find(arr[i]) == count.end())
			count[arr[i]] = 1;
		else
			count[arr[i]] += 1;
	}
	ll q;
	cin >> q;
	f(i, 0, q)
	{
		ll b, c;
		cin >> b >> c;
		ll diff = c - b;
		if (count.find(b) == count.end())
			count[b] = 0;
		sum += count[b] * diff;
		cout << sum << endl;
		
		if (count.find(c) == count.end())
		{
			count[c] = count[b];
		}
		else
			count[c] += count[b];
		count[b] = 0;
	}
	return 0;
}

Measured memory_bytes: 7928
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc160_a.cpp
 * time   : Sat May  2 21:18:48 2020
 * quest  : A - Coffee
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  cout << (((s[2] == s[3]) && (s[4] == s[5])) ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

int n, x, res;

int main() {
  init_ios();
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> x;
    if (i == 1)
      res = x;
    res = __gcd(res, x);
  }
  cout<<res<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   if(a+b>c+d)cout<<"Left\n";
   else if(a+b<c+d)cout<<"Right\n";
   else cout<<"Balanced\n";
}


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

int main(){
    long long int n;
    scanf("%lld",&n);
    long long int ans=1;
    for(int i=2;i<=n;++i)ans = (ans * i) % (1000000007);
    printf("%lld\n",ans);

    return 0;
}


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

const int N = 1e5 + 5;
int n;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    
    vector<int> p(n,0);
    for (int i = 0; i < n; i++){
        cin>>p[i];
    }
    
    int  cnt = 0;
    for (int i = 1; i < n-1; i++){
        int mx = max({p[i-1], p[i], p[i+1]});
        int mn = min({p[i-1], p[i], p[i+1]});
        
        if(p[i]!= mx && p[i]!=mn)cnt++;
    }
    
    cout<<cnt<<'\n';
    
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int m,n,ans;
	while(cin>>m,m){
		cin>>n;
		ans=0;
	for(int i=1;i<=n;i*=5)
	for(int j=i;j<=n;j*=3)
	for(int k=j;k<=n;k*=2){
		if(k>=m)
		ans++;
	}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
from collections import deque #,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,m,p = inm()
dst = [{} for i in range(n+1)]
src = [{} for i in range(n+1)]
es = []
for i in range(m):
    a,b,c = inm()
    dst[a][b] = src[b][a] = p-c
    es.append((a,b,p-c))

rf1 = [False]*(n+1)
rf1[1] = True
q = deque([1])
while len(q)>0:
    x = q.popleft()
    for y in dst[x]:
        if not rf1[y]:
            rf1[y] = True
            q.append(y)

rtn = [False]*(n+1)
rtn[n] = True
q = deque([n])
while len(q)>0:
    x = q.popleft()
    for y in src[x]:
        if not rtn[y]:
            rtn[y] = True
            q.append(y)

ddprint(rf1)
ddprint(rtn)

use = [rf1[i] and rtn[i] for i in range(n+1)]

es = [z for z in es if use[z[0]] and use[z[1]]]
ddprint(es)

dp = [BIG]*(n+1)
dp[1] = 0
for i in range(n):
    ddprint(dp)
    for a,b,c in es:
        if dp[b] > dp[a]+c:
            dp[b] = dp[a]+c
            if i==n-1:
                print(-1)
                exit()

print(max(0,-dp[n]))


Measured memory_bytes: 73188
N=int(input())
munou=[]
count=0
sumi=set()
if N==1:
    print(0)
    exit()
def factorization(n):
    def sieve(n):
        is_prime = [True for _ in range(n+1)]
        is_prime[0] = False

        for i in range(2, n+1):
            if is_prime[i-1]:
                j = 2 * i
                while j <= n:
                    is_prime[j-1] = False
                    j += i
        table = [ i for i in range(1, n+1) if is_prime[i-1]]
        return table
    arr = []
    temp = n
    for i in sieve(int(n**0.5)):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
kari=factorization(N)
for i in range(len(kari)):
    for j in range(1,kari[i][1]+1):
        z=kari[i][0]**j
        if N%z==0 and z not in sumi:
            sumi.add(z)
            N=N/z
            count+=1
print(count)
#print(kari)

Measured memory_bytes: 20208
#include<bits/stdc++.h>
#define pb push_back
#define mkp make_pair
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=2e5+5;
const int inf=0x3f3f3f3f;
ll fac[maxn];
ll mul(ll a,ll b){
	return ((a%mod)*(b%mod)+mod)%mod;
}
void pre_fac(int up){
	fac[0]=fac[1]=1;
	for(int i=2;i<up;i++)fac[i]=mul(fac[i-1],i);
}
ll fpow(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1)ans=mul(ans,a);
		a=mul(a,a);
		b>>=1;
	}
	return ans;
}
ll inv(ll x){
	return fpow(x,mod-2);
}
ll C(ll n,ll m){
	return mul(inv(fac[n-m]),mul(fac[n],inv(fac[m])));
}
ll add(ll a,ll b){
	return (a+b+mod)%mod;
}
int main(){
	ll n,k;
	pre_fac(2e5+1);
	cin>>n>>k;
	k=min(k,n-1);
	ll ans=0;
	for(int i=0;i<=k;i++){
		ans=add(ans,mul(C(n,i),C(n-i+i-1,i)));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(1||was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

class node{
	public:
		int key;
		node *left;
		node *right;
		node(int key):key(key), left(NULL), right(NULL){}
};

class tree{
	public:
		node *root;
		tree():root(NULL){}
};

void insert(tree &t, node *z){
	node *y = NULL;
	node *x = t.root;
	while(x!=NULL){
		y = x;
		if(z->key < x->key){
			x = x->left;
		}else{
			x = x->right;
		}
	}

	if(y==NULL){
		t.root = z;
	}else if(z->key < y->key){
		y->left = z;
	}else{
		y->right = z;
	}
}

void inorder(node *n){
	if(n==NULL)return;
	inorder(n->left);
	output(n->key);
	inorder(n->right);
}

void inorder(tree &t){
	inorder(t.root);
	outendl();
}

void preorder(node *n){
	if(n==NULL)return;
	output(n->key);
	preorder(n->left);
	preorder(n->right);
}

void preorder(tree &t){
	preorder(t.root);
	outendl();
}

int main(){
	tree t;
	int time;
	cin >> time;
	rep(i, time){
		string op;
		cin >> op;
		if(op=="insert"){
			int num;
			cin >> num;
			node *z = new node(num);
			insert(t, z);
		}else if(op=="print"){
			inorder(t);
			preorder(t);
		}
	}


	return 0;
}



Measured memory_bytes: 18792
class UnionFind:
    def __init__(self, N):
        self.parent = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def find(self, x):
        r = x
        while self.parent[r] != r:
            r = self.parent[r]
        while self.parent[x] != r:
            x, self.parent[x] = self.parent[x], r
        return r

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
            self.size[y] += self.size[x]
        else:
            self.parent[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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

    def get_size(self, x):
        return self.size[self.find(x)]

N, M = map(int, input().split())
uf = UnionFind(N)
for _ in range(M):
    A, B = map(int, input().split())
    uf.unite(A-1, B-1)

ans = max(uf.get_size(i) for i in range(N))
print(ans)

Measured memory_bytes: 80740