akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
long  compa(const void *a,const void *b)
{
  return *(int  *)b - *(int  *)a;
}
int main(void)
{
  int  N,K,i;
  long int total=0; 
  scanf("%d %d",&N,&K);
  int  H[N];
  
  for(i=0;i<N;i++)
  scanf("%d ",&H[i]);
  qsort(H,N,sizeof(int),compa);
 for(i=K;i<N;i++)
 {
 //  printf("%d\n",H[i]);
   total += H[i];
  }  
  printf("%ld\n",total);
 return 0;
}

Measured memory_bytes: 1788
//package atcoder;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String [] args)  {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int s=0;
		
		if(N%1000==0) {
			System.out.println(0);
		}else {
			s=N%1000;
			System.out.println(1000-s);
		}
		
	}
}

Measured memory_bytes: 35656
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

constexpr lnt MOD = 1e9+7;
struct mint
{
	lnt v;
	mint():v(0){}
	mint(lnt v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(lnt k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(lnt n, lnt k) { if(n-k<k) k=n-k; mint num(1), dom(1); for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; } return num/dom; }
	static std::vector<mint> construct_comb(int n) {
		std::vector<mint> c(n+1); mint a = 1; c[0] = a; for(int i=1;i<=n;i++) { a = a*mint(n+1-i)/i; c[i] = a; } return c;
	}
	static std::vector<mint> construct_fact(int n) { std::vector<mint> f(n+1,1); for(int i=2;i<=n;i++) f[i]=f[i-1]*i; return f; }
};
std::istream& operator>>(std::istream&i,mint&a){ lnt t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }

template <typename T>
T PIE(int n, const std::function<T(int)>& f) {
	T sum=0;
	for(int k=0;k<=n;k++) sum+=T(k%2?-1:1)*f(k);
	return sum;
}

int main() {
	lnt n,m;
	std::cin >> n >> m;
	mint ans=0;
	auto f = mint::construct_fact(m);
	auto nC = mint::construct_comb(n);
	ans=PIE<mint>(n,[&f,&nC,&n,&m](int k)->mint{return nC[k]*f[m]/f[m-k]*(f[m-k]/f[m-n]).pow(2);});
	print(ans);
}


Measured memory_bytes: 11048
/*input
2
2 2
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_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())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
ll d[maxn];
set<pll,greater<pll>> st;
vector<pii> edge;
int sz[maxn];

vector<int> G[maxn];
int dis[maxn];
bool vis[maxn];
void dfs(int u){
	vis[u]=1;
	for(int v:G[u]) if(!vis[v]){
		dis[v]=dis[u]+1;
		dfs(v);
	}
}

int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>d[i];
	REP(i,n) st.insert(MP(d[i],i));
	REP(i,n) sz[i]=1;

	while(SZ(st)>1){
		auto cur=*st.begin();
		// cout<<cur<<'\n';
		st.erase(st.begin());
		ll new_size=cur.F+sz[cur.S]-(n-sz[cur.S]);
		auto nxt=*st.lower_bound(MP(new_size,INF64));
		if(nxt.F!=new_size){
			cout<<"-1\n";
			return 0;
		}
		edge.pb(MP(cur.S,nxt.S));
		G[cur.S].pb(nxt.S);
		G[nxt.S].pb(cur.S);
		sz[nxt.S]+=sz[cur.S];
	}
	dis[0]=0;
	dfs(0);
	REP(i,n) d[0]-=dis[i];
	if(d[0]){
		cout<<"-1\n";
		return 0;
	}

	for(int i=0;i<n-1;i++){
		cout<<edge[i].F+1<<' '<<edge[i].S+1<<'\n';
	}
	return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
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;
}

const ll MOD = 1e9+7;

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

  ll N;
  cin >> N;
  vector<ll> T(N);
  vector<ll> A(N);
  vector<ll> determT(N), determA(N);

  rep(i, N){
    determT[i] = 0;
    determA[i] = 0;
  }
  
  rep(i, N) cin >> T[i];
  rep(i, N) cin >> A[i];

  determT[0] = 1;
  determA[N-1] = 1;

  bool ok = true;
  for(int i = 1; i < N; i++){
    if(T[i] > T[i-1]){
      determT[i] = 1;
    }
  }

  for(int i = N-2; i >= 0; i--){
    if(A[i] > A[i+1]){
      determA[i] = 1;
    }
  }

  for(int i = 0; i < N; i++){
    if(determT[i] && determA[i]){
      if(T[i] != A[i]){
        ok = false;
        break;
      }
    }else if(determT[i] && A[i] < T[i]){
      ok = false;
      break;
    }else if(determA[i] && T[i] < A[i]){
      ok = false;
      break;
    }
  }


  if(ok){

    ll ans = 1;

    rep(i, N){

      if(determT[i] != 1 && determA[i] != 1){
        ans = (ans * min(T[i], A[i])) % MOD;
      }
      
    }
    cout << ans << endl;

  }else{
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 3456
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>


using namespace std;

void Solution()
{
    int n;
    int a[11][11];
    
    while (true)
    {
        cin>>n;
        
        if(n == 0)
        {
            break;
        }
        
        for (int i = 0; i <= n; i++)
        {
            for (int j = 0; j <= n; j++)
            {
                a[i][j] = 0;
            }
        }

        
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                cin>>a[i][j];
                a[i][n] += a[i][j];
            }
        }
        
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j <= n; j++)
            {
                a[n][j] += a [i][j];
            }
        }
        
        for (int i = 0; i <= n; i++)
        {
            for (int j = 0; j <= n; j++)
            {
                cout<<setw(5)<<a[i][j];
            }
            
            cout<<endl;
        }
    }
    
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1172
#include<stdio.h>


void bubbleSort(int A[],int N){
  int i,j,temp,cnt=0;

  for(i=0;i<N-1;i++){
    for(j=N-1;j>=i+1;j--){
      if(A[j-1]>A[j]){
        temp=A[j-1];
        A[j-1]=A[j];
        A[j]=temp;
        cnt++;
      }
    }
  }

    for(i=0;i<N;i++){
      if(i>0) printf(" ");
      printf("%d",A[i]);
        }
    printf("\n");

    printf("%d\n",cnt);
}

  int main(){

    int N,i,A[100];

    scanf("%d\n",&N);
    for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

    bubbleSort(A,N);


    return 0;
  }




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

const int coin[] = { 500, 100, 50, 10, 5, 1 };

int main() {

	int change, coins, t;

	while (cin >> change, change) {
		change = 1000 - change;

		coins = 0;
		for (int i = 0; i < 6; ++i) {
			if (change >= coin[i]) {
				t = change / coin[i];
				coins += t;
				change -= t * coin[i];
				if (!change)
					break;
			}
		}
		cout << coins << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import heapq

n,m=map(int,input().split())

a=[[] for _ in range(m)]

d=[]

heapq.heapify(d)

for i in range(n):
  x,y=map(int,input().split())
  if x<=m:
    a[x-1].append(-y)
    
ans=0

for j in range(1,m+1):
  for h in a[j-1]:
    heapq.heappush(d,h)
  if len(d)>0:
    c=heapq.heappop(d)
    ans+=c
  
print(ans*(-1))

Measured memory_bytes: 89384
import java.util.ArrayList;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());

		Map<Integer, ArrayList<Integer>> map = new TreeMap<Integer, ArrayList<Integer>>();
		for(int i = 0; i < N; i++) {
			int K = Integer.parseInt(sc.next());
			ArrayList<Integer> list = new ArrayList<>();
			for(int j = 0; j < K; j++) {
				list.add(Integer.parseInt(sc.next()));
			}
			map.put(i + 1, list);
		}
		sc.close();
		
		int count = 0;
		for(int i = 1; i <= M; i++) {
			boolean check = true;
			for(int j = 0; j < N; j++) {
				if(map.get(j + 1).contains(i)) {
					continue;
				}else {
					check = false;
					break;
				}
			}
			if(check) count++;
		}
		System.out.println(count);
	}
}

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

using namespace std;

#define ll long long

vector<int> adj[100005];
vector<vector<int> > dp(100005,vector<int>(2,-1));

const int mod=1e9+7;

ll dfs(int v,int p,int c){
	
	if(dp[v][c]!=-1)
		return dp[v][c];
	
	ll ways=1,sz=adj[v].size();
	for(int i=0;i<sz;i++){
		int u=adj[v][i];
		if(u==p)
			continue;
		if(c==0){
			ways=(ways*(dfs(u,v,1)+dfs(u,v,0)))%mod;
		}
		else
			ways=(ways*dfs(u,v,0))%mod;
	}
	return dp[v][c]=ways;
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		--x,--y;
		adj[x].push_back(y);
		adj[y].push_back(x);		
	}
	printf("%lld",(dfs(0,-1,0)+dfs(0,-1,1))%mod);
}


Measured memory_bytes: 19584
//---Vaidik Patel---//
//-------------------Proud to be Indian--------------------------------//
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set,multi multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define pii pair<int,int>
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order()
#define deb1(x) cout<<#x<<" : "<<x<<"\n";
#define deb2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<"\n";
#define deb4(x,y,z,w) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<"\t"<<#w<<" : "<<w<<endl;
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rFOR(i,a,b) for(int i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vector<int>>
#define M 1000000007
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int powermodm(int x,int n,int m)
{int ans=1;   while(n){if(n&1){ans=(ans*x)%m;}x=(x*x)%m;n=n>>1;}return ans;}
int d, x, y;
void extendedEuclid(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else
    {
        extendedEuclid(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}
// return modulo inverse of a wrt modulo p(should be prime)
// retunt -1 if modulo inverse does not exist
int MMI(int a, int p)
{
    extendedEuclid(a,p);
    if(d==1 && p!=1)
        return ((x%p)+p)%p;
    else
        return -1;
}

void solve()
{
    int n;
    cin>>n;
    if(n==1)
    {
        cout<<0<<"\n";
        return;
    }
    if(n==2)
    {
        cout<<2<<"\n";
        return;
    }
    int x=powermodm(10,n,M);
    int y=powermodm(8,n,M);
    int z=powermodm(9,n,M);
    cout<<(x-(2*z)%M+y+M)%M<<"\n";
}
signed main()
{
   
    FIO
    int t;
    t=1;
    //cin>>t;
    FOR(i,0,t)
    {
        solve();
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <fstream>
#include <stdlib.h>
#include <ctime>
typedef long long ll;

using namespace std;

int b[500000];
//int ans[500000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(100);
 //   freopen("input.txt","r",stdin);
    int n;
    cin >> n;
    for(int i = 0;i < n;i++) {
        cin >> b[i];
    }
    multiset <int> s;
    int ans=1;
    s.insert(b[0]);
    for(int i=1;i<n;i++){
        auto it =s.lower_bound(b[i]);
        if(it == s.begin()){
            ans++;
            s.insert(b[i]);
        }
        else{
            it--;
            s.erase(it);
            s.insert(b[i]);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <vector>
#include <queue>
#include <bitset>
#include <cmath>
#include <time.h>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <deque>
#include <iomanip>
#include <complex>
//#include <ext/rope>

using namespace std;
//using namespace __gnu_cxx;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define fast_read cin.sync_with_stdio(0)
#define PREX(number) cout << fixed << setprecision(number)
#define nul point(0, 0)
#define random srand(time(NULL))
#define rand_int abs((rand() << 15) | rand())
#define str_to_int(stroka) atoi(stroka.c_str())
#define str_to_ll(stroka) atoll(stroka.c_str())
#define str_to_double(stroka) atof(stroka.c_str())
#define what_is(x) cerr << #x << " is " << x << endl
#define solve_system int number; cin >> number; forn(i, 0, number) solve()
#define solve_system_scanf int number; scanf("%d", &number); forn(i, 0, number) solve()

//easy functions
template< typename T >
T gcd(T a, T b) { return a ? gcd(b % a, a) : b; }
template< typename T >
T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
bool is_down(char x) { return ('a' <= x && x <= 'z'); }
bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
bool is_digit(char x) { return ('0' <= x && x <= '9'); }

//constants
const ld pi = 3.141592653589793238462643383279;
const ld log23 = 1.58496250072115618145373894394781;
const ld eps = 1e-8;
const ld zero = 0;
const ll INF = 1e18;
const int COUT = 30;
const int prost = 239;
const ll prost64 = 239;
const int two = 2;
const ll sr = 31;
const int MOD = 1e9 + 7;
const int BIG = 2 * 1e9 + 1;
const int alf = 26;
const int MAX_N = 1e5 + 10;
const int MAX_M = (1 << 20);
const int MAX_T = (1 << 22);
const int BLOCK = trunc(sqrt(MAX_N)) + 1;
const int MAX_LOG = 18;
const int km = (1 << 18);
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int bit_max = 32;
const int dig = 10;
const string str_alf = "abcdefghijklmnopqrstuvwxyz";
const string str_alf_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int bt = 31;
const int MX = 2001 * 2001;

// Code starts here

int n;
bitset<MX> t;

int main()
{   /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif /**/
    fast_read;
    t = 1;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        t |= (t << a);
    }
    vector<int> al;
    for (int i = 0; i < MX; i++)
        if (t[i])
            al.push_back(i);
    cout << al[al.size() / 2];
    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < ll > vl;

const int MAXN = 1e5 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 18;
const double EPS = 1e-9;
const double PI = 3.1415926535;

int dp[MAXN];
int a[110];

int main() {
    int N, K;
    cin >> N >> K;

    for(int i = 0; i < N; i++)
        cin >> a[i];


    for(int i = 0; i <= K; i++) {
        for(int j = 0; j < N; j++) {
            if(i + a[j] >= MAXN)
                continue;
            if(dp[i + a[j]] == 1)
                continue;
            dp[i + a[j]] = 1 - dp[i];
        }
    }

    if(dp[K] == 1)
        cout << "First" << endl;
    else
        cout << "Second" << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int ancestor[100000];
int find(int x){
    if(ancestor[x]==x)return x;
    return ancestor[x]=find(ancestor[x]);
}
int min(int a,int b){
    if(a<b)return a;
    return b;
}
int max(int a,int b){
    if(a>b)return a;
    return b;
}
int main(){
    int n,q,m,temp,x,y;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)ancestor[i]=i;
    for(int i=0;i<m;i++){
        scanf("%d%d",&x,&y);
        temp=find(x);
        q=find(y);
        ancestor[max(temp,q)]=min(temp,q);
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d%d",&x,&y);
        if(find(x)!=find(y))printf("no\n");
        else printf("yes\n");
    }
}

Measured memory_bytes: 2980
#include <bits/stdc++.h>
using namespace std;
long long h,n,x,sum;
int main () {
	scanf("%d%d",&h,&n);
	for (int i=1;i<=n;i++) {scanf("%d",&x);sum+=x;}
	printf("%s\n",(sum>=h?"Yes":"No"));
	return 0;
}

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

using namespace std;

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

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  string s;
  cin>>s;
  int num=0,ans=0;
  rep(i,0,s.size()){
      if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
          num++;
          if(ans<num){
              ans=num;
          }
      }else{
          num=0;
      }
  }
  cout<<ans<<endl;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(string N){
    bool check = true;
    LL ans = 0;

    if(N.size() == 1) {
        cout << N << endl;
        return;
    }

    REP1(i, N.size()) {
        check &= N[i] == '9';
    }
    if(check) {
        cout << (N[0]-'0' + 9 * (N.size()-1)) << endl;
        return;
    }

    ans = 0;
    check = false;
    REP(i, N.size()) {
        if(check) {
            ans += 9;
            continue;
        }
        if(N[i] != '9') {
            if(i == 0) {
                ans += N[i] - '0' - 1;
            } else {
                ans += 8;
            }
            check = true; 
        } else {
            ans += N[i] - '0';
        }
    }

    cout << ans << endl;
}

int main(){
    string N;
    cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 256
# abc111_a.py
# https://atcoder.jp/contests/abc111/tasks/abc111_a

# A - AtCoder Beginner Contest 999 /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 猫のすぬけは文字を書く練習をしています。 
# すぬけは今日、数字の 1 と 9 を書く練習をしていたのですが、 間違えて 1 と 9 をあべこべに書いてしまいました。
# すぬけが書いた 3桁の整数 n が与えられます。 
# nに含まれる 1 という桁をそれぞれ 9 に、 9 という桁をそれぞれ 1 に置き換えて得られる整数を出力してください。

# 制約
#     111≤n≤999
#     nは各桁が 1 か 9 である整数

# 入力
# 入力は以下の形式で標準入力から与えられる。
# n

# 出力
# nの各桁の 1 と 9を入れ替えた整数を出力してください。

# 入力例 1
# 119

# 出力例 1
# 991

# 一の位の 9 を 1 に、十の位の 1 を 9 に、百の位の 1 を 9 に書き換えた 991 が答えとなります．

# 入力例 2
# 999

# 出力例 2
# 111


def calculation(lines):
    # N = int(lines[0])
    # X, Y = list(map(int, lines[0].split()))
    n = lines[0]

    return [n.replace('9', 'a').replace('1', '9').replace('a', '1')]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['119']
        lines_export = ['991']
    if pattern == 2:
        lines_input = ['999']
        lines_export = ['111']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


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

int main() {
	int n,m,t;
	cin>>n>>m;
	int a[n];
	
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	}
	int b[n];
	b[0]=0;
	//b[1]=abs(a[0]-a[1]);
	int k,l=-1;
	for(int j=1;j<n;j++)
	{t=j-1;
	l=-1;
	    while(t>=0&&t>j-m-1)
	    {
	        k=b[t]+abs(a[t]-a[j]);
	        //cout<<k<<" ";
	        if(l>k||l==-1)
	        l=k;
	        t--;
	    }
	   b[j]=l;
	}
	cout<<b[n-1];
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x,y,A,B,C;
    cin>>x>>y;
    while(x%y!=0){
        A=max(x,y);
        B=min(x,y);
        C=A%B;
        if(C>=B){x=C;y=B;}
        else{x=B;y=C;}
    }
    cout<<y<<endl;
    return 0;
}



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

#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 MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
using namespace std;

int a[300000];
priority_queue<int, vector<int>, greater<int> > q1;
priority_queue<int> q2;
int k1[100001];
int k2[100001];

signed main()
{
	int N;
	cin >> N;
	for (int i = 0; i < 3 * N; i++) cin >> a[i];

	int s1 = 0;
	for (int i = 0; i < N; i++)
	{
		q1.push(a[i]);
		s1 += a[i];
	}
	k1[0] = s1;
	for (int i = 0; i < N; i++)
	{
		int b = a[i + N];
		if (q1.top() < b)
		{
			s1 -= q1.top();
			s1 += b;
			q1.pop();
			q1.push(b);
		}
		k1[i + 1] = s1;
	}

	int s2 = 0;
	for (int i = N * 2; i < N * 3; i++)
	{
		q2.push(a[i]);
		s2 += a[i];
	}
	k2[N] = s2;
	for (int i = 0; i < N; i++)
	{
		int b = a[(N * 2 - 1) - i];
		if (q2.top() > b)
		{
			s2 -= q2.top();
			s2 += b;
			q2.pop();
			q2.push(b);
		}
		k2[N - 1 - i] = s2;
	}


	int ans = LLONG_MIN;
	for (int i = 0; i <= N; i++)
	{
		ans = MAX(ans, k1[i] - k2[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5876
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vpll path;
//***********//
int main() {
	cin >> N >> L;
	vl A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (i = 0; i < N-1; i++) {
		if (A[i] + A[i + 1] >= L) {
			cout << "Possible" << endl;
			for (j = 0; j < i; j++) {
				cout << j + 1 << endl;
			}
			for (j = N-2; j >= i; j--) {
				cout << j + 1 << endl;
			}
			exit(0);
		}
	}
	cout << "Impossible";
}

Measured memory_bytes: 1664
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def Union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        # これ抜かさないで！！！！
        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def same(self,x,y):
        if self.find(x) == self.find(y):
            return True
        else:
            return False
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,m = readInts()
    #Uni = UnionFind(n)
    # 最初に保存しておく
    bridge = []
    for i in range(m):
        s,e = map(lambda x: int(x) - 1,input().split())
        bridge.append((s,e))
    cnt = 0
    for i in range(m):
        # ある辺を取り除いた時
        Uni = UnionFind(n)
        for j,root in enumerate(bridge,start = 0):
            # もし、取り除いた辺とidxが一緒ならば、次にいく
            if i == j:
                continue
            s,t = root
            Uni.Union(s,t)
        # ここで構成完了
        s,t = bridge[i]
        if not Uni.same(s,t): # 頂点が一致しない # その経路は必要だった
            cnt += 1
    print(cnt)


if __name__ == '__main__':
  main()


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	m := getNextInt(scanner)

	fmt.Fprintln(writer, solve(n, m))

	writer.Flush()
}

func solve(n, m int) int {
	if n-m >= 2 {
		return 0
	}
	if m-n >= 2 {
		return 0
	}

	mod := int(1e9 + 7)
	dpn := make([]int, n+1)
	dpm := make([]int, m+1)
	dpn[0] = 1
	dpm[0] = 1
	for i := 1; i <= n; i++ {
		dpn[i] = (dpn[i-1] * i) % mod
	}
	for i := 1; i <= m; i++ {
		dpm[i] = (dpm[i-1] * i) % mod
	}
	ans := (dpn[n] * dpm[m]) % mod
	if n == m {
		ans = (ans * 2) % mod
	}
	return ans
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    rep(i, N) cin >> A[i];
    
    rep(i, N) A[i] -= i + 1;
    sort(A.begin(), A.end());
    long long ans = 0;
    rep(i, N) {
        ans += abs(A[N / 2] - A[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int x, y;
    cin >> x >> y;

    int x1 = 0;
    int y1 = 0;
    if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) {
        x1 = 1;
    }
    else if (x == 4 || x == 6 || x == 9 || x == 11) {
        x1 = 2;
    }
    else if (x == 2) {
        x1 = 3;
    }
  
    if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
        y1 = 1;
    }
    else if (y == 4 || y == 6 || y == 9 || y == 11) {
        y1 = 2;
    }
    else if (y == 2) {
        y1 = 3;
    }

    if (x1 == y1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  char S[1000000];
  vector<char> F_1,F_2;
  int Q;
  cin >> S >> Q;
  int S_size = strlen(S);
  int T,F;
  char C;
  int T1_count = 0;
  REP(i,Q) {
    cin >> T;
    if(T==1) {
      T1_count++;
    } else if(T==2) {
      cin >> F >> C;
      if((F+T1_count)%2==1) {
        F_2.push_back(C);
      } else {
        F_1.push_back(C);
      }
    }
  }
  ll F_1_size = F_1.size();
  ll F_2_size = F_2.size();
  if(T1_count%2==1) {
    for(int j = F_1_size-1;j>=0;j--) cout << F_1[j];
    for(int j = S_size-1;j>=0;j--) cout << S[j];
    REP(j,F_2_size) cout << F_2[j];
  } else {
    for(int j = F_2_size-1;j>=0;j--) cout << F_2[j];
    REP(j,S_size) cout << S[j];
    REP(j,F_1_size) cout << F_1[j];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}
int a[N];
int x[N],y[N],cnt=0;

signed main()
{
	int n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+1+n);
	int now=n-1;
	while (now>1&&a[now]>=0)
	{
		cnt++;
		x[cnt]=a[1];
		y[cnt]=a[now];
		a[1]-=a[now];
		now--;
	}
	for (int i=1;i<=now;i++)
	{
		cnt++;
		x[cnt]=a[n];
		y[cnt]=a[i];
		a[n]-=a[i];
	}
	print(a[n]);
	for (int i=1;i<=cnt;i++)
	{
		print(x[i],' ');
		print(y[i]);
	}

	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r, d, x;
	cin >> r >> d >> x;
	vector<int> dp(11);
	dp[0] = x;
	for (int i = 0; i < 10; i++) {
		dp[i + 1] = dp[i] * r - d;
	}
	for (int i = 1; i < 11; i++) cout << dp[i] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int count;
  int i = 1000;
  while(count != c){
    if(a%i == 0 && b%i == 0)
      count++;
    i--;
  }
  cout << i+1 << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC150A
{
    class Program
    {
        static void Main(string[] args)
        {
            var KX = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if (KX[0] * 500 >= KX[1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadLine();
        }
    }
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k; cin >> k;
  cout << v[k-1] << endl;

}


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

using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
const ll MAXN = 2e6 + 10, inf = 1e18, mod = 1e9 + 7;

struct pair_hash {
	template <class T1, class T2>
		std::size_t operator () (const std::pair<T1,T2> &p) const {
			auto h1 = std::hash<T1>{}(p.first);
			auto h2 = std::hash<T2>{}(p.second);

			return h1 ^ h2;  
		}
};

ll pw(ll te, ll tee) {
	if (tee == 0)	return 1;
	ll res = pw(te, tee / 2);
	return (tee % 2 ? te * res * res : res * res);
}

ll n, a[MAXN], sum;
bool flag = false;

void Read_input() {
	cin >> n;
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] < 0)	flag = !flag;
		a[i] = abs(a[i]);
		sum += a[i];
	}
}

void Solve() {
	sort(a + 1, a + n + 1);
	if (flag) sum -= a[1] * 2;
	cout << sum;
}


int main() {

	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	//freopen("input.txt", "r", stdin),	freopen("output.txt", "w", stdout);

	Read_input(),	Solve();
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <cstring>
#include <queue>
#include <sys/time.h>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rev(i,n) for(int i=(int)n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ( (a)/__gcd((a),(b))*(b) )

template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}

int a[50000],b[50000],o[50000];
int main(){
	int H,W,q;
	while(cin >> H >> W >> q && H){
		int ans = 0;
		rep(i,q) cin >> a[i] >> b[i] >> o[i];
		set<int> g[2];
		rev(i,q){
			if(a[i]==0){
				if(!g[0].count(b[i]) && o[i]) ans += W - g[1].size();
				g[0].insert(b[i]);
			}else{
				if(!g[1].count(b[i]) && o[i]) ans += H - g[0].size();
				g[1].insert(b[i]);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
import scala.io.Source.stdin

object Main {
  def sumEqInt(n: Int): Int = {
    (for (i <- 0 to 9;
      j <- 0 to 9;
      k <- 0 to 9;
      l <- 0 to 9 if i+j+k+l == n) yield s"$i$j$k$l").length
  }

  def main(args: Array[String]): Unit = {    
    val num = stdin.getLines
    num.foreach(i => println(sumEqInt(i.toInt)))
  }
}

Measured memory_bytes: 87152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static String solve (int time) {
		String h = time / 3600 + "";
		if (h.length() == 1) h = "0" + h;
		time %= 3600;
		String m = time / 60 + "";
		if (m.length() == 1) m = "0" + m;
		time %= 60;
		String s = time  + "";
		if (s.length() == 1) s = "0" + s;
		return h + ":" + m + ":" + s;
	}

	public static void main(String[] args) throws IOException {

		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			String[] str = br.readLine().split(" ");
			int h = Integer.parseInt(str[0]);
			int m = Integer.parseInt(str[1]);
			int s = Integer.parseInt(str[2]);
			if (h == -1 && m == -1 && s == -1) break;
			int normal = 7200 - (h * 3600 + m * 60 + s);
			System.out.println(solve(normal));
			System.out.println(solve(normal * 3));
		}

	}

}

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

typedef long long ll;
int n,a[300005];
ll ans=0;
int main()
{
	#ifdef Kay
		freopen ("ATC.in","r",stdin);
		freopen ("ATC.out","w",stdout);
	#endif
	cin>>n;
	int i;
	for (i=1;i<=n*3;i++) scanf ("%d",&a[i]);
	sort(a+1,a+1+n*3);
	for (i=1;i<=n;i++) ans+=a[n*3-i*2+1];
	cout<<ans;
	return 0;
}


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

int main() {
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  if ((A + B) < (C + D)){
    cout << "Right" << endl;
  }else if ((A + B) > (C + D)){
    cout << "Left"<< endl;
  }else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
using System;
using static System.Console;

class Program
{
    static string check(int x)
    {
	WriteLine(x);
	return ReadLine();
    }

    static bool hasVacant(int l, int r, bool same)
    {
	if (((l - r) & 1) == 0) return !same;
	else return same;
    }
    
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int l = 0, r = n-1, m;
	char lc, rc, mc;
	lc = check(l)[0];
	if (lc == 'V') return;
	rc = check(r)[0];
	if (rc == 'V') return;

	while (l < r)
	{
	    m = (l + r) / 2;
	    mc = check(m)[0];
	    if (mc == 'V') return;
	    if (hasVacant(l, m, lc == mc))
	    {
		r = m;
		rc = mc;
	    }
	    else
	    {
		l = m;
		lc = mc;
	    }
	}
    }
}


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

using namespace std;
typedef long long ll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  ll C;
  cin >> N >> C;

  vector<ll> x(N + 1, 0), v(N + 1, 0), rwv(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    cin >> x[i] >> v[i];
  }

  // 累積和
  for (int i = 0; i < N; i++) {
    rwv[i + 1] = rwv[i] + v[i + 1];
  }

  vector<ll> r(N + 1, 0);
  for (int i = 0; i < N; i++) {
    r[i + 1] = max(r[i], rwv[i + 1] - x[i + 1]);
  }

  vector<ll> l(N + 1, 0);
  l[1] = rwv[N] - rwv[N - 1] - (C - x[N]);
  for (int i = 1; i < N; i++) {
    l[i + 1] = max(l[i], rwv[N] - rwv[N - (i + 1)] - (C - x[N - i]));
  }

  // for (int i = 0; i <= N; i++) {
  //   cout << l[i] << " ";
  // }
  // cout << endl;
  // for (int i = 0; i <= N; i++) {
  //   cout << r[i] << " ";
  // }
  // cout << endl;


  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ans = max(ans, rwv[i] - x[i]);
    if (i < N) {
      ans = max(ans, rwv[i] - 2 * x[i] + l[N - i]);
    }
  }

  for (int i = N - 1; i >= 0; i--) {
    ans = max(ans, rwv[N] - rwv[i] - (C - x[i + 1]));
    if (i > 0) {
      ans = max(ans, rwv[N] - rwv[i] - 2 * (C - x[i + 1]) + r[i]);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define sc(m) scanf("%d",&m);
#define sc(k) scanf("%d",&k);
#define sc(test) scanf("%d",&test);
#define scl(m) scanf("%lld",&m);
#define scd(m) scanf("%lf",&m);
#define pf(res) printf("%d",res);
#define pfl(res) printf("%lld",res);
#define pfd(res) printf("%lf",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];

int main()
{
    int k;
    sc(k);
    string a;
    cin>>a;
    int len=a.size();
    if(k>=len)
        cout<<a;
    else
    {
        for(int i=0;i<k;i++)
        {
            cout<<a[i];
        }
        cout<<"...";
    }
}





Measured memory_bytes: 3688
import sys

MAX = 1000000


def digit_sum(n, b):
    if n == 0:
        return 0
    else:
        return digit_sum(n // b, b) + n % b


def main():
    n = int(input())
    s = int(input())

    if n < s:
        print(-1)
        sys.exit()

    ans = -1

    for b in range(2, min(n + 1, MAX) + 1):
        sm = digit_sum(n, b)
        if sm == s:
            ans = b
            break

    if ans != -1:
        print(ans)
        sys.exit()

    if n + 1 <= MAX:
        print(-1)
        sys.exit()

    for p in reversed(range(1, MAX)):
        if (n - s) % p != 0:
            continue
        b = (n - s) // p + 1
        if b < 2:
            continue
        sm = digit_sum(n, b)
        if sm == s:
            ans = b
            break

    if ans != -1:
        print(ans)
        sys.exit()

    if n == s:
        print(n+1)
        sys.exit()

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45164
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n;
double a[111];
double anss,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		anss+=1/a[i];
	}
	ans=1/anss;
	printf("%lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int a,b;cin >> a >> b;
    int sa = b-a;
    cout << (sa+1)*sa/2 - b << endl;

    return 0;
}

Measured memory_bytes: 256
import scala.io.Source.stdin
import scala.util.control.Breaks

/**
  * Created by wintermaples on 2017/06/20.
  */
object Main {

  def main(args : Array[String]) : Unit = {
    val b = new Breaks
    var rectangleNum = 0
    var diamondNum = 0

    stdin.getLines().map(_.split(","))
      .map(sarr => (sarr(0).toInt, sarr(1).toInt, sarr(2).toInt ) )
      .foreach( t => {
        val s1 = t._1
        val s2 = t._2
        val diagonal = t._3
        if (s1*s1 + s2*s2 == diagonal*diagonal)
          rectangleNum += 1
        else if (s1 == s2)
          diamondNum += 1
    })

    println(rectangleNum)
    println(diamondNum)
  }

}

Measured memory_bytes: 43336