akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const int INF=1e9;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll count_prs;
ll PowMod_RepeatSquaring(ll N, ll P){
    ++count_prs;
    if(P==0) return 1;
    if(P%2==0){
        ll t = PowMod_RepeatSquaring(N, P/2);
        return t*t % mod;
    }
    return N * PowMod_RepeatSquaring(N, P-1);
}


int main(){
  int n,a,b;
  cin>>n>>a>>b;

  ll all=PowMod_RepeatSquaring(2,n)-1;
  mint ans=all;

  mint x1=1,y1=1,x2=1,y2=1;
  rep(i,a){
    x1*=n-i;
    y1*=a-i;
  }
  //cout<<x1<<" "<<y1<<endl;
  mint comb1=x1/y1;

  rep(i,b){
    x2*=n-i;
    y2*=b-i;
  }
  //cout<<x2<<" "<<y2<<endl;

  mint comb2=x2/y2;
  

  //cout<<ans<<endl;
  //cout<<comb1<<endl;
  //cout<<comb2<<endl;

  cout<<ans-comb1-comb2<<endl;


}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
A = i()
B = i()
C = i()
D = i()
E = i()
print(math.ceil(N/min(A,B,C,D,E))+4)

Measured memory_bytes: 77440
A = []
check = [[0,0,0],
         [0,0,0],
         [0,0,0]]
for i in range(3):
    A.append(list(map(int,input().split())))
N = int(input())
for i in range(N):
    p = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == p:
                check[j][k] = 1

flag = 0
for i in range(3):
    if check[i][0] == 1 and check[i][1] == 1 and check[i][2] == 1:
        flag = 1
    if check[0][i] == 1 and check[1][i] == 1 and check[2][i] == 1:
        flag = 1
if check[0][0] == 1 and check[1][1] == 1 and check[2][2] == 1:
    flag = 1
if check[0][2] == 1 and check[1][1] == 1 and check[2][0] == 1:
    flag = 1

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
graph = []
vis = []
N = 0
M = 0

def dfs(n):
    if vis[n] == True:
        return
    vis[n] = 1
    for i in range(N):
        if graph[n][i] == True:
            dfs(i)

N,M = map(int,input().split())
Data = []
for _ in range(M):
    Data.append(list(map(int,input().split())))

ans = 0
for i in range(M):

    graph = []
    for _ in range(N):
        graph.append([False]*N)
    for j in range(M):
        if j != i:
            [a,b] = Data[j]
            graph[a-1][b-1] = True
            graph[b-1][a-1] = True

    vis = [0]*N
    dfs(0)
    if sum(vis) != N:
        ans += 1
    
print(ans)


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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
  
    if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) 
       cout << "Yes" << endl;
    else 
       cout << "No" << endl;
    }

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string S, T, B = "~";
bool isOK(string A1, string A2) {
	for (int i = 0; i < A1.size(); i++) {
		if (A1[i] != '?' && A1[i] != A2[i])return false;
	}
	return true;
}
int main() {
	cin >> S >> T;
	for (int i = 0; i <= (int)S.size() - (int)T.size(); i++) {
		string U = S.substr(i, T.size());
		if (isOK(U, T) == true) {
			string V = S;
			for (int j = i; j < i + T.size(); j++)V[j] = T[j - i];
			for (int j = 0; j < i; j++) { if (V[j] == '?')V[j] = 'a'; }
			for (int j = i + T.size(); j < V.size(); j++) { if (V[j] == '?')V[j] = 'a'; }
			B = min(B, V);
		}
	}
	if (B == "~")cout << "UNRESTORABLE" << endl;
	else cout << B << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ARC98 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [0] + LI()
b = list(accumulate(a))
l,r,tmp,ans = 0,0,0,n
while r < n:
    if b[r+1] - b[l] == tmp ^ a[r+1]:
        tmp ^= a[r+1]
        ans += r-l
        r += 1
    elif l == r:
        tmp ^= a[l]
        l += 1
        r += 1
    else:
        l += 1
        tmp ^= a[l]
print(ans)


Measured memory_bytes: 82252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	rep(i,1e7){
		int x=i*8/100,y=i*10/100;
		if(x==a && y==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b; cin >> a >> b;
    if(a==1) a = 14;
    if(b==1) b = 14;
    if(a>b) puts("Alice");
    else if(a==b) puts("Draw");
    else puts("Bob");
    
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

    private static int solver(Integer N, Integer[] values, Integer[] costs){
        Integer results = 0;
        for (int i = 0; i < N; i++) {
            if(values[i] > costs[i]){
                results += values[i] - costs[i];
            }
        }
        return results;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        Integer N = in.nextInt();
        Integer[] values = new Integer[N];
        Integer[] costs = new Integer[N];
        for (int i = 0; i < N; i++) {
            values[i] = in.nextInt();
        }
        for (int i = 0; i < N; i++) {
            costs[i] = in.nextInt();
        }
        System.out.println(solver(N, values, costs));


    }
}


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

int main(){
    int W,H,x,y,z ;
    cin >> W>>H>>x>>y>>z ;

    if(z <= x && W-z >= x && z <= y && H-z >= y) cout << "Yes" << endl ;
    else cout <<"No" << endl ;

    return 0 ;
}


Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int ans=0,min=0,o,k,r,u=0;
  vector<int> a(5,0);
  for(int i=0;i<5;i++){
    int s;
    cin>>s;
    ans+=s;
    k=s%10;

    if(k!=0) a[i]=10-k;
  }
 
  o=a.size();

  for(int i=0;i<o;i++){
    if(min<a[i]&&a[i]!=0){
      min=a[i];
      r=i;
      u++;
    }
  }

   if(u!=0) a[r]=0;

  for(int i=0;i<o;i++){
    if(a[i]!=0) ans=ans+a[i];
  }
  cout<<ans;
  return 0;
}

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

using namespace std;
int main(){
    long long h,w,x,y;
    cin >> w >> h >> x >> y;
    cout<<w*h/2;
    if(w*h%2==1)  printf(".5000000 ");
    else printf(".00000000 ");
    if(w%2==0 && h%2 == 0 && w/2==x && h/2==y) putchar('1');
    else putchar('0');
    return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

#define MAX 300000

/*
4
1 3
2 6
4 7
5 8

4
1 3
2 4
6 8
7 9
*/
struct S{
    int A;
    int B;
    int sortnum;
    bool operator<(const S s) const{
        if(sortnum==0){
            return B>s.B;
        }
        else{
            return A<s.A;
        }
    }
};

signed main(){
    int N;
    S AB[MAX];

    cin>>N;
    for(int i=0;i<N;i++){
        int A,B;
        cin>>A;
        cin>>B;
        S tmps;
        tmps.A=A;
        tmps.B=B;
        tmps.sortnum=0;
        AB[i]=tmps;
    }

    sort(AB,AB+N);

    int rl,ll,r2,l2;
    int num=(N-1)/2;

    rl=AB[num].B;
    r2=AB[num+1].B;
    for(int i=0;i<N;i++){
        AB[i].sortnum=1;
    }

    sort(AB,AB+N);

    ll=AB[num].A;
    l2=AB[num+1].A;

    int ln=ll;
    int rn=rl;

    if(N%2==0){
        cout<<rl+r2-ll-l2+1<<endl;
    }
    else{
        cout<<rn-ln+1<<endl;
    }
}


Measured memory_bytes: 7836
#include<bits/stdc++.h>
using namespace std;
const int N=55;
struct point
{
	double x,y;
}a[N],k;
inline double dis(point a,point b){return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}
int main()
{
	int n,num=100000,p;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lf%lf",&a[i].x,&a[i].y);
		k.x+=a[i].x,k.y+=a[i].y;
	}
	k.x/=n,k.y/=n;
	double zh=0.1;
	while(num--)
	{
		p=1;
		for(int i=2;i<=n;i++)
			if(dis(k,a[p])<dis(k,a[i]))
				p=i;
		k.x+=(a[p].x-k.x)*zh;
		k.y+=(a[p].y-k.y)*zh;
		zh*=0.999;
	}
	printf("%.12lf\n",sqrt(dis(k,a[p])));
	return 0;
}

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

using namespace std;
using pi=pair<int,int>;

vector<int> treerank;
vector<vector<int>> G;
vector<bool> visited;
vector<int> et;
vector<pi> pos;

template <typename T>
struct LazySegmentTree{
private:
    int n;
    T init;
    vector<T> node;
    vector<T> lazy;

    void update(int k){
        if(lazy[k]!=0){
            if(treerank[node[k]]<treerank[lazy[k]])node[k]=lazy[k];
            if(k<n-1){
                if(treerank[lazy[2*k+1]]<treerank[lazy[k]])lazy[2*k+1]=lazy[k];
                if(treerank[lazy[2*k+2]]<treerank[lazy[k]])lazy[2*k+2]=lazy[k];
            }
            lazy[k]=0;
        }
    }
public:
    explicit LazySegmentTree(int sz,T initv=0){
        n=1;
        init = initv;
        while(n<sz)n=n*2;
        node.assign(static_cast<unsigned int>(2*n-1),init);
        for (int i = 0; i < sz; ++i) {
            node[i+n-1]=init;
        }
        lazy.assign(static_cast<unsigned int>(2*n-1),init);
    }

    void mark(int p,int q,T val,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        update(k);
        if(r<=p||l>=q)return;
        if(p<=l&&r<=q){
            lazy[k]=val;
            update(k);
        }
        else{
            mark(p,q,val,2*k+1,l,(l+r)/2);
            mark(p,q,val,2*k+2,(l+r)/2,r);
            if(treerank[node[2*k+1]]<treerank[node[2*k+2]])node[k]=node[2*k+2];
            else node[k]=node[2*k+1];
        }
    }

    T query(int p,int q,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(r<=p||l>=q)return 0;

        update(k);
        if(p<=l&&r<=q)return node[k];
        T vl=query(p,q,2*k+1,l,(l+r)/2);
        T vr=query(p,q,2*k+2,(l+r)/2,r);
        if(treerank[vl]<treerank[vr])return vr;
        else return vl;
    }
};

void dfs(int x,int rank){
    pos[x].first=et.size();
    et.push_back(x);
    visited[x]=true;
    treerank[x]=rank;
    for(auto i:G[x]){
        if(visited[i])continue;
        dfs(i,rank+1);
    }
    pos[x].second=et.size();
    et.push_back(x);
}

void EulerTour(){
    treerank.resize(G.size());
    treerank[0]=0;
    et.clear();
    visited.assign(G.size(),false);
    for (int i = 0; i < G.size(); ++i) {
        if(visited[i])continue;
        dfs(i,0);
    }
}

bool solve(){
    int n,q;
    cin>>n>>q;
    if(n==0)return false;
    G.resize(n);
    pos.resize(n);
    for (int i = 1; i < n; ++i) {
        int a;
        cin>>a;
        --a;
        G[a].push_back(i);
    }
    EulerTour();
    LazySegmentTree<int> st(2*n);
    long long ans=0;
    for (int Q = 0; Q < q; ++Q) {
        char c;
        cin>>c;
        int x;
        cin>>x;
        --x;
        if(c=='Q'){
            //cout<<ans<<endl;
            ans+=st.query(pos[x].first,pos[x].first+1)+1;
        }
        else{
            st.mark(pos[x].first,pos[x].second+1,x);
        }
    }
    cout<<ans<<endl;
    treerank.clear();
    G.clear();
    pos.clear();
    et.clear();
    pos.clear();
    return true;
}


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


Measured memory_bytes: 19120
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    /*
     人がn人座るとして
     取る幅は
     n*Y+(n-1)*Z
     */
    ll X,Y,Z;
    cin >> X >> Y >> Z;

    ll ok = 0;
    ll ng = INF;

    while(ng - ok > 1){
        ll mid = (ok + ng)/2;
        if( mid*Y+(mid+1)*Z <=X ){
            ok = mid;
        }else{
            ng = mid;
        }
    }

    cout << ok << endl;

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;

/*FUNCs=================================================*/



/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n, p; cin >>n;
    vi b;
    while(cin >> p) b.push_back(p);
  	b.push_back(1000000);
    int cnt = 0;
    rep(i, n-1){
      	if(b[i] <= b[i+1]) cnt += b[i];
      	else cnt += b[i+1];
    }
    cout << cnt + b[0] << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int temp;

		// a ?????§???????????????
		if(a<b) {
			temp = a;
			a=b;
			b=temp;
		}
		
		while((a%b)!=0){
			temp = b;
			b=a%b;
			a=temp;
		}
		System.out.println(b);

	}

}

Measured memory_bytes: 25980
#include<bits/stdc++.h>
#include<random>
#include <chrono>
#define lowbit(i) (i&(-i))
using namespace std;

namespace _ {
	bool rEOF = 1;//为0表示文件结尾
	inline char nc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return p1 == p2 && rEOF && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? (rEOF = 0, EOF) : *p1++;
	}
	template<class _T>
	inline bool read(_T &num) {
		char c = nc(), f = 1; num = 0;
		while (c<'0' || c>'9')c == '-' && (f = -1), c = nc();
		while (c >= '0'&&c <= '9')num = num * 10 + c - '0', c = nc();
		return (bool)(num *= f);
	}
	inline bool need(char &c) { return c >= 'A'&&c <= 'z' || c >= '0'&&c <= '9' || c >= 'A'&&c <= 'Z'; }//读入的字符范围
	inline bool read_str(char *a) {
		while ((*a = nc()) && need(*a) && rEOF)++a;
		*a = '\0'; return rEOF;
	}
}using namespace _;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}

int n;
int a[100000 + 5];

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int flag = 1;
	for (int i = 1; i <= n; i++)
	{
		if (a[i] - 1 >= a[i - 1] && a[i] - 1 <= a[i + 1])a[i]--;
	}
	for (int i = 1; i < n && flag; i++)
		if (a[i] > a[i + 1])
			flag = 0;
	puts(flag ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 640
n = int(input())
s = str(input())
leftblack = 0
rightwhite = s.count(".")
ans = rightwhite

for i in range(n):
  if s[i] == "#":
    leftblack += 1
  else:
    rightwhite -= 1
  ans = min(ans,leftblack + rightwhite)
print(ans)

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n, x;
int a[105];

signed main()
{
	IOS;
	cin >> n >> x;
	int tot = 0, m = 10000;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		tot += a[i];
		m = min(m, a[i]);
	}
	x -= tot;
	cout << n + floor(x * 1LL / m) << endl;
	return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
ans = [0]*n

for i in range(m):
    a,b = map(int, input().split())
    a-=1
    b-=1
    ans[a]+=1
    ans[b]+=1
    ans[a]%=2
    ans[b]%=2
if any(ans):
    print('NO')
else:
    print('YES')


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

using namespace std;

using ll=long long;

const int N =2000005;

const ll mod=1000000007;

ll pow_exp(ll a,ll b,ll n)
{
    a%=n;
    ll result=1;
    while(b>0)
    {
        if(b&1)
            result=result*a%n;
        a=a*a%n;
        b>>=1;
    }
return result;
}

vector<ll> factorialNumInverse(N + 1);

// array to precompute inverse of 1! to N!
vector<ll> naturalNumInverse(N + 1);

// array to store factorial of first N numbers
vector<ll> fact(N+1);

// Function to precompute inverse of numbers
void InverseofNumber(ll p)
{
    naturalNumInverse[0] = naturalNumInverse[1] = 1;
    for (int i = 2; i <= N; i++)
        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p;
}

// Function to precompute inverse of factorials
void InverseofFactorial(ll p)
{
    factorialNumInverse[0] = factorialNumInverse[1] = 1;

    // precompute inverse of natural numbers
    for (int i = 2; i <= N; i++)
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p;
}

// Function to calculate factorial of 1 to N
void factorial(ll p)
{
    fact[0] = 1;

    // precompute factorials
    for (int i = 1; i <= N; i++) {
        fact[i] = (fact[i - 1] * i) % p;
    }
}

// Function to return nCr % p in O(1) time
ll Binomial(ll N, ll R, ll p)
{
    // n C r = n!*inverse(r!)*inverse((n-r)!)
    ll ans = ((fact[N] * factorialNumInverse[R])
              % p * factorialNumInverse[N - R])
             % p;
    return ans;
}

int main()
{
    InverseofNumber(mod);
    InverseofFactorial(mod);
    factorial(mod);
    ll k;
    cin>>k;
    string s;
    cin>>s;
    ll m=s.length();
    ll n=m+k;
    ll y=0ll;
    for(ll i=0;i<m;i++){
        y=(y%mod+(Binomial(n,i,mod)* pow_exp(25,n-i,mod))%mod)%mod;
    }
    ll ans=(pow_exp(26,n,mod)-y%mod+mod)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 52132
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, sum = 0;
    cin >> n >> m;
    vector<ll> a(m), b;
    for(int i=0;i<m;i++){
    	cin >> a[i];
    }
    n = min(n - 1, m - 1);
    sort(be(a));
    for(int i=1;i<m;i++){
    	b.pb(a[i] - a[i-1]);
    	sum += a[i] - a[i-1];
    }
    sort(be(b));
    reverse(be(b));
    for(int i=0;i<n;i++){
    	sum -= b[i];
    }
    cout << sum << endl;
    return 0;
}


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

int main(){
	int n;
	cin>>n;
	if(n%2==0){
		n/=2;
	}
	else if(n%2==1){
		n/=2;
		n++;
	}
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] a)throws IOException{
    	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String str = null;
        int stackNum;
        int transNum;
        String[] transBefore;
        String[] transAfter;
        
    	while((str = in.readLine()) != null){
            if(str.equals("0")){
                System.exit(0);
            }else{
                transNum = Integer.parseInt(str);
                
                transBefore = new String[transNum];
                transAfter = new String[transNum];
                
                for(int i=0; i<transNum; i++){
                    str = in.readLine();
                    transBefore[i] = str.split(" ")[0];
                    transAfter[i] = str.split(" ")[1];                   
                }
                
                stackNum = Integer.parseInt(in.readLine());
                
                for(int i=0; i<stackNum; i++){
                    str = in.readLine();
                    for(int j=0; j<transNum; j++){
                        if(transBefore[j].equals(str)){
                            str = transAfter[j];
                            break;
                        }
                    }
                    System.out.print(str);
                }
                System.out.println();
            }
        }
    }
}

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

namespace ALDS1_4_DAllocation
{
	class Program
	{
		static void Main ( string[] args )
		{
			var result = Solve ();
			Console.WriteLine (result);
		}

		static long Solve ()
		{
			//input
			int[] inputNum = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
			
			int baggageCount = inputNum[0];
			int trackCount = inputNum[1];

			long[] baggage = new long[100000];

			for (int lp = 0; lp < baggageCount; lp++)
			{
				baggage[lp] = long.Parse (Console.ReadLine ());
			}

			//process
			long left = 0;
			long right = 100000 * 10000;
			long middle;

			while (1 < right - left)
			{
				middle = (left + right) / 2;

				int capacity = Check (middle, baggageCount, trackCount, baggage);

				if (baggageCount <= capacity)
				{
					right = middle;
				}
				else
				{
					left = middle;
				}
			}

			return right;
		}

		static int Check ( long capacity, int maxCapacity, int trackCount, long[] baggage )
		{
			int count = 0;

			for (int lp = 0; lp < trackCount; lp++)
			{
				long s = 0;

				while (s + baggage[count] <= capacity)
				{
					s += baggage[count];
					count++;

					if (count == maxCapacity)
					{
						return maxCapacity;
					}
				}
			}

			return count;
		}
	}
}

Measured memory_bytes: 11356
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int main()
{
    long long int x,y;cin >> x >> y;

    int cc=1;
    while(1){
        x *= 2;
        if(x<=y){
            cc++;
        } else {
            break;
        }
    }
    p(cc)
} 

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	n := nextInt()
	m := nextInt()
	clearedlist := make([]bool, n)

	clearcount := 0
	penalty := 0
	// penaltycount := 0
	penaltycount := make([]int, n)
	for i := 0; i < m; i++ {
		p := nextInt()
		s := nextLine()
		if s == "AC" && clearedlist[p-1] != true {
			clearedlist[p-1] = true
			clearcount++
		} else if s == "WA" && clearedlist[p-1] != true {
			penaltycount[p-1]++
		}
	}
	for i, p := range penaltycount {
		if clearedlist[i] == true {
			penalty += p
		}
	}
	fmt.Println(clearcount, penalty)
}

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

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


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

int main() {
  long long a, b, k; cin >> a >> b >> k;
  if(a >= k){
    a = a - k;
  }else{
    b -= (k - a);
    a = 0;
  }
  if(b < 0) b = 0;
  cout << a << " " << b;
}

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

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

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

  for(int i=n; i>=1; i--) {
    if(n<2*i) ans[i-1] = a[i-1];
    else {
      int count = 0;
      int tmp = 2;
      while(i*tmp<=n) {
        if(ans[i*tmp-1]) count++;
        tmp++;
      }
      count += a[i-1];
      ans[i-1] = count%2;
    }
  }

  int sum = 0;
  for(int i=0; i<n; i++) {
    if(ans[i]) sum++;
  }

  cout<<sum<<endl;

  int cnt = 0;
  for(int i=0; i<n; i++) {

    if(ans[i]) {
      cnt++;
      if(cnt==sum) cout<<i+1<<endl;
      else cout<<i+1<<' ';
    }
  }

  return 0;
}

Measured memory_bytes: 4492
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
ll power(ll x, ll y); 

const ll MOD = 1000000007;
const int MX = 1e5 + 5;

vector<int> v[MX];

void bfs(vector<int> &level, int s){
	queue<int> q;
	q.push(s);
	while(q.size()){
		auto p = q.front();
		q.pop();
		for(auto i : v[p]) if(!level[i]){
			level[i] = level[p] + 1;
			q.push(i);
		}
	}
}
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
	int n, late, early;
	cin >> n >> late >> early;
	in_edges(n - 1);
	vector<int> A(MX, 0), B(MX, 0);
	bfs(A, late);
	bfs(B, early);
	int mx = 1;
	repp(i, 1, n) if(B[i] >= A[i] && B[i] >= mx) mx = B[i];
	for(auto i : v[late]) if(i == early) mx = 1;
	cout << mx - 1;
}

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

Measured memory_bytes: 6656
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<numeric>
#include<bits/stdc++.h>

#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define REP(i,n) FOR(i,0,n)
#define endl "\n"

#define INF 9e18
#define ll long long int
 
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	int n, a;
	
	cin >> n;
	map<int, int> m;
	for (int i = 1; i <= n; i++) {
		m[i] = 0;
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> a;
		m[a]++;
	}
	
	for (const auto [key, value] : m) {
		cout << value << endl;
	}
	
	return 0;
}


Measured memory_bytes: 13040
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

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

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}

template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  string s;cin>>s;
  if(s.back()=='s')s+="es";
  else s+="s";

  cout<<s<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3660
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i,a,b;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  // cin>>n>>m;
  ll dp[4] = {0};
  rep(i,3){
    cin>>a>>b;
    dp[a-1]++;
    dp[b-1]++;
  }
  ll flg = 0;
  rep(i,4) if(dp[i]==3) flg =1;
  if(flg) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
ll po(ll n)
{
	ll k=0;
	while(n%2==0)
	{
		k++;
		n=n/2;
	}
	return k;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,k,n,w;
    	string s,t,x;
    	cin>>s>>t;
    	n=s.size(); m=t.size();
    	ll dp[n+1][m+1];
		repi(i,0,n)
		{
			repi(j,0,m)
			{
				if(i==0 || j==0)
				{
					dp[i][j]=0;
				}
				else if(s[i-1]==t[j-1])
				{
					dp[i][j] = dp[i-1][j-1] + 1;
				}
				else
				{
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				}
			}
		}
		l = dp[n][m];
		char lcs[l+1];
		lcs[l]='\0';
		i=n; j=m;
		while(i>0 && j>0)
		{
			if(s[i-1]==t[j-1])
			{
				lcs[--l]=s[i-1];
				i--; j--;
			}
			else if(dp[i-1][j]>dp[i][j-1])
			{
				i--;
			}
			else
			j--;
		}
		cout<<lcs;
    } 
	return 0;
}

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

using namespace std;

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

	vector<pair<int, int>> former, latter;

	for (int i = 0; i < N; i++){
		string S;
		cin >> S;

		int count = 0;
		int A = 1e9;
		for (int j = 0; j < S.size(); j++){
			if (S[j] == '('){
				count++;
			} else {
				count--;
			}
			A = min(A, count);
		}
		if(count >= 0){
			former.push_back(make_pair(-A, count));
		} else {
			latter.push_back(make_pair(count - A, -count));
		}
	}
	sort(former.begin(), former.end());
	sort(latter.begin(), latter.end());

	int count1 = 0;
	for (int i = 0; i < former.size(); i++){
		if(count1 < former[i].first){
			cout << "No" << endl;
			return 0;
		}
		count1 += former[i].second;
	}

	int count2 = 0;
	for (int i = 0; i < latter.size(); i++){
		if(count2 < latter[i].first){
			cout << "No" << endl;
			return 0;
		}
		count2 += latter[i].second;
	}

	if (count1 == count2){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 11232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int, int>;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N, M;
  cin >> N >> M;
  vector<set<int>> edge(N-1);
  rep(i,M) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    edge[a].insert(b);
  }

  int y;
  int ans = 0;
  rep(i,N-1) {
    if (!edge[i].empty()) {
      ++ans;
      y = *begin(edge[i]);
      for (; i+1<y; ++i) {
        if (!edge[i+1].empty()) {
          y = min(y, *begin(edge[i+1]));
        }
      }
    }
  }

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


Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define N 400000
using namespace std;
int h[N], k, n;

int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        int x;scanf("%d", &x);
        h[x]++;
    }
    int ans = 0, tot = 0;
    for(int i = 1; i < N; i++)
        if (h[i]) h[++tot] = h[i];
    sort(h + 1, h + tot + 1);
    for(int i = 1; i <= tot - k; i++)
        ans += h[i];
    cout << ans << endl;
}


Measured memory_bytes: 1024
from math import gcd
def prime_factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        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
n = int(input())
if n == 1:
    print(0)
    exit()
l = prime_factorization(n)
cnt = 0
for i in l:
    for j in range(1,i[1]+1):
        if n >= i[0]**j and n % i[0]**j == 0:
            n//=i[0]**j
            cnt+= 1
print(cnt)


Measured memory_bytes: 63560
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string sts[4] = {"AC", "WA", "TLE", "RE"};
	map<string, int> mm;
	
	int N;
	cin >> N;
	REP(i, N) {
		string S;
		cin >> S;
		mm[S]++;
	}
	
	REP(i, 4) cout << sts[i] << " x " << mm[sts[i]] << endl;
	
	return 0;
}


Measured memory_bytes: 3632
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
lista=[list(map(int,input().split())) for x in range(n)]
ans=0
for i in range(1,n+1):
  sum=0
  for j in range(1,m+1):
    sum+=lista[i-1][j-1]*b[j-1]
  if sum+c>0:
    ans+=1
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#define N 2000001
#define M 10001
int A[N],B[N],C[M];
int main(){
  int a,i,j;
  scanf("%d",&a);
  for(i=0;i<=M;i++)
    C[i]=0;
  
  for(i=0;i<a;i++){
    scanf("%d",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=M;i++)
    C[i]=C[i]+C[i-1];
  
  for(j=1;j<=a;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=a;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;
}
    
   

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

const int N = 100010;

int fa[N];
std::vector <int> e[N];
int deg[N];

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0, u, v; i < n + m - 1; ++ i){
        scanf("%d%d", &u, &v);
        e[u].push_back(v);
        e[v].push_back(u);
        ++ deg[v];
    }
    std::queue <int> queue;
    for (int i = 1; i <= n; ++ i){
        if (!deg[i]){
            queue.push(i);
        }
    }
    while (!queue.empty()){
        int u = queue.front();
        queue.pop();
        for (auto v : e[u]){
            -- deg[v];
            if (!deg[v]){
                fa[v] = u;
                queue.push(v);
            }
        }
    }
    for (int i = 1; i <= n; ++ i){
        printf("%d\n", fa[i]);
    }
    return 0;
}

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

using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int dx[12] = {-2,-2,-2,-1,0,1,2,2,2,1,0,-1};
int dy[12] = {-1,0,1,2,2,2,1,0,-1,-2,-2,-2};
int main() {
	int sx, sy, n;
	while(cin >> sx >> sy && (sx || sy)) {
		cin >> n;
		int x[10] = {}, y[10] = {};
		rep(i,n) {
			cin >> x[i] >> y[i];
		}
		vector<int> qx,qy;
		qx.push_back(sx), qy.push_back(sy);
		rep(k,n) {
			int sz = qx.size();
			rep2(i,-1,2) {
				if(x[k]+i < 0 || 9 < x[k]+i) continue;
				rep2(j,-1,2) {
					if(y[k]+j < 0 || 9 < y[k]+j) continue;
					rep(l,sz) {
						bool f = 0;
						rep(m,12) {
							if(x[k]+i+dx[m] == qx[l] && y[k]+j+dy[m] == qy[l]) {
								qx.push_back(x[k]+i);
								qy.push_back(y[k]+j);
								f = 1;
								break;
							}
						}
						if(f) break;
					}
				}
			}
			rep(i,sz) {
				qx.erase(qx.begin());
				qy.erase(qy.begin());
			}
		}
		if(qx.empty()) cout << "NA" << endl;
		else cout << "OK" << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
int n,a[20],m,i,q;
int dfs(int y,int p){
  if(p==0)return 1;
  if(y>=n)return 0;
  int q=dfs(y+1,p)||dfs(y+1,p-a[y]);
  return q;
}
int main(){
  for(cin>>n,i=0;i<n;i++)cin>>a[i];
  for(cin>>m,i=0;i<m;i++){
    cin>>q;
    if(dfs(0,q))cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
}


Measured memory_bytes: 3092
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<endl;

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const ll inf = 900900900100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    while(cin >> n,n){
    int t[20][20];
    rep(i,n)rep(j,n+1) cin >> t[i][j];
    vector<ll> dp(1<<n,inf);
    dp[0] = 0;
    rep(i,1<<n){
        rep(j,n){
            if(i&(1<<j)) continue;
            int cost = t[j][0];
            rep(k,n) if((i&(1<<k)) && cost > t[j][k+1]) cost = t[j][k+1];
            dp[i+(1<<j)] = min<ll>(dp[i+(1<<j)],dp[i]+cost);
            // cout << cost << endl;
        }
    }
    cout << dp[(1<<n)-1] << endl;
    }
    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll INF=(ll)(1e18);

ll wei[105];
ll val[105];
ll dp[100005][105]={0};

ll knapsack1(ll w,ll i)
{
    if(i<0) return 0;
    
    if(w-wei[i]<0) return knapsack1(w,i-1);
    if(dp[w][i]!=0) return dp[w][i];
    
    dp[w][i]= max(knapsack1(w,i-1),knapsack1(w-wei[i],i-1)+val[i]);
    return dp[w][i];
}

int main()
{
    ll a,b,c,k,d,e,f,n,mx,t;
    cin>>n>>mx;
    for(int i=0;i<n;i++)
    {
        cin>>wei[i]>>val[i];
    }
    a=knapsack1(mx,n-1);
    cout<<a;
    
    
    
    
    return 0;
}

Measured memory_bytes: 82176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string A,B;
    cin>>A>>B;
    if(A.size()>B.size()){
        cout << "GREATER" << endl;
        return 0;
    }else if(A.size()<B.size()){
        cout << "LESS" << endl;
        return 0;
    }else{
        rep(i,A.size()){
            if(A.at(i)==B.at(i)){
                continue;
            }else if(A.at(i)>B.at(i)){
                cout << "GREATER" << endl;
                return 0;
            }else{
                cout << "LESS" << endl;
                return 0;
            }
        }


    }
    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
i = 0
count = 0
length = len(S)

if S[length - 1] == "h":
  count = 1
elif length % 2 == 1:
  count = 1
else:
  while i <= len(S)-2:
    if S[i] == "h" and S[i + 1] == "i":
      i += 2
    else:
      count = 1
      break

if count == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064