akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main () {
    long int a[100000],n,h,b = 0;
    cin >> h >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b += a[i];
    }
   if ( h <= b) {
       cout << "Yes";
   }
   else if (h > b) {
       cout << "No";
   }
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

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

  int N;
  cin >> N;
  vector<int> L(N);
  for(int i = 0; i < N; i++){
    cin >> L[i];
  }

  sort(L.begin(), L.end());

  int sum = 0;
  ll  ans = 0;
  for(int i = 0; i+2 < N; i++){
    for(int j = i+1; j+1 < N; j++){
      sum = L[i] + L[j];
      int itr = lower_bound(L.begin(), L.end(), sum) - L.begin();
      if(itr - 1 > j){
        ans += (itr - 1) - j;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

typedef long long int ll;

int n,b[50];
set<ll> s;

void bin(ll x){
  for(int i=0;i<12;i++){
    printf("%lld",x&1LL);
    x >>= 1;
  }
  putchar('\n');
}

bool rec(int pos,ll bit);

bool serve(int pos,int sum,ll bit,int nxt){
  //printf("%d ",sum);
  //bin(bit);
  if(pos==n)return false;

  ll tmp;
  for(int i=pos;i<n;i++){
    if( !((bit>>i)&1LL)){
      if(b[i]<sum){
	if(serve(i+1,sum-b[i],bit|(1LL<<i),nxt))return true;
      }else if(b[i] == sum){
	if(rec(nxt,bit|(1LL<<i)))return true;
      }
    }
  }
  return false;
}

bool rec(int pos,ll bit){
  if(s.find(bit)!=s.end())return false;
  //bin(bit);
  s.insert(bit);

  if( bit == (1LL<<n)-1 )return true;

  for(int i=pos;i<n;i++){
    if( !((bit>>i)&1LL) )return false;
    if(serve(i+1,b[i],bit,i+1))return true;
  }
  return false;
}

int main(){
  while(scanf("%d",&n),n){
    for(int i=0;i<n;i++)scanf("%d",&b[i]);
    sort(b,b+n,greater<int>());
    s.clear();

    //for(int i=0;i<n;i++)printf("%d ",b[i]);putchar('\n');
    if(rec(0,1LL))puts("YES");
    else puts("NO");
  }
}

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

int qtd[11];

int main()
{
	int a, b, c;
	cin >> a >> b >> c, qtd[a]++, qtd[b]++, qtd[c]++;
	if(qtd[5] == 2 and qtd[7] == 1) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    string s;
    cin >> n >> s;
    vint b(n), w(n);
    int bc = INF;
    if (s[0] == '.') {
        b[0] = 0;
        w[0] = 1;
    }
    else {
        b[0] = 1;
        w[0] = 0;
    }
    srep(i, n, 1) {
        b[i] = b[i-1];
        w[i] = w[i-1];
        if (s[i] == '.') w[i]++;
        else b[i]++;
    }
    int ans = w[n-1];
    rep(i, n) {
        ans = min(ans, b[i] + w[n-1] - w[i]);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2180
#include<stdio.h>

#define N 44
int F[N];

int fibonacci(int n);

main(){
  
  int n,i,sum=0;
  for(i=0;i<N;i++){
    F[i]= 0;
  } 
  
  scanf("%d",&n);
  sum=fibonacci(n);
  
  printf("%d\n",sum);
 
  return 0;
}

int fibonacci(int n)
{
  if (n==0 || n==1){
    return F[n]=1;
  }
  if (F[n]!=0){
    return F[n];
  }
  return F[n]=fibonacci(n-2)+fibonacci(n-1);
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#define PI 3.141592653589
typedef long long ll;
const int MOD = 1000000007;
const int INF = 2002002002;
const int di[] = { -1, 0, 1, 0 };
const int dj[] = { 0, -1, 0, 1 };
using namespace std;

int main() {
	int n;
	cin >> n;
	n %= 10;
	if (n == 3)
		cout << "bon" << endl;
	else if (n == 0 || n == 1 || n == 6 || n == 8)
		cout << "pon" << endl;
	else
		cout << "hon" << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll mod = 1000000007;
const int INF = 1<<29;

int main(){
  int N; cin >> N;
  vector<int> x(N);
  rep(i, N) cin >> x[i];

  int sum = 0;
  rep(i, N) sum += x[i];
  int mean = sum / N;

  int res = 0;
  for (int i = 0; i < N; ++i){
    res += (x[i] - mean) * (x[i] - mean);
  }
  int tmp = 0;
  for (int i = 0; i < N; ++i){
    tmp += (x[i] - (mean + 1)) * (x[i] - (mean + 1));
  }
  res = min(res, tmp);
  cout << res << endl;
}


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

int main(){
    int N,bt,bx,by,t,x,y;
    string str = "Yes";
    cin >> N;

    bt = 0;
    bx = 0;
    by = 0;
    for (int i=0;i<N;i++){
        cin >> t >> x >> y;
        if (!(t-bt-(abs(x-bx)+abs(y-by))>=0 &&
        (t-bt)%2 == (abs(x-bx)+abs(y-by))%2)){
            str = "No";
            break;
        }
        bx = x;
        by = y;
        bt = t;
    }
    
    cout << str << endl;
    }
    //sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});

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

typedef vector<double> vdbl;

void jordan(vector<vdbl> &a){
	int n = a.size();
	for(int i = 0; i < n; ++i){
		int idx = i;
		double piv = abs(a[i][i]);
		for(int j = i + 1; j < n; ++j){
			double p = abs(a[j][i]);
			if(piv < p){
				piv = p;
				idx = j;
			}
		}

		a[i].swap(a[idx]);
		piv = a[i][i];
		for(int j = 0; j <= n; ++j){
			a[i][j] /= piv;
		}

		for(int k = 0; k < n; ++k){
			double d = a[k][i];
			for(int j = 0; j <= n; ++j){
				if(k != i){
					a[k][j] -= d * a[i][j];
				}
			}
		}
	}
}

double check(const vdbl &x, const vdbl &y){
	int n = x.size();
	int d = n - 2;
	vector<vdbl> a(d + 1, vdbl(d + 2));
	for(int i = 0; i <= d; ++i){
		for(int j = 0; j <= d; ++j){
			for(int k = 0; k < n; ++k){
				a[j][i] += pow(x[k], i + j);
			}
		}
	}
	
	for(int j = 0; j <= d; ++j){
		for(int k = 0; k < n; ++k){
			a[j][d + 1] += y[k] * pow(x[k], j);
		}
	}

	jordan(a);

	double eps = -1.0;
	for(int i = 0; i < n; ++i){
		double s = 0.0, t = 1.0;
		for(int j = 0; j <= d; ++j){
			s += a[j][d + 1] * t;
			t *= x[i];
		}
		eps = max(eps, abs(y[i] - s));
	}
	return eps;
}

int solve(const vdbl &v){
	vdbl x(v.size() - 1), y = x;

	double mineps = 1e99;
	int ans = -1;
	for(int i = 0; i < v.size(); ++i){
		int t = 0;
		for(int j = 0; j < v.size(); ++j){
			if(j != i){
				x[t] = (double)j;
				y[t] = v[j];
				++t;
			}
		}

		double eps = check(x, y);
		if(mineps > eps){
			mineps = eps;
			ans = i;
		}
	}
	return ans;
}

int main(){
	int d;
	while(scanf("%d", &d), d){
		vdbl v(d + 3);
		for(int i = 0; i < d + 3; ++i){
			scanf("%lf", &v[i]);
		}

		printf("%d\n", solve(v));
	}
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int& d: a) cin >> d;
	sort(a.begin(), a.end());
	double res = 1.0*(a[0] + a[1])/2;
	for (int i = 2; i < n; ++i) {
		res = (res + a[i])/2;
	}
	cout << fixed << setprecision(10) << res << endl;
	return 0;
}

Measured memory_bytes: 3756
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int x = scanner.nextInt();
    int[] m = new int[110];
    int sum = 0;
    int min = 1001;
    int ans = 0;

    for (int i = 1; i <= n; i++)
      m[i] = scanner.nextInt();

    for (int i = 1; i <= n; i++)
      sum += m[i];

    for (int i = 1; i <= n; i++)
      min = Math.min(min, m[i]);

    ans = n + (x - sum) / min;

    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
from sys import stdin


def main() -> None:
    x, y, z = [int(next_str()) for _ in range(3)]

    ans = (x - z) // (y + z)
    print(ans)


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

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

typedef long long ll;



int main(){

    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int sum = (h2-h1)*60;
    int xx = m2-m1;
    sum +=xx;
    cout<<sum-k<<endl;
    return 0;
}


Measured memory_bytes: 3600
void main() {
	((A, B) => A > B ? "GREATER" : A < B ? "LESS" : "EQUAL")(BigInt(rs), BigInt(rs)).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define s second
#define inf 999999999999
#define N  500009
#define M  (L+R)/2
#define ll long long
#define pb push_back
using namespace std;

ll n,m,i,j,ans,sum,a[N],fix[N],dp[N];
bool ok=true;
int main()
{

	ios::sync_with_stdio(0);
	
	cin>>n;
	
	for(i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]==a[i-1]){
			i--,n--;
		}
	}
	
	dp[0]=1;
	for(i=1;i<=n;i++){
		if(fix[a[i]]>0){
			dp[i]=dp[i-1]+dp[fix[a[i]]];
			dp[i]%=1000000007;
		} else {
			dp[i]=dp[i-1];
		}
		fix[a[i]]=i;
	}
	
	
	cout<<(dp[n])%1000000007<<endl;

return 0;
}






Measured memory_bytes: 9984
# 入力
N, Q = map(int, input().strip().split())
S = input()
l = [0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().strip().split())

# 累積和
cum_sum = [0] * N
for i in range(N):
    if i == 0:
        cum_sum[i] = 0
    elif S[i - 1] == 'A' and S[i] == 'C':
        cum_sum[i] = cum_sum[i - 1] + 1
    else:
        cum_sum[i] = cum_sum[i - 1]

for i in range(Q):
    print(cum_sum[r[i] - 1] - cum_sum[l[i] - 1])


Measured memory_bytes: 14256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main() {
    int n;
    cin>>n;
    ll a[n];
    for (int i=0;i<n;i++) {
        cin>>a[i];
    }
    
    
    ll b[n+1]{};
    for (int i=0;i<n;i++) {
        b[i+1]=(b[i]+a[i])%mod;
    }
    ll ans=0;
    for (int i = 0; i < n - 1; i++) {
        ans+=a[i]*(b[n]-b[i+1]+mod);
        ans%=mod;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 6704
N, K = map(int, input().split())
A = list(map(int, input().split()))

r = [0]*N

now = 0
r[now]=1
for i in range(N):
  now = A[now]-1
  if r[now] == 0:
    r[now] = i+2
  else:
    x1 = r[now]
    x2 = i+1
    break

roop_num = x2 - x1 + 1
x = (K-x1+1) % roop_num

if K < x1:
  print(r.index(K+1)+1)
else:
  print(r.index(x1 + x)+1)


Measured memory_bytes: 32296
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

int main(){
    string s;
    cin >> s;
    if(s.size() > 9 || s.size() < 5){
        cout << "NO" << endl;
    }
    else {
        string t = "AKIHABARA";
        int now = 0;
        rep(i, t.size()){
            if(t[i] != 'A' && t[i] != s[now]){cout << "NO" << endl;return 0;}
            if(t[i] == s[now])now++;
        }
        if(now == s.size())cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <unordered_map>
#include <list>
using namespace std;
const long long int mod1=1000000007;
const long long int mod2 = 998244353;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define FOR(i, a, b) for (int i = (a), _##i = (b); i <= _##i; ++i)
#define FORD(i, a, b) for (int i = (a), _##i = (b); i >= _##i; --i)
#define REP(i, a) for (int i = 0, _##i = (a); i < _##i; ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)
#define pll pair<ll, ll>
#define ln endl
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll lcm(ll a, ll b){
    return (a * b) / gcd(a, b);
 }
ll power1(ll a, ll b){
     ll out = 1;
     while(b){
        if(b & 1){
            out *= a;
        }
        b >>= 1;
        a *= a;
     }
     return out;
}
ll power2(ll a, ll b, ll m){
     a %= m;
     ll out = 1;
     while(b){
        if(b & 1){
            out *= a;
            out %= m;
        }
        b >>= 1;
        a = (a * a) % m;
     }
     return out;
}
ll modi(ll x, ll p){
    return power2(x, mod1 - 2, mod1);
}
int main(){
    fast;
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        long double a, b;
        cin >> a >> b;
        a *= b;
        cout << (ll)a << endl;
    }
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,ans;
  bool ok=false;
  cin>>A>>B;
  for(int i=1;i<100000;i++){
    if((int)(i*1.08)==i+A&&(int)(i*1.1)==i+B){
      cout<<i<<endl;
      ok=true;
      break;
      
    }
  }
  if(!ok){
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4.2")
#include <bits/stdc++.h>

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll n;
	cin >>n;
	
	ll as2 =0;
	for(ll i=1; i*i <= n ; i++){
		// n = mi + i >= i^2, m = (n-i)/i
		if((n-i)%i==0 && (n-i)/i > i){
			as2 += (n-i)/i;
			//cerr<< i <<":"<<(n-i)/i <<", ";
		}
	}
	cout <<as2 <<"\n";
	/*
	ll as3 =0;
	for(ll i=1; i*i<=n ;i++){
		if(n % i ==0){
			ll w = i -1;
			if(w>0 && n % w == n / w) as3 +=w;
			if(i != n/i){ 
				ll w = n/i -1;
				if(w>0 && n % w == n / w) as3 +=w;
			}
		}
	}
	cout << as3 <<"\n";
	*/
	return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');

        int k = int.Parse(str[0]);
        int x = int.Parse(str[1]);

        string ans = "";

        k--;

        for (int i = x - k; i <= x + k; i++)
        {
            ans += i.ToString() + " ";
        }

        Console.Write(ans.TrimEnd());
    }
}

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

using namespace std;

vector<int> A;
int H=0;

void maxHeapify(int idx)
{
    int left=2*idx, right=2*idx+1;
    int largest;
    if(left<=H && A[left]>A[idx]){
        largest=left;
    } else{
        largest=idx;
    }
    if(right<=H && A[right]>A[largest]){
        largest=right;
    }
    if(largest!=idx){
        swap(A[largest], A[idx]);
        maxHeapify(largest);
    }
}

void insert()
{
    int idx=H;
    int parent=idx/2;
    while(parent && A[idx]>A[parent]){
        swap(A[idx], A[parent]);
        idx=parent;
        parent/=2;
    }
}

int main()
{
    A.push_back(-1); // dummy
    while(true){
        char buf[8]; scanf("%s", buf);
        if(*buf=='i'){
            int k; scanf("%d", &k);
            A.push_back(k);
            H++;
            insert();
        } else if(buf[1]=='x'){
            printf("%d\n", A[1]);
            A[1]=A[H];
            H--;
            A.pop_back();
            maxHeapify(1);
        } else{
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 6408
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll dp[3001][3001] = {};

int main()
{
	ll ans = 0;
	int i,j,n;
	string s;
	cin>>n>>s;
	dp[n][1] = 1;
	for(i=n-1; i; i--){
		ll part = 0;
		if(s[i-1] == '>'){
			for(j=1; j<=n-i+1; j++){
				dp[i][j] = part;
				part = (part + dp[i+1][j])%mod;
			}
		}
		else{
			for(j=n-i+1; j; j--){
				dp[i][j] = part;
				part = (part + dp[i+1][j-1])%mod;
			}
		}
	}
	for(i=1; i<=n; i++) ans = (ans + dp[1][i])%mod;
	cout<<ans;
}

Measured memory_bytes: 70016
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;

int main(){

    ll N;
    cin >> N;

    vector<ll > S;
    
    //例外
    if(N == 0){
        cout << 0 << endl;
        return 0;
    }
    while(N != 0){
        //剰余
        //マイナスの剰余はC++ではマイナスになってしまいおかしいので割る数で足す
        ll t = N % 2;
        if(t < 0) t += 2;

        S.push_back(t);
        
        N = N - t;
        N /= -2;
        
    }

    reverse(S.begin(), S.end());

    //結果表示
    for(ll i = 0; i < S.size(); i++){
        cout << S[i];
    }
    cout << endl;

}

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

#pragma warning(disable : 4996)

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
//#define int long long;
signed main() {
  int a;
  string s;
  cin >> a >> s;
  string t;
  stringstream ss;
  int m;
  int c = 0;
  rep(i, 1000) {
    ss << std::setw(3) << std::setfill('0') << i << " ";
  }
  rep(i, 1000) {
    ss >> t;
    m = 0;
    //cout << t << endl;
    rep(j, a) {
      
      if (m == 2 and s[j] == t[2]) {
        m = 3;
      }
      if (m == 1 and s[j] == t[1]) {
        m = 2;
      }
      if (m == 0 and s[j] == t[0]) {
        m = 1;
      }
    }
    if (m == 3) {
      c++;
      //cout << t << endl;
    }
  }
  cout << c;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の
string型配列と同じような感じ） map<int, string> mp; for (auto itr =mp.begin();
itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int K; scanf("%d", &K);

  deque<int> deq;
  deq.push_back(1);
  vector<int> dist(K, INF);
  dist[1] = 1;
  while (not deq.empty()) {
    int u = deq.front(); deq.pop_front();
    int v = (u + 1) % K;
    if (dist[u] + 1 < dist[v]) {
      dist[v] = dist[u] + 1;
      deq.push_back(v);
    }

    int w = (u * 10) % K;
    if (dist[u] < dist[w]) {
      dist[w] = dist[u];
      deq.push_front(w);
    }
  }

  printf("%d\n", dist[0]);
  return 0;
}


Measured memory_bytes: 896
#create date: 2020-04-26 21:06

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    n = len(s)
    now = 0
    m = [0] * 2019
    for i in range(n):
        now = (now + int(s[n-i-1]) * pow(10, i, 2019)) % 2019
        #print(now)
        m[now] += 1
    m[0] += 1
    ans = 0
    for mi in m:
        ans += (mi-1) * mi //2
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9268
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
typedef pair<P,P> PP;
int n,m,INF=1<<29,dxx[4]={-1,0,1,0},dyy[4]={0,-1,0,1};
int dx[8]={-1,-1,0,1,2,2,0,1},dy[8]={0,1,-1,-1,0,1,2,2};
string s[55];
bool check(int x,int y) {return x>=0&&x<n&&y>=0&&y<m;}
bool check(int x,int y,int xx,int yy) {
  if(x>=0&&x<n&&y>=0&&y<m) {
    if(s[x][y]=='*') return 0;
    if(x==xx&&(y==yy||y==yy+1)) return 0;
    if(x==xx+1&&(y==yy||y==yy+1)) return 0;
    return 1;
  }
  return 0;
}

int calc(int sx,int sy,int tx,int ty,int xx,int yy) {
  if(!check(sx,sy,xx,yy)||!check(tx,ty,xx,yy)) return INF;
  int d[n][m];
  for(int i=0;i<n;i++)for(int j=0;j<m;j++) d[i][j]=INF;
  d[sx][sy]=0;
  queue<P> que;
  que.push(P(sx,sy));
  while(!que.empty()) {
    P p=que.front();que.pop();
    for(int i=0; i<4; i++) {
      int x=p.F+dxx[i],y=p.S+dyy[i];
      if(!check(x,y,xx,yy)||d[x][y]<=d[p.F][p.S]+1) continue;
      d[x][y]=d[p.F][p.S]+1;
      que.push(P(x,y));
    }
  }
  return d[tx][ty];
}

int main() {
  while(cin >> n >> m && n) {
    for(int i=0; i<n; i++) cin >> s[i];
    int d[n][m][4];
    for(int i=0;i<n;i++)for(int j=0;j<m;j++)for(int k=0;k<4;k++)d[i][j][k]=INF;
    vector<P> v;
    P p=P(-1,-1);
    for(int i=0;i<n;i++)for(int j=0;j<m;j++) {
        if(s[i][j]=='.')v.push_back(P(i,j));
        if(s[i][j]=='X'&&p.F==-1) p=P(i,j);
      }
    if(p==P(0,0)) {
      cout << 0 << endl;
      continue;
    }
    priority_queue<PP,vector<PP>,greater<PP> > que;
    for(int i=0; i<4; i++) {
      int b[2]={0,1};
      do {
        int cost=calc(v[0].F,v[0].S,p.F+dx[i*2+b[0]],p.S+dy[i*2+b[0]],p.F,p.S);
        cost+=calc(v[1].F,v[1].S,p.F+dx[i*2+b[1]],p.S+dy[i*2+b[1]],p.F,p.S);
        d[p.F][p.S][i]=min(d[p.F][p.S][i],cost);
      } while(next_permutation(b,b+2));
      que.push(PP(P(0,i),p));
    }
    while(!que.empty()) {
      PP pp=que.top();que.pop();
      int x=pp.S.F,y=pp.S.S,k=pp.F.S,c=pp.F.F;
      if(d[x][y][k]<c) continue;
      for(int i=0; i<4; i++) {
        int xx=x+dxx[i],yy=y+dyy[i]; 
        int cost=INF;
        int b[2]={0,1};
        do {
          int sum=calc(x+dx[k*2],y+dy[k*2],x+dx[i*2+b[0]],y+dy[i*2+b[0]],x,y);
          sum+=calc(x+dx[k*2+1],y+dy[k*2+1],x+dx[i*2+b[1]],y+dy[i*2+b[1]],x,y);
          cost=min(cost,sum);
        }while(next_permutation(b,b+2));
        if(!check(xx,yy)||d[xx][yy][(i+2)%4]<=d[x][y][k]+cost+1) continue;
        d[xx][yy][(i+2)%4]=d[x][y][k]+cost+1;
        que.push(PP(P(d[xx][yy][(i+2)%4],(i+2)%4),P(xx,yy)));
      }
    }
    int ans=INF;
    for(int i=0; i<4; i++) ans=min(ans,d[0][0][i]);
    if(ans==INF) ans=-1;
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)

vector<ll> pw2(51,1);
ll high_order_bit(ll n){ll tmp=1,i=-1;while(tmp<=n){tmp*=2;i++;}if(n==0) return 0;else return i;}
vector<ll> binary_expansion(ll n){vector<ll> B(41,0);ll tmp=n;for(ll i=high_order_bit(n);i>=0;i--){B[i]=tmp/pw2[i];tmp%=pw2[i];}return B;}

int main(){
	rep1(i,50) pw2[i]=2*pw2[i-1];

	ll N,K; cin>>N>>K;
	vector<ll> A(N);
    vector<ll> s(N+1,0);
    rep(i,N){
        cin>>A[i];
        s[i+1]=s[i]+A[i];
    }
    
    vector<vector<ll>> vec; 
    rep(i,N)FOR(j,i+1,N+1){
        vector<ll> V=binary_expansion(s[j]-s[i]);
        vec.pb(V);
    }

    vector<vector<ll>> tmp1(vec);//生き残り

    rrep(j,41){
        vector<vector<ll>> tmp2;

        rep(i,sz(tmp1)){
            //bitあればtmp2に入れる
            //Kコ以上残るとtmp2->tmp1
            //残らなければtmp2を空にして桁下げる

            if(tmp1[i][j]==1) tmp2.pb(tmp1[i]);
        }
        if(sz(tmp2)>=K) tmp1=tmp2;

        /*cout<<endl<<"j:"<<j<<endl;
        rep(i,sz(tmp1)){
            rep(k,41) cout<<tmp1[i][k];
            cout<<endl;
        }*/
    }

    ll ans=0;
    rrep(j,41){
        ll tmp=1; 
        rep(i,sz(tmp1)){
            tmp&=tmp1[i][j];
        }
        
        ans+=tmp*pw2[j];
    }

    cout<<ans;
}

Measured memory_bytes: 392104
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S = sys.stdin.readline().rstrip()
A = [ord(c) - ord('a') for c in S]
N = len(S)

# 答えの文字列の長さ
l = 0
# その文字以降で、何文字までの任意文字列を作れるか
lengths = [0] * N
counts = [0] * 26
for i, a in reversed(list(enumerate(A))):
    counts[a] += 1
    lengths[i] = l
    if min(counts) == 1:
        counts = [0] * 26
        l += 1
ans_size = l + 1

# 文字ごとの次のインデックス
graph = [[-1] * 26 for _ in range(N)]
pos = [-1] * 26
for i, a in reversed(list(enumerate(A))):
    graph[i] = pos[:]
    pos[a] = i
initials = pos


def solve(size, i=None):
    # i 番目から始まり、長さ size である、部分列でない文字列
    if i is None:
        pos = initials
    else:
        pos = graph[i]

    if size == 1:
        return chr(pos.index(-1) + ord('a'))

    size -= 1
    for ci, i in enumerate(pos):
        if lengths[i] < size:
            c = chr(ci + ord('a'))
            return c + solve(size, i)
    return ''


print(solve(ans_size))


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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;



//少数点表示
//cout <<std::fixed << std::setprecision(14)

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n;
    cin >>n;
    string s;
    cin >> s;
    int count=0;
    rep(i,n){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            count++;
        }
    }
    cout << count;

}

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

int main(){
  vector<int> a;
  int n;
  cin>>n;
  for(int i=0;i<n;++i){
    int k;
    cin>>k;
    if(i&1)a.insert(a.begin(),k);
    else a.push_back(k);
  }
  if(a.size()&1)reverse(a.begin(),a.end());
  for(int i=0;i<n-1;++i)cout << a[i] << " ";
  cout << a[n-1] << endl;
  return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<tuple<int, int, LL>> a;
    a.reserve(m);
    FOR(i, 0, m)
    {
        int l, r;
        LL c;
        cin >> l >> r >> c;
        a.EB(l, r, c);
    }
    sort(ALL(a));
    set<pair<int, LL>> q;
    q.emplace(1, 0LL);
    for (auto& op : a)
    {
        int l, r, c;
        tie(l, r, c) = op;
        auto cur_it = q.lower_bound(MP(l, -1LL));
        if (cur_it == q.end())
            break;
        LL x = cur_it->S + c;
        auto bigger = q.upper_bound(MP(r, -1LL));
        if (bigger != q.end() && bigger->S <= x)
            continue;
        else
        {
            auto it = q.emplace(r, x).F;
            while (it != q.begin() && it->S <= prev(it)->S)
                q.erase(prev(it));
        }
    }
    auto it = q.lower_bound(MP(n, -1LL));
    if (it == q.end())
        cout << -1 << "\n";
    else
        cout << it->S << "\n";
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int pi, res = 0, pmax = 0;
    for(int i=0;i<N;i++){
        cin >> pi;
        res += pi;
        pmax = max(pmax, pi);
    }
    cout<<(res - pmax/2)<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int a,b;cin>>a>>b;
	cout<<6-a-b;
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 256
def main():
  import math
  N = int(input())
  ans=0
  for i in range(1,N+1):
    for j in range(1, N+1):
      for k in range(1, N+1):
          t=math.gcd(i,j)
          t=math.gcd(t,k)
          ans+=t
        
  print(ans)

if __name__=='__main__':
  main()


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int a, b;
	cin >> a >> b;
	if (a > 9 || b > 9) cout << -1 << endl;
	else cout << a * b << endl;
    
    return 0;
}



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

typedef long long ll;

const ll mod = 10007;
const int inf = 101234567;

ll a[51], p[51];

ll f(ll N, ll X) {
    if (N == 0) {
        if (X <= 0) {
            return 0;
        } else {
            return 1;
        }
    } else if (X <= 1+a[N-1]) {
        return f(N-1, X-1);
    } else {
        return p[N-1] + 1 + f(N-1, X-2-a[N-1]);
    }
}

int main() {
    ll N, X;
    ll ans;
    cin >> N >> X;
    a[0] = 1;
    p[0] = 1;
    for (int i = 1; i < 51; i++) {
        a[i] = a[i-1]*2+3;
        p[i] = p[i-1]*2+1;
    }
    ans = f(N, X);

    cout << ans << endl;
}


Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<list>
using namespace std;


int main()
{
	int num = 0;
	char a[4];
	scanf("%s", a);
	for (int i = 0; i < 4; i++)
	{
		if (a[i] == '+')
			num++;
		else
			num--;
	}
	cout << num << endl;
	return 0;
}

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

int main(){
	int n;cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	for(int i=n-1;0<=i;i=i-2){
		cout<<a[i]<<" ";
		a.erase(a.begin()+i);
	}
	int b=n%2;
	for(int i=0;i<a.size();i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}


Measured memory_bytes: 2944
# coding: utf-8
# Your code here!

def dfs():
    path = 1
    lst_path = []
    lst_path.append((0, path))
    cnt = 0
    while len(lst_path) > 0:
        node, path = lst_path.pop()
        for i in G[node]:
            if not path & (1 << i):
                if path + (1 << i) == -1 + (1 << N):
                    cnt += 1
                    continue
                lst_path.append((i, path + (1 << i)))
    return cnt

N, M = map(int, input().split())
G= [[] for i in range(N)] 
for i in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
    
result = dfs()
print(result)




Measured memory_bytes: 39408
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second 
using ii = pair<int, int>;

#define MAXN 300010
int p[MAXN];
int tam[MAXN];

void init(){
	memset(tam, 0, sizeof tam);
	for(int i=0; i<MAXN; ++i) p[i] = i;
}
int find(int i){
	return p[i]==i ? i : p[i] = find(p[i]);
}
void join(int i, int j){
	int x = find(i), y = find(j);
	if(x!=y){
		if(tam[x]>tam[y]) swap(x, y);
		p[x] = y;
		tam[y]+=tam[x];
	}
}

int main(){
    init();
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    unordered_set<int> st;
    for(int i=0; i<m; ++i){
        int a, b, x;
        cin >> a >> b >> x;
        join(a, b);
    }
    for(int i=1; i<=n; ++i)
        st.insert(find(i));
    int ans = st.size();
    cout << ans << endl;
}   


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

int main() {
  string S;
  cin >> S;
  
  int suzi = 0;
  int ans = 1000;
  for( int i = 0; i < S.size()-2; i++ ){
    string san = S.substr(i, 3);
    suzi = stoi(san);
    if( ans > abs( 753 - suzi ) ){
      ans = abs( 753-suzi );
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;

ll a,b,c;


int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>a>>b>>c;
  ll down = a/(b+c),ao = (a%(b+c));
  if(ao > b) ao = b;  
  cout<<b*down+ao<<endl;  
  return 0;
}


Measured memory_bytes: 256
local read = io.read
local max = math.max
local min = math.min

local max_n = 1000003


local function gcd(x, y)
	if y == 0 then
		return x
	else
		return gcd(y, x % y)
	end
end

local function main()
	local n = read("n")
	local num_t = {}
	for i = 1, max_n do
		num_t[i] = 0
	end
	local z = 0
	for i = 1, n do
		local x = read("n")
		num_t[x] = num_t[x] + 1
		z = gcd(max(z, x), min(z, x))
	end
	if z ~= 1 then
		print("not coprime")
		return
	end

	for i = 2, max_n do
		local cnt = 0
		for j = i, max_n, i do
			cnt = cnt + num_t[j]
		end
		if cnt > 1 then
			print("setwise coprime")
			return
		end
	end
	print("pairwise coprime")
end

main()

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

int main()
{
  int x = 0;
  int n;
  char c;
  cin >> n;
  int max = 0;
  
  for(int i = 1; i <= n; i++)
  {
    cin >> c;
    if(c == 'I')
      x++;
    else
      x--;
    if(x >= max)
      max = x;
  }
  cout << max;
  
  return 0;
}
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
int main()
{
  ll n, m;
  cin >> n >> m;
  ll h[n];
  Graph G(n+100);

  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  for (int i = 0; i < m; i++)
  {
    ll a, b;
    cin >> a >> b;
    G[a-1].push_back(b-1);  //1indexed
    G[b-1].push_back(a-1);
  }

  ll ans = 0;
  for (int i = 0; i < n; i++)
  {
    ll temp = h[i];
    bool flag = false;
    for (int j = 0; j < G[i].size(); j++)
    {  int index = G[i][j];
      if (h[index] >= h[i])
      {
        temp = h[index];
        flag = true;
      }
    }

      if (temp == h[i] && flag == false)
      {
        // cout << i << "th" << endl;
        ans++;
      }
  
  }

  cout << ans << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int h,w,mt[2000][2000],my[2000][2000],ans;
string s;

signed main() {
    cin >> h >> w;
    rep(i,h) {
        cin >> s;
        rep(j,w) {
            if (s[j] == '#') mt[i][j] = my[i][j] = -1;
            else mt[i][j] = my[i][j] = 1;
        }
    }
    rep(i,h) {
        rep(j,w-1) {
            if (mt[i][j] != -1 && mt[i][j+1] != -1) mt[i][j+1] += mt[i][j];
        }
    }
    rep(i,h) {
        repm(j,w-1) {
            if (mt[i][j+1] > 0 && mt[i][j] > 0) mt[i][j] = mt[i][j+1];
        }
    }
    rep(i,w) {
        rep(j,h-1) {
            if (my[j][i] != -1 && my[j+1][i] != -1) my[j+1][i] += my[j][i];
        }
    }
    rep(i,w) {
        repm(j,h-1) {
            if (my[j+1][i] > 0 && my[j][i] > 0) my[j][i] = my[j+1][i];
        }
    }
    rep(i,h) rep(j,w) ans = max(ans,mt[i][j]+my[i][j]-1);
    cout << ans << endl;
}




Measured memory_bytes: 62720
require 'matrix'

ROTATE_60 = Matrix[
  [1.0/2.0, -Math.sqrt(3)/2.0], 
  [Math.sqrt(3)/2.0, 1.0/2.0]
]

def rotate60(vec)
  ROTATE_60 * vec
end

def koch(vec1, vec2)
  vec1_2 = vec2 - vec1
  vec_p1 = vec1 + vec1_2 * (1.0/3.0)
  vec_p3 = vec1 + vec1_2 * (2.0/3.0)

  vec_p3_p1 = vec_p3 - vec_p1
  vec_p2 = vec_p1 + rotate60(vec_p3_p1)

  return [vec1, vec_p1, vec_p2, vec_p3, vec2]
end

n = gets.chomp.to_i
vec1 = Vector[0.0, 0.0]
vec2 = Vector[100.0, 0.0]
points = [vec1, vec2]

(n).times do 
  new_points = []
  points.each_with_index do |point, i|
    if (i >= 1) then
      new_points << koch(points[i-1], points[i])
    end
  end
  new_points.flatten!.uniq!
  points = new_points
end

points.each do |point|
  puts "#{point[0]} #{point[1]}"
end

Measured memory_bytes: 7196
#include <stdio.h>

int main(){
	int h,w;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0){break;}
		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				printf("%c",((i+j)%2==0)?'#':'.');
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<int(b);i++)
#define rep(i,n) REP(i,0,n)

int to_minutes(int x) {
  return x/100*60 + x%100;
}

int main() {
  
  int N, P, Q;
  while(cin >> N >> P >> Q && (N|P|Q)) {
    P = to_minutes(P), Q = to_minutes(Q);
    Q -= P;
    int TL[Q+1]; memset(TL, 0, sizeof TL);
    rep(_, N) {
      int K; cin >> K;
      rep(__, K) {
        int a, b; cin >> a >> b;
        a = to_minutes(a), b = to_minutes(b);
        a -= P, b -= P;
        REP(i, a, b) {
          TL[i] ++;
        }
      }
    }
    /*
    rep(i, Q) {
      cout << TL[i] << " ";
    }
    cout << endl;
    */
    int counter = 0;
    int ans = 0;
    rep(i, Q) {
      if(TL[i] == N) {
        ans = max(ans, counter);
        counter = 0;
      }
      else {
        counter ++;
        ans = max(ans, counter);
      }
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;int a,b,c;
  a=count(s.cbegin(),s.cend(),'0');
  b=count(s.cbegin(),s.cend(),'1');
  c=s.size();
  cout<<c-abs(a-b)<<endl;
}


Measured memory_bytes: 512
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, i = 0, j = 0, ans = 0;
    cin >> n;
    vector<ll> a(n);
    for (ll &e : a)
        cin >> e;
    sort(a.begin(), a.end(), greater<ll>());
    for (i = 0, j = 0; i < n && j < n; i++, j += 2)
        ans += 2 * a[i];
    ans -= a[0];
    if (n % 2)
        ans -= a[i - 1];
    cout << ans;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

    std::vector<int> l(N), r(N);
    for (int i = 0; i < N; i++) {
        std::cin >> l[i] >> r[i];
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += (r[i] - l[i]) + 1;
    }

    std::cout << ans << std::endl;
    return 0;
}

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

using namespace std;

int limit = 1e6 ;
double ar[(int) 1e6 + 20];

int main(){
	string str;
	cin >> str;
	int ans = 0;
	for(int i = 0; i < str.size(); i++){
		ans += str[i] - '0';
	}
	if(ans % 9 == 0){
		cout << "Yes" << "\n";
	}
	else{
		cout  << "No" << endl;
	}
}


Measured memory_bytes: 3752
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long q,n,i,sum=0,b,c,x;
    map<long long,long long> mp;
    cin>>n;
    long long arr[n];
    for(i=0;i<n;i++){cin>>x;sum+=x;mp[x]++;}
    cin>>q;
    for(i=0;i<q;i++)
    {
        cin>>b>>c;
        sum+=mp[b]*c;
        sum-=mp[b]*b;
        mp[c]+=mp[b];
        mp[b]=0;
        cout<<sum<<"\n";
    }
    return 0;
}


Measured memory_bytes: 9488
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a>>s;
  ll cnt=0;
  for(int i=0;i<a;i++){
    if(s[i]=='R')cnt++;
  }
  if(cnt > s.size()-cnt)
  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256