akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int T,n,k,l,r;
long long ans;
vector<pair<int,int>>a,b;
multiset<int>s;
void sol(vector<pair<int,int>>&v)
{
	sort(v.begin(),v.end());
	s.clear();
	for(auto x:v)
	{
		s.insert(x.second);
		ans+=x.second;
		while(s.size()>x.first)
		{
			ans-=*s.begin();
			s.erase(s.begin());
		}
	}
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		ans=0;
		a.clear(),b.clear();
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d%d",&k,&l,&r);
			if(l>r)
				a.emplace_back(k,l-r);
			else if(l<r)
				b.emplace_back(n-k,r-l);
			ans+=min(l,r);
		}
		sol(a),sol(b);
		printf("%lld\n",ans);
	}
	return 0;
}

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

void input()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    #endif
}
#define endl "\n"
#define ll long long int
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
#define INF LONG_LONG_MAX
#define mod 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define cases ll t; cin>>t; while(t--)
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define sortall(a) sort(a.begin(),a.end())
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;

// --------------- My Template End --------------- //
bool isprime(ll n)
{
    if(n%2==0)return false;
    for(int i=3;i<=sqrt(n);i+=2)
    {
        if(n%i==0)return false;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
   // input();
    char a;
    cin>>a;
    if(a>=65&&a<=90)
    {
    	cout<<"A"<<endl;
    }
    else
    {
    	cout<<"a"<<endl;
    }
}




Measured memory_bytes: 3692
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      
      // 計算
      int amari = N % 1000;
      int pay = 0;
      if(amari != 0){
        pay =  1000 - amari;
      }
      
      // 出力
      System.out.println(pay);
    }

}

Measured memory_bytes: 35768
import sys

import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
"""dd = [(-1, 0), (0, 1), (1, 0), (0, -1)];
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)];
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  # SingleInt
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  # HeightString
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  # NumberGrid
def grid(n): return [s_list() for _ in range(n)]


def main():
    n = int(input())
    count = 0
    for i in range(1,n+1):
        if i % 2 != 0:
            ans = 0
            for j in range(1,i+1):
                if i % j == 0:
                    ans += 1
            if ans == 8:
                count += 1
        else:
            continue

    print(count)
if __name__ == '__main__':
    main()

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

vector<int> v;
int dp[mx5], L;

int main()
{
    int n;
    cin >> n;

    v.Pb(1);

    for(int i = 6; i <= n; i *= 6)
        v.Pb(i);
    for(int i = 9; i <= n; i *= 9)
        v.Pb(i);

    L = v.size();

    for(int i = 1; i <= n; i++)
        dp[i] = 1e9;

    for(int i = 1; i <= n; i++){
        for(int j = 0; j < L; j++)
            if(v[j] <= i)
                dp[i] = min(dp[i], 1 + dp[i - v[j]]);
    }

    cout << dp[n] << '\n';
    return 0;
}


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

int main() {
  string weather;
  string msg;
  cin >> weather;
  if(weather=="Sunny"){
    msg ="Cloudy";
  }else if(weather=="Cloudy"){
    msg="Rainy";
  }else{
    msg ="Sunny";
  }
  cout << msg <<endl;
}



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

int main() {
  int X, ans;
  cin >> X;
  ans = 0;
  
  for(int i=1; i<=360; i++){
    if(i*X%360==0){
      ans = i;
      break;
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3632
fun main(args: Array<String>) {
    var n = getInt()
    var arr = getInts().sorted()
    var m = arr.sum() / n

    var a = arr.map { m - it }.map { it * it }.sum()
    var b = arr.map { m + 1 - it }.map { it * it }.sum()

    println(Math.min(a, b))
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }

Measured memory_bytes: 37984
(n,*c),a,*q=$<.map{_1.split.map &:to_i}
b=(0..n).map{_1&-_1}
d=b.map{[]}
u=i=k=0
q.map{d[_2]<<[_1-1,k+=1]}
a.map{t=c[_1]
(b[t]-=1;t+=t&-t)until t ?t>n:u+=1
c[_1]=i+=1
d[i].map{|x,y|$*[y]=u
($*[y]-=b[x];x&=x-1)while x>0}}
puts$*

Measured memory_bytes: 171932
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

struct Point
{
	long double x, y;	int ind;
	Point (long double a = 0, long double b = 0, int i = 0)
		: x(a), y(b), ind(i) {}
	
	long double operator% 	(const Point& he) 	const
	{	return x * he.y - he.x * y;	}
	
	Point operator- (const Point& he)	const
	{	return Point(x - he.x, y - he.y, ind);	}
	
	long double len2()	const
	{	return x*x + y*y;	}
	
	bool operator< (const Point& he)	const
	{
		long double ilo = (*this) % he;
		if (ilo != 0)			return ilo > 0;
		if (y != 0 or he.y != 0)return y < he.y;
		return x < he.x;	//	!abs
	}
};

const int maxN = 1 << 6;
const long double E = 1e-5;

int x[maxN], y[maxN], z[maxN], n, k;
long double r[maxN];

vector <Point> crcInter(int i, int j)	//assert inter nonEmpty
{
	long long dx = x[i] - x[j], dy = y[i] - y[j], d2 = kw(dx) + kw(dy);
	double D = sqrt(d2);
	double X = (d2 + kw(r[j]) - kw(r[i])) / (2.0 * D);
	double Y = sqrt(kw(r[j]) - kw(X));
	vector <Point> res({Point(X, Y), Point(X, -Y)});
	double c = dx / D, s = dy / D;
	FOR(k, 0, 2)
	{
		res[k] = Point(res[k] % Point(s,c), res[k] % Point(-c,s));
		res[k].x += x[j];
		res[k].y += y[j];	
	}
	return res;
}

vector <Point> T;

bool check(long double t)
{
	T.resize(0);
	FOR(i, 0, n)
	{
		r[i] = t / z[i];
		T.pb({x[i], y[i]});
	}
	
	FOR(i, 1, n) FOR(j, 0, i)
	{
		long double R = kw(r[i] + r[j]), R2 = kw(r[i] - r[j]);
		long double D = kw(x[i] - x[j]) + kw(y[i] - y[j]);
		if (R >= D-E and D >= R2-E)
		{
			vector <Point> temp = crcInter(i, j);
			T.insert(T.end(), ALL(temp)); 
		}
	}
	
	for (Point p : T)
	{
		int cnt = 0;
		FOR(i, 0, n)
		{
			long double dx = p.x - x[i], dy = p.y - y[i], d = kw(dx) + kw(dy);
			if (d <= kw(r[i]) + E)
				cnt++;
		}
		
		if (cnt >= k)
			return true;
	}
	
	return false;	
}

void solve()
{
	scanf ("%d%d", &n, &k);

	FOR(i, 0, n)
		scanf ("%d%d%d", x+i, y+i, z+i);
		
	long double a = 0, b = 1e6;
	while (b - a > 1e-6)
	{
		long double c = (a+b)/2;
		check(c) ? b = c : a = c;
	}
	
	printf("%.9Lf\n", (a+b)/2);
} 
 
int main()
{
    int t;
    t = 1;//scanf ("%d", &t);
    while (t--)
    	solve();
    return 0;    
}




Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    int n,k;
    cin >> n >> k;
    int res = 0;
    rep(i,n){
        int h;
        cin >> h;
        if(h>=k)res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
	else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int n;cin>>n;
	vector<vector<int>> A;
	rep(i,n){
		ll a;
		cin>>a;
		A.push_back(vector<int>());
		rep(j,60){
			A[i].push_back(a%2);
			a /= 2;
		}
		reverse(all(A[i]));
	}
	ll ans = 0;
	rep(c,60){
		int count = 0;
		rep(i,n){
			count += A[i][c];
		}
		if(count%2 == 1){
			ans += lpow((ll)2, 60-c-1);
			rep(i,n){
				A[i][c] = 0;
			}
		}
	}
	vector<bool> kitei;
	rep(i,n){
		kitei.push_back(false);
	}
	rep(c,60){
		int br = 0;
		while(br < n && (A[br][c] == 0 || kitei[br])){
			br++;
		}
		if(br == n){
			continue;
		}
		kitei[br] = true;
		rep(r,n){
			if(br == r) continue;
			if(A[r][c] == 1){
				rep(j, 60){
					A[r][j] ^= A[br][j];
				}
			}

		}
	}
	/*rep(i,n){
		rep(j,60){
			cerr<<A[i][j];
		}
		cerr<<endl;
	}*/

	vector<ll> count;
	
	rep(i,60){
		count.push_back(0);
	}
	rep(c,60){
		if(count[c] > 0){
			if(count[c]%2 == 1){
				ans += lpow((ll)2,60-c);
			}
			continue;
		}
		int r = 0;
		while(r < n && A[r][c] == 0){
			r++;
		}
		if(r == n) continue;

		rep(j,60){
			count[j] += A[r][j];
		}
		ans += lpow((ll)2,60-c);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 31280
#include <cassert>
#include <algorithm>                  
#include <iostream>
#include <vector>
#include <map>
using namespace std;

template<typename T>
struct Fraction{
private:
  void reduce(){
    T g = __gcd(p,q);
    p /= g;
    q /= g;
    if(q < 0) p *= -1, q *= -1;
  }
public:
  T p, q;// p/q
  Fraction(T P, T Q){
    p = P;
    q = Q;
    reduce();
  }
  constexpr Fraction inv(){
    return Fraction(q,p);
  }
  constexpr Fraction operator+(const Fraction &rhs) const noexcept{
    return Fraction(*this) += rhs;
  }
  constexpr Fraction operator-(const Fraction &rhs) const noexcept{
    return Fraction(*this) -= rhs;
  }
  constexpr Fraction operator*(const Fraction &rhs) const noexcept{
    return Fraction(*this) *= rhs;
  }
  constexpr Fraction operator/(const Fraction &rhs) const noexcept{
    return Fraction(*this) /= rhs;
  }
  constexpr Fraction& operator*=(const T &rhs) noexcept{
    p *= rhs;
    reduce();
    return *this;
  }
  constexpr Fraction& operator/=(const T &rhs) noexcept{
    p /= rhs;
    reduce();
    return *this;
  }
  constexpr Fraction& operator+=(const Fraction &rhs) noexcept{
    p = p*rhs.q + rhs.p*q;
    q *= rhs.q;
    reduce();
    return *this;
  }
  constexpr Fraction& operator-=(const Fraction &rhs) noexcept{
    p = p*rhs.q - rhs.p*q;
    q *= rhs.q;
    reduce();
    return *this;
  }
  constexpr Fraction& operator*=(const Fraction &rhs) noexcept{
    q *= rhs.q;
    p *= rhs.p;
    reduce();
    return *this;
  }
  constexpr Fraction& operator/=(const Fraction &rhs) noexcept{
    q *= rhs.p;
    p *= rhs.q;
    reduce();
    return *this;
  }
  constexpr bool operator<(const Fraction &rhs) const {
    assert(rhs.p != 0 or rhs.q != 0);
    return p*rhs.q < q*rhs.p;
  }
  constexpr bool operator>(const Fraction &rhs) const {
    assert(rhs.p != 0 or rhs.q != 0);
    return rhs < *this;
  }
  friend ostream& operator<<(ostream& os, const Fraction f){
    os << "(" << f.p << "/" << f.q << ")";
    return os;
  }
};

int main(){
  int N, K;
  cin >> N >> K;
  vector<pair<int,int>> P;
  for(int i = 0; i < N; ++i){
    int x, y;
    cin >> x >> y;
    P.emplace_back(x,y);
  }
  using F = Fraction<long long>;
  int ans = 0;
  for(int i = 0; i < N; ++i){
    map<F,int> M;
    for(int j = 0; j < N; ++j){
      if(i == j) continue;
      int dx = P[j].first-P[i].first, dy = P[j].second-P[i].second;
      ++M[F(dx,dy)];
    }
    for(auto e : M){
      ans = max(ans,e.second+1);
    }
  }
  cout << (ans >= K) << endl;
}



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

using namespace std;

const int maxn = 1e5 + 50;

string Ret;

bool Ask( string x ){
	cout << "? " << x << endl;
	flush( cout );
	string ans;
	cin >> ans;
	if( ans == "Y" )
		return true;
	return false;
}

int PreDeal(){
	int l = 1 , r = 10;
	while( l < r ){
		int mid = l + r + 1 >> 1;
		string tr;
		tr.push_back( '1' );
		for(int i = 1 ; i < mid ; ++ i) tr.push_back( '0' );
		if( Ask( tr ) )
			l = mid ;
		else
			r = mid - 1;
	}
	return l;
}

int main( int argc , char * argv[] ){
	int len = 1;
	if( Ask( "1000000000000") ){
		for(int i = 10 ; i >= 1 ; -- i){
			string dw;
			for(int j = 1 ; j <= i ; ++ j) dw.push_back( '9' );
			if( Ask( dw ) == false ){
				len = i + 1;
				break;
			}
		}
		string www = "1";
		for(int i = 2 ; i <= len ; ++ i) www.push_back( '0' );
		cout << "! " << www << endl;
		flush( cout );
		return 0;
	}else
		len = PreDeal();
	if( len == 1 ){
		for(int i = 1 ; i <= 9 ; ++ i){
			string w;
			w.push_back( i + '0' );
			w.push_back( '9' );
			if( Ask( w ) ){
				cout << "! " << to_string( i ) << endl;
				flush( cout );
				return 0;
			}
		}
		return 0;
	}
//	cerr << "Len is " << len << endl;
	string Ret = "0";
	for(int i = 0 ; i < len - 1 ; ++ i){
		int l = i ? 0 : 1 , r = 9;
		while( l < r ){
			int mid = l + r + 1 >> 1;
			Ret[i] = mid + '0';
			if( !Ask( Ret ) )
				r = mid - 1;
			else
				l = mid ;
		}
		Ret[i] = l + '0';
		Ret.push_back( '0' );
	}
	Ret.push_back( '0' );
	for(int i = 0 ; i <= 9 ; ++ i){
		Ret[Ret.size() - 2] = i + '0';
		if( Ask( Ret ) == 1 )
			break;
	}
	Ret.pop_back();
	cout << "! " << Ret << endl;
	flush( cout );
	return 0;
}

Measured memory_bytes: 692
#include "stdio.h"                                     
int main(void){
int x,y,r;
int W,H;
scanf(" %d %d %d %d %d",&W,&H,&x,&y,&r);
if(W<x+r || H<y+r || x-r<0 || y-r<0){
puts("No");
}else{
puts("Yes");
}
return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
   int n,a; cin>>n>>a;
   cout<< n*n-a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define rp(i,n) for(int i=0;i< n;i++)
#define rpd(i,n) for(int i=n-1;i >= 0;i--)

using namespace std;



int main() {

	string s;
	cin >> s;
	ll ans = 0;
	ll n = s.length();
	rpd(i,n){
		ll r = n-1-i;
		rp(j,r+1){
			ans +=(s[i] - '0')*(1<<i)*pow(10,j)*(1<<max(r-j-1,0ll));
			// cout << ans << " - " << s[i] << ", j - "<<j<<endl;
			//12 5
		}
	}
	cout << ans;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] abc = scanner.nextLine().split(" ", 3);
        int a = Integer.parseInt(abc[0]);
        int b = Integer.parseInt(abc[1]);
        int c = Integer.parseInt(abc[2]);

        if (a + b >= c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23636
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0

def multiple(l,m,n):
    ans = 500*l + 100*m + 50*n
    return ans
o = 0
p = 0
q = 0

while o <= a:
    while p <= b:
        while q <= c:
            ans_x = multiple(o,p,q)
            if x == ans_x:
                count += 1
            q += 1
        q = 0
        p += 1
    q = 0
    p = 0
    o += 1

print(count)

Measured memory_bytes: 3064
#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 <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
const ll INF = 1LL << 60;
const double PI = acos(-1.0);



int main() {

	string str;
	cin >> str;
	int n = str.size();
	int cnt = 0;
	vector<bool> c(n, false);
	for (int i = 1; i < n; i++) {
		if (str[i] == 'T'&&str[i - 1] == 'S') {
			cnt++;
			c[i] = true; c[i - 1] = true;
			int left = i - 2, right = i + 1;
			while (left >= 0 && right < n) {
				if (c[left]) {
					left--;
					continue;
				}
				if (c[right]) {
					right++;
					continue;
				}
				if (str[left] == 'S'&&str[right] == 'T') {
					cnt++;
                  	c[left]=true; c[right]=true;
					left--; right++;
				}
				else break;
			}
		}
	}
	cout << max(n - 2 * cnt, 0) << endl;

	return 0;
}

Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var cardNum, gateNum int
	fmt.Scan(&cardNum, &gateNum)

	curMin := 1
	curMax := cardNum

	for i := 0; i < gateNum; i++ {
		var min, max int
		fmt.Scan(&min, &max)
		if min > curMin {
			curMin = min
		}

		if max < curMax {
			curMax = max
		}
	}

	masterCardNum := curMax - curMin + 1
	if masterCardNum < 0 {
		masterCardNum = 0
	}
	fmt.Println(masterCardNum)
}


Measured memory_bytes: 5504
//import java.io.*;
//import java.util.Arrays;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

class Main{
	public static void main(String[] args) throws IOException {
	  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    Deque<Integer> dq = new ArrayDeque<Integer>();

    int n = Integer.parseInt(br.readLine());

    for(int i = 0;i < n;i++){
      String com = br.readLine();
      if(com.charAt(0) == 'i') dq.push(Integer.parseInt(com.substring(7)));
      //else if(com.charAt(0) == 'd') dq.remove(Integer.parseInt(com.substring(7)));
      else if(com.charAt(6) =='F') dq.removeFirst();
      else if(com.charAt(6) =='L') dq.removeLast();
      else dq.remove(Integer.parseInt(com.substring(7)));
    }
    /*for(int i = 0; i < dq.length();i++){
      System.out.println(dq);
      //if()
    }*/
    System.out.print(dq.poll());
    for(int num : dq){
      System.out.print(" "+num);
      //dq.length();
    }
    System.out.println();
  }
}



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

int main(void)
{
	int a[3], b[3],count[5];
	bool flag = true;
	for (int i = 0; i <= 4; i++) { count[i] = 0; }
	for (int i = 0; i <= 2; i++)
	{
		cin >> a[i] >> b[i];
		count[a[i]] += 1;
		count[b[i]] += 1;
	}
	for (int i = 0; i <= 4; i++)
	{
		if (3 <= count[i]) { flag = false; }
	}
	if (flag) { cout << "YES"; }
	else { cout << "NO"; }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if(a == 1) a = 14; if(b == 1) b = 14;
    cout << (a > b ? "Alice" : (a < b ? "Bob" : "Draw")) << endl;
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/agc035/tasks/agc035_a
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce

# 成り立つ連立方程式を見ると、各項が二回ずつ出てきてることがわかる
# ということはすべての和を取ると0になるのが条件だ

N = read_a_int()
A = read_ints()
res = reduce(xor, A)
print('Yes' if res == 0 else 'No')


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

int n, A[MAX + 1], L[MAX];

int lis() {
    L[0] = A[0];
    int length = 1;
    for (int i = 1; i < n; i++) {
        if (L[length-1] < A[i]) {
            L[length++] = A[i];
        } else {
            *lower_bound(L, L + length, A[i]) = A[i];
        }
    }

    return length;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    cout << lis() << endl;

    return 0;
}


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

const int N = 100007;

vector< pair<int,int> > g[N];
bool ok = 1;
bool vis[N];
vector<int> A(N);

void dfs(int x){
	vis[x] = 1;

	for(int i = 0; i < (int)g[x].size();i++){
		int to = g[x][i].first;
		int len = g[x][i].second;
		if(!vis[to]){
			A[to] = A[x]+len;
			dfs(to);
		} else {
			if(A[to]!=A[x]+len) ok = 0;
		}
	}
}

int main(){
	
	int n,m;
	cin>>n>>m;

	for(int i = 0;i<m;i++){
		int l,r,d;
		cin>>l>>r>>d;
		g[l].push_back(make_pair(r,d));
		g[r].push_back(make_pair(l,-d));
	}

	for(int i = 1;i < n;i++){
		if(!vis[i]) dfs(i);
	}
	if(ok) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 12032
import math

n=int(input())

#def koch(p1,p2,n):
def koch(d,p1,p2):
  if d==0:
    return
  #3等分する
  s=[(2*p1[0]+1*p2[0])/3,(2*p1[1]+1*p2[1])/3]
  t=[(1*p1[0]+2*p2[0])/3,(1*p1[1]+2*p2[1])/3]
  #正三角形の頂点のひとつである座標を求める
  u=[
    (t[0]-s[0])*math.cos(math.radians(60))-(t[1]-s[1])*math.sin(math.radians(60))+s[0],
    (t[0]-s[0])*math.sin(math.radians(60))+(t[1]-s[1])*math.cos(math.radians(60))+s[1]
    ]
  koch(d-1,p1,s)
  print(*s)
  koch(d-1,s,u)
  print(*u)
  koch(d-1,u,t)
  print(*t)
  koch(d-1,t,p2)

print('0 0')
koch(n,[0,0],[100,0])
print('100 0')


Measured memory_bytes: 5780
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"

#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define LINF ((ll)1 << 60)
#define INF (1 << 28)
template<typename T>
void chmax(T& a, T b) {
        if (a < b) a = b;
}
template<typename T>
void chmin(T& a,T b) {
        if (a > b) a = b;
}
int T = 1;
//.....................
ull mod = (int)1e9 + 7;
const int MAX = (int)2e5 + 5;

bool isVowel(char c) {
        char vowels[] = {'a', 'e', 'i', 'o', 'u'};
        rep(i, 5) {
                if (c == vowels[i]) return true;
        }
        return false;
}

void solve() {
        char c;
        cin >> c;
        cout << (isVowel(c) ? "vowel" : "consonant") << endl;
}

signed main() {
        cout << fixed << setprecision(20);
        rep(i, T) {
                solve();
        }
        return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int cnt = 0;
    int max = 0;
    int next = 0;
    int maxi = 0;
    while(cnt<n){
      a[cnt] = sc.nextInt();
      if(a[cnt]>next){
        next = a[cnt];
        if(a[cnt]>max){
          next = max;
          max = a[cnt];
          maxi = cnt;
        }
      }
      cnt++;
    }
    cnt = 0;
    while(cnt<n){
      if(cnt!=maxi){
         System.out.println(max);
      }else{
         System.out.println(next);
      }
      cnt++;
    }
  } 
}

Measured memory_bytes: 92168
#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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;


const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }//最初は全て-1 :-1なら根なので全て根:木のサイズが増えると-2-3-4となる
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);//両方のルートを出して、それをつなげる
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }

  bool findSet(int x, int y) {//要素xとyが同じ集合か　→　rootを調べれば解決
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);//-1なら根、そうでないなら配列が指す場所へ移動
  }
  int size(int x) {
    return -data[root(x)];
  }
};






int main() {
  long n, m;
  cin >> n >> m;

  vector<pair<long, long>> mp(m);

  for (int i = 0; i < m; ++i){
    long a, b;
    cin >> a >> b;

    mp[i] = make_pair(a - 1, b - 1);
  }

  struct UnionFind uftree1(n);//全部で12こ//最初は全部が根
  //1と同じグループ
  // uftree1.unionSet(1, 3);


  vector<long> ans;
  ll tmp = n * (n - 1) / 2;
  for (int i = m - 1; i >= 0; --i) {
    ans.push_back(tmp);
    long x = mp[i].first;
    long y = mp[i].second;
    if ( uftree1.findSet(x, y)  ) {
    } else {
      long xs = uftree1.size(x);
      long ys = uftree1.size(y);

      tmp-=xs*ys;
      uftree1.unionSet(x, y);
    }
    
  }





  for (int i = m - 1; i >= 0; --i) {
    cout << ans[i] << endl;
  }

  // cout << ans << endl;

}




















Measured memory_bytes: 4212
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;
typedef long long ll;
const int inf = 10000000;
void chmin(int &a,int b){if(a>b) a=b;} //Compare two numbers and return smaller one in reference variety a

int N,M;
struct Data
{
    int to;
    int dis;
};


vector<vector<Data>> Tree(200010);
vector<bool> Visited(100010,false);
vector<int> dis(100010 , 0);

bool dfs(int to,int dist)
{
    if(Visited[to]==true && dist!=dis[to]) return true;
    if(Visited[to]==true && dist==dis[to]) return false;

    Visited[to]=true;
    dis[to]=dist;
    for(int j=0 ;j<(int)Tree[to].size();j++)
    {
        if(dfs(Tree[to][j].to,dis[to]+Tree[to][j].dis))return true;
    }
    return false;
}


int main()
{
    cin>>N>>M;
    for(int i=0;i<M;i++)
    {
        int l,r,d;
        cin>>l>>r>>d;
        l--,r--;
        Tree[l].push_back({r,d});
        Tree[r].push_back({l,-d});
    }
    for(int i=0;i<N;i++)
    {
        if(!Visited[i] && dfs(i,0))
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

}

Measured memory_bytes: 13440
n = int(input())
H = list(map(int, input().split()))

ans = 'Yes'
m = H[0]

if n == 1:
    ans
else:
    for i in range(1, n):       
        if H[i] >= m-1:
            m = max(H[i], m)
            continue
        else:
            ans = 'No'
            break
print(ans)


Measured memory_bytes: 20680
var
    n,x,i,max,min,atot1,atot2,btot1,btot2,ta,tb:longint;
    a,b:array[0..100010] of longint;
begin
    readln(n);
    max:=0;min:=maxlongint;
    fillchar(a,sizeof(a),0);
    fillchar(b,sizeof(b),0);
    for i:=1 to n do
        begin
            read(x);
            if odd(i) then inc(a[x]) else inc(b[x]);
            if x>max then max:=x 
            else if x<min then min:=x;
        end;
    for i:=min to max do
        begin
            if a[i]>atot1 then 
                begin 
                    atot2:=atot1;atot1:=a[i];ta:=i;
                end
            else if a[i]>=atot2 then atot2:=a[i];
            if b[i]>btot1 then
                begin 
                    btot2:=btot1;btot1:=b[i];tb:=i;
                end
            else if b[i]>=btot2 then btot2:=b[i];
        end;
    if ta<>tb then writeln(n-atot1-btot1)
    else if atot1+btot2>atot2+btot1 then writeln(n-atot1-btot2)
    else writeln(n-atot2-btot1);
end.

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


int main()
{
    string s;
    cin>>s;
    int cnt[3]={0};
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='a')
            cnt[0]++;
        else if(s[i]=='b')
            cnt[1]++;
        else cnt[2]++;
    }
    int ok=1;
    sort(cnt,cnt+3);

    while(1)
    {
        if(cnt[0]&&cnt[1]&&cnt[2])
            cnt[0]--,cnt[1]--,cnt[2]--;
        else if(cnt[1]&&cnt[2])
        {
            if(cnt[2]>1)
                ok=0;
            cnt[1]--,cnt[2]--;
        }
        else if(cnt[2])
        {
            if(cnt[2]>1)
                ok=0;
            cnt[2]--;
        }
        else break;
    }
    cout<<((ok)?"YES\n":"NO\n");
    return 0;
}


Measured memory_bytes: 512
s = list(input())

leng = len(s) - 1
ans = 0
for i in range(2 ** leng):
    bit = []
    for j in range(leng):
        if ((i >> j) & 1):
            bit.append(s[j])
            bit.append("+")
        else:
            bit.append(s[j])
    bit.append(s[leng])
    sub = 0
    plus = 0
    for k in range(len(bit)):
        if bit[k] == "+":
            sub += plus
            plus = 0
        else:
            if plus == 0:
                plus = int(bit[k])
            else:
                plus *= 10
                plus += int(bit[k])
    sub += plus
    ans += sub

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cerr << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define X first
#define Y second
#define pb push_back
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define vi vector<int>
#define vii vector<vector<int>>

int32_t main(){ fast;
	int n, x, t; cin>>n>>x>>t;
	int answer = 0;
	int tmp = 0;
	while(tmp < n){
		tmp += x;
		answer += t;
	}
	cout<<answer<<endl;
}


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

int main() {
    int no;
    double w, h;
    char c;
    while (cin >> no >> c >> w >> c >> h) {
        if (25.0 * h * h - w <= 1e-9) {
            cout << no << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1240
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    int A, B;
    cin >> A >> B;
 
    if (A <= 5)
    {
        cout << 0 << endl;
    }
    else if (6 <= A && A <= 12)
    {
        cout << B / 2 << endl;
    }
    else
    {
        cout << B << endl;
    }
 
    return 0;
}

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

int main(void)
{
    char str[1000], num[1000], c[8];
    int a, b, q, p, i, j, k;
    char g[1000];

    scanf("%s", str);
    scanf("%d", &q);

    for (i = 0; i < q; i++){
        scanf("%s %d %d", c, &a, &b);

        if (strcmp (c, "print") == 0){
            //printf("%s", str);
            for (j = a; j <= b; j++){
                printf("%c", str[j]);
            }

            printf("\n");

        }else if (strcmp(c, "reverse") == 0){
            //printf("%s", str);
            for(j = a; j <= b; j++){
                num[b - j] = str[j];
            }

            for (j = a; j <= b; j++){
                str[j] = num[j - a];
            }
            
        }else if (strcmp(c, "replace") == 0){
            scanf("%s", g);
            for (j = 0, k = a; k <= b; j++, k++){
                str[k] = g[j];
            }
        }
    }

    return (0);
}


Measured memory_bytes: 2700
#include<bits/stdc++.h>
#define ll long long
#define Speeed  ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
using namespace std;
int main(){
    Speeed
  string s, c;
  cin>>s;
  ll q, t, f;
  int flag=1;
  cin>>q;
  while(q--){
      cin>>t;
      if(t==1){
          if(flag==1)flag=0;
          else flag=1;
      }
      else{
          if(flag){
          cin>>f>>c;
          if(f==1)s.insert(0,c);
          else s+=c;
        }
        else{
            cin>>f>>c;
          if(f==1)s+=c;
          else s.insert(0,c);
            }
        }
    }
    if(!flag) reverse(s.begin(),s.end());
    cout<<s;
}

Measured memory_bytes: 912
#include <stdio.h>
#include <math.h>

int print_int128(__int128 n) {
  if (n == 0)  return printf("0\n");

  char str[40] = {0}; // log10(1 << 128) + '\0'
  char *s = str + sizeof(str) - 1; // start at the end
  while (n != 0) {
    if (s == str) return -1; // never happens

    *--s = "0123456789"[n % 10]; // save last digit
    n /= 10;                     // drop it
  }
  return printf("%s\n", s);
}

int main()
{
	int num;
	int table[1001][1001]={0};

	scanf("%d",&num);

	for( int k=1; k<=num; k++ ){
		int n = k;
		int i=2;
		while(n!=1){
			if(n%i==0){
				n /= i;
				table[k][i]++;
			}
			else{
				i++;
			}
		}
#if 0
		for( int i=1; i<=num; i++ ){
			printf("%3d %3d %3d\n",k, i, table[k][i]);
		}
#endif
	}
	int t[1001]={0};
	for( int k=1; k<=num; k++ ){
		for( int i=1; i<=num; i++ ){
			t[k]+=table[i][k];
		}
	}
#if 0
	printf("\n");
	for( int i=1; i<=num; i++ ){
		printf("%3d %d\n",i, t[i]);
	}
#endif
	__int128 cnt = 1;
	for( int i=1; i<=num; i++ ){
		cnt *= (__int128)(t[i]+1);
		cnt %= ( (__int128)pow(10,9) + 7 );
	}
	print_int128(cnt);
	//printf("%lld",cnt%( (unsigned long long int)pow(10,9) + 7 ));

	return 0;
}



Measured memory_bytes: 4096
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MAX 200001

typedef long long int lli;

int main(void)
{
	lli n, k, a[MAX], f[MAX], time[MAX];
  scanf("%lld %lld", &n, &k);

  for (lli i = 0; i < n; i++)
    scanf("%lld", &a[i]);

  for (lli i = 0; i < n; i++)
    scanf("%lld", &f[i]);

  qsort(a, n, sizeof(lli), acs);
  qsort(f, n, sizeof(lli), des);

	lli max = 0;
  for (lli i = 0; i < n; i++)
  {
    time[i] = a[i] * f[i];
		max = max(time[i], max);
  }

	lli min = 0;
	lli count = 0;
	while (max - min > 0) {
		lli half  = (max + min) / 2;
		count = 0;
		for (lli i = 0; i < n; i++) {
			if (time[i] <= half) continue;
			if ((time[i] - half) % f[i]  == 0) count += (time[i] - half) / f[i];
			else count += (time[i] - half) / f[i] + 1;
		}
		if (max - min == 1) break;
		if (count <= k) max = half;
		else min = half;
	}
	
	lli ans = 0;
	if (count <= k) ans = min;
	else ans = max;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 6396
#include<stdio.h>
int main(void){
	int n,q,i;
	scanf("%d",&n);   scanf("%d",&q);
	char qname[n][11];
	int qtime[n];
	int next[n];
	int start=0,end=n-1;
	int cnt=0;
	scanf("%s",qname[0]);   scanf("%d",&qtime[0]);
	for(i=1;i<n;i++){
	scanf("%s",qname[i]);   scanf("%d",&qtime[i]);
	next[i-1]=i;
	}
	next[n-1]=-1;
	while(start!=-1){
		if(qtime[start]>q){
			qtime[start]-=q;
			next[end]=start;
			end=start;
			start=next[start];
			next[end]=-1;
			cnt+=q;
		}else{
			cnt+=qtime[start];
			printf("%s %d\n",qname[start],cnt);
			start=next[start];
		}
	}
	return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    double num[1010];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> num[i];
    }
    double sum = 0;
    for(int i=0; i<N; i++){
        sum += 1/num[i];
    }
    cout << 1/sum;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> v[n];
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            int ans;
            cin>>ans;
            v[i].push_back(ans);
        }
    }
    for(int i = 1; i < n; i++)
    {
        v[i][0] = v[i][0] + max(v[i-1][1], v[i-1][2]);
        v[i][1] = v[i][1] + max(v[i-1][0], v[i-1][2]);
        v[i][2] = v[i][2] + max(v[i-1][1], v[i-1][0]);
    }
    cout<<*max_element(v[n-1].begin(), v[n-1].end());
}


Measured memory_bytes: 5760
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	ll N; cin >> N;
	V<ll> a(N);
	REP(i, N) cin >> a[i];
	ll ans = 0;
	while(1){
		int idx = max_element(ALL(a)) - a.begin();
		if (a[idx] < N) break;
		ans += a[idx] / N;
		REP(j, N) if (j != idx) a[j] += a[idx] / N;
		a[idx] %= N;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N,a;
  cin >> N;
  a = 0;

  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;

    if (S == "Y") {
      a++;
      cout << "Four" << endl;
      break;
    }
  }
  
  if (a==0)
    cout << "Three" << endl;
  
}


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

class Stack{
	int index = 0;
	int arr[200] = {};
public:
	bool isFull(){
		return (index > 200);
	}
	bool isEmpty(){
		return (index <= 0);
	}
	void push(int a){
		if(isFull()){ std::cout << "stack is full." << std::endl; return;}
		arr[index] = a;
		++index;
	}
	int pop(){
		if(isEmpty()){
		    std::cout << "stack is enpty." << std::endl;
		    return -1;
		}
		
		return arr[--index];
	}
};


int main(){
	Stack s;
	char c[100];
	while(std::cin >> c){
	//if(std::cin.eof()) break;
		int a, b;
		if(c[0] == '+'){
			b = s.pop();
			a = s.pop();
			s.push(a + b);
		}
		else if(c[0] == '-'){
			b = s.pop();
			a = s.pop();
			s.push(a - b);
		}
		else if(c[0] == '*'){
			b = s.pop();
			a = s.pop();
			s.push(a * b);
		}
		else{
			s.push(std::stoi(c));
		}

	}
	std::cout << s.pop() << std::endl;

	return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

using namespace std;

int main()
{
	int N,M;
	int i,j,k,l;
	long long int B = 0;
	multiset<int> S;
	cin >> N;
	cin >> l >> j >> k;
	B += k;
	S.insert(j);
	auto pos = S.begin();
	int cur = j;
	//同じ値なら左に行く
	int left = 0;
	int right = 0;
	long long int total = 0;
	for(i=1;i<N;++i)
	{
		cin >> l;
		if(l==1)
		{
			cin >> j >> k;
			B += k;
			S.insert(j);
			total += ABS(cur-j);
			if(cur <= j)
				right++;
			else
				left++;

			if(right > left + 1 && pos != S.end())
			{
				pos ++;
				total -= (right-left-1)*(*pos-cur);
				right --;
				left++;
				cur = *pos;
			}
			else if(right < left && pos != S.begin())
			{
				pos--;
				total += (left-right-1)*(cur-*pos);
				right++;
				left--;
				cur=*pos;
			}
		} 
		else
		{
			cout << *pos << " " << total+B << endl;
		}
	}

	return 0;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define INF 100000

int main()
{
  int h,w;cin>>h>>w;
  vector<vector<int>> c(10,vector<int>(10));
  vector<vector<int>> a(h,vector<int>(w));
  int i,j,k;
  rep(i,10)rep(j,10)cin>>c[i][j];
  rep(i,h)rep(j,w)cin>>a[i][j];
  vector<vector<int>> wf(10,vector<int>(10,INF));
  rep(i,10)rep(j,10)wf[i][j]=c[i][j];
  rep(k,10)rep(i,10)rep(j,10)wf[i][j]=min(wf[i][j],wf[i][k]+wf[k][j]);
  int ans=0;
  rep(i,h)
  {
    rep(j,w)
    {
      if(a[i][j]==-1)continue;
      ans+=wf[a[i][j]][1];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
n=int(input())
x=[]
y=[]
for i in range(n):
  a,b=map(int,input().split())
  x.append(a)
  y.append(b)
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    ans+=((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5



print(ans*2/n)

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<int>());
    while (A.size() > 1) {
        for (int i = 0; i < A.size()-1; i++) A[i] = A[i] % A[A.size()-1];
        sort(A.begin(), A.end(), greater<int>());
        while (A.back() == 0) A.pop_back();
	}
    cout << A[0] << endl;

    return 0;
}

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

int n;
long long A[305][305];
int g[305][305];

int main()
{
	scanf("%d", &n);
	long long sum = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			scanf("%lld", &A[i][j]), sum += A[i][j];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			for (int k = 1; k <= n; k++) {
				if (i == j || i == k || j == k) continue;
				if (A[i][k]+A[k][j] < A[i][j]) {
					puts("-1");
					return 0;
				}
				if (!g[i][j] && A[i][j] == A[i][k]+A[k][j]) g[i][j] = g[j][i] = 1, sum -= A[i][j]*2;
			}
        cout << sum/2 << endl;
	return 0;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int A,B,C,N,W,H,ans = 0,dp[HMAX][WMAX],K,X,Y;
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){

}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N >> K >> X >> Y;
	for (int i = 0; i < N; ++i)
	{
		if(i < K){
			ans += X;
		}else{
			ans += Y;
		}
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 256