akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAX_S 305 

double dp[MAX_S][MAX_S][MAX_S];
int c[3];
double n;

void odp(int t1,int t2, int t3){
	if(dp[t1][t2][t3]!=0)
		return;
	
	if(t1==0&&t2==0&&t3==0)
		return;
	double par=n/((double)(t1+t2+t3));
	if(t1){
		odp(t1-1,t2,t3);
		dp[t1][t2][t3]+=(dp[t1-1][t2][t3]+par)*((double)(t1)/(double)(t1+t2+t3));
	}
	if(t2){
		odp(t1+1,t2-1,t3);
		dp[t1][t2][t3]+=(dp[t1+1][t2-1][t3]+par)*((double)(t2)/(double)(t1+t2+t3));
	}
	if(t3){
		odp(t1,t2+1,t3-1);
		dp[t1][t2][t3]+=(dp[t1][t2+1][t3-1]+par)*((double)(t3)/(double)(t1+t2+t3));
	}
}

int main(){//wykmin to samemu...
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	
	REP(i,n){
		int t1;
		cin>>t1;
		c[t1-1]++;
	}
	
	cout.precision(100);
	odp(c[0],c[1],c[2]);
	cout<<dp[c[0]][c[1]][c[2]];
	
	return 0;
}


Measured memory_bytes: 219392
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  if(a+b+c>21){
    cout << "bust" << endl;
  }
  else{
    cout << "win" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int minimumChar(string S1, string S2)
{
	int n = S1.size(), m = S2.size();
	int ans = INT_MAX;
	for (int i = 0; i < m - n + 1; i++) {
		int minRemovedChar = 0;
		for (int j = 0; j < n; j++) {
			if (S1[j] != S2[i + j]) {
				minRemovedChar++;
			}
		}
		ans = min(minRemovedChar, ans);
	}
	return ans;
}
int main()
{
	string s,ss;
	cin>>s>>ss;
	cout<<minimumChar(ss,s)<<endl;
	return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  map<ll, vector<int>> mp;
  ll sum = 0;
  ll ans = 0;
  mp[1].push_back(-1);
  rep(i, N) {
    sum += A[i];
    if(mp.count((sum-i)%K)) ans += mp[(sum-i)%K].end() - lower_bound(all(mp[(sum-i)%K]), i-K+1);
    mp[(sum-i)%K].push_back(i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 23680
import java.util.*;
import java.io.*;
import java.math.BigInteger; 

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
// ends

//......................................@uthor_Alx..............................................


//  (Binary lifting)LCS implementation <O(NlogN,logN)>...<preprocessing,query>
//static int l,time;
//static int[][] f; // f[n][l]..
//static int[] tin, tout;
//static List<Integer>[] adj;
/*	return tin[u]<=tin[v]&&tout[u]>=tout[v]; 
}
static void dfs(int u, int p){
	tin[u]=time++;
	f[u][0]=p;
	for(int i=1;i<=l;i++){
		f[u][i]= f[f[u][i-1]][i-1];
	}

	for(int v: adj[u]){
		if(v!=p) dfs(v,u);
	}
	tout[u]=time++;
}
static int lca(int u, int v){
	if(ok(u,v)){return u;}
	if(ok(v,u)){return v;}

	for(int i=l;i>=0;i--){
		if(!ok(f[u][i],v)){
			u=f[u][i];
		}
	}
	return f[u][0];
}*/

public static void main(String[] args) throws  IOException{
	        		  assign();
              int s=int_v(read());
              long x=(long)(s/500)*1000 +((s-500*(s/500))/5)*5;
              out.write(x+"\n");
              out.flush();
	        		 
	        	}
	       
	          
	        }

	    

	
  





Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll a,b; cin >> a >> b;
  cout << (a+b+1)/2 << endl;
}

Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>
using namespace std;
const int N = 2*(int)1e5+5;
int a[N], ans[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n;
	cin >> n;
	for(int i=1; i<=n; i++) cin >> a[i];
	for(int i=n; i>=1; i--) {
		int sum = 0;
		for(int j=i+i; j<=n; j+=i) sum += ans[j];
		ans[i] = (2+a[i]-sum%2)%2;
	}
	int c = 0;
	for(int i=1; i<=n; i++) c+=ans[i];
	cout << c << "\n";
	for(int i=1; i<=n; i++) if(ans[i]) cout << i << " ";
	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;
class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n;
    int m;
    n = sc.nextInt();
    m = sc.nextInt();
    System.out.println(n*(n-1)/2 + m*(m-1)/2);
  }
}


Measured memory_bytes: 24020
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <cstdio>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll func(ll a,ll b,ll& ans_x,ll& ans_y){
    if(b == 0){
        ans_x = 1;
        ans_y = 0;
        return a;
    }else{
        ll ret = func(b,(a%b),ans_y,ans_x);
        ans_y -= (a/b)*ans_x;
        return ret;
    }
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

ll dp[50010];



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

    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}


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

int main()
{
    int ans;
    for (int i = 1; i <= 5; i++)
    {
        int t;
        cin >> t;
        if (t == 0)
            ans = i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int w,h;
int c[55][55];
int d[55][55];
int a;

void dfs(int i,int j);
void dfs_(int i,int j){
  if(i>=0 && j>=0) if(c[i][j]==1) dfs(i,j);
}

void dfs(int i,int j){
  if(d[i][j]==1)return;
  d[i][j] = 1;
  rep(l,0,3) rep(r,0,3) dfs_(i-1+l,j-1+r);
}


int imain(){
  a=0;
  rep(i,0,52) rep(j,0,52) c[i][j]=d[i][j]=0;
  rep(i,0,h) rep(j,0,w) {
    cin >> c[i][j];
  }

  rep(i,0,h) rep(j,0,w) if(c[i][j]==1 && d[i][j]==0) {
    dfs(i,j);
    a++;
  }
  cout << a << endl;

  return 0;
}

int main(){
  for(;;){
    cin >> w >> h;
    if(w==0 && h==0)break;
    imain();
  }
  return 0;
}



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

using namespace std;
typedef unsigned long long Int;

int main() {
    Int n;
    cin >> n;
    vector<Int> vec;

    for(Int i = 1; i < sqrt(n) + 1; i++) {
        if(n % i == 0) {
            vec.push_back(i + (n / i));
        }
    }
    Int min = n;
    for(Int i = 0; i < vec.size(); i++) {
        if(min > vec[i]) min = vec[i];
    }
    cout << ((min == n) ? min - 1 : min - 2) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,n;
  cin>>k>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int ans = a[n-1]-a[0];
  for(int i=1;i<n;i++){
  	ans = min(ans, k-(a[i]-a[i-1]));
  }
   cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)
const long double PI = (acos(-1));

int main() {

	int n, m, c;
	cin >> n >> m >> c;

	vector<int> b(m);
	vector<vector<int>> a(n, vector<int>(m));
	int sum = 0, cnt = 0;

	rep(i, 0, m) cin >> b[i];

	rep(i, 0, n) {
		rep(j, 0, m) {
			cin >> a[i][j];
			sum += a[i][j] * b[j];
		}
		sum += c;
		if (sum > 0) cnt++;
		sum = 0;
	}

	cout << cnt << endl;

	return 0;
}

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

class UnionFind {
	vector<int> parent;
	vector<int> rank;

	int root(int x) {
		if (parent[x] == x) return x;
		else return parent[x] = root(parent[x]); // 経路圧縮
	}

public:
	UnionFind(int _size): parent(_size), rank(_size, 0) {
		for (int i = 0; i < _size; ++i) {
			parent[i] = i;
		}
	}

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;

		// ランクを使わない
		// parent[rx] = ry;

		// ランクを使う
		if (rank[rx] < rank[ry]) {
			swap(rx, ry);
		}
		rank[rx] += rank[ry];
		parent[ry] = rx;
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}
};

int main(int argc, char const *argv[])
{
	int n, q; cin >> n >> q;
	UnionFind uf(n);
	for (int i = 0; i < q; ++i) {
		int comp, x, y;
		cin >> comp >> x >> y;
		if (comp == 0) {
			uf.unite(x, y);
		} else {
			cout << (uf.same(x, y) ? "1" : "0") << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3176
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N = int(input())
    reds = [tuple(map(int, input().split())) for _ in range(N)]
    blues = [tuple(map(int, input().split())) for _ in range(N)]
    cnt = 0

    blues = sorted(blues, key=lambda x: x[0])
    for i in blues:
        temp = (-1, -1)

        for j in reds:
            if j[0] < i[0] and j[1] < i[1]:
                if j[1] > temp[1]:
                    temp = (j[0], j[1])
                    tempind = j
        if temp != (-1, -1):
            cnt += 1
            # blues.remove(i)
            reds.remove(tempind)
    print(cnt)


resolve()

Measured memory_bytes: 38896
import numpy as np

H,N = list(map(int, input().split()))
As = []
Bs = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    As.append(a)
    Bs.append(b)
As = np.array(As)
Bs = np.array(Bs)

dp = np.full((H+1), np.inf)
dp[0] = 0

for c in range(1,H+1):
    dp[c] = np.amin(dp[np.maximum(c - As, 0)] + Bs)

print(int(dp[-1]))


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

int main(){
	
	char s[100];
	char p[99];
	char ss[10000];
	
	scanf("%s %s", s,p);
	strcpy(ss,s);
	strcat(ss,s);
	if (strstr(ss, p)) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

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

int N, S, E;
int64_t T;
vector<pair<int, int64_t>> edges[100000];

int nxt[100000];

bool dfs1(int i, int par){
    nxt[i] = -1;
    bool res = (i==E);
    for(auto& p : edges[i]){
        int j = p.first;
        if(j != par){
            if(dfs1(j, i)){
                res = true;
                nxt[i] = j;
            }
        }
    }
    return res;
}

int num[100000];

void fail(){
    cout << "No" << endl;
    exit(0);
}

void dfs2(int i, int par){
    vector<pair<int, int64_t>> child;
    for(auto& p : edges[i]) if(p.first != par) if(p.first != nxt[i]) child.push_back(p);
    sort(child.begin(), child.end(), [&](auto e1, auto e2){
        return e1.second - T*edges[e1.first].size() < e2.second - T*edges[e2.first].size();
    });
    for(auto& p : edges[i]) if(p.first != par) if(p.first == nxt[i]) child.push_back(p);
    for(auto& p : child){
        int j = p.first;
        int64_t c = p.second;
        if(T*(num[i]+num[j]) >= c) fail();
        num[j]++;
        dfs2(j, i);
        if(nxt[i] != j){
            if(T*(num[i]+num[j]) >= c) fail();
            num[i]++;
        }
    }
}

int main(){
    cin >> N >> T >> S >> E;
    S--; E--;
    for(int i=0; i<N-1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        edges[a-1].emplace_back(b-1, c);
        edges[b-1].emplace_back(a-1, c);
    }

    dfs1(S, -1);
    dfs2(S, -1);
    cout << "Yes" << endl;
}



Measured memory_bytes: 15136
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 1000000007 
#define mx 3003

long long fak[10003], inv[10003];

long long POW(long long a, int b){
	long long ret = 1;
	while(b > 0){
		if(b & 1)
			ret = ret * a % MOD;
		b >>= 1;
		a = a * a % MOD;
	}
	return ret;
}

long long C(int n, int k){
	if(k > n)
		return 0;
	return fak[n] * inv[k] % MOD * inv[n - k] % MOD;
}

long long dep[mx][mx], n, m, pref0[mx], pref1[mx], l, r;
string ss;
vector<pair<int, int>> ve;



long long dp(int now, int satu){
	if(now == sz(ve))
		return 1;
	long long &ret = dep[now][satu];
	if(ret != -1)
		return ret;
	ret = 0;
	if(now == sz(ve) - 1 || ve[now].s < ve[now + 1].f){
		int kiri = ve[now].f;
		int tengah = kiri;
		int kanan = ve[now].s;
		if(now > 0 && ve[now - 1].s >= kiri)
			tengah = ve[now - 1].s + 1;
		//dari kiri -> tengah - 1 dan tengah -> kanan
		int nol = pref0[kanan] - pref0[tengah - 1] + tengah - kiri - satu;
		int sat = pref1[kanan] - pref1[tengah - 1] + satu;
		ret = dp(now + 1, 0) * C(nol + sat, sat) % MOD;
		// cout << now << ' ' << satu << ' ' << ret <<endl;
		return ret;
	}
	int kiri = ve[now].f;
	int tengah = kiri;
	int kanan = ve[now].s;
	int batas = ve[now + 1].f - 1;
	if(now > 0 && ve[now - 1].s >= kiri){
		// debug(tengah);
		tengah = ve[now - 1].s + 1;
	}
	int berapa = batas - kiri + 1;

	int nol = pref0[kanan] - pref0[tengah - 1] + tengah - kiri - satu;
	int sat = pref1[kanan] - pref1[tengah - 1] + satu;
	// cout << now << ' ' << satu << ' ' << nol << ' ' << sat << ' ' << kiri << ' ' << tengah << ' ' << kanan << endl;
	for(int i = max(0, berapa - sat); i <= min(nol, berapa); i++){
		int j = berapa - i;
		assert(0 <= i && i <= nol);
		assert(0 <= j && j <= sat);
		ret = (ret + dp(now + 1, sat - j) * C(i + j, i)) % MOD;
	}
	// cout << now << ' ' << satu << ' ' << ret <<endl;
	return ret;

}

int main(){
	fak[0] = 1;
	for(int i = 1; i <= 10000; i++)
		fak[i] = fak[i - 1] * i % MOD;

	inv[10000] = POW(fak[10000], MOD - 2);
	for(int i = 10000 - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1) % MOD;
	// for(int i = 0; i <= 10000; i++)
		// inv[i] = POW(fak[i], MOD - 2);
	// debug(inv[2]);
	cin >> n >> m >> ss;

	for(int i = 0; i < n; i++){
		if(i > 0){
			pref0[i] = pref0[i - 1];
			pref1[i] = pref1[i - 1];
		}
		if(ss[i] == '0')
			pref0[i] += 1;
		else pref1[i] += 1;
	}


	for(int i = 0; i < m; i++){
		cin >> l >> r;
		l -= 1;
		r -= 1;
		ve.pb({l, r});
	}
	sort(ALL(ve), [&](pair<int, int> x, pair<int, int> y){
		if(x.f == y.f)
			return x.s > y.s;
		return x.f < y.f;
	});
	vector<pair<int, int>> sem = ve;
	ve.clear();
	for(auto i : sem){
		if(ve.empty())
			ve.pb(i);
		else if(ve.back().s < i.s)
			ve.pb(i);
	}
	reset(dep, -1);
	cout << dp(0, 0) << endl;
}

Measured memory_bytes: 71040
#include <stdio.h>

int main(void){

  int n;
  scanf("%d", &n);
  int h[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &h[i]);
  }
  int answer = n;
  int max = h[0];
  for (int i = 1; i < n; i++) {
    if (h[i] < max) {
      answer--;
    }
    if (h[i] > max) {
      max = h[i];
    }
  }
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 1e5+1;
int n,v[N];

int main(){
    long double sm = 0.0;
    scanf("%d",&n);
    for(int i = 0; i<n; ++i){
        scanf("%d",v+i);
        long double ad = 1.0/v[i];
        sm += ad;
    }
    cout << (long double)1.0/sm;
}


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

const int N = 100005;

int n, m, a[N], r, v[N];
vector<int> e[N];
set<int> s;

void f(int x){
    v[x] = 1;
    s.insert(a[x]);
    for(int i : e[x]) if(!v[i]) f(i);
}

void g(int x){
    v[x] = 2;
    if(s.find(x) != s.end()) r++;
    for(int i : e[x]) if(v[i] != 2) g(i);
}

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++) scanf("%d", a + i);
    for(int i = 0, x, y; i < m; i++){
        scanf("%d%d", &x, &y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    for(int i = 1; i <= n; i++){
        if(v[i]) continue;
        s.clear();
        f(i);
        g(i);
    }
    printf("%d\n", r);
}

Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r;
  cin >> r;
  if (r < 1200){
    cout << "ABC" << endl;
  }else if (r < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 3636
import heapq
from itertools import repeat, starmap
from operator import mul

R = lambda: map(int, input().split())
n, m = R()
a = list(zip(R(), repeat(1)))
heapq.heapify(a)
for _ in range(m):
    b, c = R()
    i = b
    while i:
        x, y = a[0]
        if x >= c:
            break
        d = min(i, y)
        i -= d
        y -= d
        if y:
            heapq.heapreplace(a, (x, y))
        else:
            heapq.heappop(a)
    heapq.heappush(a, (c, b - i))
print(sum(starmap(mul, a)))


Measured memory_bytes: 20872
#include <cstdio>
#include <vector>
#include <climits>
#include <queue>
#include <functional>
using namespace std;
struct edge { 
    int to, cost;
    edge(int _to, int _cost) { to = _to; cost = _cost; }
};
typedef pair<int, int> P;
void solve() {
    int T, N;
    scanf("%d%d",&N,&T);
    vector<edge> G[N];
    int d[N];
    for (int i=0; i<T; i++) {
        int x, y, c1, c2;
        scanf("%d%*c%d%*c%d%*c%d", &x,&y,&c1,&c2);
        G[x-1].push_back(edge(y-1,c1));
        G[y-1].push_back(edge(x-1,c2));	
    }
    int start, goal, gift, cost;
    scanf("%d%*c%d%*c%d%*c%d",&start,&goal,&gift,&cost);
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+N, INT_MAX);
    d[start-1] = 0;
    que.push(P(0,start-1));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i=0; i<G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
    int res = gift-cost-d[goal-1];
    fill(d, d+N, INT_MAX);
    d[goal-1] = 0;
    que.push(P(0,goal-1));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i=0; i<G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
    printf("%d\n", res-d[start-1]);
}
int main() {
    solve();
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 1100000;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    if (k == 0){
        cout << n * n;
        return 0;
    }
    for (int i = k + 1; i <= n; i++){
        int f = n % i;
        if (f >= k) ans += f - k + 1;
        int m = n - f;
        int x = i - k;
        ans += m / i * x;
    }
    cout << ans;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
c = Array.new(8){false}
free = 0
a.each{|r|
    if r >= 3200
        free += 1
    else
        c[r / 400] = true
    end
}
min = c.count(true)
max = min + free
if min == 0
    min = 1
end
puts "%d %d" % [min, max]


Measured memory_bytes: 14316
import java.io.BufferedReader;
import java.io.Console;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.TreeMap;

import javax.naming.ldap.SortControl;

public class Main {

	static FastReader input = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws IOException {
		String s = input.nextLine();
		int[] a = new int[60];
		for (int i = 0; i < s.length(); i++) {
			a[s.charAt(i) - 'A']++;
		}

		boolean isOk = true;
		for (int i = 0; i < a.length; i++) {
			if (a[i] != 0 && a[i] != 2) {
				isOk = false;
				break;
			}
		}
		out.println(isOk ? "Yes" : "No");
		out.flush();
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		String nextLine() throws IOException {
			String str = "";
			str = br.readLine();
			return str;
		}
	}

	static class con {
		static int IINF = (int) 1e9;
		static int _IINF = (int) -1e9;
		static long LINF = (long) 1e15;
		static long _LINF = (long) -1e15;
		static double EPS = 1e-9;
	}

	static class Triple implements Comparable<Triple> {
		int x;
		int y;
		int z;

		Triple(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		@Override
		public int compareTo(Triple o) {
			if (x == o.x && y == o.y)
				return z - o.z;
			if (x == o.x)
				return y - o.y;
			return x - o.x;
		}
	}

	static class Pair implements Comparable<Pair> {
		int x;
		int y;

		Pair(int x, int y) {
			this.x = x;
			this.y = y;

		}

		@Override
		public int compareTo(Pair o) {
			if (x == o.x)
				return y - o.y;
			return x - o.x;
		}
	}

	static void shuffle(int[] a) {
		for (int i = 0; i < a.length; i++) {
			int r = i + (int) (Math.random() * (a.length - i));
			int tmp = a[r];
			a[r] = a[i];
			a[i] = tmp;
		}
	}

}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;

const ll MAX = 2000100;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 順列計算
ll ARR(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[n-k] % MOD;
}
//重複組合せ計算
ll MULTICOM(ll n, ll k){
    return COM(n+k-1,k);
}
//べき乗計算
ll modpow(ll a,ll n,ll mod=MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

void Main(){
    int k;
    string S;
    cin >> k >> S;
    int s = S.size();
    int n = k + s;
    For(i,1,n+1){
        ans += COM(i-1,s-1) * modpow(25,i-s) %MOD * modpow(26,n-i) %MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

int main(){
    COMinit();
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 52160
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s[20];
  cin >> s;
  int n=strlen(s),a,b=0;
  for(int i=0;i<n;i++){
    a=0;
    for(int j=i;j<n;j++){
      if(s[j]=='A'||s[j]=='G'||s[j]=='C'||s[j]=='T')a++;
      else break;
    }
    if(b<a)b=a;
  }
  cout << b;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

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

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N, M;
    cin >> N >> M;
    if (N == M) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

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

	int a, b, c;
	cin >> a >> b >> c;

	vector<int> data;
	data.push_back(a);
	data.push_back(b);
	data.push_back(c);
	sort(data.begin(), data.end());
	
	int diff_1 = data.at(2) - data.at(0);
	int diff_2 = data.at(2) - data.at(1);

	int count = diff_1 / 2 + diff_2 / 2;
	int d_count = diff_1 % 2 + diff_2 % 2;
	if (d_count == 2) {
		count++;
	}
	else if (d_count == 1) {
		count += 2;
	}
	cout << count << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();

		ArrayList<Integer> yakusu = new ArrayList<Integer>();
		for(int i=1; i*i<=m; i++) {
			if(m%i==0) {
				yakusu.add(i);
				if(m/i != i) {
					yakusu.add(m/i);
				}
			}
		}

		int ans = 1;
		for(int i : yakusu) {
			if((long)i*n<=m) {
				ans = Math.max(ans, i);
			}
		}
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 35792
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point
{
public:
  double x, y;

  Point(double x = 0, double y = 0) : x(x), y(y) {}

  Point operator+(Point p) { return Point(x + p.x, y + p.y); }
  Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  Point operator*(double a) { return Point(a * x, a * y); }
  Point operator/(double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }

  bool operator<(const Point &p) const
  {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator==(const Point &p) const
  {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};

typedef Point Vector;

struct Segment
{
  Point p1, p2;
};

double dot(Vector a, Vector b)
{
  return a.x * b.x + a.y * b.y;
}

double norm(Vector a)
{
  return a.x * a.x + a.y * a.y;
}

Point project(Segment s, Point p)
{
  Vector base = s.p2 - s.p1;
  double r = dot(p - s.p1, base) / norm(base);
  return s.p1 + base * r;
}

Point reflect(Segment s, Point p)
{
  return p + (project(s, p) - p) * 2.0;
}

int main()
{
  Segment s;
  cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;
  int q;
  cin >> q;

  for (int i = 0; i < q; i++)
  {
    Point p;
    cin >> p.x >> p.y;
    Point ans = reflect(s, p);
    cout << fixed << setprecision(11) << ans.x << " " << fixed << setprecision(11) << ans.y << endl;
  }

  return 0;
}



Measured memory_bytes: 3292
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const int imax = ~(1 << 31);
const long long linf = 1ll << 61;
const long long lmax = ~(1ll << 63);
const double PI = acos(-1.0);

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

int N;
double x[100];
double y[100];
double argmin[100];
double argmax[100];

void add(int i, double arg)
{
	double l = fmod(arg + 4 * PI, 2 * PI);
	double r = l + PI;
	if (r < argmin[i]) {
		l += 2 * PI;
		r += 2 * PI;
	} else if(l > argmax[i]) {
		l -= 2 * PI;
		r -= 2 * PI;
	}
	argmin[i] = max(argmin[i], l);
	argmax[i] = min(argmax[i], r);
}

int main(int argc, char* argv[])
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lf%lf", &x[i], &y[i]);
		argmin[i] = 0;
		argmax[i] = 4 * PI;
	}
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			double dx = x[i] - x[j];
			double dy = y[j] - y[i];
			double d = sqrt(dx * dx + dy * dy);
			double arg = asin(dx / d);
			if (dy < 0)
				arg = PI - arg;
			add(j, arg);
			add(i, arg + PI);
		}
	}
	for (int i = 0; i < N; i++) {
		if (argmax[i] <= argmin[i]) {
			printf("0.0\n");
		} else {
			double p = (argmax[i] - argmin[i]) / (2 * PI);
			printf("%.8f\n", p);
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

double ab(double x) {
    return x < 0 ? -x : x;
}

int main() {
    int n;
    std::cin >> n;
    std::vector<double> x;
    std::vector<double> y;

    for (int i = 0; i < n; i++) {
        double t;
        std::cin >> t;
        x.push_back(t);
    }
    for (int i = 0; i < n; i++) {
        double t;
        std::cin >> t;
        y.push_back(t);
    }
    double d1, d2, d3, di;
    d1 = 0;
    d2 = 0;
    d3 = 0;
    di = 0;
    for (int i = 0; i < n; i++) {
        double t = ab(x[i] - y[i]);
        d1 += t;
        d2 += t*t;
        d3 += t * t*t;
        if (t > di)
            di = t;
    }
    d2 = std::sqrt(d2);
    d3 = std::pow(d3, double(1.0 / 3.0));

    std::cout << std::setprecision(20);
            std::cout << d1 << std::endl << d2 << std::endl << d3 << std::endl << di << std::endl;


    return 0;
}

Measured memory_bytes: 3440
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int w = sc.nextInt();
		
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < s.length(); i+=w) {
			sb.append(s.charAt(i));
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 22608
import numpy as np
row = input().split()
N = int(row[0])
x = int(row[1])

row2 = input().split()
a = list(map(int, row2))
a.sort()
count = 0
for i in range(N):
    x -= a[i]
    if x >= 0:
        count += 1
    else:
        break

if x <= 0:
    print(count)
else:
    print(count-1)

Measured memory_bytes: 21020
#include <stdio.h>
#include <stdlib.h>
#define MAX 101

void Cal(int *,char);
int i=0;

int main(){
  int x;
  int A[MAX];
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
        Cal(A,s[0]);
    } else if ( s[0] == '-' ){
        Cal(A,s[0]);
    } else if ( s[0] == '*' ){
        Cal(A,s[0]);
    } else {
      x = atoi(s);
      i++; 
      A[i] = x;
    }
  }
printf("%d\n",A[1]);
  return 0;
}

void Cal(int *A,char s)
{
    int num;
    if(s=='+') { num=A[i-1]+A[i]; A[i-1]=num; i=i-1;}
    if(s=='-') { num=A[i-1]-A[i]; A[i-1]=num; i=i-1;}
    if(s=='*') { num=A[i-1]*A[i]; A[i-1]=num; i=i-1;}
}


Measured memory_bytes: 2064
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;
typedef struct {
  int to, cost;
}edge;
typedef pair<int, int> P;

const int start = 2*30*60;
const int MAX_V = 2*30*60+1;
const int INF = 1000000000;
vector<edge> G[MAX_V];
int d[MAX_V];

int ctoi(char c) {
  if ('0' <= c and c <= '9')
    return (int)(c - '0');
  else if (c == 'T')
    return 0;
  else
    return (int)c;
}

void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d+MAX_V, INF);
  d[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
	d[e.to] = d[v] + e.cost;
	que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  int lx[9] = {1, 2, 3, 1, 2, 1, 2, 1, 1};
  int ly[9] = {0, 0, 0, 1, 1, -1, -1, 2, -2};
  int rx[9] = {-1, -2, -3, -1, -2, -1, -2, -1, -1};
  int ry[9] = {0, 0, 0, 1, 1, -1, -1, 2, -2};
  while (true) {
    int w, h;
    scanf("%d%d", &w, &h);
    if (w == 0 and h == 0) break;

    int s[h][w];
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
	char c;
	cin >> c;
	s[i][j] = ctoi(c);
      }
    }
    
    for (int i = 0; i < MAX_V; i++)
      G[i].clear();

    vector<int> t;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
	switch(s[i][j]) {
	case (int)('X'): break;
	case 0: 
	  t.push_back(2*(w*i+j));
	  t.push_back(2*(w*i+j)+1);
	  break;
	case (int)('S'):
	  G[start].push_back(edge{2*(w*i+j), 0});
	  G[start].push_back(edge{2*(w*i+j)+1, 0});
	default:
	  for (int k = 0; k < 9; k++) {
	    int x = j + lx[k], y = i + ly[k];
	    if (0 <= x and x < w and 0 <= y and y < h and s[y][x] != (int)('X') and s[y][x] != (int)('S')) {
	      G[2*(w*i+j)].push_back(edge{2*(w*y+x)+1, s[y][x]});
	    }
	  }

	  for (int k = 0; k < 9; k++) {
	    int x = j + rx[k], y = i + ry[k];
	    if (0 <= x and x < w and 0 <= y and y < h and s[y][x] != (int)('X') and s[y][x] != (int)('S')) {
	      G[2*(w*i+j)+1].push_back(edge{2*(w*y+x), s[y][x]});
	    }
	  }
	  break;
	}
      }
    }

    dijkstra(start);
    int res = INF;
    for (int i = 0; i < t.size(); i++) {
      res = min(res, d[t[i]]);
    }
    if (res < INF)
      printf("%d\n", res);
    else
      printf("-1\n");
  }
}

Measured memory_bytes: 1848
#include<stdlib.h>
#include<stdio.h>
int cmp(const void *a,const void *b){
  return (*(int *)b-*(int *)a);
}
int main(){
  int i,five[5];

  scanf("%d %d %d %d %d",five,five+1,five+2,five+3,five+4);
  qsort(five,5,sizeof(int),cmp);
  printf("%d %d %d %d %d\n",five[0],five[1],five[2],five[3],five[4]);
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
//#define random_shuffle(r...)random_shuffle(r,[](int _){return my_rand()%_;})

 int main(){

    ll a,b,c,k;
    cin>>a>>b>>c>>k;

  int cnt = a;

  if(k<a) cnt -= (a-k);
  if((a+b) < k) cnt -= k-(a+b);

  cout<<cnt<<endl;

 return 0;
 }

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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<int>());
  string ans = "No";
  
  for(int i = 0; i < s.size(); ++i) {
    for(int j = 0; j < t.size(); ++j) {
      if(s[i] < t[j]){
        ans = "Yes";
        break;
      }
    }
  }

int count = 0;
  if(ans == "No" && s.size() < t.size()) {
    ans = "Yes";
    for(int i = 0; i < min(s.size(), t.size()); ++i) {
      if (s[i] != t[i]) {
        ans = "No";
        break;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
//inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

int main()
{
	ll n=rd();int m=rd();
	while(m--) n-=rd();
	printf("%lld\n",max(n,-1ll));
	return 0;
}

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

using namespace std;

const int maxx = 1e5 + 20;

int deg[maxx], n, m, a, b;
bool mark[maxx];

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	mark[0] = true;
	fill(deg, deg + n, 1);
	for(int i = 0; i < m; i++)
	{
		cin >> a >> b;
		a--, b--;
		if (mark[a]) mark[b] = true;
		deg[a]--; deg[b]++;
		if (!deg[a]) mark[a] = false;
	}
	int t = 0;
	for(int i = 0; i < n; i++) if (mark[i]) t++;
	cout << t << '\n';
	return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
using namespace std;
int main() {
	int n,s[200];
	scanf("%d",&n);
	for(int i=0; i<n; i++) {
		scanf("%d",&s[i]);
	}
	int ans=0,flag=1;
	while(flag) {
		for(int i=0; i<n; i++) {
			if(s[i]%2==0){
				s[i]/=2;
			}else{
				flag=0;
				break;
			}
		}
		ans++;
	}
	printf("%d\n",ans-1);
	return 0;
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        v: [(usize1, usize1); m]
    }
    let mut g = vec![0; n];
    for &(a, b) in &v {
        g[a] += 1;
        g[b] += 1;
    }
    println!("{}", if g.iter().all(|&x| x % 2 == 0) {"YES"} else {"NO"});
}


Measured memory_bytes: 6396
#include <cstdio>

int main(){
    int D,N;
    scanf("%d%d",&D,&N);
    if(D == 0){
        if(N < 100){
            printf("%d",N);
        }else{
            printf("%d",N + 1);
        }
    }else if(D == 1){
        if(N < 100){
            printf("%d",100 * N);
        }else{
            printf("%d",100 * N + 100);
        }
    }else if(D == 2){
        if(N < 100){
            printf("%d",100 * 100 * N);
        }else{
            printf("%d",10000 * N + 10000);
        }
    }
    printf("\n");

    return 0;
}

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

int main() {
  
  int N; cin >> N; int ans = 0;
  
  for (int i = 1; i < N + 1; i++) {
    int tmp = 0;
    if (i % 2 == 0) continue;
    else {
      for (int j = 1; j < i + 1; j++) {
        if (i % j == 0) tmp++;
      }
    }
    if (tmp == 8) ans++;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    N, K, Q = map(int, input().split())
    A = [int(input()) for _ in range(Q)]

    cntA = Counter(A)

    ans = []
    for i in range(1, N + 1):
        if K - (Q - cntA[i]) > 0:
            ans.append('Yes')
        else:
            ans.append('No')

    print(*ans, sep='\n')


sol()

Measured memory_bytes: 13436
#include <cstdio>
#include <algorithm>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

using ll = long long;

ll N, K;
std::vector<ll> x, y;

int main()
{
    scanf( "%lld%lld", &N, &K );
    rep( i, N )
    {
      ll tx, ty;
      scanf( "%lld%lld", &tx, &ty );
      x.push_back( tx );
      y.push_back( ty );
    }

    ll ans = 5000000000000000000;

    rep( i, N ) rep( j, N ) rep( k, N ) rep( l, N )
    {
        //[i,j] [k,l]

        ll lx = std::min( x[i], x[j] ), rx = std::max( x[i], x[j] );
        ll ly = std::min( y[k], y[l] ), ry = std::max( y[k], y[l] );

        int cnt = 0;

        rep( i2, N ) if( lx <= x[i2] && x[i2] <= rx && ly <= y[i2] && y[i2] <= ry )
          ++cnt;

        if( cnt >= K )
            ans = std::min( ans, 1ll*(rx-lx)*(ry-ly) );
    }

    printf( "%lld\n", ans );

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  string s[n];
  int t[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> t[i];
  }
  string x;
  cin >> x;
  bool flag = false;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!flag && s[i] == x) {
      flag = true;
    } else if (flag) {
      ans += t[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <math.h>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define K 10000

int A[MAX],C[K+1],B[MAX+1];

void argCout(int A[],int N){
  cout<<A[1];
  for(int i=2;i<N;i++){
    printf(" %d",A[i]);
  }
  cout<<endl;
}

void CountingSort(int n){
  for(int i=0;i<=K;i++){
    C[i]=0;
  }
  for(int i=0;i<n;i++){
    C[A[i]]++;
  }
  for(int i=1;i<=K;i++){
    C[i]=C[i]+C[i-1];
  }
  for(int i=n-1;i>=0;i--){
    B[C[A[i]]]=A[i];
    C[A[i]]--;
  }
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  CountingSort(n);
  argCout(B,n+1);
}



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

int main(){
	vector<int> x1(3);
	vector<int> x2(3);
	vector<int> x3(3);
	cin>>x1[0]>>x1[1]>>x1[2];
	cin>>x2[0]>>x2[1]>>x2[2];
	cin>>x3[0]>>x3[1]>>x3[2];
	
	int a1,a2,a3;
	int b1,b2,b3;
	a1=0;
	b1=x1[0];
	b2=x1[1];
	b3=x1[2];
	a2=x2[0]-b1;
	a3=x3[0]-b1;
	
	if(a2+b2==x2[1]&&a3+b2==x3[1]&&a2+b3==x2[2]&&a3+b3==x3[2]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc;
	boolean[] dp;
	boolean[] primes;
	int[] cost;
	int budget;
	int n;
	
	void isPrime() {
		primes = new boolean[1000001];
		primes[0] = primes[1] = false;
		for(int i=2;i<1000001;i++) primes[i] = true;
		for(int i=2;i<1000001;i++) {
			if(primes[i]) for(int j=2*i;j<1000001;j+=i)
				primes[j] = false;
		}
	}
	
	int solve() {
		int ans = -1;
		for(int i=0;i<budget+1;i++) {
			if(dp[i]) {
				ans = primes[i]? i:ans;
				for(int j=0;j<n;j++) 
					if(i+cost[j] <= budget) dp[i+cost[j]] = true;
			}
		}
		return ans;
	}
	
	void run() {
		sc = new Scanner(System.in);
		isPrime();
		while (true) {
			n = sc.nextInt();
			if(n == 0) break;
			budget = sc.nextInt();
			 cost = new int[n];
			for (int i=0;i<n;i++) cost[i] = sc.nextInt();
			dp = new boolean [budget+1];
			for (int i=0;i<budget+1;i++) dp[i] = false;
			dp[0] = true;
			int ans = solve();
			if(ans <= 0) System.out.println("NA");
			else System.out.println(ans);
			
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17000