akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<iostream>
using namespace std;
#define SIZE 262144
class segtree
{
public:
	int seg[SIZE * 2];
	void update(int beg, int end, int node, int lb, int ub, int num)
	{
		if (ub < beg || end < lb)return;
		if (beg <= lb&&ub <= end)
		{
			seg[node] += num;
			return;
		}
		update(beg, end, node * 2, lb, (lb + ub) / 2, num);
		update(beg, end, node * 2 + 1, (lb + ub) / 2 + 1, ub, num);
	}
	int get(int pl, int node, int lb, int ub)
	{
		if (lb == ub)return seg[node];
		if (pl <= (lb + ub) / 2)return seg[node] + get(pl, node * 2, lb, (lb + ub) / 2);
		else return seg[node] + get(pl, node * 2 + 1, (lb + ub) / 2 + 1, ub);
	}
};
segtree tree;
set<int>se[100000];
int to[100000];
int main()
{
	string s;
	cin >> s;
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		if (za <= (s.size() - 1) / 2 && zb >= s.size() / 2)
		{
			if (za < s.size() - 1 - zb)se[za].insert(s.size() - 1 - zb - 1);
			else if (za > s.size() - 1 - zb)se[s.size() - 1 - zb].insert(za - 1);
		}
		else if (za <= (s.size() - 1) / 2)se[za].insert(zb);
		else se[s.size() - 1 - zb].insert(s.size() - 1 - za);
	}
	for (int i = 0; i < s.size(); i++)to[i] = i;
	for (int i = 0; i < s.size() / 2; i++)
	{
		int t = (s[s.size() - 1 - i] + 52 - s[i] - tree.get(i, 1, 0, SIZE - 1) % 26) % 26;
		if (t != 0 && se[to[i]].size() == 0)
		{
			printf("NO\n");
			return 0;
		}
		if (se[to[i]].size() != 0)
		{
			set<int>::iterator it = se[to[i]].begin();
			int x = *it;
			se[to[i]].erase(it);
			tree.update(i, x, 1, 0, SIZE - 1, t);
			int y = to[i], z = to[x + 1];
			if (se[y].size() > se[z].size())
			{
				to[x + 1] = y;
				it = se[z].begin();
				for (;;)
				{
					if (it == se[z].end())break;
					se[y].insert(*it);
					it++;
				}
			}
			else
			{
				to[i] = z;
				it = se[y].begin();
				for (;;)
				{
					if (it == se[y].end())break;
					se[z].insert(*it);
					it++;
				}
			}
		}
	}
	printf("YES\n");
}

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


// 2011/10/23

// 0196 ìåï
public class Main {
	
	
	class Team implements Comparable<Team> {
		String name;
		int win;
		int lose;
		public Team(String name, int win, int lose) {
			this.name = name;
			this.win = win;
			this.lose = lose;
		}
		@Override
		public int compareTo(Team o) {
			if (win != o.win) {
				return -(win - o.win);
			}
			else
				return (lose - o.lose);
		}
		
	}
	

	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		int n = readIntArray()[0];
		if (n == 0)
			return false;
		
		List<Team> list = new ArrayList<Team>();
		for(int i = 0; i < n; i++) {
			String s = reader.readLine();
			String[] sp = s.split(" ");
			
			int win = 0;
			int lose = 0;
			for(int j = 0; j < n - 1; j++) {
				String r = sp[j + 1];
				if (r.equals("0")) {
					win++;
				}
				else if (r.equals("1")) {
					lose++;
				}
			}
			list.add(new Team(sp[0], win, lose));
		}	
		
		Collections.sort(list);
		
		for(Team t: list) {
			System.out.printf("%s\n", t.name);
		}
		
//		System.out.printf("%d\n", sum / size);
		
		return true; // ³íI¹ Ö
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
			String inputStr = "1:15:";

			inputStr = inputStr.replace(":", "\n");

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}
		
		int N = Integer.MAX_VALUE;
		//int N = readIntArray()[0];

		for(int i = 0; i < N; i++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè1sªÌæØè¶æØèÅÌ®lðÇÞ
	// EOFÌêÍnullðÔ·
	private static int[] readIntArray() throws IOException {

		String s = null;
		for(;;) {
			s = reader.readLine();
//			log.printf("%s\n", s);
			if (s == null)
				return null;
			s = s.trim();
			if (s.length() != 0) // ¦¦¦@Ç¤àËRósðÇÞ±Æª éBÇÝòÎ·Æ¤Ü­¢­çµ¢BBBB
				break;
		}
		
		String[] sp = s.split("[ ,]"); // æØè¶ÍXy[X©J}
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

Measured memory_bytes: 12000
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n=inp()
    a=inpl()
    b=inpl()
    dif = sum(b) - sum(a)
    for i in range(n):
        if a[i]<b[i]:
            dif -= (b[i]-a[i])//2 + (b[i]-a[i])%2
    if dif < 0:
        print("No")
    else:
        print("Yes")

if __name__ == "__main__":
    main()

Measured memory_bytes: 42860
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int n,an=0;
    cin>>n;
    long long int a[n];
    long long int max =0;
    for(long long int i =0; i<n;i++){
        cin>>a[i];
        if(max<a[i])
            max = a[i];
    }
    long long int f[max+1];
    long long int b[max+1];
    for(long long int i=0; i<max+1;i++){
        f[i]=0;
        b[i]=-1;
}
    for(long long int i=0;i<n;i++){
        f[a[i]]++;
    }
    for(long long int i=0; i<max+1;i++)
        an = an + (((f[i]*(f[i]-1))/2));

    for(long long int k=0;k<n;k++){
        if(b[a[k]]==-1){
        int y = ((f[a[k]]*(f[a[k]]-1))/2) - (((f[a[k]]-1)*(f[a[k]]-2))/2);
        cout<<an-y<<endl;
        b[a[k]]=an-y;
        continue;
        }else
        cout<<b[a[k]]<<endl;
    }

}


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

public class Main {
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			try{
				String[] strA = insBR.readLine().split(" ");
				int[] intA = new int[strA.length];
				for(int i = 0;i < strA.length ;i++){
					intA[i] = Integer.parseInt(strA[i]);
				}
				int intTest = 0;
				if(intA[0] == -1 || intA[1] ==-1){
					intTest = intA[0] + intA[1] + 1;
				}else{
					intTest = intA[0] + intA[1];
				}
				String strRecord = "";
				if(intA[0] == -1 && intA[1] == -1 && intA[2] == -1){
					break;
				}else if(intA[0] == -1 || intA[1] == -1){
					strRecord = "F";
				}else if(80 <= intTest){
					strRecord = "A";
				}else if(65 <= intTest && intTest < 80){
					strRecord = "B";
				}else if(50 <= intTest && intTest < 65){
					strRecord = "C";
				}else if(30 <= intTest && intTest < 50){
					if(50 <= intA[2]){
						strRecord = "C";
					}else{
						strRecord = "D";
					}
				}else {
					strRecord = "F";
				}
				System.out.println(strRecord);
			}catch(IOException e){
				e.printStackTrace();
			}catch(NumberFormatException e){
				e.printStackTrace();
			}
		}
	}
}



Measured memory_bytes: 24252
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

struct UnionFind {
	vector<int> par;
	vector<int> sz;

	UnionFind(int n = 0) { if (n > 0) initialize(n); }
	void initialize(int n) {
		par.resize(n);
		sz.assign(n, 1);
		for (int i = 0; i < n; i++) {
			par[i] = i;
		}
	}

	int find(int x) {
		if (par[x] == x) {
			return x;
		} else {
			return par[x] = find(par[x]);
		}
	}

	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return false;
		if (sz[x] > sz[y]) swap(x, y);
		par[x] = y;
		sz[y] += sz[x];
		return true;
	}

	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return sz[find(x)]; }
};

int main(void) {
	int N, M, K;
	cin >> N >> M >> K;
	vector<int> A(M), B(M), C(K), D(K);
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
	}
	for (int i = 0; i < K; i++) {
		cin >> C[i] >> D[i];
		C[i]--; D[i]--;
	}

	UnionFind uf(N);
	for (int i = 0; i < M; i++) uf.unite(A[i], B[i]);

	vector<int> ans(N);
	for (int i = 0; i < N; i++) ans[i] = uf.size(i) - 1;
	for (int i = 0; i < M; i++) {
		ans[A[i]]--;
		ans[B[i]]--;
	}
	for (int i = 0; i < K; i++) if (uf.same(C[i], D[i])) {
		ans[C[i]]--;
		ans[D[i]]--;
	}
	for (int i = 0; i < N; i++) cout << ans[i] << " \n"[i == N - 1];
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,K;
int a[2005][2005];
int dx[5],dy[5];
void add(int x1,int y1,int x2,int y2) {
    if(x1 > x2 || y1 > y2) return;
    a[x1][y1]++;a[x2 + 1][y2 + 1]++;
    a[x1][y2 + 1]--;a[x2 + 1][y1]--;
}
void Solve() {
    read(N);read(K);
    int x,y;char c[5];
    for(int i = 1 ; i <= N ; ++i) {
	read(x);read(y);scanf("%s",c + 1);
	++x;++y;
	int tx = x % K,ty = y % K;
	int now = ((x / K) ^ (y / K)) & 1,u;
	if(c[1] == 'W') u = 0;
	else u = 1;
	dx[1] = K - tx,dx[2] = K,dx[3] = tx;
	dy[1] = K - ty,dy[2] = K,dy[3] = ty;
	for(int i = 1 ; i <= 3 ; ++i) dx[i] += dx[i - 1],dy[i] += dy[i - 1];
	for(int h = 1 ; h <= 3 ; ++h) {
	    for(int t = 1 ; t <= 3 ; ++t) {
		int w = (h ^ t ^ now) & 1;
		if(w == u) {
		    add(dx[h - 1] + 1,dy[t - 1] + 1,dx[h],dy[t]);
		}
	    }
	}
    }
    int ans = 0;
    for(int i = 1 ; i <= 2 * K ; ++i) {
	for(int j = 1 ; j <= 2 * K ; ++j) {
	    a[i][j] = a[i][j] + a[i][j - 1] + a[i - 1][j] - a[i - 1][j - 1];
	    ans = max(ans,a[i][j]);
	}
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 15872
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let d,x = Scanf.scanf "%d %d " (fun a b -> a,b) in
  let a_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in

  let tmp = List.map (fun x -> ((d-1)/x)+1) a_lst in
  let ans = List.fold_left (+) 0 tmp in

  Printf.printf "%d\n" @@ ans + x


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N;
    read(N);
    string ans = "";
    switch(N % 10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
        ans = "hon";
        break;
        case 0:
        case 1:
        case 6:
        case 8:
        ans = "pon";
        break;
        case 3:
        ans = "bon";
        break;
    }
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

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

vector<int> v;

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

	for(int i = 0; i < n; i++){
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	//v.push_back(t);

	int ans = 0;
	//exeption
	ans += v[0] - m;

	for(int i = 1; i < n; i++){
		if(v[i] - v[i-1] > 2 * m) ans += (v[i] - v[i-1]) - 2 * m;
	}

	if(t - v[n-1] > m) ans += (t - v[n-1]) - m;

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3136
#include<stdio.h>
 
int gcd(int*, int*);
 
int main(void) {
    int x, y, result;
    scanf("%d%d",&x,&y);
     
    if(x>=y) result = gcd(&x, &y);
    else result = gcd(&y, &x);
     
    printf("%d\n", result);
    return 0;
}
 
int gcd(int *x, int *y) {
    int ret, mod;
     
    if(*y==0) ret= *x;
    else {
        mod = *x % *y;
        ret = gcd(y, &mod);
    }
    return ret;
}

Measured memory_bytes: 1808
A,B,C=map(int,input().split())
K=int(input())
flag=True
for i in range(K):
    if A>=B:
        B*=2
        continue
    if B>=C:
        C*=2
        continue
    if C>B and B>A:
        flag=False
        break
if C>B and B>A:
    flag=False
print('Yes' if flag==False else "No")

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 

const ll large_P = 1e9 + 7;


int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A.at(i);
  
  map<ll, ll> memo;
  rep(i,N) memo[A.at(i)]++;
  
  ll res = 0;
  for(const auto& x : memo){
    res += x.second*(x.second-1)/2;
  }
  
  rep(i, N){
    cout << res - (memo[A.at(i)] - 1);
    cout << endl;
  }
  
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout<<endl<<"answer : "<<x<<endl<<endl;
#define op(x) cout<<x<<endl;
#define maxn 500005
#define lld_max 5000000000000000000
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0,l=0,r=0,mid=0,lo=0,hi=0;string s;bool flag=false;
        cin>>s;
        n = s.length();
        if(s[n-1]=='s')
            s+="es";
        else s+='s';
        cout<<s<<endl;
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 3660
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <cmath>

using namespace std;

const int NR = 110;
const int mov[8][2] = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}};

char s[NR][NR];
int num[NR][NR];


int main()
{
    
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
    	scanf("%s", s[i] + 1);
    for (int i = 1; i <= n; i++) 
    	for (int j = 1; j <= m; j++) {
    		if (s[i][j] == '#') 
    			for (int k = 0; k < 8; k++)
    				num[i + mov[k][0]][j + mov[k][1]]++;
    	}
    for (int i = 1; i <= n; i++) {
    	for (int j = 1; j <= m; j++)
    		if (s[i][j] == '#') printf("#");
    		else printf("%d", num[i][j]);
    	puts("");
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int cand[100];

int main(void) {
    while(true) {
        int i,n,p,wan;
        scanf("%d%d",&n,&p);
        if(!n && !p) break;

        wan = p;
        memset(cand, 0, sizeof(cand));
        for(i=0; cand[i]!=p; i=(i+1)%n) {
            if(wan) cand[i]++, wan--;
            else wan+=cand[i], cand[i]=0;
        }
        printf("%d\n", i); 
    }
    return 0;
}

Measured memory_bytes: 1028
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>

int main(void)
{
	double r;

	scanf("%lf", &r);

	printf("%f %f",r*r*M_PI,2 * r*M_PI);

	return 0;
}

Measured memory_bytes: 1080
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc160/tasks/abc160_e>
 問題文============================================================
 E - Red and Green Apples
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll X,Y,A,B,C; cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A),q(B),r(C);
    for(auto& in:p) cin >> in;
    for(auto& in:q) cin >> in;
    for(auto& in:r) cin >> in;
    
    vector<pll> V;
    for(auto v:p) V.emplace_back(pll(v,0));
    for(auto v:q) V.emplace_back(pll(v,1));
    for(auto v:r) V.emplace_back(pll(v,2));
    
    sort(V.rbegin(),V.rend());
    ll Z = 0;
    for(int i = 0; i < (int)V.size(); i++){
        ll v,id; tie(v,id) = V[i];
        
        if(id == 0){
            if(X){
                res += v;
                X--;
            }
        }else if(id == 1){
            if(Y){
                res += v;
                Y--;
            }
        }else{
            res += v;
            Z++;
        }
        if(X+Y == Z) break;
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 13036
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;
using namespace std;

int main(){
    int N;
    int K;
    cin >> N >> K;
    vector<int> ds(K, 0);
    rep(i, K){
        cin >> ds[i];
    }

    int ans = 0;

    for(int i = N; i < 100000; i ++){
        int tmp = i;
        bool flag = true;
        while(tmp){
            int keta = tmp % 10;
            tmp /= 10;
            rep(j, ds.size()){
                if(ds[j] == keta){
                    flag = false;
                    break;
                }
            }
            if(! flag){
                break;
            }
        }
        if(flag){
            ans = i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

int main() {
  ll N, M;
  cin >> N >> M;

  vector<ll> g1(1000, 0);
  vector<ll> g2(1000, 0);
  ll index = 0;
  for (int i = 1; i <= sqrt(M); i++) {
    if (M % i == 0) {
      g1[index] = i;
      g2[index] = M / i;
      index++;
    }
  }
  ll MIN = M;
  for (int i = 0; i < 1000; i++) {
    if (g1[i] == 0) break;
    if (g1[i] >= N) MIN = min(MIN, g1[i]);
    if (g2[i] >= N) MIN = min(MIN, g2[i]);
  }

  cout << (M / MIN) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=1e5+10;
const uli mod=1e9+7;
int a[mx],b[mx];
uli fxp(uli b,uli x){
  uli a=1;
  for(;x!=0;b=b*b%mod,x>>=1)
    if(x&1ll)a=a*b%mod;  
  return a;
}
int main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",a+i);
  for(int i=0;i<n;i++)scanf("%d",b+i);
  vector<pair<int,int> >idxa,idxb;
  for(int i=0;i<n;){
    int v=a[i];
    idxa.push_back(make_pair(i,v));
    while(i<n && a[i]==v)i++;
  }
  for(int i=n-1;i>=0;){
    int v=b[i];
    idxb.push_back(make_pair(i,v));
    while(i>=0 && b[i]==v)i--;
  }
  if(idxa.back().second==idxb.back().second && idxa.back().first<=idxb.back().first){
    uli ans=1ll;
    vector<pair<int,int> >all;
    for(auto x:idxa)all.push_back(x);
    for(auto x:idxb)all.push_back(x);    
    sort(all.begin(),all.end());
    all.resize(unique(all.begin(),all.end())-all.begin());
    for(int i=1;i<int(all.size());i++){
      int h=min(all[i].second,all[i-1].second);
      int cnt=all[i].first-all[i-1].first-1;
      ans=ans*fxp(h,cnt)%mod;
    }
    printf("%lld\n",ans);
  }
  else puts("0");
  return 0;
}


Measured memory_bytes: 2936
import functools
from math import gcd
N = int(input())
A = list(map(int, input().split()))
MAX = 10 ** 6 + 10

if functools.reduce(gcd, A) != 1:
    print("not coprime")
    exit()

prime_list = [i for i in range(MAX + 1)]
p = 2
while p * p <= MAX:
    if prime_list[p] == p:
        for q in range(2*p, MAX+1, p):
            if prime_list[q] == q:
                prime_list[q] = p
    p += 1

prime = set()
for a in A:
    tmp = set()
    while a > 1:
        tmp.add(prime_list[a])
        a //= prime_list[a]
    for p in tmp:
        if p in prime:
            print("setwise coprime")
            exit()
        prime.add(p)
else:
    print("pairwise coprime")


Measured memory_bytes: 127632
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    string str;
    while(cin >> str) {
        int len = str.length();
        for(int i = 0; i < len - 8; ++i)
            cout << str[i];
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

// header area

int main(){
    int K; cin >> K;
    string S; cin >> S;

    int len = S.length();

    if(len > K) cout << S.substr(0, K) << "..." << endl;
    else cout << S << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int N =100101;
const int K = 3;
string pom[N];
bool pos[N][K][K][K];
char pop[N][K][K][K];
vi prevq[N][K][K][K];

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	vi a(3);
	cin >> n >> a[0] >> a[1] >> a[2];
	REP(i, 3) a[i] = min(a[i], K - 1);
	REP(i, n) {
		cin >> pom[i];
	}
	pos[0][a[0]][a[1]][a[2]] = true;
	REP(i, n) {
		int p1 = pom[i][0] - 'A';
		int p2 = pom[i][1] - 'A';
		// uzupelniam row: i + 1
		REP(a1, K) REP(a2, K) REP(a3, K) {
			if (!pos[i][a1][a2][a3]) {
				continue;
			}
			// printf(" pos[%d][%d][%d][%d] = true\n", i, a1,a2,a3);
			vi q{{a1, a2, a3}};
			if (q[p1] > 0) {
				vi p{{a1, a2, a3}};
				--p[p1];
				p[p2] = min(K - 1, p[p2] + 1);
				pos[i + 1][p[0]][p[1]][p[2]] = true;
				pop[i + 1][p[0]][p[1]][p[2]] = pom[i][1];
				prevq[i+1][p[0]][p[1]][p[2]] = q;
				// debug() << imie(pop[i + 1][p[0]][p[1]][p[2]]);
			}
			if (q[p2] > 0) {
				vi p{{a1, a2, a3}};
				--p[p2];
				p[p1] = min(K - 1, p[p1] + 1);
				pos[i + 1][p[0]][p[1]][p[2]] = true;
				pop[i + 1][p[0]][p[1]][p[2]] = pom[i][0];
				prevq[i+1][p[0]][p[1]][p[2]] = q;
			}
		}
	}
	REP(a1, K) REP(a2, K) REP(a3, K) {
		if (pos[n][a1][a2][a3]) {
			vector<char> res;
			vi q{{a1,a2,a3}};
			FORD(i, n + 1, 1) {
				// printf("jest ok:runda: %d : %d, %d, %d\n", i, a1, a2, a3);
				// assert(pos[i][a1][a2][a3] == true);
				char c = pop[i][q[0]][q[1]][q[2]];
				res.pb(c);
				q = prevq[i][q[0]][q[1]][q[2]];
				// printf(" w rundzie: %d, biore: %c\n", i, c);
			}
			reverse(res.begin(), res.end());
			cout << "Yes\n";
			REP(i, n) {
				cout << res[i] << endl;
			}
			return 0;
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 128528
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
typedef long long ll;
int n, m;

ll myPow(ll a, ll b){
    ll ans = 1, base = a;
    while(b > 0){
        if(b & 1)ans = ans * base % mod;
        base = base * base % mod;
        b >>= 1;
    }
    return ans;
}
ll check(int x){
    ll a = 1, b = 1;
    for(int i=1;i<=x;i++)a = a * i % mod;
    for(int i=1;i<=x;i++)b = b * (n - i + 1) % mod;
    return b * myPow(a, mod - 2) % mod;
}
int main()
{
    int a, b;
    scanf("%d", &n);
    scanf("%d%d", &a, &b);
    ll ans = myPow(2, n);
    ll x = check(a);
    ll y = check(b);
    ans = (ans + mod + mod + mod - x - y - 1) % mod;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
               
using namespace std;
               
int len;       
long ans = 0;
string S;   
               
void dfs(int i, int j, long sum)
{              
  if(i == len - 1){ 
    sum += stol(S.substr(j, i + 1 - j));
    ans += sum;
    return; 
  }            
  else{        
    dfs(i + 1, j, sum);
               
    sum += stol(S.substr(j, i + 1 - j));
    dfs(i + 1, i + 1, sum);
  }            
  return;   
}              
               
int main()  
{              
  cin >> S;  
  len = S.size();
  dfs(0, 0, 0);
  cout << ans << endl;
  return 0;  
}              


Measured memory_bytes: 384
#include <stdio.h>


int main(void) {
	int n, q;
	int v, c = 0;
	int S[10000];
	int i;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; ++i) {
		scanf("%d", &v);
		S[i] = v;
	}
	
	scanf("%d", &q);
	
	++q;
	while (--q) {
		scanf("%d", &v);
		for (i = 0; i < n; ++i) {
			if (S[i] == v) {
				++c;
				break;
			}
		}
	}
	
	printf("%d\n", c);
	
	return 0;	
}

Measured memory_bytes: 636
class Accumulate2D:
    def __init__(self, a):
        self.height = len(a)
        self.width = len(a[0])
        self.acc = self.accumulate(a)

    def accumulate(self,a):
        b = [[0]*(self.width+1) for i in range(self.height+1)]
        b[1][1] = a[0][0]
        for i in range(self.height):
            for j in range(self.width):
                b[i+1][j+1] = b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j]
        return b

    def sum(self, p, q):
        y1,x1 = p
        y2,x2 = q
        b = self.acc
        if y1>y2 or x1>x2:
            return 0
        else:
            return b[y2+1][x2+1]-b[y2+1][x1]-b[y1][x2+1]+b[y1][x1]


n,k = map(int, input().split())

kk = k*2

z = [[0]*kk for i in range(kk)]

for i in range(n):
    x,y,c = input().split()
    x = int(x) % kk
    y = int(y) % kk
    if c=='W':
        x = (x+k)%kk
    z[x][y]+=1

z = Accumulate2D(z)

ans = 0
for i in range(k):
    for j in range(k):
        a = z.sum([0,0],[i-1,j-1])\
            + z.sum([i,j],[i+k-1,j+k-1])\
            + z.sum([0,j+k],[i-1,kk-1])\
            + z.sum([i+k,0],[kk-1,j-1])\
            + z.sum([i+k,j+k],[kk-1,kk-1])
        ans = max(ans,a,n-a)

print(ans)



Measured memory_bytes: 112732
const bool TEST=1;
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
#include<sstream>
#include<stack>
const int inf=0x7fffffff;
#define IF if(TEST)
#define FI if(!TEST)
#define gts(s) fgets((s),sizeof(s),stdin)
#define ALL(s) (s).begin(),(s).end()
#define MK(a,b) make_pair((a),(b))
typedef long long int LL;
typedef unsigned int U;
typedef unsigned long long ULL;
using namespace std;
typedef pair<int,int> Point;
template <typename T>
void pA(T *begin,int n){ for(int i=0;i<n;i++){ cout<<*(begin++); } printf("\n"); }
const int N= 2e5+1e5;
char s[N];
void sol(){
	scanf("%s", s);
	int len = strlen(s);
	int _max=0;
	int _min = len-1 ;
	for(int i= 0;i<len;i++){
		switch(s[i]){
			case 'A':_min=min(_min,i);
							 break;
			case 'Z':_max=max(_max,i);
							 break;
			default:break;
		}
	}
	cout<<_max-_min+1<<endl;
}
int main()
{
	sol();
	return 0;
}
//B.cc
//generated automatically at Sat Jan 28 20:10:52 2017
//by xsthunder


Measured memory_bytes: 384
#define print(x) printf("%d\n",x)

#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int c[5][5][5];
int cnt[5][5][5];

int main(){
  int casen = 1;
  while(const int n = getInt()){
    REP(i,5) REP(j,5){
      char buff[10];
      scanf("%s", buff);
      REP(k,5)
        c[i][j][k] = buff[k] - '0';
    }

    vector<int> a;
    vector<int> b;

    const int ma = getInt();
    REP(i,ma) a.push_back(getInt());
    const int mb = getInt();
    REP(i,mb) b.push_back(getInt());

    REP(cc,n){
      REP(i,5) REP(j,5) REP(k,5) cnt[i][j][k] = 0;

      REP(i,5) REP(j,5) REP(k,5) if(c[i][j][k]){
        REP(ii,3) REP(jj,3) REP(kk,3){
          if(ii == 1 && jj == 1 && kk == 1)
            continue;

          const int iii = i + ii - 1;
          const int jjj = j + jj - 1;
          const int kkk = k + kk - 1;

          if(IN(iii, 0, 5) &&
             IN(jjj, 0, 5) &&
             IN(kkk, 0, 5))
            cnt[iii][jjj][kkk]++;
        }
      }

      /*
      printf("Day %d\n", cc + 1);
      REP(i,5){
        REP(j,5){
          REP(k,5){
            printf("%2d ", cnt[i][j][k]);
          }
          puts("");
        }
        puts("");
      }
      */

      REP(i,5) REP(j,5) REP(k,5){
        if(c[i][j][k] == 0){
          REP(m,ma){
            if(cnt[i][j][k] == a[m])
              c[i][j][k] = 1;
          }
        }else{
          c[i][j][k] = 0;
          REP(m,mb){
            if(cnt[i][j][k] == b[m])
              c[i][j][k] = 1;
          }
        }
      }
    }

    if(casen != 1) puts("");
    printf("Case %d:\n", casen++);
    REP(i,5){
      REP(j,5){
        REP(k,5){
          printf("%d", c[i][j][k]);
        }
        puts("");
      }
      if(i != 4) puts("");
    }
  }

  return 0;
}

Measured memory_bytes: 1072
/*input
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
*/
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let mut lines = stdin.lock().lines().map(|l| l.unwrap());
    let n = lines.next().unwrap().parse().unwrap();
    let m = lines.take(n).map(|i| i.parse::<u32>().unwrap());
    println!(
        "{}",
        m.filter(|&i| if i == 2 {
            true
        } else if i % 2 == 0 {
            false
        } else {
            for j in 3..(i as f64).sqrt().floor() as u32 + 1 {
                if i % j == 0 {
                    return false;
                }
            }
            true
        })
        .count()
    );
}



Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>
using namespace std;
#define INF ( 1 << 30 )
int N,mas[16][17],dp[1<<17];

int rec(int bit){
  if(dp[bit]) return dp[bit];
  if(!bit) return 0;

  int ret = INF;
  for(int i = 0 ; i < N ; i++ ){
    if(!(bit & (1 << i))) continue;
    int min_cost = mas[i][0];
    for(int j = 0 ; j < N ; j++ ){
      if(i != j && !(bit & (1 << j))) min_cost = min( min_cost, mas[i][j+1]);
    }
    ret = min( ret, min_cost + rec(bit&~(1 << i)));
  }
  return dp[bit] = ret;
}

int main(){
  while(cin >> N , N ){
    fill_n( dp, 1<<17, 0);
    for(int i = 0 ; i < N ; i++ ){
      for(int j = 0 ; j <= N ; j++ ){
        cin >> mas[i][j];
      }
    }
    cout << rec((1 << N)-1) << endl;
  }
}

Measured memory_bytes: 1672
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let HP = xs[0];
   let attack = xs[1];
   let count = 1;
   
   while(HP>attack){
       count++;
       HP = HP-attack;
   }
   console.log(count);

}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

signed main() {
	ios::sync_with_stdio(false);
	int w, h, n, i, j,k;
	cin >> w >> h >> n;
	vvi  rect(h, vector<int>(w, 0));
	rep(i, n) {
		int x, y, a;
		cin >> x >> y >> a;
		int xc, yc;
		rep(yc, h) {
			rep(xc, w) {
				switch (a)
				{
				case 1:
					if (xc < x)
						rect[yc][xc] = 1;
					break;
				case 2:
					//debug(xc);
					if (xc >= x) {
						rect[yc][xc] = 1;
					}
					break;
				case 3:
					if(yc >= h - y)
						rect[yc][xc] = 1;
					break;
				case 4:
					if(yc < h - y )
						rect[yc][xc] = 1;
					break;
				}
			}
		}
	}
	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			if (rect[i][j] == 0)
				ans++;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
ll sum;
ll A[500], K;
ll B[500];
ll ans;

int main() {
    cin >> n >> K;
    rep(i,n) cin >> A[i];
    rep(i,n) sum += A[i];
    for (ll i = 1; i*i <= sum; i++) {
        if (sum%i != 0) continue;
        ll j = sum / i;
        ll hoge[2] = {i,j};
        for (ll x: hoge) {
            rep(j,n) B[j] = A[j]%x;
            sort(B, B+n);
            int en = n-1;
            ll cnt = K;
            rep(j,n) {
                cnt -= B[j];
                ll b = B[j];
                while (B[en]+b >= x) {
                    b -= (x-B[en]);
                    B[en] = 0;
                    en--;
                }
                (B[en] += b) %= x;
            }
            if (cnt >= 0) ans = max(ans,x);
        }
    }
    cout << ans << endl;
}

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

long long a[100007];

int main(){
	int n;
	long long sum = 0,ans1 = 0,ans2 = 0;
	
	cin >> n;
	for(int i = 0; i < n;i++){
		cin >> a[i];
	}
	int sign = 1;
	int signt;
	for(int i = 0;i < n;i++){
		sum+=a[i];
		//cout << sum << endl;
		if(sum > 0) signt = 1;
		else if(sum < 0) signt = 0;
		else{
			if(sign) signt = 1;
			else signt = 0;
		}
		if(sign==signt){
			ans1+=(abs(sum)+1);
			if(sum < 0) sum = 1;
			else if(sum > 0) sum = -1;
			else{
				if(sign) sum = -1;
				else sum = 1;
			}
		}
		if(sign) sign = 0;
		else sign = 1;
	}
	sign = sum = 0;
	for(int i = 0;i < n;i++){
		sum+=a[i];
		if(sum > 0) signt = 1;
		else if(sum < 0) signt = 0;
		else{
			if(sign) signt = 1;
			else signt = 0;
		}
		if(sign==signt){
			ans2+=(abs(sum)+1);
			if(sum < 0) sum = 1;
			else if(sum > 0) sum = -1;
			else{
				if(sign) sum = -1;
				else sum = 1;
			}
		}
		if(sign) sign = 0;
		else sign = 1;
	}
	cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
using namespace std;
int main()
{
	fast;
	ll n;
	cin>>n;
	ll ar[n],br[n];
	rep(i,0,n)
	{
		cin>>ar[i];
	}
	br[n-1]=0;
	ll c=0;
	ll maxi=ar[n-1];
	nrep(i,n-2,0)
	{
		if(maxi<=ar[i])
		{
			c++;
		}
		else
		{
			c=0;
		}
		br[i]=c;
		maxi=ar[i];
	}
	ll ans=*max_element(br,br+n);
	cout<<ans;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int main()
{
    int h, n;

    cin >> h >> n;

    int zbir = 0;

    for(int i = 0; i < n; i++)
    {
        int broj;
        cin >> broj;
        zbir += broj;
    }

    cout << ((zbir >= h) ? ("Yes") : ("No")) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
void push(long int x[],long int i,long int k){//最小が根になる x: 配列，i:push後のデータ数，k: pushするデータ
  x[i]=k;
  for(int j=i;j>1;j/=2)if(x[j]<x[j/2])x[j]^=x[j/2]^=x[j]^=x[j/2];
}
long int pop(long int x[],long int i){//最初値を取り出す x: 配列，i:pop前のデータ数
  int j=1,k;
  x[0]=x[1];x[1]=x[i];
  while(j*2<i&&(x[j*2]<x[j]||x[j*2+1]<x[j])){
    k=x[j*2]<x[j*2+1]?j*2:j*2+1;
    x[j]^=x[k]^=x[j]^=x[k];
    j=k;
  }
  return x[0];
}
int main(){
  long int a[300000],x[100002],y[100002],k[100001],l[100001];
  long int i,n,j;
  scanf("%ld",&n);
  for(i=0;i<n*3;i++)scanf("%ld",&a[i]);
  k[0]=0;
  for(i=0;i<n;i++){push(x,i+1,a[i]);k[0]+=a[i];}
  for(i=0;i<n;i++){push(x,n+1,a[n+i]);k[i+1]=k[i]+a[n+i]-pop(x,n+1);}
  l[n]=0;
  for(i=0;i<n;i++){push(y,i+1,-a[n*3-i-1]);l[n]-=a[n*3-i-1];}
  for(i=0;i<n;i++){push(y,n+1,-a[n*2-i-1]);l[n-i-1]=l[n-i]-a[n*2-i-1]-pop(y,n+1);}
  j=k[0]+l[0];
  for(i=0;i<n;i++)j=j<k[i+1]+l[i+1]?k[i+1]+l[i+1]:j;
  printf("%ld",j);
}


Measured memory_bytes: 5632
#include<stdio.h>
int main(void){
	int a,b;
	int d,r;
	double f;
	scanf("%d %d",&a,&b);
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%d %d %.5f\n",d,r,f);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),n.end()
#define PI acos(-1)
using namespace std;
int main(){

  int a[2]={0};
  rep(i,2){
    rep(j,4){
      int tmp;
      cin>>tmp;
      a[i]+=tmp;
    }
  }
  if(a[0]==a[1])cout<<a[0]<<endl;
  else cout<<max(a[0],a[1])<<endl;



}

Measured memory_bytes: 1160
from __future__ import print_function
import sys


if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    if y % 2 == 0 and 2*x <= y <= 4*x:
        print("Yes")
    else:
        print("No")




x, y = RA()
solve()


Measured memory_bytes: 64944
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
const double PI=3.14159265358979323846;


int main(){
  int H,W,N,ans;
  cin>>H>>W>>N;
  if(N%max(H,W)==0)ans = N/max(H,W);
  else ans = N/max(H,W)+1;

  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

	void run() {

		Node a = new Node("A");
		Node x = new Node("X");
		Node y = new Node("Y");
		Node z = new Node("Z");
		Node w = new Node("W");
		Node b = new Node("B");
		Node desert = new Node("D");
		a.zero = x;
		a.one = y;
		x.zero = desert;
		x.one = z;
		z.one = b;
		z.zero = w;
		w.zero = b;
		w.one = y;
		y.zero = x;
		y.one = desert;
		b.one = x;
		b.zero = y;
		for (;;) {

			String r = sc.next();

			if (r.equals("#"))
				break;
			Node now = a;
			for (int i = 0; i < r.length(); i++) {
				if (r.charAt(i) == '0') {
					now = now.zero;
				} else {
					now = now.one;
				}
				if (now.city.equals("D")) {
					break;
				}
			}
			if (now.city.equals("B")) {
				System.out.println("Yes");
				continue;
			}
			System.out.println("No");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

class Node {
	public String city = "";
	public Node zero;
	public Node one;

	public Node(String c) {
		city = c;
	}
}

Measured memory_bytes: 17168
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>


int max(int a, int b){
    if(a > b){
        return a;
    }else{
        return b;
    }
}

int main(){
    int n;
    scanf("%d", &n);
    int i;
    int sn, temp = n;
    while(temp>0){
        sn += temp%10;
        temp = temp/10;
    }

    // printf("%d\n", sn);
    
    if(n%sn == 0){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <queue>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    long N, M;
    cin >> N >> M;
    pair<int, long> AB[N];
    for(int i = 0; i < N; i++){
        cin >> AB[i].first >> AB[i].second;
    }
    sort(AB, AB + N);
    long ans = 0;
    for(int i = 0; i < N; i++){
        ans += min(M, AB[i].second) * AB[i].first;
        M -= min(M, AB[i].second);
    }
    cout << ans << endl;
}


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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    if(a==2||b==2)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
    #include<string>
    #include<vector>
    #include<math.h>
    #include<cmath>
    #include<stack>
    #include <algorithm>
    #include <functional>
    //#include<stdlib.h>
    using namespace std;
     
    int main()
    {
    	short i[5]; int l;
    	for (int k = 0; k < 5; k++)
    	{
    		cin >> i[k];
    	}
    	cin >> l;
    	if (i[4] - i[0] <= l) { cout << "Yay!"; }
    	else { cout << ":("; }
    	return 0;
    }

Measured memory_bytes: 256