akhauriyash/Code-Regression huggingface dataset:
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

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

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

n = readInt()
b = readInts()

ans = [b[0]]

for i in range(1,n):
	ans.append(b[i-1])
	if ans[-2]>ans[-1]:
		ans[-2]=ans[-1]

print(sum(ans))

Measured memory_bytes: 3444
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int x;
  cin >> x;
  if (x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3100
#include<math.h>
#include<string.h>
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<sstream> //istringstream stm(string); stm >> x;
#include<vector>
#include<queue>
#define INF 2139062143
#define inf -2139062144
#define ll long long
using namespace std;
const int maxn = 1005;
ll a[305][305];
ll tempa[305][305];
struct Edge {
	ll from, to, dist;

	Edge(ll u, ll v, ll d) : from(u), to(v), dist(d) {}
};

struct HeapNode {
	ll d, u;

	bool operator<(const HeapNode &rhs) const {
		return d > rhs.d;
	}
};

struct Dijkstra {
	ll n, m;
	vector <Edge> edges;
	vector<ll> G[maxn];
	bool done[maxn];
	ll d[maxn];
	ll roadcount[maxn];
	ll p[maxn];     //×î¶ÌÂ·ÖÐµÄÉÏÒ»Ìõ»¡
	vector<ll> path;

	void init(ll n) {
		this->n = n;
		for (ll i = 0; i < n; i++) G[i].clear();
		edges.clear();
		path.clear();
	}

	void addEdge(ll from, ll to, ll dist) {
		edges.push_back(Edge(from, to, dist));
		m = edges.size();
		G[from].push_back(m - 1);
	}

	void dijkstra(ll s) {    //´Ósµã¿ªÊ¼
		priority_queue <HeapNode> Q;
		for (ll i = 0; i <= n; i++) d[i] = INF;
		for (ll i = 0; i <= n; i++) roadcount[i] = 0;
		d[s] = 0;
		memset(done, 0, sizeof(done));
		Q.push((HeapNode) {
			0, s
		});
		while (!Q.empty()) {
			HeapNode x = Q.top();
			Q.pop();
			ll u = x.u;
			if (done[u]) continue;
			done[u] = true;
			for (ll i = 0; i < G[u].size(); i++) {
				Edge &e = edges[G[u][i]];
				if (d[e.to] > d[u] + e.dist) {
					d[e.to] = d[u] + e.dist;
					roadcount[e.to] = roadcount[u] + 1;
					p[e.to] = G[u][i];
					Q.push((HeapNode) {
						d[e.to], e.to
					});
				} else {
					if(d[e.to] == d[u] + e.dist) {
						roadcount[e.to] = max(roadcount[e.to],roadcount[u] + 1);
					}
				}
			}
		}
	}

	void findpath(ll x, ll end) {
		path.clear();
		path.push_back(x);
		findd(x, end);
	}

	void findd(ll x, ll end) {
		if (x == end)
			return;
		else {
			path.push_back(this->edges[this->p[x]].from);
			findd(this->edges[this->p[x]].from, end);
		}
	}
};

int main() {
	ll n;
	scanf("%lld",&n);
	Dijkstra dj;
	dj.init(n);
	for(ll i=0; i<n; i++) {
		for(ll j=0; j<n; j++) {
			scanf("%lld",&a[i][j]);
			tempa[i][j] = a[i][j];
			if(i != j)
				dj.addEdge(i,j,a[i][j]);
		}
	}
	bool flag = true;
	for(ll i=0; i<n && flag; i++) {
		dj.dijkstra(i);
		for(ll j=0; j<n; j++) {
			if(a[i][j] > dj.d[j])	flag = false;
			if(dj.roadcount[j] > 1) {
				tempa[i][j] = 0;
				tempa[j][i] = 0;
			}
		}

	}
	if(!flag)	printf("-1\n");
	else {
		ll anss = 0;
		for(ll i=0; i<n; i++) {
			for(ll j=0; j<n; j++) {
				anss += tempa[i][j];
			}
		}
		printf("%lld\n",anss / 2);
	}
	return 0;
}

Measured memory_bytes: 6060
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)


// 最大公約数を求める
// 計算量O(logn)
template<class T>
T gcd(T a, T b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

// 最小公倍数を求める
// 計算量O(logn)
template<class T>
T lcm(T a, T b){
    return a/gcd(a,b)*b;
}

// 素数判定
// 計算量O(√n)
template<class T>
bool isPrime(T n){
    if(n < 2) return false;
    for(long long i = 2; i*i <= n; ++i) if(n % i == 0) return false;
    return true;
}

// 素数列挙
// nまでの素数をEratosthenesの篩で列挙する
// 計算量O(nloglogn)
template<class T>
vector<T> prime_list(T n){
    vector<T> ret;
    vector<T> isPrime(n+1,1);
    isPrime[0] = isPrime[1] = 0;
    for(long long i = 2; i <= n; ++i){
        if(isPrime[i] == 0) continue;
        ret.push_back(i);
        for(long long j = i*i; j <= n; j += i) isPrime[j] = 0;
    }
    return ret;
    // return isPrime;  // 状況によってはこっちを返す
}

// 素因数分解
// nを素因数分解してmapに記録
// 計算量O(√nlogn),必要ならmapではなくvectorにすると計算量を落とせる
template<class T>
map<T,int> prime_factor(T n){
    map<T,int> ret;
    if(n <= 0){
        cout << "Prime_factor Error" << "\n";
        return ret;
    }
    for(long long i = 2; i*i <= n; ++i){
        while(n%i== 0){
            ++ret[i];
            n /= i;
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}


// 関数名：pow
// 概要：modつき指数関数
// 第一引数a：指数の底
// 第二引数b：指数
// 第三引数mod：法となる値
// 戻り値：a^b(m mod)
// 計算量O(log b)
template<class T>
T pow(T a, int b){
    if(b == 0) return 1;
    if(b%2){
        T ret = pow(a,(b-1)/2); 
        return ret*ret*a;
    }else{
        T ret = pow(a,b/2);
        return ret*ret;
    }
}

template<class T>
T pow(long long a, long long b, T mod){
    if(b == 0) return 1;
    if(b % 2 == 0){
        T d = pow(a,b/2,mod);
        return (d*d)%mod;
    }else return a%mod*pow(a,b-1,mod)%mod;
}

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

    const ll MOD = 1e9+7;
    int n, k; cin >> n >> k;
    if(k == 0){
        cout << 0 << endl;
        return 0;
    }
    vector<ll> a(n); rep(i,n) cin >> a[i];
    ll comb[n+1];
    comb[k-1] = 1LL;
    for(ll i = k; i <= n; ++i){
        ll tmp = comb[i-1];
        tmp = (tmp*i)%MOD;
        tmp = (tmp*pow(i-(k-1),MOD-2, MOD))%MOD;
        comb[i] = tmp;
    }
    sort(a.begin(), a.end(), greater<ll>());
    ll ans = 0LL;
    rep(i,n-k+1){
        ans += (a[i]*comb[n-(i+1)])%MOD;
        ans %= MOD;
    }
    reverse(a.begin(),a.end());
    rep(i,n-k+1){
        ans -= (a[i]*comb[n-(i+1)])%MOD;
        ans += MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <cstdio>
using namespace std;
int main(void){
    // Here your code !
    int small;
    int medium;
    int big;
    int x;
    
    scanf("%d %d %d", &small, &medium, &big);
    
    if (small > medium ){
        x = small;
        small = medium;
        medium = x;
    }
    if (medium > big ){
        x = medium;
        medium = big;
        big = x;
    }
    if (small > medium ){
        x = small;
        small = medium;
        medium = x;
    }
    printf("%d %d %d\n", small, medium, big);
    return 0;
}

Measured memory_bytes: 2680
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define CL clear()



ll arr[2000010];


int main()
{
    ll n, m;
    cin >> n >> m;
    for(ll i = 0; i <=n; i++)
        arr[i] = 0;

    ll t = 0;
    for(ll i = 0; i < n; i++)
    {
        ll r;
        cin >> r;
        if(arr[r]==0)
            t++;
        arr[r]++;
    }
    if(t<= m)
        cout <<0 ;
    else
    {
        for(int i = 0; i <= n; i++)
        {
            if(arr[i]==0)
                arr[i] = LONG_MAX;
        }
        ll e = 0;
        sort(arr+1, arr+n+1);
//        for(int i = 1; i <= n; i++)
//            cout << arr[i] <<" ";
        for(int i = 1; i <= t - m; i++)
        {

            e += arr[i];
        }
        cout << e;
    }


    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int num[256], i, t;
	unsigned char x[1001];

	num['0'] = 0;
	num['1'] = 1;
	num['2'] = 2;
	num['3'] = 3;
	num['4'] = 4;
	num['5'] = 5;
	num['6'] = 6;
	num['7'] = 7;
	num['8'] = 8;
	num['9'] = 9;

	for (;;) {
		t = 0;
		scanf("%s", x);
		for (i = 0; x[i] != '\0'; i++) {
			t += num[x[i]];
		}
		if (t == 0) return 0;
		printf("%d\n", t);
	}
	return 0;
}



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

int main(){
  int N,M;
  cin >> N >> M;
  vector< pair<int64_t,int> > AB(N);
  for(int i=0;i<N;i++){
    cin >> AB.at(i).first >> AB.at(i).second;
  }
  sort(AB.begin(),AB.end());
  int64_t ans=0;
  int64_t count=0;
  for(int i=0;i<N;i++){
    if(AB.at(i).second+count<=M){
      ans+=AB.at(i).first*AB.at(i).second;
    }else{
      ans+=AB.at(i).first*(M-count);
    }
    count+=AB.at(i).second;
    if(count>=M){
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1920
#include <iostream>

using namespace std;
int N, M, X;
int main() {
    cin >> N >> M >> X;
    int l = 0, r = 0;
    for(int i = 1; i <= M; i++){
	int m;
	cin >> m;
	if(m < X) l++;
	else r++;
    }
    if(l < r) cout << l << endl;
    else cout << r << endl;
}

Measured memory_bytes: 256
(defun card-game (n)
 	(let ((mylist (make-array n))
         (alice 0)
         (bob 0))
     (dotimes (i n) 
         (setf (aref mylist i) (read)))
     (sort mylist #'>)
 	(dotimes (i n)
         (if (zerop (rem i 2))
       	    (setf alice (+ alice (aref mylist i)))
       	    (setf bob (+ bob (aref mylist i)))))
         (- alice bob)))
 
 (format t "~A~%" (card-game (read)))

Measured memory_bytes: 11108
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
int Gcd(int a,int b){if (b == 0) return a; return Gcd(b , a%b);}
int Lcm(int a, int b){ return a/Gcd(a,b)*b;}
inline int read(){
    int f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
const int maxn = 1e5 + 10;
int main(){
    int n = read();
    string s;
    cin >> s;
    int k = read();
    char ch = s[k-1];
    for(int i=0; i<n; i++){
        if (s[i] != ch){
            s[i] = '*';
        }
    }
    cout << s << endl;
    return 0;
}   

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int i,n,N;
	int A[201];
	int cnt;

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

	while (1) {

		n = 0;
		for (i = 0; i < N; i++) {
			if  (A[i] % 2 == 0) { A[i] = A[i] / 2; }
			else { break; }
			n++;
		}

		cnt++;
		if (n !=  N) { break; }
	}

	printf("%d", cnt - 1);

}

Measured memory_bytes: 256
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
dx = [0] * (m - 1)
for i in range(m - 1):
    dx[i] = x[i + 1] - x[i]
dx.sort()
print(sum(dx[:m-n]) if m > n else 0)

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


int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for (int tsumugi = 0; tsumugi < n; tsumugi++){
        cin >> a[tsumugi];
    }
    
    bool flag = true;
    int count = 0;

    for (int kaori = 0; kaori < n; kaori++){
        if (a[kaori] % 2 == 1){
            flag = false;
        }
    }
    while (flag){
        // count++;
        for (int matsuri = 0; matsuri< n; matsuri++){
            if(a[matsuri] % 2 == 0){
                a[matsuri] = a[matsuri] / 2;
            }
            else{
                flag = false;
                break;
            }
        }
        if (flag == true) count++;
    }

    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std; 
#define int long long int
#define ld long double
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(v) (int) v.size()
#define For(i, st, en) for(int i=st; i<en; i++)
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef SWAPNIL07
#define endl '\n'
#endif
mt19937
rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){    // l, r inclusive
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);   }

const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

bool Q;

struct Line {
    mutable ll m, c, p;
    bool operator<(const Line& o) const {
        return Q ? p < o.p : m < o.m;
    }
};
struct LineContainer : multiset<Line> {
    // (for doubles, use inf = 1/.0, div(a,b) = a/b)
    const bool minmax; // true for min, false for max
    LineContainer(bool minmax):minmax(minmax) {}
    const ll inf = LLONG_MAX;
    ll div(ll a, ll b) { // floored division
        return a / b - ((a ^ b) < 0 && a % b); }
    bool isect(iterator x, iterator y) {
        if (y == end()) { x->p = inf; return false; }
        if (x->m == y->m) x->p = x->c > y->c ? inf : -inf;
        else x->p = div(y->c - x->c, x->m - y->m);
        return x->p >= y->p;
    }
    void add(ll m, ll c) {
        if(minmax)
            m *= -1, c *= -1;
        auto z = insert({m, c, 0}), y = z++, x = y;
        while (isect(y, z)) z = erase(z);
        if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
        while ((y = x) != begin() && (--x)->p >= y->p)
            isect(x, erase(y));
    }
    ll query(ll x) {
        if(empty()) return 0;
        Q = 1; auto l = *lower_bound({0,0,x}); Q = 0;
        return (minmax?-1:1)*(l.m * x + l.c);
    }
};


signed main() {
    IOS;
    #ifdef SWAPNIL07
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, c; cin>>n>>c;
    int dp[n+1], h[n+1];
    For(i, 1, n+1){
    	cin>>h[i];
    }
    dp[1]=0;
    LineContainer l(1);
    l.add(-2*h[1], h[1]*h[1]);
    For(i, 2, n+1){
    	dp[i] = l.query(h[i]) + h[i]*h[i] + c;
    	l.add(-2*h[i], dp[i]+h[i]*h[i]);
    }
    cout<<dp[n];
    return 0;       
 }


Measured memory_bytes: 15872
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>

using namespace std;


int w,h,x,y;
int a,b,c,d;
int ans;
char data[10];

int main() {

  for(int i=0;i<4;i++){
    cin >> data[i];
  }

  if ((data[0] == data[1])
    || (data[1] == data[2])
    || (data[2] == data[3])) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    string x , y , c;
    cin>>x>>y;
    int a , b; cin>>a>>b;
    cin>>c;
    if(c==x)
        cout<<--a<<" "<<b<<endl;
    else cout<<a<<" "<<--b<<endl;

    return 0;
}


Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n; cin >> n;
	vector<ll> v(n);
	rep(i, n)cin >> v[i];
	sort(all(v));
	ll k = 0;
	rep(i, n - 1) {
		if (v[i] == v[i + 1]) k++;
	}
	if (k % 2 == 1)k++;
	cout << n - k << endl;
}

Measured memory_bytes: 1024
<?php
fscanf(STDIN, "%d%d", $n, $d);
for($i = 0; $i < $n; $i++){
  $x[] = array_map("intval", explode(" ", trim(fgets(STDIN))));
}
$c = 0;
for($i = 0; $i < $n; $i++){
  for($j = 0; $j < $i; $j++){
    $dist = 0;
    for($k = 0; $k < $d; $k++){
      $dist += ($x[$i][$k] - $x[$j][$k])**2;
    }
    if(abs(sqrt($dist) - round(sqrt($dist)))<10**-10){
      $c++;
    }
  }
}
echo $c;

Measured memory_bytes: 4728
#include<iostream>
using namespace std;
int main(){
  int n,i,j;
  cin >> n;
  for(i=1;i<=9;i++){
    for(j=1;j<=9;j++){
      if(i*j==n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n;
ll a[305][305], b[305][305];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	ll sum = 0;
	FOR(i, n) FOR(j, n) {
		cin >> a[i][j];
		b[i][j] = a[i][j];
		sum += a[i][j];
	}
	FOR(k, n) FOR(i, n) FOR(j, n) b[i][j] = min(b[i][j], b[i][k]+b[k][j]);
	FOR(i, n) FOR(j, n) {
		if (a[i][j] != b[i][j]) {
			cout << -1 << endl;
			return 0;
		}
	}
	sum /= 2;
	FOR(i, n) {
		for (int j = i+1; j < n; j++) {
			bool ok = false;
			FOR(k, n) {
				if (k == i || k == j) continue;
				if (!ok && a[i][k] + a[k][j] == a[i][j]) {
					sum -= a[i][j];
					ok = true;
				}
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,n) for(int i=0;i<n;++i)
#define pie 3.141592653589793238462643383279
#define mod 1e9+7
int x[100000],y[100000];
signed main(){
	int a,b,ans=0,ma=0;
	cin>>a;
	f(i,a){
		cin>>b;
		if(b>=ma){
			ans++;
			ma=max(ma,b);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
/* Internet-->"http://arcoder.jp/contests/arc103/tests/arc103_a" */
/* (arc)103C */
/* C-/\/\/\/ */
#include<bits/stdc++.h>
using namespace std;

int main() {
    int n, ans = 1e9, i;
    vector <pair<int, int>> v, w;
    map <int, int> mp1, mp2;
    map <int, int>::iterator it;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        int x;
        
        scanf("%d", &x);
        
        if (i % 2 == 0) {
            mp1[x]++;
        } else {
            mp2[x]++;
        }
    }
    
    mp1[1e9] = 0;
    mp2[1e9] = 0;
    
    for (it = mp1.begin(); it != mp1.end(); it++) v.push_back(make_pair(it->second, it->first));
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    
    for (it = mp2.begin(); it != mp2.end(); it++) w.push_back(make_pair(it->second, it->first));
    sort(w.begin(), w.end());
    reverse(w.begin(), w.end());
    
    for (i = 0; i < v.size(); i++) {
        int p = 0;
        
        if (v[i].second == w[0].second) p = 1;
        
        ans = min(ans, n - (v[i].first + w[p].first));
    }
    
    printf("%d\n", ans);
    
    return 0;
}

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

using namespace std;

typedef long long ll;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    int c0 = 0, c1 = 0, c2 = 0;
    for (int i =0 ; i < n; i++)
    {
        int p;
        cin >> p;
        if (p <= a) c0++;
        if (a < p && p <= b) c1++;
        if (b < p) c2++;
    }
    cout << min(min(c1, c0), c2);
}


Measured memory_bytes: 256
#!/usr/bin/python3

import math
import os
import sys


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, K, S):
    A = []
    i = 0
    while i < N:
        j = i
        while j < N and S[j] == S[i]:
            j += 1
        A.append(j - i)
        i = j

    assert sum(A) == N
    cur = N - len(A)
    return min(cur + 2 * K, N - 1)


def main():
    N, K = [int(e) for e in inp().split()]
    S = inp()
    print(solve(N, K, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 45168
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    int Y,M,D;
    cin >> Y >> M >> D;
    int count=0;
    bool ok=false;
    for(int j=1;j<=999;j++){
      for(int k=1;k<=10;k++){
        for(int l=1;l<=(j%3==0?20:(k%2==0?19:20));l++){
          if(Y==j&&M==k&&D==l)ok=true;
          if(ok)count++;
        }
      }
    }
    cout << count << endl;
  }
}



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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

const int MAXN = 105000;

int n;
int a[MAXN];
long long sum[MAXN];

int main() {

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

    sum[n] = a[n];
    for (int i = n - 1; i >= 0; i--)
        sum[i] = sum[i + 1] + a[i];

    long long ans = 0;
    long long nxtLevel = 1;

    for (int i = 0; i <= n; i++) {
        ans += nxtLevel;
        if (nxtLevel < a[i]) {
            puts("-1");
            return 0;
        }
        nxtLevel -= a[i];

        if (i == n) {
            if (nxtLevel != 0) {
                puts("-1");
                return 0;
            } else
                break;
        }

        long long leaves = sum[i + 1];
        nxtLevel = min(2 * nxtLevel, leaves);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4912
#include "bits/stdc++.h"
using namespace std;

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

	string ans;
	if (s == "Sunny") {
		ans = "Cloudy";
	} else if (s == "Cloudy") {
		ans = "Rainy";
	} else {
		ans = "Sunny";
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    int even = 0, odd = 0;
    for(int i=0;i<N;i++){
        int A;
        cin >> A;
        if(A % 2 == 0){
            even++;
        }else{
            odd++;
        }
    }
    if(odd % 2 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    string s; cin>>s;
    int n = (int)s.size();
    vector<vector<ll>> dp(n,vector<ll> (13));
    ll p10 = 10;
    if(s.back()!='?'){
        dp[n-1][s.back()-'0']++;
    }
    else{
        for(int dig = 0; dig < 10; dig++){
            dp[n-1][dig%13]++;
        }
    }
    auto add = [&](ll &a ,ll b){
        a = (a+b)%mod1;
    };
    for(int i = n-2; i >= 0; i--){
        if(s[i]=='?'){
            for(int dig = 0; dig < 10; dig++){
                for(int mod = 0; mod < 13; mod++){
                    add(dp[i][(dig*p10%13 + mod)%13], dp[i+1][mod]);
                }
            }
        }
        else{
            for(int mod = 0; mod < 13; mod++){
                add(dp[i][(mod + (s[i]-'0')*p10%13)%13] , dp[i+1][mod]);
            }
        }
        p10 = p10*10%13;
    }
    cout<<dp[0][5]<<endl;
    return 0;
}

Measured memory_bytes: 16628
def jud(x,y):
  if x<y:
    x,y = y,x
  if x == y:
    return x
  else:
    return x-y

n = int(input())
a = [int(input()) for i in range(2**n)]
for i in range(n):
  b = [0]*2**(n-i-1)
  for j in range(0,2**(n-i),2):
    b[j//2] = jud(a[j],a[j+1])
  a = b
print(a[0])

Measured memory_bytes: 18700
import Control.Monad

comb :: Int -> [a] -> [[a]]
comb 0 xs = [[]]
comb _ [] = []
comb n (x:xs) = [x:y | y <- comb (n-1) xs] ++ comb n xs

getData = map read . words <$> getLine :: IO[Int]

main = do
 [n,d] <- getData
 xList <- replicateM n getData
 let combination = comb 2 [0..(n-1)]
 let tmp = map (\[a,b] -> [xList !! a, xList !! b]) combination 
 let a = map (\x -> x^2) [1 .. (40^2 * d)]
 let b = map sum $ map (\x -> zipWith (\a b -> (a - b)^2) (x !! 0) (x !! 1)) tmp
 print $ sum $ map (\x -> if x then 1 else 0) $ map (flip elem a) b

Measured memory_bytes: 5448
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std ; 

int  dp[2][2][1000005] , n ; 


int fun(int zero,int nine,int idx){ 
    if (idx <= 0){
        return (zero and nine) ; 
    }
    if (dp[zero][nine][idx] != -1) return dp[zero][nine][idx];
    int sum=0;
    for (int i=0;i<=9;i++) { 
        sum += fun(zero or i==0, nine or i==9, idx-1); 
        sum %= 1000000007LL ; 
    }
    return dp[zero][nine][idx] = sum ; 
}

inline void solve(){ 
    cin >> n ; 
    memset(dp,-1,sizeof(dp));
    cout << fun(0,0,n) << endl ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

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

  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; ++i) cin >> S.at(i);
  sort(S.begin(), S.end());
  for (int i = 0; i < N; ++i) cout << S.at(i); cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;
int A, B, M;
int a[100000], b[100000];
int x[100000], y[100000], c[100000];
int main() {
	cin >> A >> B >> M;
	for (int i = 0; i < A; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> x[i] >> y[i] >> c[i];
	}
	int a_min = a[0];
	for (int i = 0; i < A; i++) {
		if (a_min > a[i]) { a_min = a[i]; }
	}
	int b_min = b[0];
	for (int i = 0; i < B; i++) {
		if (b_min > b[i]) { b_min = b[i]; }
	}
	int ans = a_min + b_min;

	for (int i = 0; i < M; i++) {
		if (ans > a[x[i] - 1] + b[y[i] - 1] - c[i]) {
			ans = a[x[i] - 1] + b[y[i] - 1] - c[i];
		}
	}

	cout << ans;
}

Measured memory_bytes: 2176
#include<stdio.h>

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	while(1){
		bool c=false;
		if(!(a|b))return 0;
		for(int i=a;i<=b;i++){
			if(i%400==0){
				c=true;
				printf("%d\n",i);
			}else if(i%100==0);
			else if(i%4==0){
				c=true;
				printf("%d\n",i);
			}
		}
		if(!c)printf("NA\n");
		scanf("%d%d",&a,&b);
		if(a|b)printf("\n");
	}
}



Measured memory_bytes: 2576
import math
a,b,C=[float(x) for x in input().split(' ')]

m=math.sqrt(a**2+b**2-(2*a*b*math.cos(math.radians(C))))
L=a+b+m

sinC=math.sin(math.radians(C))
r=(m/sinC)/2

S=b*a*sinC/2
h=sinC*b
print("{:.4f}".format(S))
print("{:.4f}".format(L))
print("{:.4f}".format(h))


Measured memory_bytes: 5708
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var a = [0,0,0,0,0];
  a[o.a()]++;
  a[o.a()]++;
  a[o.a()]++;
  a[o.a()]++;
  a[o.a()]++;
  a[o.a()]++;
  return Math.max(...a) <= 2 ? "YES" : "NO";
}

Measured memory_bytes: 21064
n = int(input())
str = input()
 
r = 0
l = 0
i = 0
 
while i < n:
    if str[i] == '(':
        l += 1
        i += 1
    elif str[i] == ')' and l == 0:
        str = '(' + str
        n += 1
        i += 2
    else:
        l -= 1
        i += 1
 
if l > 0:
    while l > 0:
        str = str + ')'
        l -= 1
 
print(str)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    vector<pair<int, int> > p(n);
    for(int i=0;i<n;i++) {
        cin >> a[i];
        p[i] = make_pair(a[i],i+1);
    }
    sort(p.begin(),p.end());
    for(int i=0;i<n;i++) cout << p[i].second << " \n"[i+1 == n];
    return 0;

}

Measured memory_bytes: 2048
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int total = 0;
    for(int i = 0; i < n; ++i){
        int j, k;
        cin >> j >> k;
        total += k - j + 1;
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())),reverse=True)

total=sum(a)
import math
border=math.ceil(total/(4*m))
cnt=0
for i in a:
    if i>=border:
        cnt+=1
print('Yes' if cnt>=m else 'No')


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(0);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    VI(v,n);
    double a=0;
    rep(i,n)a+=v[i];
    a/=n;
    double m=inf;
    int ans=0;
    rep(i,n){
        double t=abs(a-v[i]);
        if(m>t){
            m=t;
            ans=i;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

int gcd(const int& a, const int& b) {
  return b == 0 ? a : gcd(b, a % b);
}

int main()
{
  bool ans = false;
  int n, k, g, x;
  scanf("%d %d %d", &n, &k, &g);
  if (g >= k)
    ans = true;
  for (int i = 1; i < n; ++i) {
    scanf("%d", &x);
    if (x >= k)
      ans = true;
    g = gcd(g, x);
  }
  if (ans && k % g == 0)
    printf("POSSIBLE\n");
  else
    printf("IMPOSSIBLE\n");
  return 0;
}

Measured memory_bytes: 256
def main():
    s = int(input())
    a_list = [s]
    a = s
    index = 1
    while(True):
        index += 1
        new_a = func(a)
        if new_a in a_list:
            print(index)
            break
        a_list.append(new_a)
        a = new_a


def func(n):
    if n%2 == 0:
        return n/2
    else:
        return 3*n+1
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
#define  ll long long
using namespace std;
const int MAX = 100005;
//Union-Find木の実装
class UnionFind{
  public:
  vector<int> parent; //親の番号を格納
  UnionFind(int n){ //まずはparentを-1にする
    parent= vector<int>(n,-1);
  }
  int root(int a){ //aがどのグループに属しているか調べる
    if(parent[a] < 0) return a;
    return parent[a] = root(parent[a]);
  }
  int size(int a){ //頂点数を調べる
    return -parent[root(a)];
  }
  bool connect(int a,int b){ //root(a),root(b)をくっつける
    a = root(a);
    b = root(b);
    if(a == b) return false;
    //大きい方に小さい方をくっつけたい
    if(size(a) < size(b)) swap(a,b);
    parent[a] += parent[b];
    parent[b] = a;
    return true;
  }
};

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m);
  rep(i,m){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }
  vector<ll> ans(m);
  ans[m-1] = (ll)n*(n-1)/2;
  UnionFind Uni(n);
  for(int i=m-1;i>=1;i--){
    ans[i-1] = ans[i];
    if(Uni.root(a[i]) != Uni.root(b[i])){
      ans[i-1] -= (ll)Uni.size(a[i])*Uni.size(b[i]);
      Uni.connect(a[i],b[i]);
    }
  }
  rep(i,m){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 3328
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd, atan2
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
AB = [LIST() for _ in range(N)]

zero = 0
tmp = []
dic = defaultdict(lambda: [0, 0])

for x, y in AB:
	if x == 0 and y == 0:
		zero += 1
	else:
		g = gcd(x, y)
		x //= g
		y //= g
		if y < 0: x *= -1; y *= -1
		if y == 0 and x < 0: x *= -1; y *= -1

		rot90 = (x <= 0)
		if rot90:
			x, y = y, -x
		if rot90:
			dic[(x, y)][0] += 1
		else:
			dic[(x, y)][1] += 1

ans = 1
for l in dic.values():
	ans *= (pow(2, l[0], mod)-1 + pow(2, l[1], mod)-1 + 1)
	ans %= mod

ans -= 1
ans += zero
print(ans%mod) 


Measured memory_bytes: 100348
/**
 *		author:  zvm
 *		created: 25.09.2020 18:16:43
**/

#include <bits/stdc++.h>

using namespace std ;

int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);	

	int n ;
	cin >> n ;

	auto digit_sum = [&]( int x ) {
		int res = 0 ;
		for( ; x ; x /= 10 ) {
			res += x%10 ;
		}
		return res ;
	};

	cout << ( n%digit_sum(n) ? "No" : "Yes" ) << endl ;
}


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

using namespace std;

int main(int argc, char *argv[]) {
    string s;
    cin >> s;
    string rs = s;
    reverse(rs.begin(), rs.end());

    int q;
    cin >> q;
    int ct = -1;
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            swap(s, rs);
        } else {
            int f;
            cin >> f;
            char c;
            cin >> c;
            if (f == 1) {
                s.insert(0, {c});
                rs.push_back(c);
            } else {
                s.push_back(c);
                rs.insert(0, {c});
            }
        }
        ct = t;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 1316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int a,b;string s;cin>>a>>b>>s;
    rep(i,s.size()){
        if((i==a)&&(s[i]!='-')){co("No");return 0;}
        if((i!=a)&&(s[i]=='-')){co("No");return 0;}
    }
    co("Yes");
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

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

int main(){
	int elaps = 0,c;
	int i,q;
	P u;
	scanf("%d %d", &n, &q);

	for(i=1;i<=n;i++){
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].t);
	}
	head = 1; tail = n + 1;

	while(head != tail){
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if(u.t > 0) enqueue(u);
		else{
			printf("%s %d\n",u.name,elaps);
		}
	}

	return 0;
}

Measured memory_bytes: 12752
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	
	int t[n], a[n], b[n];
	
	bool ans = true;
	
	for (int i = 0; i < n; i++) {
	    cin >> t[i] >> a[i] >> b[i];
	    if( (t[i] < (a[i] + b[i])) or ( (t[i] % 2) != ((a[i] + b[i]) % 2) )) ans = false;
	}
	
	if(ans) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
	
	return 0;
}

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

int B[100];
bool flag;
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, K;
  int S[100];
    
  while (cin >> N >> K, N + K){
    for (int i = 0; i < K; i++){
      cin >> S[i];
      B[i] = 0;
    }

    for (int i = 0; i < N; i++){
      for (int j = 0; j < K; j++){
        int a;
        cin >> a;
        B[j] += a;
      }
    }

    flag = true;
    for (int i = 0; i < K; i++){
      if (S[i] < B[i]){
        flag = false;
      }
    }

    if (flag){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;

    }
  }
}

Measured memory_bytes: 1188
n, k = map(int, input().split())
ww = [int(input()) for _ in range(n)]
def chk(p):
    c = 1
    s = 0
    for w in ww:
        if w > p:
            return False
        if s + w <= p:
            s += w
        else:
            c += 1
            s = w
        if c > k:
            return False
    return True
def search(l, r):
    if r - l < 10:
        for i in range(l, r):
            if chk(i):
                return i
    m = (l + r) // 2
    if chk(m):
        return search(l, m + 1)
    else:
        return search(m, r)
print(search(0, 2 ** 30))

Measured memory_bytes: 11656
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 100000
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_W = 101;
const int MAX_H = 101;

int dp[MAX_W][MAX_H][2];
int w,h;

int main()
{
	while(1){
	scanf("%d%d",&w,&h);
	if(w==0&&h==0){
		break;
	}
	for(int i=1;i<=w;i++){
		dp[i][1][0] = 1;
		dp[i][1][1] = 0;
	}
	for(int j=1;j<=h;j++){
		dp[1][j][0] = 0;
		dp[1][j][1] = 1;
	}
	dp[1][1][0] = 1;
	dp[1][1][1] = 1;
	for(int i=1;i<w;i++){
		for(int j=1;j<h;j++){
			dp[i+1][j+1][0] = (dp[i][j][1] + dp[i][j+1][0])%MOD;
			dp[i+1][j+1][1] = (dp[i][j][0] + dp[i+1][j][1])%MOD;
		}
	}
	printf("%d\n",(dp[w][h][0]+dp[w][h][1])%MOD);
	}
	return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


string ABCD;


void solve(){
	int n[4] = { ABCD[0]-'0', ABCD[1]-'0', ABCD[2]-'0', ABCD[3]-'0' };
	int i;
	for(i = 0;i < 1<<3;i++){
		int express = n[0];
		rep(j, 0, 3){
			if((i>>j)&1) express += n[j+1];
			else express -= n[j+1];
		}
		if(express == 7) break;
	}
	cout << n[0];
	rep(j, 0, 3){
		if((i>>j)&1) cout << '+';
		else cout << '-';
		cout << n[j+1];
	};
	cout << "=7" << endl;
}


signed main(){
	cin >> ABCD;

	solve();

	return 0;
}

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

int main() {
  int R, G, B, N, ans = 0;
  cin >> R >> G >> B >> N;
  for (int i = 0; R * i <= N; i++) {
    for (int j = 0; R * i + G * j <= N; j++) {
      if ((N - R * i - G * j) % B == 0) ans++;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;

struct pos {
	int x, y;
	int c;

	pos() {}
	pos(int x_, int y_, int c_) {
		x = x_; y = y_; c = c_;
	}
};

bool visited[22][22][105][1024];

int main() {
	int x, y;
	while(cin >> x >> y, x || y) {
		vector<string> shop;
		string str;
		int sale[10][3];
		int mx_t = 0;
		for(int i = 0; i < 22*22*105*1024; i++)
			visited[0][0][0][i] = false;
		for(int i = 0; i < x+2; i++)
			str += "#";
		shop.push_back(str);
		cin.ignore();
		for(int i = 0; i < y; i++) {
			string tmp;
			tmp = "#";
			for(int j = 0; j < x; j++) {
				char in;
				cin >> in; cin.ignore();
				tmp += in;
			}
			tmp += "#";
			shop.push_back(tmp);
		}
		shop.push_back(str);

		int n;
		cin >> n;
		for(int i = 0; i < n; i++) {
			int g, d, s, e;
			cin >> g >> d >> s >> e;
			sale[g][0] = s; sale[g][1] = e; sale[g][2] = d;
			mx_t = max(mx_t, e);
		}

		pos P;
		for(int i = 0; i < y; i++) {
			for(int j = 0; j < x; j++) {
				if(shop[i+1][j+1] == 'P') {
					P = pos(j+1, i+1, 0);
					shop[i+1][j+1] = '.';
				}
			}
		}

		/*
		for(int i = 0; i < shop.size(); i++) {
			for(int j = 0; j < shop[i].size(); j++) {
				cout << shop[i][j];
			} cout << endl;
		}
		// */

		const int dxy[] = {0, 1, 0, -1, 0};
		int res = 0;
		queue<pos> q;
		q.push(P);
		for(int t = 0; t <= mx_t; t++) {
			queue<pos> nex;
			while(!q.empty()) {
				pos cur = q.front(); q.pop();
				
				for(int i = 0; i < 4; i++) {
					char ca = shop[cur.y+dxy[i]][cur.x+dxy[i+1]];
					if(ca != '.' && ca != '#' && sale[ca-'0'][0] <= t && t < sale[ca-'0'][1]) {
						cur.c |= 1 << (ca - '0');
					}
				}
				for(int i = 0; i < 4; i++) {
					char ca = shop[cur.y+dxy[i]][cur.x+dxy[i+1]];
					if(ca == '.' && !visited[cur.y+dxy[i]][cur.x+dxy[i+1]][t+1][cur.c]) {
						visited[cur.y+dxy[i]][cur.x+dxy[i+1]][t+1][cur.c] = true;
						nex.push(pos(cur.x + dxy[i+1], cur.y + dxy[i], cur.c));
					}
				}
			}
			if(t == mx_t) {
				while(!nex.empty()) {
					pos cur = nex.front(); nex.pop();
					int tmp = 0;
					for(int i = 0; i < 10; i++) {
						if(cur.c & (1 << i)) {
							tmp += sale[i][2];
						}
					}
					res = max(res, tmp);
				}
			}

			q = nex;
		}

		cout << res << endl;
	}
}

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

int main()
{
  long long int N,A,i;
  cin >> N;
  i=1;
  bool flag = true;
  while((i<=N) && flag)
  {
    cin >> A;
    if ((A % 2 == 0) && ((A % 5 != 0)&&(A % 3 != 0)))
        {
          flag=false;
        }
    i++;
  }
  if (flag)
        {
          cout << "APPROVED" << endl;
        }
        else
        {
          cout << "DENIED" << endl;
        }
      
  return 0;
}

Measured memory_bytes: 256
import heapq
import math

def dist(xyzr0, xyzr1):
    vec = [xyzr0[i] - xyzr1[i] for i in range(3)]
    d = math.sqrt(sum([elem*elem for elem in vec]))
    return max(0, d - xyzr0[3] - xyzr1[3])

def mst(n, dists):
    in_tree = [False] * n
    start = 0
    in_tree[start] = True
    q = [(dists[start][to], start, to) for to in range(n)]
    heapq.heapify(q)
    ans = 0
    cnt = 0
    while q and cnt < n-1:
        dist, fr, to = heapq.heappop(q)
        if in_tree[to]:
            continue
        in_tree[to] = True
        ans += dist
        cnt += 1
        for to_ in range(n):
            heapq.heappush(q, (dists[to][to_], to, to_))
    return ans

def solve(n):
    XYZR = []
    for _ in range(n):
        XYZR.append(list(map(float, input().split())))
    dists = [[0] * n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            dists[i][j] = dist(XYZR[i], XYZR[j])
    ans = mst(n, dists)
    print('%.3f' % ans)


while True:
    n = int(input())
    if n == 0:
        break
    solve(n)



Measured memory_bytes: 6908
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
 
int main(){
    string S; cin>>S;
    int count=0;
    for(int i=0;i<S.size()-1;i++){
        if(S.at(i)!=S.at(i+1))count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#define LL long long int
using namespace std;


int main()
{
    LL n,ans;
    scanf("%lld",&n);
    LL sq=sqrt(n)+0.5;
    for(LL i=sq;i>0;i--)
    {
        if(n%i==0)
        {
           ans=i+n/i-2;
           printf("%lld\n",ans);
           return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
sortl = sorted(l)
count = 0

for a in range(n-2):
    for b in range(a+1, n-1):
        if sortl[a] == sortl[b]:
            continue
        for c in range(b+1, n):
            if sortl[b] == sortl[c]:
                continue
            else:
                if sortl[a] + sortl[b] > sortl[c]:
                    count += 1

            

print(count)

Measured memory_bytes: 8992