akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
//const ll MOD = 1000000007;
typedef long long ll;

const ll dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const ll Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
const ll INF=1LL<<50;
ll n, m, p;
class BellmanFord{
    public:
        typedef struct Edge{
            ll from;
            ll to;
            ll cost;
            Edge(ll f,ll t,ll c):from(f),to(t),cost(c){}
        } Edge;
        ll edge_num, vertex_num, start, goal;
        vector<Edge> edges;
        vector<ll> dist;
        vector<ll> afby_nc;
 
    BellmanFord(ll e,ll v,ll s,ll g) : edge_num(e),vertex_num(v),start(s),goal(g){
        dist=vector<ll>(vertex_num,INF);
        dist[start]=0;
        afby_nc=vector<ll>(vertex_num,false);
    }
 
    void connect(ll from, ll to, ll cost) {
        edges.push_back(Edge(from,to,cost));
    }
 
    void relax(){
        REP(i,vertex_num){
            for(auto edge : edges){
                if(dist[edge.from]!=INF && dist[edge.to]>dist[edge.from]+edge.cost)
                   dist[edge.to]=dist[edge.from]+edge.cost;
            }
        }
    }
 
    void check_negative_cycle(){
        REP(i,vertex_num){
            for(auto edge : edges){
                if(dist[edge.from]==INF)continue;
                if(dist[edge.to]>dist[edge.from]+edge.cost){
                    afby_nc[edge.to]=true;
                    dist[edge.to]=dist[edge.from]+edge.cost;
                }
                if(afby_nc[edge.from]==true)afby_nc[edge.to]=true;
            }
        }
    }
 
    ll distance(){
        this->relax();//this->object内で自分のメンバ関数を呼び出すときに使う
        ll ans_dist=dist[goal];
        //for(auto vv:dist)prllf("###%lld\n",vv);
        this->check_negative_cycle();
        //for(auto vv:dist)prllf("######%lld\n",vv);
        if(ans_dist>dist[goal] || afby_nc[goal]==true)return -INF;
        else return ans_dist;
    }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    ll a, b, c;
    BellmanFord bf(m,n,0,n-1);
    for(ll i=0;i<m;i++){
        cin>>a>>b>>c;
        bf.connect(a-1,b-1,-c);
    }
    ll dist=bf.distance();
    if(dist==-INF)
    cout << "inf" << "\n";
    else cout<<-dist<<"\n";
}

Measured memory_bytes: 384
#define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    auto c = [&](ll x){
        if(x == 1){
            bool ok = true;
            rep(i,n-1)ok &= a[i+1] > a[i];
            return ok;
        }
        map<ll,ll> mp;
        reps(i,n-1){
            if(a[i] > a[i-1])continue;
            mp[a[i]]++;
            auto itr = mp.find(a[i]);
            itr++;
            mp.erase(itr, mp.end());
            if(mp[a[i]] == x){
                ll t = a[i];
                while(mp[t] >= x){
                    mp[--t]++;
                    mp.erase(t+1);
                }
            }
        }

        return mp.count(0) == 0;
    };

    ll ok = 1e6;
    ll ng = 0;

    while(abs(ok - ng) > 1){
        ll x = (ok + ng) / 2;
        if(c(x))ok = x;
        else ng = x;
    }

    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 1792
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }
char s[2],s2[2];
int main(){
    scanf("%s%s",s,s2);
    if (s[0]==s2[0]) puts("=");
    else if (s[0]>s2[0]) puts(">");
    else puts("<");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int n, m;
    cin >> n >> m;
    Graph G(n+1);
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> num(n);
    iota(num.begin(), num.end(), 1);
    Graph perm;
    do{
        perm.push_back(num);
    }while(next_permutation(num.begin()+1, num.end()));

    int ans = 0, cnt;
    for(int i=0;i<perm.size();i++){
        cnt = 0;
        for(int j=0;j<n-1;j++){
            for(int k: G[perm[i][j]]){
                if(perm[i][j+1] == k) cnt++;
            }
        }
        if(cnt == n-1){
            ans++;
        }
    }

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

Measured memory_bytes: 640
A, B, H, M = map(float, input().split())

import math
PI = math.pi
radA = (2.0 * PI * (H + M / 60.0)) / 12.0
radB = (2.0 * PI * M) / 60.0
print(math.hypot(A * math.cos(radA) - B * math.cos(radB),
                 A * math.sin(radA) - B * math.sin(radB)))

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

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

    int a;
    std::deque<int> b;
    for (int i = 0; i < n; ++i) {
        std::cin >> a;

        if (i % 2 == 0) {
            b.push_back(a);
        } else {
            b.push_front(a);
        }
    }

    if (n % 2 != 0) {
        std::reverse(b.begin(), b.end());
    }

    for (int v : b) {
        std::cout << v << " ";
    }
    std::cout << std::endl;


    return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>

int main() {
	int n, f = 0;
	char s[51];
	scanf("%d", &n);
	scanf("%s", &s);
	for (int i = 0; i < n-2; i++) {
		if (s[i] == 'A'&&s[i + 1] == 'B'&&s[i + 2] == 'C') {
			f++;
		}
	}
	printf("%d", f);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a;
	long double b;
	cin>>a>>b;
	long double ans = a*b;
	ll Ans = ans;
	cout<<Ans;
}

Measured memory_bytes: 3736
(let* ((n (read))
       (a (make-array (list (1+ n))))
       (ans 0)
       (c 1))
  (loop :for i :from 1 :to n
        :do (setf (aref a i) (read)))
  ;
  (defun main ()
    (cond ((= c 2)
           (format t "~A~%" ans))
          ((> ans n)
           (format t "-1~%"))
          (t
           (setf c (aref a c))
           (incf ans)
           (main))))
  (main))


Measured memory_bytes: 76992
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    int X,N;
    cin >> X >> N;
    vector<int> p(N);
    vector<int> check(101,0);
    for(int i=0; i<N; i++){
        cin >> p.at(i);
        check.at(p.at(i))=1;
    }
    if(check.at(X)==0) cout << X << endl;
    else{
        for(int i=1; i<60; i++){
            if(X-i==0){
                cout << 0 << endl;
                break;
            }else if(check.at(X-i)==0){
                cout << X-i << endl;
                break;
            }
            if(X+i==101){
                cout << 101 << endl;
                break;
            }else if(check.at(X+i)==0){
                cout << X+i << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

int main() {
  string s;
  cin >> s;
  int ans=0;
  rep(i, 3){
    if(s[i]=='1')ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

Q = sum(B)
for i in range(N-1):
    if A[i+1] == A[i]+1:
        Q += C[A[i]-1]
        
print(Q)
        


Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
	int W,H,x,y,r;
	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(x>=r&&W-x>=r)
	{
	if(y>=r&&H-y>=r)
	{
	printf("Yes\n");
	}
	else{printf("No\n");}
	}
	else{printf("No\n");}
	return 0;
}


Measured memory_bytes: 2112
if __name__ == '__main__':
    n = int(input())
    ans = [1, 1, ]
    if n == 0 or n == 1:
        print(ans[n])
    else:
        for i in range(2, n + 1):
            ans.append(ans[i - 2] + ans[i - 1])
        print(ans[n])


Measured memory_bytes: 5600
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $k);
if ($a >= $k) {
  echo ($a-$k)." ".$b;
} elseif ($b >= $k-$a) {
  echo "0 ".($b-($k-$a));
} else {
  echo "0 0";
}

Measured memory_bytes: 3704
def main():
  M=10**9+7
  r1,c1,r2,c2=map(int,input().split())
  n=r2+c2+2
  fac=[1]
  val=1
  append=fac.append
  for i in range(1,n+1):
    val=val*i%M
    append(val)
  f=lambda r,c:fac[r+c+2]*pow(fac[c+1],M-2,M)*pow(fac[r+1],M-2,M)-c-r-2
  print((f(r2,c2)-f(r2,c1-1)-f(r1-1,c2)+f(r1-1,c1-1))%M)
main()

Measured memory_bytes: 82220
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;

bool comp(const pair<string,int> a, const pair<string,int> b) {
  if (a.first != b.first)
    return a.first < b.first; // 高い順に並べたいので演算子を逆に
  else{
      return a.second > b.second;
  }
}

int Dx[6] = { 0, 0, 1, 1,-1,-1};
int Dy[6] = { 1,-1, 1, 0, 0,-1};

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;
int main(){
    string s;
    string ans = "Good";

    cin >>s;
    for(int i = 1;i<4;i++){
      if(s[i-1] == s[i]){
        ans = "Bad";
      }
    }

    cout <<ans<<endl;

    return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

*/

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	m := make(map[string]int)
	for i := 0; i < N; i++ {
		sc.Scan()
		s := sc.Text()
		rs := []rune(s)
		is := make([]int, 10)
		for j := 0; j < 10; j++ {
			is[j] = int(rs[j])
		}
		sort.Ints(is)
		for j := 0; j < 10; j++ {
			rs[j] = rune(is[j])
		}
		s = string(rs)
		m[s]++
	}
	count := 0
	for _, v := range m {
		if v > 1 {
			count += v * (v - 1) / 2
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 16024
#include <iostream>
using namespace std;
#include <stdio.h>
void ushm(char x);
struct sai {
	int dicet[3][2];
	int diceus[2], dicemh[2];
	int dicenow;
};
struct sai a = { { 1, 6, 2, 5, 3, 4 },{ 5, 2 },{ 4, 3 }, 1 };
int main()
{
	int	atai[6], i;
	char houi[101];
	for (i = 0; i < 6; i++) { cin >> atai[i]; }
	cin >> houi;
	for (i = 0; i <= 100 && houi[i] != '\0'; i++) {
		ushm(houi[i]);
	}
	printf("%d\n", atai[a.dicenow - 1]);
	return 0;
}
void ushm(char x)
{
	int now = a.dicenow, nowt, i;
	for (i = 0; i < 3; i++)
	{
		if (a.dicet[i][0] == now)
			nowt = a.dicet[i][1];
		else if (a.dicet[i][1] == now)
			nowt = a.dicet[i][0];
	}
	switch (x) {
	case 'N': a.dicenow = a.diceus[1]; a.diceus[0] = now; a.diceus[1] = nowt; break;
	case 'S': a.dicenow = a.diceus[0]; a.diceus[1] = now; a.diceus[0] = nowt; break;
	case 'W': a.dicenow = a.dicemh[1]; a.dicemh[0] = now; a.dicemh[1] = nowt; break;
	case 'E': a.dicenow = a.dicemh[0]; a.dicemh[1] = now; a.dicemh[0] = nowt; break;
	}
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
ll inf = 1e18+9;
//LLONG_MIN

//ac
//min(A,B)については，どっちを選んでもいいとする（どうせ最適解ではminになっているので）．
//全てAまたは全てBなら閉路は作れる．
//それ以外の場合，sort(A_1,...,A_n,B_1,...,B_n)をして，前半N項の中に同じ添字のものがあれば，閉路を作れる．
//無ければ，全てのiについて，i番目をO型にしたときのコストと今のコストを比較．

int main(void){
	bool is_double=false;
	ll n,visited[100010]={},ans,sum_a=0,sum_b=0,sum=0;
	mp x[200010];
	cin>>n;
	rep(i,n){
		ll a,b;
		cin>>a>>b;
		x[2*i]=make_pair(a,i);
		x[2*i+1]=make_pair(b,i);
		sum_a+=a;
		sum_b+=b;
	}
	ans=min(sum_a,sum_b);//全てAまたは全てBでも閉路は作れる．
	sort(x,x+2*n);
	rep(i,n){
		mp a=x[i];
		// printf("%lld:%lld\n",a.second,a.first);
		sum+=a.first;
		if(visited[a.second]==0){
			visited[a.second]=1;
		}else{//２回通った
			is_double=true;
		}
	}
	if(is_double){
		ans=sum;
	}else{
		rep(i,n){//x[i]番目をO型にする
			ll tmp=sum-x[i].first;
			if(x[n].second!=x[i].second){
				tmp+=x[n].first;
			}else{
				tmp+=x[n+1].first;
			}
			ans=min(ans,tmp);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define S_MAX 1000
#define N_MAX 50
#define M_MAX 50
#define INF 2000000000
#define MOD 1000000007
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;
typedef   signed long long dll;

typedef struct {
	int a;
	int b;
	int c;
} moneydata;

int n, m;
int h, w;
int i, j;
int k;

dll a[N_MAX][2];
dll c[M_MAX][2];

ull max(ull a, ull b){
	return (a > b) ? a : b;
}

ull min(ull a, ull b){
	return (a < b) ? a : b;
}

ull abs(dll a) {
	if (a >= 0) return (ull)a;
	else return (ull)(-a);
}

void solve(){
	dll answer[N_MAX][2];

	for (i = 0; i < n; i++) {
		answer[i][0] = -1;
		answer[i][1] = INF;
	}

	for (i = 0; i < m; i++) {
		for (j = 0; j < n; j++) {
			dll x = abs(a[j][0] - c[i][0]) + abs(a[j][1] - c[i][1]);
			if (x < answer[j][1]) {
				answer[j][0] = i;
				answer[j][1] = x;
			}
		}
	}

	for (i = 0; i < n; i++) printf("%lld\n", answer[i][0] + 1);

	return;
}

int main (void) {
	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) scanf("%lld%lld", &a[i][0], &a[i][1]);
	for (i = 0; i < m; i++) scanf("%lld%lld", &c[i][0], &c[i][1]);

	solve();
	
	return 0;
}




Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int H, W;
    int w, h;

	while (1){
	    scanf("%d %d", &H, &W);
	
	   	if (H == 0 && W == 0){
			break;
	   	}
		
	    for (int h = 0; h < H; h++){
	        for (int w = 0; w < W; w++){
	            printf("#");
	         }
	         printf("\n");
	    }
    	printf("\n");
    }

    return (0);
}



Measured memory_bytes: 2020
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define pb push_back
#define INF 1e11
#define mod 11092019
#define eps 1e-15
#define abs(x) ((x)>=0?(x):-(x))
#define y1 solai
#define fi first
#define se second
typedef long long ll;
typedef long double ldb;
typedef pair<ll,ll> pll;
const ll N=2100;
ll n,k,a[N],ans;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin>>n>>k;
	for(ll i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(ll i=1;i<=k;i++)
		ans+=a[i];
	cout<<ans;
}


Measured memory_bytes: 3656
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<set>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000;

using ll = long long;
using namespace std;

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

    int road[60]={0};
    rep(i, m){
        int a, b;
        cin >> a;
        cin >> b;
        road[a-1]++;
        road[b-1]++;
    }

    rep(i, n) cout << road[i] << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
D=[1] * (n + 1)
for _ in range(m):
    D[int(input())] = 0
for i in range(n+1):
    if D[i] == 0 or i < 2:
        continue
    D[i] = (D[i-1] + D[i-2]) % 1000000007 
print(D[i])

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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

ll POW(ll a, ll b){
	if(b==1) return a;
	if(b%2==0) return POW(a*a%INF, b/2);
	return a*POW(a, b-1)%INF;
}

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << a+b+c-max({a, b, c}) << endl;
	return 0;
} 


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input(), K = input();
    vector< i64 > A(N);
    cin >> A;
    
    i32 sum = whole(accumulate, A, 0);
    
    vector< i32 > div;
    for (int i = 1; i * i <= sum; ++i) {
        if (sum % i != 0) continue;
        
        if (i * i == sum) div.push_back(i);
        else {
            div.push_back(i);
            div.push_back(sum / i);
        }
    }
    
    rwhole(sort, div);
    for (auto d: div) {
        vector< i32 > md(N);
        range(i, 0, N) {
            md[i] = A[i] % d;
        }
        
        whole(sort, md);
        
        int l = 0, r = N - 1;
        i64 cnt = 0;
        
        while (l < r) {
            int diff = min(md[l], d - md[r]);
            md[l] -= diff;
            md[r] += diff;
            
            cnt += diff;

            if (md[l] == 0) l++;
            if (md[r] == d) r--;
        }
        
        if (cnt <= K) {
            cout << d << endl;
            return;
        }
    }
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
def main():
    input()
    rate = [399, 799, 1199, 1599, 1999, 2399, 2799, 3199, 4800]
    t = list(map(int, input().split()))
    ret = {399: 0, 799: 0, 1199: 0, 1599: 0, 1999: 0, 2399: 0, 2799: 0, 3199: 0, 4800: 0}
    for v in t:
        for r in rate:
            if v <= r:
                ret[r] += 1
                break
    count = 0
    for k in ret:
        if ret[k] >= 1 and k != 4800:
            count += 1
    if count == 0:
        print(1, count + ret[4800])
    else:
        print(count, count + ret[4800])
    # print(ret)



if __name__ == '__main__':
    main()


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

typedef pair<int,int> pint;
typedef pair<pint,pint> ppint;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int> > a(H, vector<int>(W, 0));
    int odd = 0;
    for (int i = 0; i < H; ++i) for (int j = 0; j < W; ++j) {
        cin >> a[i][j];
        if (a[i][j] & 1) ++odd;
    }
    
    vector<ppint> res;
    int num = 0;
    int x = 0, y = 0;
    for (int iter = 0; iter < W*H; ++iter) {
        if (a[x][y] & 1) ++num;
            
        int nx = x, ny = y;
        if (x % 2 == 0) {
            if (ny == W-1) ++nx;
            else ++ny;
        }
        else {
            if (ny == 0) ++nx;
            else --ny;
        }
        if (num & 1) if (num < odd) res.push_back(ppint(pint(x, y), pint(nx, ny)));
        x = nx, y = ny;
    }
        
    cout << res.size() << endl;
    for (auto p : res) {
        cout << p.first.first+1 << " " << p.first.second+1 << " " << p.second.first+1 << " " << p.second.second+1 << endl;
    }
}


Measured memory_bytes: 5232
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> b(n - 1); REP(i, n - 1) cin >> b[i];
  vector<int> a(n);
  a[0] = b[0];
  FOR(i, 1, n - 1) a[i] = min(b[i - 1], b[i]);
  if (n >= 2) a[n - 1] = b[n - 2];
  long long ans = 0;
  REP(i, n) ans += a[i];
  cout << ans << '\n';
  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 vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c - max({a,b,c}) == max({a,b,c})){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST_IO   ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Relocate freopen("./in.txt","r",stdin);freopen("./out.txt","w",stdout)
#define up(mi,a,b) for(mi=a;mi<=b;++mi)
#define down(mi,b,a) for(mi=b;mi>=a;--mi)
#define mfill(a,v) memset(a,v,sizeof(a))
#define INF 0x3f3f3f3f
#define MAX 5005
#define v_n 5005
#define LL long long
#define e_n 5000005
#define MOD 1000000007
#define eps 0.000000001
#define Blen 32
using namespace std;
int main(void)
{
	int i, j, k;
	FAST_IO;
	//Relocate;
	int N, K;
	cin >> N >> K;
	string a;
	cin >> a;
	a[K - 1] = a[K - 1] + 'a' - 'A';
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
if n == 1:
    print(0)
    exit()
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f**2 <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
b = []
d = prime_factorize(n)
c = len(d)
count = 1
for i in range(1,c):
    if d[i] != d[i-1]:
        b.append(count)
        count = 1
    else:
        count+=1
b.append(count)
ans = 0
for i in b:
    j = 1
    count2 = 0
    while count2 <= i:
        count2 += j
        j += 1
    ans += (j - 2)
print(ans)

Measured memory_bytes: 9252
#include<iostream>
using namespace std;
int main()
{
	int a[100000];
	int b[100002];
	int ans=-10,num;
	cin>>num;
	for (int i=0;i<100000;i++)
	{
		a[i]=0;
		b[i]=0;
	}
	b[100000]=0;
	b[100001]=0;
	for (int i=0;i<num;i++)
		cin>>a[i];
	for (int i=0;i<num;i++)
	{
		b[a[i]+2]++;
		b[a[i]+1]++;
		b[a[i]]++;
	}
	for (int i=0;i<100002;i++)
	{
		if (ans<b[i])
			ans=b[i];
	}
	cout<<ans;
return 0;
}


Measured memory_bytes: 1024
S = input()
T = input()

ans = 'Yes'

d = dict([])
for i,s in enumerate(S):
    t = T[i]
    try:
        if d[s] != t:
            ans = 'No'
            break
    except:
        d[s] = t

d = dict([])
for i,t in enumerate(T):
    if ans == 'No':
        break
    s = S[i]
    try:
        if d[t] != s:
            ans = 'No'
            break
    except:
        d[t] = s
        
print(ans)

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 20:52:46 2019

@author: Owner
"""


import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break

"""


N, Q = map(int, input().split())
S = input()

p_ac = []
n = 0
while True:
    tmp = S.find('AC', n, N+1)
    if tmp == -1:
        break
    else:
        p_ac.append(S.find('AC', n, N+1))    
        n = tmp+1
l = [0]*Q
r = [0]*Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())
    li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-2)       
    #print(p_ac, li, ri, len(S[li:ri]))
    print( len(S[li:ri]))
    







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

int main() {
    int n, a[110000];
    cin >> n;

    long long sum = 0;
    bool zero = false;
    int cnt_minus = 0;
    int mn = 1e9;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += abs(a[i]);
        if (a[i] == 0) zero = true;
        if (a[i] < 0) cnt_minus++;
        mn = min(mn, abs(a[i]));
    }

    if (zero || cnt_minus % 2 == 0) {
        cout << sum << endl;
    }
    else {
        cout << sum - 2 * mn << endl;
    }

    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class11
    {
        static void Main()
        {
            int[] NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NK[0], K = NK[1];
            var h = new int[N];
            for(int i = 0; i < N; i++)
            {
                h[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(h);
            int ans = int.MaxValue;
            for(int i = 0; i <= N - K; i++)
            {
                ans = Math.Min(ans, h[i + K - 1] - h[i]);
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 15584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define CL(a,x) memset(a, x, sizeof(a))
typedef long long LL;
const int P = 998244353;
const int N = 3005;
const double PI = acos(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, L, a[N];

int main(){
	cin>>n>>L;
	rep(i,1,n)cin>>a[i];
	double ansx = 0, ansy = 0;
	rep(i,1,n-1)rep(j,i+1,n){
		double angle = PI * (a[i]+a[j]) / L;
		int k = j - i - 1;
		ansx += cos(angle) * (n-2*k-2);
		ansy += sin(angle) * (n-2*k-2);
	}
	ansx *= 6.0/n/(n-1)/(n-2), ansy *= 6.0/n/(n-1)/(n-2);
	cout<<setprecision(15)<<fixed<<ansx<<" "<<ansy<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	a := ReadInts(3)
	sort.Ints(a)
	c := 0
	c += (a[2] - a[0]) / 2
	c += (a[2] - a[1]) / 2
	if (a[2]-a[0])%2 == 1 && (a[2]-a[1])%2 == 1 {
		c += 1
	} else if (a[2]-a[0])%2 == 1 || (a[2]-a[1])%2 == 1 {
		c += 2
	}
	fmt.Println(c)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N,M;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N >> M;
}

int solve(){
    ll ans=0;
    if(N>M) swap(N,M);
    if(N>2) ans = (N-2)*(M-2);
    if(N==2) ans = 0;
    if(N==1 && M>1) ans = M-2;
    if(N==1 && M==1) ans = 1;
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  ll C[N]; rep(i,N) cin >> C[i];
  sort(C,C+N,greater<ll>());

  if (N==1) {
    cout << (C[0]*2)%MOD << endl;
    return 0;
  }

  ll p2 = 1; rep(i,N-2) { p2 *= 2; p2 %= MOD; }
  ll result = 0;
  rep(i,N) {
    result += ((p2*(i+2))%MOD)*C[i];
    result %= MOD;
  }
  result *= (p2*4)%MOD; result %= MOD;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	int mx = 0, sum = 0;
	rep(i, n){
		int l;
		cin >> l;
		sum += l;
		mx = max(mx, l);
	}
	if(mx < sum-mx) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <memory.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
#include <set>
#include <map>

using ii = std::pair<int, int>;

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

	std::vector<int> seq(n);

	for (int i = 0; i < n; i++)
		scanf("%d", &seq[i]);

	std::sort(seq.begin(), seq.end());

	int x = seq[(n - 1) / 2];

	int l = 0, r = 0;
	int max = 0;

	while (r < seq.size())
	{
		while (seq[r] - seq[l] > 2)
			l++;

		max = std::max(max, r - l + 1);
		r++;
	}

	printf("%d", max);

	return 0;
}

Measured memory_bytes: 640
package main
import (
	"bufio"
	"fmt"
	"io"
	"os"
	"runtime/debug"
	"strconv"
)
var in = NewScanner(os.Stdin, 0)
func init(){
	debug.SetGCPercent(-1)
}
func main(){
	n := in.Int()
	a := in.ArrayInt(n)
	m := Max(a...)
	s := Sum(a...) - m
	if s > m{
		Pln("Yes")
	} else{
		Pln("No")
	}
}
const M7 = 1000000007
type Scanner struct{
	*bufio.Scanner
}
func NewScanner(r io.Reader, x int) *Scanner{
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if x <= 0{
		x = 1048576
	}
	s.Buffer([]byte{}, x)
	return &Scanner{s}
}
func (s *Scanner) Int() int{
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil{
		panic(e)
	}
	return int(i)
}
func (s *Scanner) ArrayInt(n int) IntSlice{
	r := make(IntSlice, n)
	for i := 0; i < n; i++{
		r[i] = s.Int()
	}
	return r
}
func isSpace(b byte) bool{
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(d []byte, e bool) (int, []byte, error){
	s := 0
	for s < len(d) && isSpace(d[s]){
		s++
	}
	for i := s; i < len(d); i++{
		if isSpace(d[i]){
			return i + 1, d[s:i], nil
		}
	}
	if e && len(d) > s{
		return len(d), d[s:], nil
	}
	return s, nil, nil
}
func Sum(a ...int) (r int){
	for _, x := range a{
		r += x
	}
	return
}
func Max(a ...int) (r int){
	r = a[0]
	for _, x := range a{
		if x > r{
			r = x
		}
	}
	return
}
func Pln(s ...interface{}){
	fmt.Println(s...)
}
type ByteSlice []byte
type IntSlice []int


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

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

    int r, g, b;
    cin >> r >> g >> b;

    int num = r * 100 + g * 10 + b;

    cout << (num % 4 == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int w, a, b;
    scanf("%d %d %d", &w, &a, &b);

    int c;
    if (a < b) {
        c = b - (a+w);
    } else {
        c = a - (b+w);
    }

    if (c <= 0) {
        printf("0\n");
    } else {
        printf("%d\n", c);
    }

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		
		while(true) {
			c -= b;
			if(c<=0) {
				System.out.println("Yes");
				break;
			}
			
			a -= d;
			if(a<=0) {
				System.out.println("No");
				break;
			}
		}
	}
}

Measured memory_bytes: 35608
using System;
class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var A = int.Parse(input[0]);
        var B = int.Parse(input[1]);
        var result = 0;
        
        for(var i=0; i<2; i++){
            result += Math.Max(A,B);
        }
        if(A!=B){
            result--;
        }
        
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 13140
# https://atcoder.jp/contests/abc130/tasks/abc130_b


N, X = gets.split.map(&:to_i)
Ls = gets.split.map(&:to_i)
Ds = Ls.reduce([0]) { |memo, d| memo + [memo.last + d] }
ans = Ds.count { |d| d <= X }
puts ans


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

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 100010;

int A[N];
bool ans;

int gcd(int x, int y){
	return !y ? x : gcd(y, x % y);
}

void quit(){
	puts(ans ? "First" : "Second");
	exit(0);
}

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

	long long sum = 0;
	For(i, 1, n){
		scanf("%d", &A[i]);
		sum += A[i];
	}
	ans = (sum - n) & 1;

	while((sum - n) % 2 == 0){
		int pos = 0;
		For(i, 1, n) if(A[i] & 1){
			if(pos) quit();
			pos = i;
		}

		if(A[pos] == 1) quit();

		A[pos]--;
		int g = A[pos];
		For(i, 1, n) g = gcd(g, A[i]);
		if((sum - 1) / g % 2 == (sum - 1) % 2) quit();

		sum = 0;
		For(i, 1, n) A[i] /= g, sum += A[i];
		ans ^= 1;

	}
	quit();

	return 0;
}

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

using namespace std;

int main(void){
	char s[20];
	int i;
	cin >> s;
	if(strlen(s) < 4){
		cout << "No" << endl;
	}else if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I'){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(vector<long long> M, vector<long long> D) {
    int ans = 0;
    vector<ll> not_31_lsit = {2, 4, 6, 9, 11};
    bool not_31;

    // x in a
    not_31 = find(not_31_lsit.begin(), not_31_lsit.end(), M[0]) != not_31_lsit.end();
    if (not_31) {
        if (M[0] == 2 && D[0] == 28) {
            ans = 1;
        } else if (M[0] != 2 && D[0] == 30) {
            ans = 1;
        }
    } else {
        if (D[0] == 31) {
            ans = 1;
        }
    }

    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  vector<long long> M(2);
  vector<long long> D(2);
  for (int i = 0; i < 2; i++) {
    cin >> M[i];
    cin >> D[i];
  }
  solve(move(M), move(D));
  return 0;
}


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

int main(){
	int X, A, B;
            cin >> X >> A >> B;
	if(B <= A){
		cout <<"delicious"<< endl;
	}
	else if(B - X <= A){
		cout <<"safe" << endl;
	}
	else{
		cout << "dangerous" << endl;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC94 B

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

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

ans1,ans2 = 0,0
for i in range(m):
    if a[i] > x:
        ans1 += 1
    elif a[i] < x:
        ans2 += 1
print(min(ans1,ans2))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (int)998244353
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
template <class T, class U>
bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
int modpow(int a, int b, int m = mod) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	int memo = modpow(a, b / 2, m);
	return memo * memo % m;
}
class modInt {
	int value, modulo;
public:
	modInt() : value(0), modulo(mod) { value = 0; }
	template<typename T>
	modInt(T value = 0, int modulo = mod) : value(value), modulo(modulo) {
		this->value = value % modulo;
	}
	operator int()const { return value; }
	modInt& operator+=(modInt x) {
		value += x.value;
		if (value >= modulo)value -= modulo;
		return *this;
	}
	modInt& operator++() {
		if (value == modulo - 1)value = 0;
		else value++;
		return *this;
	}
	modInt& operator-()const {
		return modInt(0) -= *this;
	}
	modInt& operator-=(modInt x) {
		value -= x.value;
		if (value < 0)value += modulo;
		return *this;
	}
	modInt& operator--() {
		if (value == 0)value = modulo - 1;
		else value--;
		return *this;
	}
	modInt& operator*=(modInt x) {
		value = value * x.value % modulo;
		return *this;
	}
	modInt& operator/=(modInt x) {
		return operator*=(x.inv());
	}
	modInt inv() {
		return modpow(*this, modulo - 2);
	}
	template<typename T> modInt operator+(T x) { return modInt(*this) += x; }
	template<typename T> modInt& operator+=(T x) { return operator+=(modInt(x)); }
	template<typename T> modInt operator-(T x) { return modInt(*this) -= x; }
	template<typename T> modInt& operator-=(T x) { return operator-=(modInt(x)); }
	template<typename T> modInt operator*(T x) { return modInt(*this) *= x; }
	template<typename T> modInt& operator*=(T x) { return operator*=(modInt(x)); }
	template<typename T> modInt operator/(T x) { return modInt(*this) /= x; }
	template<typename T> modInt& operator/=(T x) { return operator/=(modInt(x)); }
};
istream& operator>>(istream& ist, modInt& x) {
	int a;
	ist >> a;
	x = a;
	return ist;
}
modInt modpow(modInt a, int b) {
	if (!b)return modInt(1);
	if (b & 1)return modpow(a, b - 1) * a;
	modInt memo = modpow(a, b / 2);
	return memo * memo;
}
int n, r[2010];
string s;
modInt dp[4010][4010];
signed main() {
	cin >> s;
	n = s.size();
	rep(i, n) {
		r[i] = 2 - (s[i] - '0');
		if (i)r[i] += r[i - 1];
	}
	dp[0][0] = 1;
	rep(i, 2 * n) {
		rep(j, 2 * n + 1) {
			if (i + 1 - j <= 2 * min(n, i + 1) - r[min(n - 1, i)])dp[i + 1][j] += dp[i][j];
			if (j + 1 <= r[min(n - 1, i)])dp[i + 1][j + 1] += dp[i][j];
		}
	}
	cout << dp[2 * n][r[n - 1]] << endl;
	return 0;
}


Measured memory_bytes: 254868
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define SREP(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;
int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	char s[4];
	int f[3] = { 0 };
	scanf("%s", s);
	REP(i, 3) {
		switch (s[i]) {
		case 'a':
			f[0]++;
			break;
		case 'b':
			f[1]++;
			break;
		case 'c':
			f[2]++;
			break;
		}
	}
	REP(i, 3) {
		if (f[i] != 1) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 128