akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#include <unordered_set>

#define _USE_MATH_DEFINES
#include <math.h>


#include <vector>
#include <list>

#include <set>
#include <map>

#include <unordered_map>

#include <queue>

#include <string>

#include <vector>

#define sqr(x) (x) * (x)

#include <algorithm>
#include <functional>

#include <bitset>

#include <functional>

#include <chrono>

typedef unsigned int u32;
typedef int i32;

typedef unsigned long long int u64;
typedef long long int i64;

typedef uint16_t u16;
typedef int16_t i16;

typedef uint8_t u8;
typedef int8_t i8;


using namespace std;
using namespace std::chrono;

struct less_key
{
    bool operator() (pair<i64, i64> p1, pair<i64, i64> p2)
    {
        return p1.first < p2.first || (p1.first == p2.first && p1.second < p2.second);
    }
};

struct pair_hash {
public:
    std::size_t operator()(const std::pair<u64, u64> &x) const
    {
        return std::hash<u64>()(x.first) ^ std::hash<u64>()(x.second);
    }
};

const i64 mod = 1000000007ll;
const i64 smod = 999983;

// del

i64 f(i64 a) {
    i64 r = ((a + 1) / 2) % 2;

    i64 d = 2;

    while (a / d) {
        i64 q = (a / d) % 2;
        if (q) {
            i64 z = (a % d + 1) % 2;
            if (z) {
                r |= d;
            }
        }
        d <<= 1;
    }

    return r;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    i64 a, b;

    cin >> a >> b;

    cout << (f(a - 1) ^ f(b));

    return 0;
}

Measured memory_bytes: 256
mine = []
h, w = map(int, input().split())
for i in range(h):
    mine.append(list(input()[:]))
ans = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if mine[i][j] == '#':
            if i != 0:
                ans[i-1][j] += 1
            if j != 0:
                ans[i][j-1] += 1
            if i != h-1:
                ans[i+1][j] += 1
            if j != w-1:
                ans[i][j+1] += 1
            if i != 0 and j != 0:
                ans[i-1][j-1] += 1
            if i != 0 and j != w-1:
                ans[i-1][j+1] += 1
            if i != h-1 and j != 0:
                ans[i+1][j-1] += 1
            if i != h-1 and j != w-1:
                ans[i+1][j+1] += 1

for i in range(h):
    for j in range(w):
        if mine[i][j] == "#":
            print("#", end="")
        else:
            print(ans[i][j], end="")
    print()


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

int a[100009], b[100009], n, maxn = 0;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[a[i] + 3]++;
	}
	for (int i = 3; i <= 100003; i++) {
		maxn = max(maxn, b[i - 1] + b[i] + b[i + 1]);
	}
	cout << maxn << endl;
	return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  vector<int> c(a);
  rep(i,b){
    cin >> c[i];
  }
  int cnt=0;
  rep(i,b){
    cnt +=c[i];
  }
  
  if(cnt>a){
    cout << -1 <<endl;
  }
  else{
    cout << a-cnt <<endl;
  }
}
  

Measured memory_bytes: 7200
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))

def solve(x):
    if(x==1):
        return 1
    else:
        return x*solve(x-1)

def solve2(ls):
    x=ls[0]
    data=sorted(ls)
    return data.index(x)


ans1=0
ans2=0
for i in range(1,n):
    ans1+=solve(n-i)*solve2(p)
    del p[0]

    ans2+=solve(n-i)*solve2(q)
    del q[0]

print(abs(ans1-ans2))


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        br.lines().forEach(s -> {
            List<Integer> list = Arrays.stream(s.split(" "))
                    .map(Integer::parseInt)
                    .collect(Collectors.toList());

            int h = list.get(0);
            int w = list.get(1);

            if (h == 0 && w == 0) {
                return;
            }

            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        });
    }
}

Measured memory_bytes: 36704
n=int(input())
ans=0
a=n//100
b=n//10-(a*10)
c=n%10
if a==1:
    ans+=900
else:
    ans+=100
if b==1:
    ans+=90
else:
    ans+=10
if c==1:
    ans+=9
else:
    ans+=1
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
 
 
main()
{
  int i;
  int kukan[11];
  int kyori[11];
  int v1,v2;
  float cross;
   
  kyori[0]=0;
 
  while(1){
  for(i=1;i<=10;i++)
    {
      if(EOF == scanf("%d,",&kukan[i]))
        goto END;
      else
        kyori[i] = kyori[i-1]+kukan[i];
    }
   scanf("%d,%d",&v1,&v2); 
 
  cross = (float)kyori[10] * (float)v1/((float)v1+(float)v2);
 
   
  for(i=1;i<=10;i++)
    {   
      if((float)kyori[i-1] <  cross && cross <= (float)kyori[i])
        printf("%d\n",i);
    }
  }
    END:
return(0);
}


Measured memory_bytes: 2036
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
YNeos='YNeos'
mo=10**9+7
imp='IMPOSSIBLE'
alp=string.ascii_lowercase
num=enumerate(alp)
d=dict()
for i,j in num:
    d[j]=i

k,x=MI()
a=[i for i in range(x-k+1,x+k)]
print(*a)

Measured memory_bytes: 38512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

typedef long double lld;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-7)
#define INF (1e9 + 1)
#define PI (acos(-1))

int a[10];

int main()
{
	REP(i, 3) cin >> a[i];
	int ans = INF;
	ans = min(ans, a[0] + a[1]);
	ans = min(ans, a[1] + a[2]);
	ans = min(ans, a[0] + a[2]);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    ll n;
    cin(n);

    ll m = 0;
    ll sum = 0;

    rep2(i, n) {
        ll a;
        cin(a);

        if (m > a) { sum += m - a; }
        else m = a;
    }

    print(sum);
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ul unsigned long long
#define ll long long

int main() {
  ul n,q,s[100000],t[50000];
  cin>>n;
  for (size_t i = 0; i < n; i++)
  {
    cin >> s[i];
  }
  cin>>q;
  for (size_t i = 0; i < q; i++)
  {
    cin >> t[i];
  }
  ul id[3],ct=0;
  for (size_t i = 0; i < q; i++)
  {
    id[0]=0;id[1]=n/2;id[2]=n-1;
    if (s[id[0]] == t[i] || s[id[2]] == t[i]) ct++;
    else {
      while (id[0] != id[1])
      {
        if (s[id[1]] == t[i])
        {
          ct++;
          break;
        }
        else if (s[id[1]] > t[i])
          id[2] = id[1];
        else
          id[0] = id[1];
        id[1] = (id[0] + id[2]) / 2;
      }
    }
  }
  cout<<ct<<endl;
  //1

  return 0;
}



Measured memory_bytes: 4256
/*
ID: toooooEasy or RafaelSaddatimov
PROG:
*/
#include <bits/stdc++.h>
#define MAX 100005
#define MAXN 100005
#define MOD 1000000007
#define INF 21000000
#define EPS 1e-5
#define ll long long
#define F first
#define S second
#define all(a) a.begin(), a.end()
#define pb push_back
#define io ios_base::sync_with_stdio(false); cin.tie(0)
using namespace std;


int main() {
    vector<int> arr(3);
    scanf("%d%d%d", &arr[0], &arr[1], &arr[2]);
    int res = INF;
    sort(all(arr));
    do {
        int cur = 0;
        for(int i=1; i<3; ++i)
            cur += abs(arr[i] - arr[i - 1]);
        res = min(res, cur);
    }while(next_permutation(all(arr)));
    printf("%d", res);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

main() {
	long long int a=0,b=0,c=0,n, m, k = 0;
	char str[5];
	scanf("%lld%lld", &a,&b);
	
	printf("%lld", (a + b + 1) / 2);
	
	
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll a, b; cin>>a>>b;
    ll g = __gcd(a, b);

    int ans=0;
    for(ll i=2; i*i<=g; i++){
        if (g%i == 0){
            while(g%i == 0) g/=i;
            ans++;
        }
    }
    if (g!=1) ans++;
    cout << ans+1 << "\n";
	return 0;
}

//g = __gcd(a, b)としてgを素因数分解
//素因数の種類数+1


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
struct UnionFind{
   vector<int> par;
   vector<int> cnt;
   UnionFind(int n):par(n,-1),cnt(n){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       bool ok = (-par[x]>cnt[x]||-par[y]>cnt[y]);
       if(x==y){
           cnt[x]++;
       }
       else if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
           cnt[y]+=cnt[x]+1;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
           cnt[x]+=cnt[y]+1;
       }
       return ok;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};
int main(){
    int n,h,w;
    cin>>n>>h>>w;
    ll a[n],b[n],c[n];
    rep(i,n)cin>>a[i]>>b[i]>>c[i];
    vector<int> ord(n);
    rep(i,n)ord[i]=i;
    sort(ord.begin(),ord.end(),[&](int x,int y){
        return c[x]>c[y];
    });
    ll ans = 0;
    UnionFind uf(h+w);
    for(auto i : ord){
        --a[i];--b[i];
        if(uf.unite(a[i],b[i]+h))ans+=c[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  sort(s.begin(),s.end());
  for(int i=0;i<n;i++){
    cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

struct trump {
	int num;
	char grasp[2];
};

void search(struct trump card[52], int n){
	struct trump origin[52];
	int i,j;
	for (i = 0; i < 52; i++){
		if (i < 13){
			origin[i].grasp[0] = 'S';
			origin[i].num = i + 1;
		}
		else if (i < 26){
			origin[i].grasp[0] = 'H';
			origin[i].num = i - 12;
		}
		else if (i < 39){
			origin[i].grasp[0] = 'C';
			origin[i].num = i - 25;
		}
		else if (i < 52){
			origin[i].grasp[0] = 'D';
			origin[i].num = i - 38;
		}
		else
			break;
	}
	int c;
	for (i = 0; i < 52; i++){
		c = 0;
		for (j = 0; j < n; j++){
			if (origin[i].num == card[j].num&&
				origin[i].grasp[0] == card[j].grasp[0]){
				;
			}
			else{
				c++;
			}
			if (c == n)
				printf("%c %d\n", origin[i].grasp[0], origin[i].num);
			
		}
	}
}

int main(void){
	int n;
	scanf("%d", &n);
	struct trump card[52];
	int i;
	for (i = 0; i < n; i++){
		scanf("%s %d", &card[i].grasp, &card[i].num);
	}
	search(card, n);


	return 0;
}


Measured memory_bytes: 2060
from collections import deque

d = deque(list(input()))
q = int(input())
flag = 1
for i in range(q):
    query = input().split()
    if query[0] == '1':
        flag = - flag
    elif query[0] == '2':
        if flag == 1:
            if query[1] == '1':
                d.appendleft(query[2])
            elif query[1] == '2':
                d.append(query[2])
        else:
            if query[1] == '1':
                d.append(query[2])
            elif query[1] == '2':
                d.appendleft(query[2])
if flag == -1:
    d.reverse()
print(''.join(list(d)))

Measured memory_bytes: 8676
def factorize(N):
  fCount = []
  d = 2
  while d*d <= N:
    if N % d == 0:
      cnt = 0
      while N % d == 0:
        N //= d;
        cnt += 1
      fCount.append(cnt)
    d += 1

  if N > 1: ## N is prime
    fCount.append(1)
    N = 1

  return fCount
## ----------------------
N = int(input())
arr = factorize(N)
arr.sort()  ## 2 2 3 3 3 4

def triangle(k):
  return k * (k+1)//2

smallerTriangle = [0]*45 # 2**45 > 10**12
for i in range(45):
  for j in range(1, 10000):
    if triangle(j) > i:
      smallerTriangle[i] = j-1
      break

ans = 0
for expo in arr:
  ans += smallerTriangle[expo]
print(ans)


Measured memory_bytes: 62848
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

int main() {
  int N; cin >> N;
  ll h[100010]; rep(i,N) cin >> h[i];

  // 初期化
  ll dp[100010];
  rep(i, 100010) dp[i] = INF;
  // 初期条件
  dp[0] = 0;
  // ループ
  for (int i = 1; i < N; ++i) {
      chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
      if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  // 答え
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
// #include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <chrono>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr ll LL2_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = { { typeid(int), "%d" },
{ typeid(ll), "%lld" },
{ typeid(double), "%lf" },
{ typeid(char), "%c" } };

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
// static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	 //INFILE();
	 
	 ll n, m;
	 cin >> n >> m;

	 ll count = n - m;

	 if (n >= m) {
		 cout << 0 << endl;
		 return 0;
	 }

	 vector<ll> v(m);
	 vector<ll> sub(m- 1);
	 scan(v);

	 sort(v.begin(), v.end());
	 for (int i = 0; i < m - 1; i++) {
		 sub[i] = abs(v[i] - v[i + 1]);
	 }
	 sort(sub.begin(), sub.end());

	 ll total = 0;
	 for (int i = 0; i < m - n; i++) {
		 total += sub[i];
	 }

	 cout << total << endl;



	return 0;
}

template <class T> static void scan(vector<T> &v) {
	auto tFormat = scanType[typeid(T)];
	for (T &n : v) {
		scanf(tFormat, &n);
	}
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

	int i = 0, size = static_cast<int>(v.size());
	string s;
	getline(cin, s);

	if (s.size() != 0) {
		i++;
		v[0] = s;
	}

	for (; i < size; ++i) {
		getline(cin, v[i]);
	}
}

//static boost::dynamic_bitset<> scan(char trueValue) {
//	string s;
//	getline(cin, s);
//
//	if (s.size() == 0) {
//		getline(cin, s);
//	}
//
//	for_each(begin(s), end(s),
//		[trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
//	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
//}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

//ここからAtCoder向けdefine
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;

using namespace std;
int x[100001];
int y[100001];
int t[100001];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i, n) cin >> t[i] >> x[i] >> y[i];
    
    int sx = 0;int sy = 0;int st = 0;
    int sat, sax, say;
    int atleast;
    rep(i, n){
        sat = t[i] - st;
        sax = abs(x[i] - sx);
        say = abs(y[i] - sy);
        atleast = sax + say;
        //cerr << atleast << endl;
        if(atleast > sat || (sat - atleast) % 2 != 0){
            no;
            return 0;
        }
        st = t[i];sx = x[i];sy = y[i];
    }
    yes;
    
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define N 400005
#define ll long long
#define P 1000000007
using namespace std;
int n,X,Y,col[N],inv[N],fac[N],ifac[N],ans,sum,vis[N],b[N];
int to[N*2],nxt[N*2],l,fst[N];
struct T
{
	int id,w;
};
bool operator<(T a,T b)
{
	return a.w<b.w;
}
vector<T>a[N];
void link(int x,int y)
{
	to[++l]=y;nxt[l]=fst[x];fst[x]=l;
	to[++l]=x;nxt[l]=fst[y];fst[y]=l;
}
void dfs(int x)
{
	sum++;
	vis[x]=1;b[col[x]]++;
	for (int i=fst[x];i;i=nxt[i])
		if (!vis[to[i]])
			dfs(to[i]);
}
void solve(int x)
{
	vis[x]=2;
	ans=(ll)ans*ifac[b[col[x]]]%P;b[col[x]]=0;
	for (int i=fst[x];i;i=nxt[i])
		if (vis[to[i]]==1)
			solve(to[i]);
}
int main()
{
	scanf("%d%d%d",&n,&X,&Y);
	inv[1]=fac[1]=ifac[1]=fac[0]=ifac[0]=1;
	for (int i=2;i<=n;i++)
	{
		inv[i]=(ll)(P-P/i)*inv[P%i]%P;
		fac[i]=(ll)fac[i-1]*i%P;
		ifac[i]=(ll)ifac[i-1]*inv[i]%P;
	}
	for (int i=1;i<=n;i++)
	{
		int w;
		scanf("%d%d",&col[i],&w);
		a[col[i]].push_back((T){i,w});
	}
	int Mn1=0,Mn2=0;
	for (int i=1;i<=n;i++)
	if (a[i].size())
	{
		sort(a[i].begin(),a[i].end());
		for (int j=1;j<a[i].size();j++)
			if (a[i][j].w+a[i][0].w<=X) link(a[i][j].id,a[i][0].id);
		if (!Mn1||a[Mn1][0].w>a[i][0].w)Mn2=Mn1,Mn1=i;
		else if (!Mn2||a[Mn2][0].w>a[i][0].w)Mn2=i;
	}
	for (int i=1;i<=n;i++)
	if (a[i].size())
	{
		for (int j=0;j<a[i].size();j++)
			if (i!=Mn1)
			{
				if (a[i][j].w+a[Mn1][0].w<=Y) link(a[i][j].id,a[Mn1][0].id);
			}
			else if (Mn2)
			{
				if (a[i][j].w+a[Mn2][0].w<=Y) link(a[i][j].id,a[Mn2][0].id);
			}
	}
	//puts("ok");
	ans=1;
	for (int i=1;i<=n;i++)
		if (!vis[i])
		{
			sum=0;
			dfs(i);
			ans=(ll)ans*fac[sum]%P;
			solve(i);
		}
	printf("%d\n",ans);
}

Measured memory_bytes: 30208
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

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

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


func main() {
   oneInt()
	K := oneInt()
	S := oneStr()

	var temp = strings.ToLower(string(S[K-1]))
	out := []rune(S)
	out[K-1] = rune(temp[0])
	fmt.Println(string(out))
}


Measured memory_bytes: 640
#include<iostream>
#include<string>

std::string str;

int main()
{
	while( std::getline( std::cin, str ) )
	{
		for( int i = 0; i < 26; i++ )
		{
			for( int j = 0; j < str.size(); j++ )
				if( str[j] >= 'a' && str[j] <= 'z' )
					str[j] = str[j] + 1 > 'z' ? 'a' : str[j] + 1;
		
			if( str.find( "the" ) != std::string::npos || str.find( "this" ) != std::string::npos || str.find( "that" ) != std::string::npos )
			{
				std::cout << str << std::endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1172
//#pragma GCC oplmize(2)
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%lld",&x)
#define scs(x) scanf("%s",x+1)
#define pr(x) printf("%lld\n",x)
#define prs(x) printf("%s\n",x)
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
const double pi=acos(-1.0);
const double eps = 1e-8;
ll n,k,ma=-0x3f3f3f3f,ww,cc,ans[5005],s;
struct node{
    ll nex,val;
}a[5005];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    sc(n),sc(k);
    for(int i=1;i<=n;i++) sc(a[i].nex);
    for(int i=1;i<=n;i++) sc(a[i].val);
    for(int i=1;i<=n;i++){
        cc=0;
        ww=a[i].nex;
        memset(ans,0,sizeof(ans));
        while(ww!=i && cc<k){
            cc++;
            ans[cc]=ans[cc-1]+a[ww].val;
            ma=max(ma,ans[cc]);
            ww=a[ww].nex;
        }
        if(cc<k) {
            cc++;
            ans[cc]=ans[cc-1]+a[ww].val;
            ma=max(ma,ans[cc]);
        }
        if(ans[cc]>0 && k>cc){
            s=k/cc*ans[cc];
            ma=max(ma,s);
            for(int i=1;i<=k%cc;i++){
                s+=ans[i]-ans[i-1];
                ma=max(ma,s);
            }
            s=(k/cc-1)*ans[cc];
            for(int i=1;i<=cc;i++){
                s+=ans[i]-ans[i-1];
                ma=max(ma,s);
            }
        }
    }
    pr(ma);
    return 0;
}

Measured memory_bytes: 3960
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, val;
    cin >> n;
    int a = 0, b = 0;
    vector<int> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    sort(arr.begin(), arr.end());
    reverse(arr.begin(), arr.end());
    for(int i = 0; i < n; i++) {
        if (i % 2 == 0)
            a += arr[i];
        else
            b += arr[i];
    }
    // cout << a << " " << b << endl;
    cout << a-b << endl;
    return 0;
}




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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
//------------------------------------------------------

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

    int r;
    cin >> r;
    if (r < 1200) cout << "ABC" << endl;
    else if (r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}

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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int N =nextInt();
		long[] a = nextLongs();
		long[] b = new long[N-1];

		for(int i=1;i<N;i++){
			b[i-1]=a[i]-a[i-1];
		}
		long flg=0;
		long ans=1;
		for(int i=0;i<b.length;i++){
			if(flg==0){
				if(b[i]==0){

				}else if(b[i] < 0){
					flg=-1;
				}else{
					flg=1;
				}
			}else if(flg==1){
				if(b[i] < 0){
					flg=0;
					ans++;
				}
			}else{
				if(b[i] > 0){
					flg=0;
					ans++;
				}
			}
		}
		System.out.println(ans);

	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 50776
#define _USE_MATH_DEFINES
//#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <complex>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;

void solve(ll N, std::vector<ll> A){
  sort(A.begin(),A.end(),greater<ll>());
  priority_queue<ll> que;
  ll result=0;
  que.push(A[0]);
  for(int i=1;i<N;i++){
    result+=que.top();
    que.pop();
    que.push(A[i]);
    que.push(A[i]);
  }
  cout<<result<<endl;
}

int main(){
  ll N;
  scanf("%lld",&N);
  std::vector<ll> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 6940
import java.util.*

fun main(args: Array<String>) = abc159e()

fun abc159e() {
    val (h, w, k) = readLine()!!.split(' ').map { it.toInt() }
    val grid = Array(h) { readLine()!!.toCharArray().map { Character.getNumericValue(it) }.toIntArray() }

    var answer = Int.MAX_VALUE

    bitWholeSearch@ for (bit in 0 until Math.pow(2.0, h.toDouble()).toLong()) {
        val bitSet = BitSet.valueOf(longArrayOf(bit))
        if (bitSet[0]) continue

        var above = 0
        var divCount = 0

        val rows = mutableListOf<List<IntArray>>()

        while (above < h) {
            var below = above
            while (below + 1 < h && !bitSet[below + 1]) below++
            rows.add(grid.slice(above..below))
            above = below + 1
        }

        val whiteOnLeft = IntArray(rows.size)

        for (x in 0 until w) {
            val whiteOnRows = rows.map { row -> row.map { it[x] }.sum() }
            if (whiteOnRows.any { it > k }) continue@bitWholeSearch
            if (whiteOnRows.mapIndexed { index, white -> white + whiteOnLeft[index] }.any { it > k }) {
                divCount++
                for (i in whiteOnLeft.indices) whiteOnLeft[i] = whiteOnRows[i]
            } else {
                for (i in whiteOnLeft.indices) whiteOnLeft[i] += whiteOnRows[i]
            }
        }

        answer = Math.min(answer, bitSet.cardinality() + divCount)
    }

    println(answer)
}


Measured memory_bytes: 128740
# coding: utf-8

def countingSort(A, B, k):
    C = [0 for i in range(k+1)]

    for i in range(n):
        C[A[i]] += 1
    
    for i in range(1,k+1):
        C[i] = C[i] + C[i-1]
    
    for i in range(n-1, -1,-1):
        B[C[A[i]]-1] = A[i]
        C[A[i]] -= 1

n = int(input().rstrip())
A = [int(i) for i in input().rstrip().split()]
B = [0 for i in range(n)]
countingSort(A, B, 10000)
print(" ".join([str(i) for i in B]))


Measured memory_bytes: 243084
n,m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

if a.index{|v| v.odd?}
  p 0
  exit
end

mul = 1
while a.index{|v| v.odd?}.nil?
  a.map!{|v| v/2}
  mul *= 2
end

if a.all?{|v| v.odd?}
  minX = mul / 2
  a.each do |v|
    minX = minX.lcm(v)
    if minX > m
      p 0 
      exit
    end
  end
  ans = (m / minX + 1) / 2
  p ans
else
  p 0
end


Measured memory_bytes: 8588
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def calc(x):
    lim=a*b-1
    mx=(x+1)//2*(x+1-(x+1)//2)
    return mx>lim

Q=INT()
for _ in range(Q):
    a,b=MAP()

    # 例外処理
    if a==b:
        print((a-1)*2)
        continue

    # 二分探索
    low=1
    hi=10**18
    while low+1<hi:
        mid=(hi+low)//2
        if calc(mid):
            hi=mid
        else:
            low=mid
    print(low-1)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdint>
#include<algorithm>
#include<vector>
using namespace std;
#define MAX 100000
int main() {
	int N, a, b;
	int64_t K;
	cin >> N >> K;
	vector<pair<int, int> > add(N);
	for (int i = 0;i < N;i ++) {
		cin >> a >> b;
		add[i] = make_pair(a, b);
	}
  	sort(add.begin(), add.end());
	
	for (int i = 0;i < N;i ++) {
		K -= add[i].second;
		if (K <= 0) {
			cout << add[i].first;
			break;
		}
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define inf1 INT_MAX
#define inf2 LLONG_MAX
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define sbit __builtin_popcount
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define rit(it,x) for(auto it=x.begin();it!=x.end();it++)
#define cases(t) int t; cin>>t; rep(casn,1,t+1)
#define fill(a,b) memset(a,b,sizeof(a))
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define infile ifstream fin; fin.open("input.txt")
#define outfile ofstream fout; fout.open("output.txt")
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<ll,int>
#define pll pair<ll,ll>
#define p_queue priority_queue< plii,vector< plii >,greater< plii > > 
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%lld",&x)
#define sst(x) scanf("%s",x)
#define pl(x) printf("%lld\n",x)
#define pi(x) printf("%d\n",x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mex 200005
ll tree[8*mex],h[mex],arr[mex],aux[mex];

inline void upd(int u,int s,int e,int idx,ll val)
{
    if(s==e){
        tree[u]=val; return;
    }
    int m=(s+e)/2;
    if(idx<=m) upd(2*u+1,s,m,idx,val);
    else upd(2*u+2,m+1,e,idx,val);
    tree[u]=max(tree[2*u+1],tree[2*u+2]);
}

inline ll que(int u,int s,int e,int l,int r)
{
    if(s>r || e<l) return -1;
    if(s>=l && e<=r) return tree[u];
    int m=(s+e)/2;
    return max(que(2*u+1,s,m,l,r),que(2*u+2,m+1,e,l,r));
}

inline ll solve(int n)
{
    fill(tree,-1); 
    repr(i,n-1,0){
        ll temp=que(0,0,n-1,h[i],n-1); //dbg(temp);
        if(temp!=-1) upd(0,0,n-1,h[i],temp+arr[i]),aux[h[i]]=temp+arr[i];
        else upd(0,0,n-1,h[i],arr[i]),aux[h[i]]=arr[i];
    }
    return tree[0];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    rep(i,0,n){
        cin>>h[i];
        h[i]--;
    }
    rep(i,0,n) cin>>arr[i];
    cout<<solve(n)<<endl;
}

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

int main(){
	int N, i;
	cin >> N;
	double A[N];
	for(i=0; i<N; i++){
		cin >> A[i];
	}
	
	double sum=0;
	for(i=0; i<N; i++){
		sum += 1/A[i];
	}
	
	double ans = 1/sum;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<numeric>
using namespace std;
int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	int g = min(a,b);
	int cnt = 0;
	int i;
	for (i = g;; i--) {
		if (a%i == 0 && b%i == 0) {
			cnt++;
			if (cnt == k) {
				break;
			}
		}
	}
	cout << i << endl;
	return 0;
}

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

int main(){
    long x;cin>>x;
    long ans=0;
    if(x%2==0){
        long i=10;
        while(i<=x){
            ans+=(x/i);
            i*=5;
        }
    }
    cout<<ans<<endl;
}

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

const int N = 1e5 + 10;

int n, fa[N];
char s[N];

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	s[0] = '0';
	if(s[1] == '0') { puts("-1"); return 0; }
	for(int i = 1; i <= n; i ++) 
		if(s[i] != s[n - i]) {
			puts("-1"); return 0;
		}
	int sz = 1, p = n; s[n] = '1';
	for(int i = 2; i <= n; i ++) {
		if(s[i] == '1') {
			int o = i - sz - 1, f = p - o - 1;
			for(; p != f; p --) fa[p] = f;
			sz = i;
		}
	}
	for(int i = 1; i <= n; i ++) if(fa[i])
		printf("%d %d\n", i, fa[i]);
	return 0;
}


Measured memory_bytes: 1792
H,W= map(int,input().split())
alpha=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(H):
	A = list(str(_) for _ in input().split())
	for j in range(W):
		if A[j] == "snuke" :
			al = alpha[j]
			high = str(i+1)
			print(al+high)
			break


Measured memory_bytes: 3064
from collections import Counter
from functools import reduce
import bisect
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # Greatest Common Divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # Least Common Multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


a, b ,t = MI()
sum = 0
for i in range(a,t+1,a):
    sum += b
print(sum)


Measured memory_bytes: 5768
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine(), " ", false);
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());		
		br.close();
		int out = 0;
		for (int i = a; i <= b; i++) {
			if (c % i == 0) out++;
		}
		System.out.println(out);
	}
}



Measured memory_bytes: 24436
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 27 16:39:16 2019

@author: yuta
"""

def cakedonut(n):
    count = 0
    if n != 0:
        max_count = (int(n/7) + 1) * (int(n/4) + 1)
        for i in range(int(n/7) + 1):
            for j in range(int(n/4) + 1):
                price = 7 * i + 4 * j
                rest = n - price
                if rest == 0:
                    break
                else:
                    count += 1
        if count < max_count:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
        
N = int(input())
cakedonut(N)

Measured memory_bytes: 3064
program main
   implicit none
   integer i,h,n
   integer,allocatable :: a(:)
   
   read(*,*) h,n
   allocate(a(n))
   read(*,*) (a(i),i=1,n)
   if(sum(a)>=h) then
      write(*,'(a)') 'Yes'
   else
      write(*,'(a)') 'No'
   endif
end program main



Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, W; cin >> N >> W;
	vector<ll> v(N), w(N);
	for (int i = 0; i < N;i++)cin >> v[i] >> w[i];
	vector<ll> dp(W + 1, 0);
	for (int i = 0; i <= W;i++) {
		for (int j = 0; j < N;j++) {
			if (i + w[j] > W)continue;
			dp[i + w[j]] = max(dp[i + w[j]], dp[i] + v[j]);
		}
	}
	cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 3232
#coding: utf-8

while True:
    a, op, b =  (i for i in input().split())
    a = int(a)
    b = int(b)

    if op == '+':
        print(a + b)

    elif op == '-':
        print(a - b)

    elif op == '*':
        print(a * b)

    elif op == '/':
        print(int(a / b))

    else:
        break



Measured memory_bytes: 5608
n = int(input())
a = {}
for i in range(n):
    s = str(input())
    if s in a.keys():
        a[s] = a[s] + 1
    else:
        a[s] = 1
        
m = int(input())
for i in range(m):
    t = str(input())
    if t in a.keys():
        a[t] = a[t] - 1
    else:
        a[t] = -1
if max(a.values()) >= 0:
    print(max(a.values()))
elif max(a.values()) < 0:
    print(0)

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;



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

    //string result = "";

    size_t L = s.length();

    for(int i = 0; i < L; i++){
        if(i%2 == 0){
            //result.push_back(s[i]);
            printf("%c",s[i]);
        }
    }


    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int max(int c[3]){
  int max = c[0];
  int i;
  for(i=1;i<3;i++){
    if(max < c[i]) max = c[i];
    
  }
  return max;
}

int main(void){
  int a, b, c[3], M;
  scanf("%d",&a);
  scanf("%d",&b);
  c[0] = a + b;
  c[1] = a - b;
  c[2] = a * b;
  M = max(c);
  printf("%d\n",M);
  return 0;
}

Measured memory_bytes: 128
#include<string>
#include<iostream>
#include<map>
using namespace std;
const long long p=1000000007;
long long n;
map<long long,long long> f;
long long dp(long long x)
{
	if(f[x]) return f[x];
	else return f[x]=(dp(x/2)%p+dp((x-1)/2)%p+dp((x-2)/2)%p)%p;
}
int main(){
	f[0]=1;
	f[1]=2;
	cin>>n;
	cout<<dp(n);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string arr[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	string s;
	cin >> s;
	int ans;
	for (int i = 0; i < 7; ++i){
		if (arr[i] == s){
			ans = i;
			break;
		}
	}
	cout << 7 - ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string s;
    cin >> s;
    bool a = s[0] == 'A';
    bool b = true;
    bool c = true;
    int cnt = 0;
    rep(i,1,s.length()){
        if(s[i] == 'C'){if(i >= 2 && i <= s.length()-2)cnt++;}
        else if(s[i] < 'a' || s[i] > 'z')c = false;
    }
    b = cnt == 1;
    if(a & b & c)cout << "AC" << endl;
    else         cout << "WA" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int n;
int ans = 0;

int main()
{
    cin >> n;
    queue<ll> q;
    q.push(3); q.push(5); q.push(7);
    int ans = 0;
    while(1){
        ll now = q.front(); q.pop();
        if(now > n) break;
        q.push(10*now + 3); q.push(10*now + 5); q.push(10*now + 7);
        vector<int> a(3,0);
        while(now != 0){
            if(now%10 == 3){
                a[0] = 1;
                now = now/10;
            }else if(now%10 == 5){
                a[1] = 1;
                now = now/10;
            }else if(now%10 == 7){
                a[2] = 1;
                now = now/10;
            }
        }
        if(a[0] == 1 && a[1] == 1 && a[2] == 1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4100
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int a,b; cin>>a>>b;
	if((b%a)==0) cout<<(a+b);
	else cout<<(b-a);
	
	return 0;
}

Measured memory_bytes: 256
"""
    This template is made by Satwik_Tiwari.
    python programmers can use this template :)) .
"""

#===============================================================================================
#importing some useful libraries.
from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]
from itertools import permutations as permutate
from bisect import bisect_left as bl
#If the element is already present in the list,
# the left most position where element has to be inserted is returned.
from bisect import bisect_right as br
from bisect import bisect
#If the element is already present in the list,
# the right most position where element has to be inserted is returned

#===============================================================================================
#some shortcuts

mod = 1000000007
def inp(): return sys.stdin.readline().strip() #for fast input
def out(var): sys.stdout.write(str(var))  #for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
def graph(vertex): return [[] for i in range(0,vertex+1)]
def zerolist(n): return [0]*n
def nextline(): out("\n")  #as stdout.write always print sring.
def testcase(t):
    for p in range(t):
        solve()
def printlist(a) :
    for p in range(0,len(a)):
        out(str(a[p]) + ' ')
def lcm(a,b): return (a*b)//gcd(a,b)


#===============================================================================================
# code here ;))

def solve():
    a,b = sep()
    print(a*b)

testcase(1)


Measured memory_bytes: 72656
#include <stdio.h>
int main(void)
{
    int a,b,c,d;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b)
    {
        d=a;
        a=b;
        b=d;
    }
    if(b>c)
    {
        d=b;
        b=c;
        c=d;
    }
    if(a>b)
    {
        d=a;
        a=b;
        b=d;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


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

using namespace std;

typedef long long int ll;



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

    ll n, z, w;
    cin >> n >> z >> w;
    ll a = 0;
    ll preva;
    for(ll i=0; i < n; i++) {
        preva = a;
        cin >> a;

    }
    if(n == 1) {
        cout << abs(a-w) << endl;
    }
    else {
        cout << max(abs(a-w), abs(preva-a)) << endl;
    }
}


Measured memory_bytes: 256