akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
  int H, N; cin >> H >> N;
  vector<int> A(N), B(N);
  for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
  vector<vector<int> > dp(N + 1, vector<int> (H + 1, INF));
  for(int i = 0; i <= N; i++) dp[i][0] = 0;
  for(int j = 1; j <= H; j++){
    dp[0][j] = ((j - 1)/A[0] + 1) * B[0];
  }

  for(int i = 1; i < N; i++){
    for(int j = 1; j <= H; j++){
      if(j <= A[i]) dp[i][j] = min(dp[i - 1][j], B[i]);
      else{
        dp[i][j] = min(dp[i - 1][j], dp[i][j - A[i]] + B[i]);
      }
    }
  }
  cout << dp[N - 1][H] << endl;
}

Measured memory_bytes: 39424
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int K_MAX = 100002;

int k;

ll a[K_MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> k;
    for(int i = 1; i <= k; i++)
        cin >> a[i];
    a[0] = 1;
    ll mi = 2;
    for(int i = k; i >= 1; i--)
    {
        mi = (mi + a[i] - 1) / a[i];
        mi *= a[i];
        mi = (mi + a[i - 1] - 1) / a[i - 1] * a[i - 1];
    }
    ll mx = 2;
    for(int i = k; i >= 1; i--)
    {
        mx = (mx + a[i] - 1) / a[i];
        mx = mx * a[i] + a[i] - 1;
        mx = mx / a[i - 1] * a[i - 1];
    }
    ll val = mi;
    for(int i = 1; i <= k; i++)
        val = val / a[i] * a[i];
    if(val != 2)
        cout << "-1\n";
    else
        cout << mi << " " << mx << "\n";
    return 0;
}


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

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

#define pb push_back
#define mp make_pair
#define fora(i, a, n) for(int i = a; i < n; i++)
#define forb(i, a, n) for (int i = a; i >= (n); --i)
#define PI 3.1415926535897932384626433832795
#define INF 1e9

int main(){ 
ios::sync_with_stdio(false);
cin.tie(NULL);
//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

int k; cin >> k;
k--;
queue < ll > q;
fora(i, 1, 10) q.emplace(i);
while(k--){
    ll a = q.front();
    q.pop();
    if(a%10 != 0) q.emplace(10*a + a%10 - 1);
    q.emplace(10*a + a%10);
    if(a%10 != 9) q.emplace(10*a + a%10 + 1);

}
cout<< q.front(); 

}

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

const long long INFLL = 0x3f3f3f3f3f3f3f3fLL;

long long D[101010];

vector<pair<int, int> > conn[101010];

void dfs(int a, int d)
{
  if(D[a] == INFLL)
  {
    D[a] = d;
    for(auto x: conn[a])
    {
      int u, v; tie(u, v) = x;
      dfs(u, d+v);
    }
  }
  if(D[a] != d) { puts("No"); exit(0);}
}


int N, M;
int main()
{
  scanf("%d%d", &N, &M);  
  for(int i=0; i<M; ++i)
  {
    int l, r, d; scanf("%d%d%d", &l, &r, &d);
    conn[l].emplace_back(r, d);
    conn[r].emplace_back(l, -d);
  }
  memset(D, 0x3f, sizeof D);
  for(int i=1; i<=N; ++i)
  {
    if(D[i] == INFLL) dfs(i, 0);
  }
  puts("Yes");
}

Measured memory_bytes: 12416
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))


A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ABC = []

for i, a in enumerate(A):
    for j, b in enumerate(B):
        if (i + 1) * (j + 1) > K:
            break
        for k, c in enumerate(C):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            ABC.append(a + b + c)

ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])

Measured memory_bytes: 8732
import static java.util.Arrays.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	void solve() {
		int hh = sc.nextInt();
		int mm = sc.nextInt();
		int ss = sc.nextInt();
		if (hh < 0) return;
		int x = hh * 3600 + mm * 60 + ss;
		int r = 3600 * 2 - x;
		System.out.printf("%02d:%02d:%02d\n", r / 3600, r / 60 % 60, r % 60);
		r *= 3;
		System.out.printf("%02d:%02d:%02d\n", r / 3600, r / 60 % 60, r % 60);
	}

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

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  cin >> n;
  int c[n][3], p[n] = {};
  rep(i, 0, n) {
    rep(j, 0, 3) {
      cin >> c[i][j];
    }
  }

  rep(i, 0, 3) {
    map<int, int> mp;
    rep(j, 0, n) {
      mp[c[j][i]]++;
    }
    rep(j, 0, n) {
      if(mp[c[j][i]] == 1) p[j] += c[j][i];
    }
  }
  rep(i, 0, n) {
    cout << p[i] << endl;
  }
}

Measured memory_bytes: 3140
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N,X[100010],Y[100010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N;
	int x,y;
	rep(i,N){
		cin>>x>>y;
		X[i]=x-y;
		Y[i]=x+y;
	}
	int loX=*min_element(X,X+N);
	int hiX=*max_element(X,X+N);
	int loY=*min_element(Y,Y+N);
	int hiY=*max_element(Y,Y+N);
	int lo=0,hi=400001;
	while(lo+1<hi){
		int mi=(lo+hi)/2;
		int ok1=1,ok2=1;
		rep(i,N){
			if(X[i]<=loX+mi && Y[i]<=loY+mi
			|| X[i]>=hiX-mi && Y[i]>=hiY-mi){
			}
			else{
				ok1=0;break;
			}
		}
		rep(i,N){
			if(X[i]<=loX+mi && Y[i]>=hiY-mi
			|| X[i]>=hiX-mi && Y[i]<=loY+mi){
			}
			else{
				ok2=0;break;
			}
		}
		if(ok1 || ok2)hi=mi;
		else lo=mi;
	}
	cout<<hi<<endl;
}

Measured memory_bytes: 1976
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
int main() {
	// 入力
	ll A,B,C;cin>>A>>B>>C;
    
	// 解法
    ll ans = B+C - A;
    if (ans<0) ans = 0;
	//出力
	cout << ans << endl;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> b(n - 1);
  rep(i, n - 1) cin >> b[i];

  vector<int> a;
  a.eb(b[0]);
  REP(i, 1, b.size()) { a.eb(min(b[i - 1], b[i])); }
  a.eb(b.back());

  int ans = 0;
  rep(i, a.size()) ans += a[i];

  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    print(1.0/sum(map(lambda x:1.0/x, A)))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
using ll = long long;
int main(void){
    int k,n;
    cin>>k>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    int m=0;
    for(int i = 0;i<n-1;i++){
        m=max(m,a[i+1]-a[i]);
    }
    m=max(m,k-a[n-1]+a[0]);
    cout<<k-m<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<string>
#include<cctype>

int main()
{
	std::string str;
	std::map<std::string,int> frequency;
	std::string longest,frequent;
	int freq=0;
	int len=0;
	
	std::getline(std::cin,str);
	
	str+=' ';
	
	int begin=0;
	bool inword=false;
	for(int i=0;i<str.size();i++)
	{
		std::string word;
		if(!inword&&isalpha(str[i]))
		{
			inword=true;
			begin=i;
		}
		else if(!isalpha(str[i]))
		{
			inword=false;
			word=str.substr(begin,i-begin);
			if(word.size()>len)
			{
				len=word.size();
				longest=word;
			}
			if(frequency.find(word)==frequency.end())
			{
				frequency.insert(std::pair<std::string,int>(word,0));
			}
			if(++frequency[word]>freq)
			{
				freq=frequency[word];
				frequent=word;
			}
		}
	}
	std::cout<<frequent<<' '<<longest<<std::endl;
	return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<climits>
using namespace std;

int N, Q;
string s;
vector<char> t, d;

const int downL = 0;
const int downR = INT_MAX;

int calc(int index)
{
	for (int i = 0; i < Q; i++) {
		if (s[index] != t[i])
			continue;

		if (d[i] == 'L')
			index--;
		else
			index++;

		if (index < 0)
			return downL;
		else if (index >= N)
			return downR;
	}

	return index + 1;
}

int main(void)
{
	cin >> N >> Q;
	
	cin >> s;

	t = vector<char>(Q);
	d = vector<char>(Q);
	for (int i = 0; i < Q; i++)
		cin >> t[i] >> d[i];

	int vL = calc(0);
	int vR = calc(N - 1);
	if (vL > N || vR < 1) {
		cout << 0 << endl;
		
		return 0;
	}

	int left = 0;
	if (vL == downL) {
		int l = 0;
		int r = N - 1;
		// left
		while (r - l > 1) {
			int mid = (l + r) / 2;
			int v = calc(mid);
			if (v == downL)
				l = mid;
			else
				r = mid;
		}

		left = r;
	}
	
	int right = N - 1;
	if (vR == downR) {
		int l = 0;
		int r = N - 1;
		// right
		while (r - l > 1) {
			int mid = (l + r) / 2;
			int v = calc(mid);
			if (v == downR)
				r = mid;
			else
				l = mid;
		}

		right = l;
	}

	cout << right - left + 1 << endl;

	return 0;
}


Measured memory_bytes: 900
my $N = <STDIN>;
my $tmin = 10000;
my $D = &GetDigit($N);
foreach my $A (1..$N-1) {
        my $B = $N - $A;
        my $t = 0;
        foreach my $n (split(//,$A)){
                $t += $n;
        }
        foreach my $n (split(//,$B)){
                $t += $n;
        }
        if ($t < $tmin) {
                $tmin = $t;
        }
}
print $tmin;

sub GetDigit($){
        my $num = shift;
        my $digit = 0;
        while($num != 0){
                $num = int($num/10);
                $digit++;
        }
        return $digit;
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;
const double Pi = 3.14159265358979323146;

int main(){
  double r; cin >> r;
  printf("%.10f\n", 2*r*Pi);
  return 0;
}


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

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; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    set<char> m;
    string s; cin>>s;
    for(auto c:s)m.insert(c);
    for(char i = 'a'; i <= 'z'; i++){
        if(!m.count(i)){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
}

Measured memory_bytes: 3708
import sys
input = sys.stdin.readline

s = input().split() 
s = list(s[0])
s = list(map(int,s))

K = int(input())
cnt=0
for i in range(len(s)):
    if s[i]==1:
        cnt+=1
        if cnt==K:
            print(1)
            break
    else:
        print(s[i])
        break

Measured memory_bytes: 3064
c=[[int(i) for i in input().split()]for j in range(3)]
for i in range(2):
    if not c[i+1][0]-c[i][0]==c[i+1][1]-c[i][1]==c[i+1][2]-c[i][2]:
        print('No')
        exit()
for i in range(2):
    if not c[0][i+1]-c[0][i]==c[1][i+1]-c[1][i]==c[2][i+1]-c[2][i]:
        print('No')   
        exit()
print('Yes')

Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;

void min_u(int&m, int v)
{
	if(m>v) m=v;
}

int main(void)
{
	int n, x, y;

	while(scanf("%d%d%d", &n, &x, &y)==3)
	{
		vi ans(n);

		for(int s=1;s<=n;s++)
		{
			vi d(n+1);
			for(int g=1;g<=n;g++) d[g]=abs(g-s);

			for(int g=1;g<=n;g++) min_u(d[g], d[y]+1+abs(g-x));
			for(int g=1;g<=n;g++) min_u(d[g], d[x]+1+abs(g-y));

			for(int g=1;g<=n;g++) ans[d[g]]++;

//for(int md:d) printf("%d ", md); printf("\n");
		}
//		printf("---\n");
		for(int i=1;i<n;i++) printf("%d\n", ans[i]/2);
	}
	return 0;
}


Measured memory_bytes: 256
for i in [1]*input():
	c,a,n=map(int,raw_input().split())
	s=0
	while c>0 and a>0 and n>0:
		s,c,a,n=s+1,c-1,a-1,n-1
	while c>0 and a>0:
		s,c,a=s+1,c-2,a-1
	print s+c/3

Measured memory_bytes: 4220
class RMQ:
    def __init__(self, length, ini_num = float("inf")):
        self.length = 1
        self.ini_num = ini_num
        while self.length < length:
            self.length <<= 1
        self.segtree = [ini_num] * (2 * self.length - 1)

    def update(self, index, n):
        leaf_index = index + self.length - 1
        self.segtree[leaf_index] = n
        while leaf_index > 0:
            leaf_index = (leaf_index - 1) // 2
            self.segtree[leaf_index] = min(self.segtree[leaf_index * 2 + 1], self.segtree[leaf_index * 2 + 2])

    def find(self, a, b, index, l, r):
        if a <= l <= r <= b:
            return self.segtree[index]
        elif b < l or r < a:
            return self.ini_num
        else:
            return min(self.find(a, b, index * 2 + 1, l, (l + r) // 2), self.find(a, b, index * 2 + 2, (l + r) // 2 + 1, r))

v_num, query = (int(n) for n in input().split(" "))
rmq = RMQ(v_num, 2147483647)
for _ in range(query):
    com, i, n = (int(n) for n in input().split(" ") )
    if com == 0:
        rmq.update(i, n)
    else:
        print(rmq.find(i, n, 0, 0, rmq.length - 1))

Measured memory_bytes: 10884
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>

using namespace std;

#define N_MAX 10

double dist(pair<int, int> s, pair<int, int> t)
{
	return sqrt((double)((s.first - t.first)*(s.first - t.first) + (s.second - t.second)*(s.second - t.second)));
}

void solv()
{
	int N; scanf("%d", &N);
	pair<int, int> table[N_MAX];
	int perm[N_MAX], fact = 1;

	for (int i = 0; i < N; i++){
		int x, y; scanf("%d%d", &x, &y);
		table[i] = make_pair(x, y);
		perm[i] = i;
		fact *= (i + 1);
	}

	double sum = 0.0l;
	while (true){
		for (int i = 1; i < N; i++){
			sum += dist(table[perm[i - 1]], table[perm[i]]);
		}

		if (!next_permutation(perm, perm + N)){
			break;
		}
	};

	printf("%.10lf", sum / (double)fact);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;

#define MAX 100002
int n;
map<int, int> mp;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		mp[a]++;
	}
	long long int ans = 0;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		int a = (*it).second;
		int val = (*it).first;
		if (val > a) {
			ans += a;
		}
		else {
			ans += a - val;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4736
# -*- coding: utf-8 -*-
n, h = int(input()), list(map(int, input().split()))
print(len([i for i, x in enumerate(h) if (i == 0) or ((i == 1) and (h[0] <= h[i])) or ((i > 1) and (max(h[:i]) <= h[i]))]))


Measured memory_bytes: 2940
[a,b,c,x,y] = [int(i) for i in input().split()]

ans = a * x + b * y
cnt = 1

while x != 0 or y != 0:
  x = max(x - 1, 0)
  y = max(y - 1, 0)
  ans = min(ans,a*x+b*y+c*2*cnt)
  cnt += 1
print(ans)

Measured memory_bytes: 39536
n,c = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
a = 0
for i in x: a += i[1]
y,y2 = [max(0,x[0][1]-2*x[0][0])],x[0][1]
for i in range(1,n-1):
	y2 += x[i][1]
	y.append(max(y2-2*x[i][0],y[-1]))
z,z2 = [max(0,x[-1][1]-2*(c-x[-1][0]))],x[-1][1]
for i in range(n-2,0,-1):
	z2 += x[i][1]
	z.append(max(z2-2*(c-x[i][0]),z[-1]))
ans,sub = max(a-x[-1][0],a-(c-x[0][0]),0),0
z = z[::-1]
for i in range(n-1):
	sub += x[i][1]
	ans = max(sub-x[i][0]+z[i],ans)
sub = 0
for i in range(n-1,0,-1):
	sub += x[i][1]
	ans = max(sub-(c-x[i][0])+y[i-1],ans)
print(ans)

Measured memory_bytes: 27172
#include <stdio.h>

int main(){
	int h, m, s, S;
	scanf("%d", &S);
	h = S / 3600;
	m = (S % 3600) / 60;
	s = ((S % 3600) % 60) % 60;
	
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	int a[n];
	float min = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		min += a[i];
	}
	min /= (4 * m);
	if (m > n)
	{
		cout << "No";
		return 0;
	}
	sort(a, a + n, greater<int>());

	if (a[m - 1] >= min)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map { it.toInt() }

    val dp = Array(100005){ Int.MAX_VALUE}

    dp[0] = 0
    dp[1] = Math.abs(h[0]-h[1])
    for(i in 2 until n){
        if(dp[i-2] + Math.abs(h[i] - h[i-2]) >= dp[i-1] + Math.abs(h[i] - h[i-1])) {
            dp[i] = dp[i-1] + Math.abs(h[i] - h[i-1])
        }else{
            dp[i] = dp[i-2] + Math.abs(h[i] - h[i-2])
        }
    }

    println(dp[n-1])
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

priority_queue<ll> q0,q1;
ll sum0=0,sum1=0,mid=0,tot=0;

void add(ll x){
  if(x<mid){
    q0.push(x); sum0+=x; tot++;
  }else{
    q1.push(-x); sum1+=x; tot++;
  }
  ll h=tot/2;
  while(q0.size()<h){
    ll t=-q1.top(); q1.pop();
    sum1-=t; sum0+=t;
    q0.push(t);
  }
  while(q0.size()>h){
    ll t=q0.top(); q0.pop();
    sum0-=t; sum1+=t;
    q1.push(-t);
  }
  if(tot%2==0){
    mid=q0.top();
  }else{
    mid=-q1.top();
  }
}

ll query(){
  ll cnt0=q0.size(),cnt1=q1.size();
  return -sum0+sum1+cnt0*mid-cnt1*mid;
}

ll Q;

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

  cin>>Q;
  ll sumb=0;
  while(Q--){
    ll t;
    cin>>t;
    if(t==1){
      ll a,b;
      cin>>a>>b;
      sumb+=b;
      add(a);
    }else{
      cout<<mid<<" "<<query()+sumb<<'\n';
    }
  }

  return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int a,n,x,sum;
int main()
{
	cin>>a>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		sum+=x;
	}
	if(sum>=a)
		cout<<"Yes";
	else
		cout<<"No";
}

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

int table[310][310];

string backtrace(const string &s,const string &t,int i,int j) {
    if(i == 0 || j == 0) return "";
    else if(s[i-1] == t[j-1]) {
        return backtrace(s,t,i-1,j-1) + s[i-1];
    }else {
        if(table[i][j-1] > table[i-1][j]) return backtrace(s,t,i,j-1);
        else return backtrace(s,t,i-1,j);
    }
}

string lcs(const string &s,const string &t) {
  memset(table, 0, sizeof(table));

  for(int i=0; i<=s.length(); ++i)
    for(int j=0; j<=t.length(); ++j)
      table[i][j] = 0;

  for(int i=1; i<=s.length(); ++i) {
    for(int j=1; j<=t.length(); ++j) {
      int m = (s[i-1] == t[j-1]) ? 1 : 0;
      int value = max(table[i-1][j-1] + m, max(table[i-1][j], table[i][j-1]));
      table[i][j] = value;
    }
  }

  return backtrace(s,t,s.length(),t.length());
}


string lps(string s) {
    string s1,s2,ans;
    int ansl = 0;
    for(int i=1; i<s.length(); ++i) {
        string tmp = lcs(s.substr(0,i),s.substr(i));
        if(ans.length() < tmp.length()) {
            ans = tmp;
        }
    }

    return ans;
}


int main() {
    string input;
    while(cin>>input) {
        if(input == "#END") break;
        cout<<lps(input)<<endl;
    }
}

Measured memory_bytes: 1292
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin >> t;
	int d = t % 10;
	if(d==3)
		cout<<"bon\n";
	else if(d==0 || d==1 || d==6 || d==8)
		cout<<"pon\n";
	else
		cout<<"hon\n";
	return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main()
{
  	int m ,n, a;
    scanf("%d %d",&m, &n);
  
  if(m<10)
    if(n<10)
    	a=m*n;
    else
    	a=-1;
  else
    a=-1;
  printf("%d",a);
}
  

Measured memory_bytes: 128
#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>;

int main() {
  int x, y;
  cin >> x >> y;
  string res = "No";
  
  if(y % 2 != 0){
    cout << res << endl;
    return 0;
  }
  
  int a = 2 * x - y/2;
  int b = y/2 - x;
  
  if(a >= 0 && b >= 0) res = "Yes";
  
  cout << res << endl;
  return 0;
  
}


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

using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    ll l2 = 2;
    ll l1 = 1;
    ll li = 0;

    for (int i = 0; i < N-1; i++) {
        // cout << li << " " << l1 << " " << l2 << endl;
        li = l1 + l2;
        l2 = l1;
        l1 = li;
    }
    if (N != 1) {
        cout << li;
    } else {
        cout << l1;
    }

    return 0;
}


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

int main(void) {
    int n;
    double var, mean, sum, sd;
    int s[1000];
    while (1) {
        cin >> n;
        if (n == 0) break;
        sum = 0;
        for (int i = 0; i < n; i++) {
            cin >> s[i];
            sum += s[i];
        }
        mean = double(sum) / n;
        var = 0;
        for (int i = 0; i < n; i++) {
            var += pow(s[i] - mean, 2);
        }
        var /= n;
        cout << fixed << sqrt(var) << endl;
    }
    return 0;
}

Measured memory_bytes: 1236
#listが要素に持つ配列について、target_indexのインデックスの要素の出現回数をディクショナリに出力
def count(list, target_index = None):
    dict = {}
    if target_index == None:
        for i in range(len(list)):
            dict[list[i]] = dict.get(list[i], 0) + 1
    if target_index != None:
        for i in range(len(list)):
            dict[list[i][target_index]] = dict.get(list[i][target_index], 0) + 1
    return dict

#n回の整数入力を受け付け
def input_int_list(n):
    list = [0]*n
    for i in range(n):
        list[i] = int(input())
    return list

num = int(input())
discs = input_int_list(num)

print(str(len(count(discs))))


Measured memory_bytes: 9104
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x) cin >> x
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N, X;
    in(N); in(X);

    vi L(N);
    rep(i, N) in(L[i]);

    int d = 0;
    int count = 1;
    
    rep(i, N)
    {
        d += L[i];
        if (d > X) break;
        count++;
    }

    outl(count);

    return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    long long L[N];
    L[0] = 2;
    L[1] = 1;

    for (int i = 2; i < N + 1; i++)
    {
        L[i] = L[i - 1] + L[i - 2];
    }

    cout << L[N];
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a*b, c*d) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, A[59], B[59];
int M, U[29], V[29];
int condition[59];
vector<pair<int, int>> X[59];
vector<int> L, L2;
bool used[59];

void dfs(int pos, int goal) {
	used[pos] = true;
	if (pos == goal) { L2 = L; return; }

	for (int i = 0; i < X[pos].size(); i++) {
		if (used[X[pos][i].first] == true) continue;
		L.push_back(X[pos][i].second);
		dfs(X[pos][i].first, goal);
		L.pop_back();
	}
}

vector<int> getpath(int u, int v) {
	for (int i = 1; i <= N; i++) used[i] = false;
	L.clear(); L2.clear();
	dfs(u, v);
	return L2;
}

int main() {
	cin >> N;
	for (int i = 1; i <= N - 1; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(make_pair(B[i], i));
		X[B[i]].push_back(make_pair(A[i], i));
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> U[i] >> V[i];
		vector<int> E = getpath(U[i], V[i]);
		for (int j = 0; j < E.size(); j++) condition[E[j]] += (1 << i);
	}

	long long ans = 0;
	for (int i = 0; i < (1 << M); i++) {
		int cnt = 0;
		for (int j = 0; j < M; j++) { if ((i / (1 << j)) % 2 == 1) cnt++; }

		int cnt2 = 0;
		for (int j = 1; j <= N - 1; j++) {
			if ((condition[j] & i) == 0) cnt2++;
		}
		if (cnt % 2 == 0) ans += (1LL << cnt2);
		if (cnt % 2 == 1) ans -= (1LL << cnt2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>                                                        
using namespace std;                                                            
                                                                                
int main(){                                                                     
                                                                                
        int s,w;                                                                
        scanf("%d %d", &s, &w);                                                 
        if(s > w){                                                              
                printf("safe");                                                 
        } else if(s <= w){                                                      
                printf("unsafe");                                               
        }                                                                       
                                                                                
        return 0;                                                               
} 

Measured memory_bytes: 3748
'use strict';
function main(input) {
  const args = input.split(' '),
        L = parseInt(args[0]),
        R = parseInt(args[1]);
  const LMod = L % 2019,
        RMod = R % 2019;
  let min = 2018;
  if (R-L >= 2018) {
    console.log(0);
  } else {
    for(let i = LMod; i <= RMod-1; i++) {
      for(let j = i+1; j <= RMod; j++) {
        min = Math.min(min, (i*j) % 2019);
      }
    }
    console.log(min);
  }  
};
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] list = new int[3 * n];
        for (int i = 0; i < 3 * n; i++) {
            list[i] = sc.nextInt();
        }
        Arrays.sort(list);
        long count = 0;
        for (int i = 1; i <= n; i++) {
            count += list[3 * n - 2 * i];
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 93568
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
      ll n,k,ans=1;
      cin>>n>>k;
      for(ll i=0;i<n;i++)
      {
          if(ans<=k)
          ans=ans*2;
          else
          ans=ans+k;
      }
      cout<<ans;
      
    } 
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int k, s;
	cin >> k >> s;
	int counter = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			int z = s - i - j;
			if (0 <= z && z <= k) counter++;
		}
	}
	cout << counter << endl;
 	return 0;
}

Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;



int main(void)
{
	//変数の宣言
	int n,m;
	int a,b;
	char s[20];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	int vec[100010];
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	char stemp[100010];
	
	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);

//	scanf("%s",&s);
//	scanf_s("%s",&s,100010);


/*	for(i=0;i<n;i++){
//		scanf("%d",&b[i]);
		scanf_s("%d",&b[i]);
	}*/


/*	for(i=0;i<3;i++){
//		scanf("%s",&s);
		scanf_s("%s",&s[i],100010);
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	for(i=0;i<4;i++){
		vec[i]=n%10;
		n=n/10;
	}

	if(vec[0]==vec[1]&&vec[1]==vec[2]){
		printf("Yes");
	}else if(vec[3]==vec[1]&&vec[1]==vec[2]){
		printf("Yes");
	}else{
		printf("No");
	}


//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	//printf("%d",min(sum+2*m,n-1));

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

 
int main(){
  unsigned short *A, *B;
 
  int C[10001];
  int n, i, j;
  scanf("%d", &n);
 
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
 
  for ( i = 0; i <= 10000; i++ ) C[i] = 0;
 
  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }
 
  for ( i = 1; i <= 10000; i++ ) C[i] = C[i] + C[i - 1];
 
  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
     
  
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");
  
  return 0;
}

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

int main(void){
    int n;
    cin>>n;
    int frag=0;
    for(int i=1;i<=9;i++){
        if(n%i==0&&0<n/i&&n/i<10){
            frag=1;
            break;
        }
    }
    if(frag==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

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

int main() {
  for(int n, k, m; cin >> n >> k >> m && (n|k|m); ) {
    vector<int> v;
    for(int i = 1; i <= n; ++i) v.push_back(i);
    int p = (m - 1 - k + n) % n;
    while(v.size() > 1) {
      p = (p + k) % v.size();
      v.erase(v.begin() + p);
      --p;
    }
    cout << v[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 1324
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vecint vector<int>
#define vecll vector<ll>
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	int n; cin >> n;
	vector<LLPair> ab(n);
	rep(i, n){
		cin >> ab[i].second >> ab[i].first;
		//ab[i].first -= ab[i].second;
	}
	sort(ALL(ab));

	ll time = 0;
	rep(i, n){
		time += ab[i].second;
		if(ab[i].first < time){
			cout << "No" << endl;
			return 0;
		}
	}

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

Measured memory_bytes: 3328
import sys
X = int(input())
L = []
for i in range(1000):
    a = int(i**5)
    L.append(a)
    for j in range(len(L)):
        if X == a-L[j]:
            print(i, j)
            sys.exit()
        elif X == a+L[j]:
            ans = j*-1
            print(i, ans)
            sys.exit()


Measured memory_bytes: 8936
n, k = map(int, input().split())
X = list(map(int, input().split()))

ans = []
for i in range(n-k+1):
    left = X[i]
    right = X[i+k-1]
    if left * right < 0:
        result = min(abs(left), abs(right)) * 2 + max(abs(left), abs(right))
    else:
        result = max(abs(left), abs(right))
    ans.append(result)

print(min(ans))

Measured memory_bytes: 14568
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
class UnionFind(): #集合の取り扱い、辺に重み、階層を意識するときは使えない
    def __init__(self,n):
        self.n=n
        self.par = [-1]*n
    def find(self,x):
        if self.par[x] <0: #負なら親、要素数
            return x
        else: #正なら親の番号
            self.par[x]=self.find(self.par[x]) #一回調べたら根を繋ぎ変える、経路圧縮
            return self.par[x]
    def union(self,x,y):
        x=self.find(x) #x,yの親
        y=self.find(y)

        if x==y: #親が同じなら何もしない
            return 
        if self.par[x]>self.par[y]: #要素数が大きい方をxにする
            x,y=y,x
        self.par[x]+=self.par[y] #xがある集合にyが入った集合をくっつける
        self.par[y]=x

    def size(self,x):
        return -self.par[self.find(x)] #親のサイズ
    
    def same(self,x,y): #親が同じ、すなわち同じ集合か
        return self.find(x)==self.find(y)

    def member(self,x): #同じ木（集合）にある要素全部リストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i)==root ]
    
    def roots(self): #集合の根になってる要素をリストで返す
        return [i for i , x in enumerate(self.par) if x<0]
    
    def group_count(self): #集合の数、木の数
        return len(self.roots())

    def all_member(self): #辞書型で返す
        return {r: self.member(r) for r in self.roots()}
    def __str__(self):
        return "\n".join('{}:{}'.format(r,self.member(r)) for r in self.roots)

n,m=map(int,input().split())
p=list(map(int,input().split()))
tree=UnionFind(n)
for i in range(m):
  x,y=map(int,input().split())
  tree.union(x-1,y-1)
ans=0
for i in range(n):
  if tree.same(p[i]-1,i):
    ans+=1
print(ans)

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

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

Measured memory_bytes: 3632
def pn_bool(x):
    if x == 2: return True
    if x % 2 == 0 or x < 2: return False
    sqrt_x = x ** 0.5
    for i in range(3, int(sqrt_x) + 1, 2):
        if x % i == 0:
            return False
    return True


count = 0
for _ in range(int(input())):
    if pn_bool(int(input())):
        count += 1
print(count)



Measured memory_bytes: 5672
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
int k;
cin>>k;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
int b[m];
for(int i=0;i<m;i++)
    cin>>b[i];
    int ans=0;
    for(int i=1;i<n;i++)
    {
        arr[i]+=arr[i-1];
    }
    for(int  i=1;i<m;i++)
    {
        b[i]+=b[i-1];
    }
     ans=0;
    for(int i=0;i<n;i++)
    {
        if(arr[i]<=k)
        {
            int cnt=i+1;
            int val=k-arr[i];
            int pos=upper_bound(b,b+m,val)-b;
            cnt+=pos;
            ans=max(ans,cnt);
        }
    }
    for(int i=0;i<m;i++)
    {
        if(b[i]<=k)
        {
            int cnt=i+1;
            int val=k-b[i];
            int pos=upper_bound(arr,arr+n,val)-arr;
            cnt+=pos;
            ans=max(ans,cnt);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int main(){
  ll a, b;
    cin >> a >> b;
  if((a+b)%2==0){
    cout << (a+b)/2 << endl;
  }else
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

public class Program
{

    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        int c = int.Parse(s[2]);

        List<int> list = new List<int>();
        int num = 0;
        int amari = 0;
        string ans = "";
        for (int i = 1; true; i++)
        {
            num = i * a;
            amari = num % b;
            if (amari == c) { ans = "YES"; break; }
            else
            {
                //存在する
                if (list.Contains(amari)) { ans = "NO"; break; }
                else list.Add(amari);
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13144
#!/usr/bin/perl

$line == 0;
while(<>) {
    chomp;
    if ($line == 0) {
    } else {
        $a{$_}++;
    }
    $line++;
}

$total = 0;
foreach (keys %a) {
    if ($a{$_} % 2 == 1) {
        $total++;
    }
}
print "$total\n";


Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

  string N;
  cin>>N;
  //vector<int> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int>> A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  if(N!="AAA"&&N!="BBB")cout<<"Yes"<<endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 764