akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int A, B, M;
    int x[100000];
    int y[100000];
    int c[100000];
    int i, j, s;
    int min = 100;

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> A >> B >> M;

    vector<int> a(A);
    vector<int> b(B);

    for(i=0; i<A; i++) {
        cin >> a[i];
    }
    for(i=0; i<B; i++) {
        cin >> b[i];
    }
    for(i=0; i<M; i++) {
        cin >> x[i] >> y[i] >> c[i];
    }

    int amin, bmin;

    amin = *min_element(a.begin(), a.end());
    bmin = *min_element(b.begin(), b.end());

    min = amin + bmin;

    for(i=0; i<M; i++) {
        s = a[x[i]-1] + b[y[i]-1] - c[i];
        if (s < min) {
            min = s;
        }
    }
     cout << min;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

vector<int> g[100005];
int z[100005];

void dfs(int x, int p) {
    for (int i : g[x]) if (i != p && !z[i]) {
        z[i] = 1;
        dfs(i, x);
    }
}

int main() {
    ios::sync_with_stdio(false);
    int n, m, u, v, w, y = 0;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) cin >> u >> v >> w, w %= 2, g[u].push_back(v), g[v].push_back(u);
    for (int i = 1; i <= n; i++) if (!z[i]) z[i] = 1, dfs(i, i), y++;
    cout << y;
}


Measured memory_bytes: 10752
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}



int main(void){
   
long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,sum2,min,f,c,r,o,sum1,sum=0,y,a,b,count1=0,a2,b2, k;
scanf("%lld%lld",&n,&k);
count=0;
for(i=0;i<n;i++){
    scanf("%lld",&a);
    if(a>=k){
        count++;
    }
}
printf("%lld",count);
return 0;
}


Measured memory_bytes: 128
A['   '];
B, X, Y;
W, J, I;
main(M) {
  scanf("%d%d", &I, &M);
  for (; ~scanf("%d%d", &X, &Y);) {
    for (B = Y + 1, J = 1; J * J <= M; J++)
      I = (X + J - 1) / J, W = Y / J + 1, A[I]++, A[W < B ? W : B]--, B = I;
    for (I = 1; I < B; I++)
      (X - 1) / I < Y / I ? A[I]++, A[I + 1]-- : 0;
  }
  for (I = 1; I <= M; I++)
    A[I] += A[I - 1], printf("%d\n", A[I]);
}

Measured memory_bytes: 1280
#include<iostream>
#include<queue>
#include<vector>
#include<utility>
#include<functional>

using namespace std;

typedef pair<int, int> P;

struct State {
	int enemy, town, cost;
	State(int _enemy, int _town, int _cost) {
		enemy = _enemy;
		town = _town;
		cost = _cost;
	}
};

struct Road {
	int to, cost, enemy;
	Road(int _to, int _cost, int _enemy) {
		to = _to;
		cost = _cost;
		enemy = _enemy;
	}
};

int N, M, L;
vector<Road> road[100];

int dijkstra() {
	vector<vector<int>>d(100, vector<int>(101, 1000000000));
	auto comp = [](const State& s1, const State& s2) {return s1.enemy > s2.enemy; };
	priority_queue<State, vector<State>, decltype(comp)> q(comp);
	d[0][0] = 0;
	q.push(State(0, 0, 0));
	while (!q.empty()) {
		State s = q.top(); q.pop();
		if (s.town == N - 1)return s.enemy;
		if (d[s.town][s.cost] < s.enemy)continue;
		for (int i = 0; i < road[s.town].size(); i++) {
			Road r = road[s.town][i];
			if (d[r.to][s.cost] > d[s.town][s.cost] + r.enemy) {
				d[r.to][s.cost] = d[s.town][s.cost] + r.enemy;
				q.push(State(d[r.to][s.cost], r.to, s.cost));
			}
			if (r.cost + s.cost > L)continue;
			if (d[r.to][s.cost + r.cost] > d[s.town][s.cost]) {
				d[r.to][s.cost + r.cost] = d[s.town][s.cost];
				q.push(State(d[r.to][s.cost + r.cost], r.to, s.cost + r.cost));
			}
		}
	}
}

int main() {
	while (cin >> N >> M >> L, N) {
		for (int i = 0; i < M; i++) {
			int a, b, d, e;
			cin >> a >> b >> d >> e;
			road[a - 1].push_back(Road(b - 1, d, e));
			road[b - 1].push_back(Road(a - 1, d, e));
		}
		cout << dijkstra() << endl;
		for (int i = 0; i < 100; i++) {
			road[i].clear();
		}
	}
}

Measured memory_bytes: 3300
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;

using namespace std;

int main() 
{
    string s;
    cin >> s;
    if((s[0] == s[1] && s[1] == s[2]) ||
       (s[1] == s[2] && s[2] == s[3])   ) { 
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}
    



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

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int xa = min(k,a);
  k -= xa;
  int xb = min(k,b);
  k -= xb;
  int xc = k;
  cout << xa -xc << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <stdio.h>

using namespace std;

struct Card{
	char suit;
	int value;
}; 

void BubbleSort(struct Card A[],int N){
	bool flag = true;
	for(int i = 0;flag;i++){
		flag = false;
		for(int j = N-1; j>=i+1;j--){
			if(A[j].value < A[j-1].value){
				Card t = A[j];
				A[j] = A[j-1];
				A[j-1] = t;
				flag = true;	
			}
		}
	}
}

void SelectionSort(struct Card A[],int N){
	int minj;
	for(int i = 0; i<N;i++){
		minj = i;
		for(int j = i+1; j<N;j++){
			if(A[j].value < A[minj].value){
				minj = j;
			}
		}
		Card t = A[i];
		A[i] = A[minj];
		A[minj] = t;
	}
}

void trace(struct Card A[],int N){
	for(int i = 0; i<N;i++){
		if(i) printf(" ");
		cout << A[i].suit<< A[i].value;
	}
	printf("\n");
}

bool isStable(struct Card C1[], struct Card C2[],int N){
	bool flag = true;
	for(int i = 0; i<N;i++){
		if(C1[i].value==C2[i].value&&C1[i].suit!=C2[i].suit){
			flag = false;
		}
	}
	return flag;
}

int main(){
	int N;
	bool flag = true;
	Card C1[100],C2[100];
	cin >> N;
	for(int i = 0; i<N;i++){
		cin >> C1[i].suit >> C1[i].value;
	}
	for(int i = 0; i<N;i++){
		C2[i] = C1[i];
	}
	BubbleSort(C1,N);
	SelectionSort(C2,N);
	flag = isStable(C1,C2,N);
	trace(C1,N);
	printf("Stable\n");
	trace(C2,N);
	if(flag){
		printf("Stable\n");
	}
	else{
		printf("Not stable\n");
	}
	
	return 0;
}


Measured memory_bytes: 3112
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(" ");
		double N = double.Parse(input[0]);
		double D = double.Parse(input[1]);
		double counter = 0;

		//出力
		for(int count=0;count<N;count++)
		{
			string[] inputi = Console.ReadLine().Split(" ");
			double xi = double.Parse(inputi[0]);
			double yi = double.Parse(inputi[1]);
			if (Math.Sqrt(Math.Pow(xi, 2) + Math.Pow(yi, 2)) <= D)
			{
				counter++;
			}
		}
		Console.WriteLine(counter);
		
	}
}


Measured memory_bytes: 40844
#include<bits/stdc++.h>
using namespace std;
int main()
{
  bool N=0,S=0,E=0,W=0;
  string A;
  cin >> A;
  for(int i=0;i<A.size();i++)
  {
    char b=A.at(i);
    if(b=='N')N=1;
    else if(b=='S')S=1;
    else if(b=='E')E=1;
    else if(b=='W')W=1;
  }
  if(N==S&&E==W)cout << "Yes" << endl;
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// JavaProgram.cpp
// Author : Priydarshi Singh (@dryairship)
// One cat just leads to another. One bug leads to two others.

#include <bits/stdc++.h>
using namespace std;

// I like my types defined.
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
typedef map<int, int>       mii;

// Traditional science is all about finding "hashtag define"s.
#define fr(i, n)            for(int i=0; i<(n); ++i)
#define frC(i, n, c)        for(int i=0; (i<(n)) && (c); ++i)
#define frA(i, a, n)        for(int i=a; i<=(n); ++i)
#define frD(i, a, n)        for(int i=a; i>=(n); --i)
#define fill(a)             memset(a, 0, sizeof(a))
#define fill1(a)            memset(a, -1, sizeof(a))
#define revsort(a, b)       sort(a, b, greater<int>())
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define dout                if(DEBUGGING) cout
#define dbg                 if(DEBUGGING) 
#define endl                "\n"

// When you realize MOD > INF...
int DEBUGGING    =          0;
const int INF    =          1000000000;
const int MOD    =          1000000007;
const ll LINF    =          1e18;
const double PI  =          3.1415926535897932;
const double EPS =          1e-7;

// I'D SPAM. Hehe.
ll gcdEx                    (ll a, ll b, ll *x, ll *y){if(!a){*x=0;*y=1;return b;} 
ll x1,y1,gcd=gcdEx          (b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
ll modI(ll b, ll m)         {ll x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
ll modD(ll a, ll b)         {return (modI(b,MOD)*(a%MOD))%MOD;}
ll modS(ll a, ll b)         {return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;} y=y>>1; x=(x*x)%MOD;} return r;}
ll modA(ll a, ll b)         {return ((a%MOD)+(b%MOD))%MOD;}
ll modM(ll a, ll b)         {return ((a%MOD)*(b%MOD))%MOD;}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(int TEST_CASE){
    int n,k;
    cin >> n >> k;
    int a[n];
    fill(a);
    int d, t;
    fr(i,k){
        cin >> d;
        fr(j,d){
            cin >> t;
            a[t-1]=1;
        }
    }
    int c=0;
    fr(i,n){
        if(!a[i]) c++;
    }
    cout << c;
}

int main(int argc, char* argv[]){
    if(argc==2 && argv[1][1]=='v') DEBUGGING = 1;
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int nTestCases=1;
    //cin >> nTestCases;
    frA(i,1,nTestCases) solve(i);
    return 0;
}

Measured memory_bytes: 3648
function main()
    n = parse(Int, readline())
    a = parse.(Int, split(readline()))
    q = parse(Int, readline())
    d = Dict{Int, Int}()
    for i in 1:n
        if haskey(d, a[i])
            d[a[i]] += 1
        else
            d[a[i]] = 1
        end
    end
    ans = sum(a)

    for i in 1:q
        b, c = parse.(Int, split(readline()))
        num = 0
        if haskey(d, b)
            num = d[b]
        end
        ans -= b * num 
        ans += c * num 
        delete!(d, b)
        if haskey(d, c)
            d[c] += num
        else
            d[c] = num
        end
        println(ans)
    end
end

main()

Measured memory_bytes: 215724
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<stw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;

int main(void){
    int N;cin>>N;
    if(N%2==1){
        cout << N/2+1 << endl;
    }else{
        cout << N/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    cout<<fixed<<setprecision(5);
    int a,b;
    cin>>a>>b;
    cout<<a/b<<" "<<a%b<<" "<<(double)a/b<<endl;

    return 0;

}



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

int main() {

int n;
cin >> n;
int ans=0;
  rep(N,n+1)
  {  int divisornum=0;
    //Nの約数を数えるプログラム
    for (size_t i = 1; i*i <= N; i++)
    {
      if(N%i==0)
      {divisornum++;
       if(N/i!=i)
       {divisornum++;}
      }
      
      
    }
    

    if(divisornum==8&&N%2!=0)
    ans++;
  }

printf("%d\n",ans);
return 0;

}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

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

int main(){
  int n;
  int ans;
  cin >> n;
  if(n%1000==0){
    cout << 0;
  }else{
    cout << 1000-n%1000 << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true) cerr

template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << "(" << p.first << ", " << p.second << ")";
    return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print(const ContainerType<ValueType, Args...> &c)
{
    for (const auto &v : c)
        cout << v << ' ';
    cout << '\n';
}

void print() { cout << '\n'; }
template <typename T, typename... Args>
void print(T a, Args... args)
{
    cout << a << " ";
    print(args...);
}

lli llipower(lli x, lli y, lli p = LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}

//---------------------------------------------------------------------------------


int main(){
    lli n;
    cin>>n;
    lli ans=0;
    lli orign=n;
    set<lli> div;
    for(lli i=2;i*i<=orign;i++){
    //    cout<<i<<endl;
        if(orign%i==0){
            div.insert(i);
            if(i!=orign/i)
                div.insert(orign/i);
            
        }

    }
    for(lli i:div){
        if(n%i==0){
            lli d = i;
            while (n % d == 0)
            {
               // print(d);
                n /= d;
                d *= i;
                ans++;
            }
            while(n%i==0) n/=i;
        }
    }
    if(orign==1) cout<<0<<endl;
    else cout<<max(ans,1LL)<<endl;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[111];
int l[1];
int j[1];

long long x,y,z,mod=1000000007;
string r;
//char r[111];

P u[1];
queue<int> q;

stack<int> s;
map<int,int> p;
vector<int> v;

bool as(P a,P b)
{
  if(a.x==b.x)
  return a.y<b.y;
  return a.x<b.x;
}

int f(int n,int m)
{
  if(n<m) return 1;
  return f(n/m,m)+1;
}

int main()
{
  scanf("%d",&a);
  for(int t=1;t<=a;t++)
    scanf("%d",&o[t]);
  k=mod;
  for(int t=1;t<=100;t++)
  {
    e=0;
    for(int w=1;w<=a;w++)
      e+=(o[w]-t)*(o[w]-t);
    k=min(k,e);
  }
  printf("%d",k);
}





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


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(10)<<fixed;
	
	int s,w;
	cin>>s>>w;
	if(w>=s)
		cout<<"unsafe"<<endl;
	else
		cout<<"safe"<<endl;
	return 0;
}

Measured memory_bytes: 3692
#include<iostream>
using namespace std;
int main()
{
	int i,j,k;
	int j_1,k_1;
	int max=0;
	int height[10];
	int temp_1;
	int height_2[10];
	
	for(int a=0;a<10;a++)
		cin>>height[a];
		
	for(int a=0;a<10;a++)
		height_2[a]=height[a];
	for(int a=0;a<10;a++)
	{
		if(height[a]>=max)
			{
				max=height[a];
		        k=max;
				k_1=a;
			
		}
	
	}
	max=0;
	for(int a=0;a<10;a++)
	{
		if(a==k_1)
		{
			temp_1=height[a];
			height[a]=0;
		}
		if(height[a]>=max)
			{
				max=height[a];
		        j=max;
				j_1=a;
				
		}
		height[a]=temp_1;
		
	}
	max=0;
	for(int a=0;a<10;a++)
	{
		if(a==j_1)
		{
			height_2[a]=0;
		}
		if(a==k_1)
			{
				height_2[a]=0;
		    }
		if(height_2[a]>=max)
			{
				max=height_2[a];
		 	}
	}
	cout<<k<<endl<<j<<endl<<max<<endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 10000;

int main() {
	int n, m;
	cin >> n >> m;
	int a[9];
	rep(i, m) cin >> a[i];
	sort(a, a + m, greater<int>());

	int f[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	int dp[N + 1];
	dp[0] = 0;
	rep1(i, n) dp[i] = -1;
	rep1(i, n) {
		rep(j, m) {
			if(i >= f[a[j]]) {
				dp[i] = max(dp[i], dp[i - f[a[j]]] + 1);
			}
		}
	}

	string ans;
	int match = n;
	int remain = dp[n];
	while(match > 0) {
		rep(j, m) {
			if(match >= f[a[j]] && remain == dp[match - f[a[j]]] + 1) {
				ans += (char)(a[j] + '0');
				match -= f[a[j]];
				remain--;
				break;
			}
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 1010
#define inf 1000000007
using namespace std;
typedef long long ll;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,p1,p2,p3,p4,s,t;
int head[maxn*2],nxt[maxn*20],to[maxn*20],c[maxn*20],v[maxn*20],tot=1;
void add(int x,int y,int z,int u)
{
    ++tot;
    nxt[tot]=head[x];
    head[x]=tot;
    to[tot]=y;
    c[tot]=z;
    v[tot]=u;
}
void addx(int x,int y,int z,int u)
{
    add(x,y,z,u);
    add(y,x,0,-u);
}
ll ans;
ll dis[maxn*2];
int pre[maxn*2],pre_num[maxn*2],vis[maxn*2];
queue<int>q;
int spfa()
{
    for(int i=1;i<=t;i++)  dis[i]=-1e16;
    q.push(s);dis[s]=0;vis[s]=1;
    while(q.size())
    {
        int now=q.front();q.pop();vis[now]=0;
        for(int i=head[now];i;i=nxt[i])
        {
            if(dis[to[i]]<dis[now]+v[i]&&c[i])
            {
                dis[to[i]]=dis[now]+v[i];
                pre[to[i]]=now;
                pre_num[to[i]]=i;
                if(!vis[to[i]])  q.push(to[i]),vis[to[i]]=1;
            }
        }
    }
    if(dis[t]==-1e16)  return 0;
    int di=inf;
    for(int i=t;i!=s;i=pre[i])  di=min(di,c[pre_num[i]]);
    for(int i=t;i!=s;i=pre[i])  c[pre_num[i]]-=di,c[pre_num[i]^1]+=di;
    ans+=dis[t]*di;
    return di;
}
int main()
{
    n=read();p1=2*n+1;p2=p1+1;p3=p2+1;p4=p3+1;s=p4+1;t=s+1;
    for(int i=1;i<=n;i++)
    {
        int x=read(),y=read(),z=read();
        addx(s,i,z,0);
        addx(i,p1,inf,x+y);
        addx(i,p2,inf,x-y);
        addx(i,p3,inf,-x+y);
        addx(i,p4,inf,-x-y);
    }
    for(int i=1;i<=n;i++)
    {
        int x=read(),y=read(),z=read();
        addx(i+n,t,z,0);
        addx(p1,i+n,inf,-x-y);
        addx(p2,i+n,inf,-x+y);
        addx(p3,i+n,inf,x-y);
        addx(p4,i+n,inf,x+y);
    }
    while(spfa()){};
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 640
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		long max = Long.MIN_VALUE;
		int A[] = new int[N];
		int C[] = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt() - 1;
		}
		for (int i = 0; i < N; i++) {
			C[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			int count = 0;
			long cost = 0;
			int now = A[i];
			Set<Integer> set = new HashSet<Integer> ();
			for (; count < N && count < K; count++) {
				if (set.contains(now)) {
					break;
				}
				set.add(now);
				cost += C[now];
				now = A[now];
				if (cost > max) {
					max = cost;
				}
			}
			if (count <K) {
				int roop = count ;
				if (cost>0) {
					if (K%roop!=0) {
						cost = cost *(K/roop);
						if (cost > max) {
							max = cost;
						}
						for (int j=0;j<K%roop;j++) {
							cost += C[now];
							now = A[now];
							if (cost > max) {
								max = cost;
							}
						}
					} else {
						cost = cost *(K/roop-1);
						if (cost > max) {
							max = cost;
						}
						for (int j=0;j<roop;j++) {
							cost += C[now];
							now = A[now];
							if (cost > max) {
								max = cost;
							}
						}
					}

				}
			}
		}
		System.out.println(max);
	}
}


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

typedef long long int ll;
void solved(){
	ll a,b,n;cin>>a>>b>>n;
	ll c = min(n,b - 1);
	cout<<(a*c/b)-a*(c/b)<<endl;
}
int main(){
	solved();
	return 0;
} 

Measured memory_bytes: 3564
#include <iostream>
#include <iomanip>
using namespace std;
double dp[1500][3000];
double prob[2999];
int main()
{
    long long n;
    cin>>n;

    for(int i=0;i<n;i++)
    {
        cin>>prob[i];
    }
    dp[0][0]=1-prob[0];
    dp[0][1]=prob[0];
    for(int i=0;i<(n+1)/2-1;i++)
    {
        //cout<<i<<endl;

        for(int j=0;j<=i*2+1;j++)
        {
            dp[i+1][j+2]+=(dp[i][j]*prob[i*2+1]*prob[i*2+2]);
            dp[i+1][j+1]+=(dp[i][j]*prob[i*2+1]*(1-prob[i*2+2])+dp[i][j]*(1-prob[i*2+1])*prob[i*2+2]);
            dp[i+1][j]+=(dp[i][j]*(1-prob[i*2+1])*(1-prob[i*2+2]));
        }

    }
    double ans=0;
    for(int j=(n+1)/2;j<=n;j++)
    {
        //cout<<dp[(n+1)/2-1][j]<<" "<<j<<endl;
        ans+=dp[(n+1)/2-1][j];
    }
    cout<<setprecision(9)<<ans<<endl;
}

Measured memory_bytes: 33792
import sys
input=sys.stdin.readline
n=int(input())
k=[]
for _ in range(n):
    s,t=input().split()
    s.rstrip()
    t=int(t)
    k.append((s,t))
x=input().rstrip()
ans=0
for i in k:
    ans+=i[1]
    if i[0]==x:
        break
s=0
for i in k:
    s+=i[1]
print(s-ans)


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

int main(){
  int N;
  cin >> N;
  vector<long long> T(N);
  for(int i=0; i<N; i++) cin >> T.at(i);
  long long LCM = T.at(0);
  for(int i=1; i<N; i++){
    long long A, B;
    A = max(T.at(i), LCM);
    B = min(T.at(i), LCM);
    long long R = A%B;
    while(R>0){
      A = B;
      B = R;
      R = A%B;
    }
    LCM = LCM/B*T.at(i);
  }
  
  cout << LCM << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 131072;
long long int getv(long long int *idx, int a, int b)
{
    a += MAXN; b += MAXN;
    long long ans = 0;
    while(a<=b)
    {
        if(a%2==1) ans += idx[a++];
        if(b%2==0) ans += idx[b--];
        a /= 2; b /= 2;
    }
    return ans;
}
void setv(long long int *idx, int a, int v)
{
    a += MAXN; idx[a] = v;
    while(a = a/2)
    {
        idx[a] = idx[2*a] + idx[2*a+1];
    }
}
long long int sumtree[2*MAXN], counttree[2*MAXN];
int N; int arr[MAXN]; int ni[MAXN];
long long int ans[MAXN];
int main()
{
    
    scanf("%d", &N);
    int pi = 0; 
    for(int i=1; i<=N; ++i)
    {
        scanf("%d", arr+i);
        if(arr[pi] < arr[i])
        {
            ni[pi] = i;
            pi = i;
        }
        
    }
    vector<pair<int, int> > V;
    for(int i=0; i<=N; ++i) V.emplace_back(arr[i], i);
    sort(V.rbegin(), V.rend());
    long long ss = 0;
    for(auto x: V)
    {
        if(ni[x.second])
        {
            long long v1 = getv(sumtree, x.second, N);
            long long v2 = getv(counttree, x.second, N);
            ans[ni[x.second]] = v1 - v2 * x.first - ss;
            ss = v1 - v2 * x.first;
        }
        setv(sumtree, x.second, x.first);
        setv(counttree, x.second, 1);
    }
    for(int i=1; i<=N; ++i) printf("%lld\n", ans[i]);
    return 0;
} 




















Measured memory_bytes: 7668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int a,b,c,x,ans;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>x;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                int temp = 500*i + 100*j + 50*k;
                if(temp==x)ans++;
            }
        }
    }
    cout<<ans<<newl;
}


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

int main() {
  
  int a, b;
  char c;
  cin >> a >> c >> b;
  
  if (c == '+'){
    cout << a + b << endl;
  }
  else if (c == '-'){
    cout << a - b << endl;
  }

 }

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

using namespace std;

int main()
{
	int n;
	scanf("%d",&n);
	long long res=0;
	int lim=floor(sqrt(n));
	for(int i=1;i<=lim;i++)
	{
		res+=i*i;
		int d=n/i;
		for(int j=i+1;j<=d;j++)
			res+=2*i*j;
	}
	printf("%lld\n",res);
}

Measured memory_bytes: 3716
while True:
  n = int(input())
  if n == 0:
    break
  ascore = 0
  bscore = 0
  for i in range(n):
    a,b = list(map(int,input().split()))
    if a < b:
      bscore += a + b
    elif a > b:
      ascore += a + b
    elif a == b:
      ascore += a
      bscore += b
  print(f"{ascore} {bscore}") 


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

int main() {
    
      long long n,i,k,j,sum=0,count=0,ans=0,m,w,mx=0,l,r,x,y;
      cin>>n>>k>>x;
      cout<<x<<" "<<n<<" "<<k;      
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
inline int in(){ int x; scanf("%d",&x); return x;}

int main(){
  int i,j,k;
  string s;
  int res = 0;

  while(cin >> s){
    string r(s.rbegin(),s.rend());
    if(s == r) res++;
  }
  printf("%d\n",res);


  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;


int m[10][10];
int n;
int x,y;

void foo(int a,int b){
	if(a<0||a>7||b<0||b>7) return;
	if(m[a][b]==1){
		m[a][b]=0;
		rep(i,3){
			foo(a+i+1,b);
			foo(a,b+i+1);
			foo(a-i-1,b);
			foo(a,b-i-1);
		}
	}
}

int main(){
	cin>>n;
	rep(l,n){
		rep(i,8){
			rep(j,8){
				char t;
				cin>>t;
				m[i][j]=t-'0';
			}
		}
		cin>>x>>y;
		x--;
		y--;
		foo(y,x);
		cout<<"Data "<<l+1<<":"<<endl;
		rep(i,8){
			rep(j,8){
				cout<<m[i][j];
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul  unsigned long long int
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod
//ll divide(ll a, ll b)  //euler's theorem(a/b)%mod
//{
//   return a*power(b,mod-2)%mod;  //only when mod is prime
//}

ll power(ll x, ll y)
{
    ll res = 1;
   while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
int main()
{
    speed;
    int t;
    cin>>t;
    cout<<t*t<<'\n';


	return 0;
}


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

using namespace std;

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

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

int cnt = 0;


void solve()
{
	string s; cin >> s;
	int n = s.length();
	int i = 0, j = n - 1, cnt0 = 0, cnt1 = 0;
	for (int k = i; k <= j; ++k)
	{
		if (s[k] == '0') cnt0++;
		else cnt1++;
	}
	cout << 2 * min(cnt0, cnt1);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 3760
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  string s;
  cin >> s;
  
  if (s.length() == 1)
    cout << s << endl;
  else {
    cout << s[0] << s.length()-2 << s[s.length()-1] << endl;
  }
  
  
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in();
	auto A=vecin(N);

	int Q=in();
	REP(i,Q){
		auto res = lower_bound(ALL(A),in());
		out(distance(A.begin(),res));
	}
	return 0;
}


Measured memory_bytes: 3344
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n;
	cin >> n;
	ll sum = 0;
	vector<ll> a(n);
	for(int i = 0;i < n;i++){
		cin >> a[i];
		sum += a[i];
		sum %= MOD;
	}

	ll ans = 0;
	for(int i = 0;i < n-1;i++){
		sum = (sum - a[i] + MOD) % MOD;
		ans += (a[i] * sum) % MOD;
		ans %= MOD;
	}

	cout << ans << endl;
}


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

int main(){
  
  //N,Mが10以下なので全探索でも間に合う
  
  int N,M;
  cin >> N >> M;
  vector<vector<int>>S(12,vector<int>(12));
  vector<int>P(M);
  vector<int>K(M);
  int k;
  
  rep(i,M){
    cin >> K[i];
    int a = K[i];
    rep(j,a){
      cin >> S[i][j];
    }
  }
  
  rep(i,M)cin >> P[i];
  
  //bit全探索
  int ans = 0;
  
  for(int bit = 0; bit < (1 << N); bit++){
    //スイッチの組み合わせを全探索。bitが立っているところのスイッチが起動している
    bool flag = true;
    //M個の電球についてみていく
    rep(i,M){
      int num = 0;
      //スイッチの条件(num % 2 == P[i])が一致している時だけ先に進む
      int k = K[i];
      rep(j,k){
        int now = S[i][j] - 1;
        if(bit & (1 << now))num++;
      }
      if(num % 2 != P[i]){
        flag = false;
      }
    }
    if(flag)ans++;
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define FOR(i, N) for (long i = 0; i < (N); i++)

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

    int A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;

    bool ikeru = false;

    for (int k = 0; k < K; k++) {
        if (A >= B) {
            B *= 2;
            continue;
        } else if (B >= C) {
            C *= 2;
            continue;
        } else {
            ikeru = true;
        }
    }

    if (ikeru || (A < B && B < C)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
list = []
for i in range(6):
    a = int(input())
    list.append(a)

flag = False
for i in range(5):
    for j in range(i+1, 5):
        if list[j] - list[i] > list[5]:
            flag = True

if flag:
    print(':(')
else:
    print('Yay!')


Measured memory_bytes: 2940
// Math = ♥
// Sometimes it is people that no one imagines anything of who do things that no one can imagine
// After all this time? Always

#include <bits/stdc++.h>                        // uncomment before submission
//#include <ext/pb_ds/assoc_container.hpp>		// uncomment before submission
//#include <ext/pb_ds/tree_policy.hpp>			// uncomment before submission
//using namespace __gnu_pbds;					// uncomment before submission
using namespace std;
//<---------------------------------------------------Template----------------------------------------------------------->
#define int long long
#define ll long long
#define ld long double
const int INF = 1e5 + 7;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;                  // Vector of long long
typedef vector<vi> vvi;                 // Vector of vi
typedef vector<ii> vii;                 // Vector of pairs
typedef vector<vii> vvii;               // Vector of Vector of pairs
typedef vector<bool> vb;                // Vector of bool
#define pq priority_queue               // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                        // For pairs
#define ss second                       // For pairs
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//<----------------------------------------------------------------------------------------------------------------------->

vi f, h;

int solve(int i)
{
    if (i <= 1)
        return 0;
    if (f[i] != -1)
        return f[i];

    if (f[i - 1] != -1 && f[i - 2] != -1)
        return f[i] = min(f[i - 1] + labs(h[i] - h[i - 1]), f[i - 2] + labs(h[i] - h[i - 2]));
    else if (f[i - 1] != -1 && f[i - 2] == -1)
        return f[i] = min(f[i - 1] + labs(h[i] - h[i - 1]), solve(i - 2) + labs(h[i] - h[i - 2]));
    else if (f[i - 1] == -1 && f[i - 2] != -1)
        return f[i] = min(solve(i - 1) + labs(h[i] - h[i - 1]), f[i - 2] + labs(h[i] - h[i - 2]));
    else
        return f[i] = min(solve(i - 1) + labs(h[i] - h[i - 1]), solve(i - 2) + labs(h[i] - h[i - 2]));
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;

    f.resize(INF, -1), h.resize(INF, 0);
    for (int i = 1; i <= n; i++) cin >> h[i];
    f[0] = f[1] = 0, f[2] = labs(h[1] - h[2]), f[3] = min(f[1] + labs(h[3] - h[1]), f[2] + labs(h[3] - h[2]));

    f[n] = solve(n);
    cout << f[n] << endl;
    return 0;
}


Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] iArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long a = iArray[0];
            long b = iArray[1];
            string result = "";
            for(long p = 0; p < Math.Max(a, b); p++)
            {
                result += Math.Min(a, b).ToString();
            }
            Console.WriteLine(result);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

Measured memory_bytes: 13268
from bisect import*
n,d,a,*t=map(int,open(0).read().split())
c=[0]*-~n
z=sorted(zip(*[iter(t)]*2))
s=0
for i,(x,h)in enumerate(z):
    c[i]+=c[i-1]
    h-=c[i]
    t=min(-h//a,0)
    c[i]-=t*a
    c[bisect(z,(x+d+d,9e9))]+=t*a
    s-=t
print(s)

Measured memory_bytes: 48852
#include <stdio.h>

#define SIZE 2000000

int main() {
  setvbuf(stdout, NULL, _IOFBF, 5000);
  int A[SIZE];
  int H=0;
  int i, l, largest, tmp, n;
  char com[21], buf[20];
  buf[19]='\n';
  char *p,*c1,*c2;
  c1 = com+1;
  c2 = com+2;
  do {
    fgets(com, 20, stdin);
    if (*com == 'i') {
      n = 0;
      p = com+7;
      while (*p!='\n') {
        n = n*10+*p-'0';
        p++;
      }
      A[++H] = n;
      for (i=H; i>1 && A[i>>1]<A[i];i>>=1) {
        tmp = A[i>>1];
        A[i>>1] = A[i];
        A[i] = tmp;
      }

    } else if (*c1=='x') { // extract
      n = A[1];
      for (i=18; n>0; n/=10) buf[i--]=(n%10)+'0';
      fputs(buf+i+1, stdout);
      A[1] = A[H];
      i = 1;
      while (1) {
        l = i<<1;
        if (l < H && A[l] > A[i])        largest = l;
        else         largest = i;
        if (l+1 < H && A[l+1] > A[largest])  largest = l+1;
        if (largest == i) break;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        i = largest;
      }
      H--;
    }
  } while (*c2!='d');
  return 0;
}


Measured memory_bytes: 5496
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    ll n,d; cin >> n >> d;
    int ans = 0;
    rep(i,n){
        ll x,y; cin >> x >> y;
        ll dist = x*x + y*y;
        if(dist<=d*d) ans++;
    }
    cout << ans << '\n';
    
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
using namespace std;
map<int,int>mp;
int n,ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(mp[x]==1){
			ans--;
			mp[x]=0;
		}else{
			ans++;
			mp[x]=1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
def resolve():
    n, m = map(int, input().split())
    hhh = list(map(int, input().split()))
    nice = [1] * n

    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        ha = hhh[a]
        hb = hhh[b]
        if ha <= hb:
            nice[a] = False
        if ha >= hb:
            nice[b] = False

    print(sum(nice))


resolve()

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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> w(n),e(n);
    if(s.at(0) == 'W'){
        w.at(0) = 1;
    }
    for(int i = 1;i < n;i ++){
        w.at(i) = w.at(i-1);
        if(s.at(i) == 'W'){
            w.at(i) ++;
        }
    }
    if(s.at(n-1) == 'E'){
        e.at(n-1) = 1;
    }
    for(int i = n-2;i >= 0;i --){
        e.at(i) = e.at(i+1);
        if(s.at(i) == 'E'){
            e.at(i) ++;
        }
    }

    int ans = 1000000;
    for(int i = 1;i < n-1;i ++){
        ans = min(ans,w.at(i-1)+e.at(i+1));
    }
    ans = min(ans,e.at(0));
    ans = min(ans,w.at(n-1));

    cout << ans << endl;
}

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

struct card {
    char suit;
    char value;
};

int main() {
    int N; cin >> N;
    card B[N];
    card S[N];

    rep(i, N){
        cin >> B[i].suit >> B[i].value;
        S[i] = B[i];
    }

    rep(i, N){
        for (int j = N - 1; j >= i + 1; j--){
            if (B[j].value < B[j - 1].value){
                swap(B[j], B[j - 1]);
            }
        }
    }

    rep(i, N){
        if (i == N - 1){
            cout << B[i].suit << B[i].value << endl;
            cout << "Stable" << endl;
        } else {
            cout << B[i].suit << B[i].value << " ";
        }
    }

    rep(i, N){
        int minj = i;
        for (int j = i + 1; j < N; j++){
            if (S[j].value < S[minj].value){
                minj = j;
            }
        }
        if (minj != i){
            swap(S[i], S[minj]);
        }
    }

    rep(i, N){
        if (i == N - 1){
            cout << S[i].suit << S[i].value << endl;
        } else {
            cout << S[i].suit << S[i].value << " ";
        }
    }

    rep(i, N){
        if (B[i].suit != S[i].suit){
            cout << "Not stable" << endl;
            break;
        } else {
            if (i == N - 1){
                cout << "Stable" << endl;
            }
        }   
    }

    return 0;
}


Measured memory_bytes: 3124
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }

int N, K;
int snk[200];

signed main()
{
	cin >> N >> K;
	REP(i, K)
	{
		int d;
		cin >> d;
		REP(j, d)
		{
			int a;
			cin >> a;
			snk[a]++;
		}
	}

	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		if (snk[i] == 0) ans++;
	}
	cout << ans << endl;
}





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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;


int n,x;

int main(){
  cin >> n >> x;
  vector<int> l(n);
  rep(i,0,n)cin >> l[i];
  int ans = 1;
  int d = 0;
  for(int i=0; i< n;i++){
    d = d+l[i];
    if(d > x)break;
    ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

int a[200005], sum[200005];
map <int, int> cnt;

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		a[i] += k - 1;
		a[i] %= k;
		
		sum[i] = (sum[i - 1] + a[i]) % k;
	}
	
	cnt[0]++;
	
	long long res = 0;
	
	for (int i = 1; i <= n; i++) {
		if (i >= k) cnt[sum[i - k]]--;
		res += cnt[sum[i]];
		cnt[sum[i]]++;
	}
	
	printf("%lld\n", res);
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;
  cout << n*(n+1)/2 << endl;
}


Measured memory_bytes: 256