akhauriyash/Code-Regression huggingface dataset:
use strict;
use utf8;
use warnings;
use feature qw/say/;

my $a = <>; chomp($a);
my $b = <>; chomp($b);
my $c = <>; chomp($c);
my $d = <>; chomp($d);
my $e = <>; chomp($e);
my $k = <>; chomp($k);

my @arr = ($a, $b, $c, $d, $e);

if ($e - $a <= $k) {
    say 'Yay!';
} else {
    say ':(';   
}

Measured memory_bytes: 768
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define pi 2*acos(0.0)
int main()
{
    int rad;
    double circum;

    scanf("%d",&rad);

    circum=2*pi*rad;

    printf("%lf\n",circum);

    return 0;
}


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

int main(){
  int N, ans;
  
  cin >> N;
  
  for(int i = 0; i < N; i++){
    int l, m;
    cin >> l >> m;
    ans += ((m - l) + 1);
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    string s;
    cin >> s;
    vector<char> T;
    for (int i = 0; i < s.size(); i++){
        if (s.at(i) != 'B') {
            T.push_back(s.at(i));
            continue;
        }
        if (T.size() > 0) {
            T.pop_back();
        }
    }
    for (int i = 0; i < T.size(); i++) {
        cout << T.at(i);
    }
    cout << endl;
}

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

const int MAX = 1 << 30;

struct node {
	ll sum, add;
	node *lch, *rch;
	node() : sum(0), add(0), lch(nullptr), rch(nullptr) {}
};

const int pmax = 1e7;
node pool[pmax];
int it = 0;

node* fix(node *x) {
	node *y = &pool[it++];
	if (x) *y = *x;
	return y;
}

node* add(node *x, int l, int r, int lb = 0, int ub = MAX) {
	if (r <= lb || ub <= l) return x;
	x = fix(x);
	if (l <= lb && ub <= r) {
		x->add++;
		return x;
	}
	int c = (lb + ub) / 2;
	x->lch = add(x->lch, l, r, lb, c);
	x->rch = add(x->rch, l, r, c, ub);
	x->sum += min(r, ub) - max(l, lb);
	return x;
}

ll find(node *x, int l, int r, int lb = 0, int ub = MAX) {
	if (!x || r <= lb || ub <= l) return 0;
	if (l <= lb && ub <= r) return x->sum + x->add * (ub - lb);
	int c = (lb + ub) / 2;
	return find(x->lch, l, r, lb, c) + find(x->rch, l, r, c, ub) + x->add * (min(r, ub) - max(l, lb));
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<vector<int>> vab(M, vector<int>(3));
	vector<int> vs;
	for (int i = 0; i < M; i++) {
		cin >> vab[i][1] >> vab[i][2] >> vab[i][0]; vab[i][1]--;
		vs.push_back(vab[i][0]);
	}
	sort(vab.begin(), vab.end());
	sort(vs.begin(), vs.end());
	vs.erase(unique(vs.begin(), vs.end()), vs.end());
	int s = vs.size();
	node* root = nullptr;
	vector<node*> rts(s);
	for (int i = 0, j = 0; i < s; i++) {
		while (j < M && vab[j][0] == vs[i]) {
			root = add(root, vab[j][1], vab[j][2]);
			j++;
		}
		rts[i] = root;
	}
	while (Q--) {
		int x, y;
		ll j;
		cin >> x >> y >> j; x--, j--;
		int lb = -1, ub = s - 1;
		while (ub - lb > 1) {
			int m = (lb + ub) / 2;
			if (find(rts[m], x, y) <= j) {
				lb = m;
			}
			else {
				ub = m;
			}
		}
		printf("%d\n", vs[ub]);
	}
	return 0;
}



Measured memory_bytes: 322096
#include<bits/stdc++.h>
using namespace std;
#define mx 10000000
#define ll long long
ll a[mx+5]={};
vector<ll> v;

void finddiv()
{
    ll i,j;
    v.push_back(0);
    for(i = 1; i <= mx; i++)
    {
        for(j = i; j <= mx; j+=i)
        {
            a[j]++;
        }
        v.push_back(a[i]*i+v.back());
    }
}
int main()
{
    finddiv();
    ll n,a1;
    cin>>n;
   // a1 = accumulate(v.begin(),v.begin()+n,0);
    cout<<v[n];



}



Measured memory_bytes: 212476
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;

int main(){
    ll n, k;
    cin>>n>>k;

    n = n%k;

    cout<<min(n, k-n)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
  int money;
  int kind=0;
  
  do {
    scanf("%d",&money);
  } while(money < 0 || money > 1000000000);
  
  while(money >= 500){
    kind += 1000;
  	money -= 500;
  }
  while(money >=5){
    kind += 5;
    money -= 5;
  }
  printf("%d\n",kind);
    
  return 0;
}

Measured memory_bytes: 128
#include <stdint.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long X, long long N, std::vector<long long> p) {
  vector<bool> v(102, false);
  REP(i, N) {
    v[p[i]] = true;
  }
  ll ans = 0;
  FOR(i, 1, v.size()) {
    if (!v[i]) {
      if (abs(i - X) < abs(ans - X)) {
        ans = i;
      }
    }
  }
  cout << ans << endl;
}

int main() {
  long long X;
  scanf("%lld", &X);
  long long N;
  scanf("%lld", &N);
  std::vector<long long> p(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &p[i]);
  }
  solve(X, N, std::move(p));
  return 0;
}


Measured memory_bytes: 3692
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        List<Integer> result = new ArrayList<>(Arrays.asList(1,2,3));
        result.removeIf(val -> val == a || val == b);

        // 出力
        System.out.println(result.get(0));
    }
}

Measured memory_bytes: 28364
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int N , M;
    cin >> N >> M;
    vector<int> A(N) , B(N);
    for(int i=0;i<N;i++){
        cin >> A[i] >> B[i];
    }
    vector<pair<int,int>> AB(N);
    for(int i=0;i < N;i++){
        AB[i] = make_pair(A[i],B[i]);
    } 
    sort(AB.begin(),AB.end());
    long long ans =0;
    for(int i =0;i<N;i++){
        int m = min(AB[i].second,M);
        ans += (long long)m * AB[i].first;
        M -= m;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
using System;
 
namespace AtCoder {
    class Program {
        static void Main() {
            int n = int.Parse(Console.ReadLine());
            long sum = 0;
            for(int i = 1; i <= n; i++) {
                sum += i % 3 == 0 ? 0 : i % 5 == 0 ? 0 : i; 
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 27540
n=int(input())

def solve(n):
  for i in range(n//2):
    a=str(i+1)
    b=str(n-i-1)
    temp=0
    for ca in a:
      temp+=int(ca)
    for cb in b:
      temp+=int(cb)
    if i==0:
      res=temp
    else:
      res=min(res,temp)
  return res
  
print(solve(n))

Measured memory_bytes: 3064
h, w, k = map(int, input().split())

MOD = 10**9 + 7
k -= 1

dp = [[0] * w for _ in range(h+1)]
dp[0][0] = 1

for i in range(h):
    for j in range(w):
        for bit in range(1<<(w-1)):
            ok = True
            for _ in range(w-2):
                if not (bit + (bit<<1) == bit ^ (bit<<1)):
                    ok = False
            if not ok:
                continue
            ni = i+1; nj = j
            if (bit>>j) & 1:
                nj = j+1
            elif j > 0 and (bit>>(j-1)) & 1:
                nj = j-1
            dp[ni][nj] += dp[i][j]
            dp[ni][nj] %= MOD           

ans = dp[h][k]
ans %= MOD
print(ans)

Measured memory_bytes: 43756
h, w = map(int, input().split())
masu = [[0 for x in range(w)] for y in range(h)]
for y in range(0, h):
    z = list(input())
    for x in range(0, w):
        masu[y][x] = z[x]
hantei = "Yes"
for y in range(0, h):
    for x in range(0, w):
        if (masu[y][x] == "#"):
            if (not((y > 0 and masu[y - 1][x] == "#") or (y < h - 1 and masu[y + 1][x] == "#") or (x > 0 and masu[y][x - 1] == "#") or (x < w - 1 and masu[y][x + 1] == "#"))):
                hantei = "No"
print (hantei)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
struct node
{
    int k;
    int a[15];
    int p;
}s[15];
int main()
{
    int n,m;
    int i,j,k;
    int b[15],num,flag,ans,flag1;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        ans=0;
        for(i=0;i<m;i++)
        {
            scanf("%d",&s[i].k);
            for(j=0;j<s[i].k;j++)
            {
                scanf("%d",&s[i].a[j]);
            }
        }
        for(i=0;i<m;i++)
            scanf("%d",&s[i].p);
        for(i=0;i<(1<<n);i++)
        {
            flag=0;
            memset(b,0,sizeof(b));
            for(j=0;j<n;j++)
            {
                if(i&(1<<j))
                {
                    b[j+1]=1;
                }
            }
            
            for(j=0;j<m;j++)
            {
                num=0;
                for(k=0;k<s[j].k;k++)
                {
                    if(b[s[j].a[k]]==1)
                        num++;
                }
                if(num%2!=s[j].p)
                {
                    flag=1;
                    break;
                }
            }
            if(flag==0)
                ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

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

#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
#define deb(x) cout<<#x<<" "<<x<<"\n"
#define Clear(x) memset(x,0,sizeof(x))
#define all(x) (x).begin(),(x).end()

void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pair< ll,ll > &a,pair< ll,ll > &b)
{
	if(a.ff!=b.ff)
		return a.ff<b.ff;
	else
	{
		if(a.ss>b.ss)
			return b.ss<a.ss;
		else if(a.ss<b.ss)
			return a.ss<b.ss;
	}
	return a.ff>b.ff;
}

ll powe(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		{
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}
ll n;
vector< pair<ll,ll> > p;
bool canwe(ld m)
{
	ld mini=inf,maxi=-inf;
	for(ll i=0;i<n;i++)
	{
		ld op=(p[i].ff-m*p[i].ss),ok=(p[i].ff+m*p[i].ss);
		mini=min(mini,ok);
		maxi=max(maxi,op);
	}
	if(maxi<=mini)
		return 1;
	return 0;
}
int main()
{
	checkpoint1();
	ll n,im;
	cin>>n>>im;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	ll l=0,r=1e10;
	while(r>l+1)
	{
		ll m=(l+r)/2;
		ll k=0;
		for(ll i=0;i<n;i++)
			k+=(a[i]-1)/m;
		if(k<=im)
			r=m;
		else
			l=m;
	}
	cout<<r;
	return 0;
}


Measured memory_bytes: 5148
#include <stdio.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
typedef long long ll;

ll max(ll x, ll y, ll z) {
  if(x >= y && x >= z) return x;
  return y >= z ? y : z;
}

ll min(ll x, ll y, ll z) {
  if(x <= y && x <= z) return x;
  return y <= z ? y : z;
}

int main(void) {
  ll N;
  scanf("%lld", &N);
  ll A[1LL << 18];
  REP(i, 0, 1LL << N) scanf("%lld", A + i);

  ll ans = 0;
  REP(k, 1, 1LL << N) {
    ll p = 0, q = 0;
    ll i = k;
    do {
      ll w = max(p, q, A[i]);
      q = p + q + A[i] - w - min(p, q, A[i]);
      p = w;
      i = (i - 1) & k;
    } while(i != k);
    ans = max(ans, p + q, 0);
    printf("%lld\n", ans);
  }
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << ", "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << ", "; cerr << "\n"; }
#define dbm(map) cerr << #map << ":"; for (auto p : map) cerr << "(" << p.first << ", " << p.second << "), "; cerr << "\n";
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vb = vector<bool>;
using vvi = vector<vi>; using vvl = vector<vl>; using vvb = vector<vb>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using vpii = vector<pii>; using vpll = vector<pll>;
using ti3 = tuple<int, int, int>; using tl3 = tuple<ll, ll, ll>;
using mii = map<int, int>; using mil = map<int, ll>; using mli = map<ll, int>; using mll = map<ll, ll>;

const int MOD = 1000000007; // 998244353;

ll modadd(ll x, ll y) {
	ll xp = x % MOD;
	if (x < 0) x += MOD;
	ll yp = y % MOD;
	if (y < 0) y += MOD;
	return (x + y) % MOD;
}

ll modsub(ll x, ll y) {
	return modadd(x, -y);
}

ll modmul(ll x, ll y) {
	return x * y % MOD;
}

// power(mod) x^n
ll modpow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = modmul(res, x);
		x = modmul(x, x);
		n >>= 1;
	}
	return res;
}

// inverse(mod) x^(-1)
ll inv(ll x) {
	return modpow(x, MOD - 2);
}

ll moddiv(ll x, ll y) {
	return modmul(x, inv(y));
}

pii divs(int N, int prm) {
	int deg = 0;
	while (N % prm == 0) {
		N /= prm; deg++;
	}
	pii res(N, deg);
	return res;
}

mii pf(int N) {
	mii res;
	int prm = 2, deg;
	while (prm * prm <= N) {
		if (N % prm == 0) {
			tie(N, deg) = divs(N, prm);
			res[prm] = deg;
		}
		prm += 1;
	}
	if (N > 1) res[N] = 1;
	return res;	
}

int main() {	
	int N; cin >> N;
	vector<int> A(N); rep(i, N) cin >> A.at(i);
	vector<mii> pfA(N);
	mii pfK;
	rep(i, N) {
		for (pii pd : pf(A[i])) {
			int prm, deg; tie(prm, deg) = pd;
			if (pfK.count(prm)) pfK[prm] = max(pfK[prm], deg);
			else pfK[prm] = deg;
		}
	}
	ll K = 1;
	for (pii pd : pfK) {
		int prm, deg; tie(prm, deg) = pd;
		K = modmul(K, modpow(prm, deg));
	}
	ll ans = 0;
	rep(i, N) ans = modadd(ans, moddiv(K, A[i]));
	cout << ans << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
#define PAD(a,b) MP(((a).first + (b).first),((a).second, (b).second))

#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //移動
	{ 0, 1 }, { -1, 0 }, { 1, 0 }, { 0, -1 },
	{ 1, 1 }, { 1, -1 }, { -1, 1 }, { -1, -1 }
};

signed main() {
	int x;
	scanf("%d", &x);
	int cc = 0,ama;
	for (int i = 1;; i++){
		cc += i;
		if (x <= cc){
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import itertools

s = input()

sum = 0

for bs in itertools.product([0, 1], repeat = len(s) - 1):
    ps = list(itertools.compress(range(1, len(s)), bs))
    ls = [0] + ps
    rs = ps + [len(s)]
    for l, r in zip(ls, rs):
        sum += int(s[l:r])

print(sum)


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

//#include <boost/algorithm/string/join.hpp>
//#include <boost/range/irange.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//#include "boost/multi_array.hpp"
//
//using boost::irange;
//using boost::algorithm::join;
//
// boost::multi_array<int, 3> table;
// table.resize(boost::extents[10][9][8]);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N;
  cin >> N;
  vector<string> S(N);
  vi T(N);
  REP(i, N) {
    cin >> S[i] >> T[i];
  }
  string X;
  cin >> X;

  int i=0;
  for (auto& s : S) {
    i++;
    if (s == X) break;
  }

  int ret = 0;
  for (;i<N; i++) {
    ret += T[i];
  }

  cout << ret << endl;

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 384
#define	Rd(s) scanf("%d", &s)
#define	Rs(s) scanf("%s", &s)
#define	Rf(s) scanf("%f", &s)

#define RTNd(n, s, i) for (int i = 0;(i<n) ? scanf("%d", &s), true : false;i++)
#define RTNf(n, s, i) for (int i = 0;(i<n) ? scanf("%lf", &s), true : false;i++)

#define RTEs(s) while (fgets(s, sizeof(s), stdin) != NULL)
#define RTEc(s) while ((s = scanf("%c")) != EOF)

#define Pd(s) printf("%d", s);
#define Pf(s) printf("%f", s);

#define Pn printf("\n");

#define SORTV(v) sort(v.begin(), v.end())
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
typedef long long lli;
using namespace std;


int main() {
	char c;
	int i = 0,j=0;
	while (c = fgetc(stdin), c != '\n') {
		i++;
		if (c == 'p')j++;
	}
	printf("%d\n",i / 2 - j);

	return 0;
}
//改行注意



Measured memory_bytes: 256
#include<iostream>
using namespace std ;
int main()
{
	int m=0 , f=0 , r=0 , t=0 ;
	while(1)
	{
		cin >> m >> f >> r ;
		t=m+f ;
		if(m==-1&&f==-1&&r==-1) break ;
		if(m==-1|f==-1) cout << "F" ;

		else if(80<=t) cout << "A" ;

		else if(65<=t&&t<80) cout << "B" ;

		else if(50<=t&&t<65) cout << "C" ;

		else if(30<=t&&t<50)
		{
			if(50<=r) cout << "C" ;
			else cout << "D" ;
		}
		else if(m+f<30) cout << "F" ;
		cout << endl ;
	}
	return 0 ;
}



Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int L;
	cin >> L;
	double num = L / 3.0;
	printf("%.7f\n", num * num * num);
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    n,m,l = map(int,input().split())
    d = [[10**12]*n for _ in [0]*n]
    for i in range(m):
        a,b,c = map(int,input().split())
        if l >= c:
            d[a-1][b-1] = d[b-1][a-1] = c
    for i in range(n):
        d[i][i] = 0

    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])

    edge = [[10**12]*n for _ in [0]*n]
    for i in range(n):
        for j in range(n):
            if d[i][j] <= l:
                edge[i][j] = 1

    for k in range(n):
        for i in range(n):
            for j in range(n):
                edge[i][j] = min(edge[i][j],edge[i][k] + edge[k][j])

    q = int(input())
    for _ in [0]*q:
        s,t = map(int,input().split())
        if edge[s-1][t-1] >= 10**12:
            print(-1)
        else:
            print(edge[s-1][t-1]-1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 56156
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
#define int long long
#define ll long long
const int maxn=2e5+5;
const ll mod=1e9+7;
int a[maxn];
bool choose[maxn];
bool Less(int x,int y)
{
    return fabs(x)>fabs(y);
}
signed main()
{
    int n,k;
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    sort(a+1,a+n+1,Less);
    int neg=0,pos_which=-1,neg_which=-1;
    for(int i=1;i<=k;i++)
    {
        choose[i]=true;
        if(a[i]>0)
            pos_which=i;
        else if(a[i]<0)
        {
            neg++;
            neg_which=i;
        }
        else if(a[i]==0)
        {
            puts("0");
            return 0;
        }
    }
    int pos_next=-1,neg_next=-1;
    if(neg%2)
    {
        for(int i=k+1;i<=n;i++)
        {
            if(a[i]>0&&pos_next==-1)
                pos_next=i;
            else if(a[i]<0&&neg_next==-1)
                neg_next=i;
            if(pos_next!=-1&&neg_next!=-1)
                break;
        }
        
        if((pos_which!=-1&&neg_next!=-1)&&(neg_which!=-1&&pos_next!=-1))
        {
            if((ll)a[neg_which]*a[neg_next]>(ll)a[pos_which]*a[pos_next])
            {
                choose[pos_which]=false;
                choose[neg_next]=true;
            }
            else
            {
                choose[neg_which]=false;
                choose[pos_next]=true;
            }
        }
        else if(pos_which!=-1&&neg_next!=-1)
        {
            choose[pos_which]=false;
            choose[neg_next]=true;
        }
        else if(neg_which!=-1&&pos_next!=-1)
        {
            choose[neg_which]=false;
            choose[pos_next]=true;
        }
        else
        {
            if(a[n]==0)
            {
                puts("0");
                return 0;
            }
            else
            {
                memset(choose,false,sizeof(choose));
                for(int i=n;i>=n-k+1;i--)
                    choose[i]=true;
            }
        }
    }
    ll ans=1;
    for(int i=1;i<=n;i++)
        if(choose[i])
        {
            ll val=(ll)((ll)a[i]%mod+mod)%mod;
            ans=(ans*val)%mod;
        }
    printf("%lld\n",ans);
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a.at(i);

	int max_num = 0;
	int min_num = __INT_MAX__;
	rep(i, n){
		max_num = max(max_num, a.at(i));
		min_num = min(min_num, a.at(i));
	}

	cout << max_num-min_num << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  char a[H][W+5];
  for (int i=0; i<H; i++)
    cin >> a[i];
  for (int i=0; i<W+2; i++)
    cout << '#';
  cout << endl;
  for (int i=0; i<H; i++) {
    cout << '#';
    for (int j=0; j<W; j++)
      cout << a[i][j];
    cout << "#\n";
  }
  for (int i=0; i<W+2; i++)
    cout << '#';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io::stdin;

fn sum_of_geometric_progression(first_term: &i64, common_ratio: &i64, n: &u32) -> i64 {
    let numerator = first_term * (1 - common_ratio.pow(*n));
    let denominator = 1 - common_ratio;
    numerator / denominator
}

fn main() {
    let stdin = stdin();

    let mut input = String::new();
    stdin.read_line(&mut input).ok();
    let mut hp: i64 = input.trim().parse().unwrap();

    let mut count = 0;
    while hp > 0 {
        hp /= 2;
        count += 1;
    }
    let attack_num = sum_of_geometric_progression(&1, &2, &count);
    println!("{}", attack_num);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdlib>
#include<cstdio>
template<int BUFSIZE>
struct ans_buf {
  char buf[BUFSIZE];
  int i;
  ans_buf(): i(0) {}
  void putZ(unsigned int v, char delim='\n') {
    unsigned int k = 1;
    while(k <= v/10) k*=10;
    for(; k>0; v%=k, k/=10) buf[i++] = (v/k)+'0';
    buf[i++] = delim;
  }
  void out() { std::fwrite(buf, 1, i, stdout); }
};
unsigned int getZ() {
  unsigned int v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

int const MAXN = 3e5;
int const MAXA = 6.4e5;
int N, m[MAXN], d[MAXN+1];

int main() {
  N = getZ();
  std::fill_n(m, N, 0);
  for(int i = 0; i < N; ++i) ++m[getZ()-1];
  std::fill_n(d, N+1, 0);
  for(int i = 0; i < N; ++i) ++d[m[i]];
 
  ans_buf<MAXA> buf;
  int sum_D = 0, sum_iD = N, k = 1;
  for(int ans = N; ans >= 1; --ans) {
    sum_D += d[ans];
    sum_iD -= d[ans]*ans;
    int next_k = sum_iD/ans + sum_D + 1;
    for(int i = k; i < next_k; ++i) buf.putZ(ans);
    k = next_k;
  }
  while(k <= N) { buf.putZ(0); ++k; }
  buf.out();
  return 0;
}


Measured memory_bytes: 3840
from math import factorial
from Queue import PriorityQueue

FACTORIAL=[factorial(i) for i in xrange(13)]
LEFT,UP,RIGHT,DOWN=0,1,2,3
MOVE=[[0] for u in xrange(13)]
MOVE[0] =[-1,-1,-1, 2]
MOVE[1] =[-1,-1, 2, 5]
MOVE[2] =[ 1, 0, 3, 6]
MOVE[3] =[ 2,-1,-1, 7] 
MOVE[4] =[-1,-1, 5,-1]
MOVE[5] =[ 4, 1, 6, 9]
MOVE[6] =[ 5, 2, 7,10]
MOVE[7] =[ 6, 3, 8,11]
MOVE[8] =[ 7,-1,-1,-1]
MOVE[9] =[-1, 5,10,-1]
MOVE[10]=[ 9, 6,11,12]
MOVE[11]=[10, 7,-1,-1]
MOVE[12]=[-1,10,-1,-1]

def hash(cell):
    work = cell[:]
    hash = 0
    for i in xrange(12):
        hash += work[i] * FACTORIAL[13-1-i]
        for ii in xrange(i+1,13):
            if work[ii]>work[i]:
                work[ii]-=1
    return hash

def dehash(key):
    cell=[]
    for i in xrange(13):
        cell.append(key/FACTORIAL[13-1-i])
        key %= FACTORIAL[13-1-i]
    for i in xrange(13-1,-1,-1):
        for ii in xrange(i+1,13):
            if cell[i]<=cell[ii]:
                cell[ii]+=1
    return cell

def evaluate(cell):
    point=[[0,2],
           [1,1],[1,2],[1,3],
           [2,0],[2,1],[2,2],[2,3],[2,4],
           [3,1],[3,2],[3,3],
           [4,2]]
    eva=0
    for i in xrange(0,13):
        if not (cell[i]==0 or cell[i]==12):
            eva+=abs(point[cell[i]][0]-point[i][0])
            eva+=abs(point[cell[i]][1]-point[i][1])
    return eva

while True:
    p=[input()]
    if p==[-1]:
        break
    for u in xrange(4):
        for pp in map(int,raw_input().split()):
            p.append(pp)
    p[p.index(0)]=12
    pq=PriorityQueue()
    init_hash=hash(p)
    init_eva=evaluate(p)
    pq.put([init_eva,init_hash,0])
    visited={}
    visited[init_hash]=True
    ans=0 if init_eva==0 else "NA"
        #cur=[eva,hashkey,step]
    while not pq.empty():
        cur_eva,cur_hash,cur_step=pq.get()
        cur_cell=dehash(cur_hash)
        if not (cur_eva<=20 and ans=="NA"):
            break
        for i in xrange(13):
            if cur_cell[i]==0 or cur_cell[i]==12:
                for ii in [LEFT,UP,RIGHT,DOWN]:
                    if not MOVE[i][ii]==-1:
                        cur_cell[i],cur_cell[MOVE[i][ii]]=cur_cell[MOVE[i][ii]],cur_cell[i]
                        hashkey=hash(cur_cell)
                        if not hashkey in visited:
                            eva=evaluate(cur_cell)
                            if eva==0:
                                ans=cur_step+1
                                break
                            pq.put([evaluate(cur_cell)+cur_step+1,hashkey,cur_step+1])
                            visited[hashkey]=True
                        cur_cell[i],cur_cell[MOVE[i][ii]]=cur_cell[MOVE[i][ii]],cur_cell[i]
    print ans

Measured memory_bytes: 5128
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

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

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

void clr(auto &a,int n){
  a.clear();
  a.resize(n);
}

void unq(auto &a){
  sort(all(a));
  a.resize(unique(all(a))-a.begin());
}

const int N=200005;

vector<int>fc,inv;

int nCr(int n,int r){
  if(n<r){
    return 0;
  }
  return mul(mul(fc[n],inv[r]),inv[n-r]);
}

void prec(int n){
  fc.resize(n);
  inv.resize(n);
  fc[0]=1;
  for(int i=1;i<n;i++){
    fc[i]=mul(fc[i-1],i);
  }
  inv[n-1]=powz(fc[n-1],mod-2);
  for(int i=n-2;i>=0;i--){
    inv[i]=mul(inv[i+1],i+1);
  }
}

ll gett(int x){
  if(x<=1){
    return 0;
  }
  return (x*1ll*(x-1))/2;
}

void solve(){
  int n;
  cin>>n;
  prec(n+1);
  vi a(n);
  cin>>a;
  int ans=0;
  map<int,int>cnt;
  for(auto i:a){
    cnt[i]++;
  }
  for(auto i:cnt){
    ans+=(i.S)*1ll*(i.S-1)/2;
  }
  for(int i=0;i<n;i++){
    cout<<ans-gett(cnt[a[i]])+gett(cnt[a[i]]-1)<<'\n';
  }
  
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    //cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}



Measured memory_bytes: 14208
def getResult(HList, std) :
    for i in range(1, N) :
        if HList[i] > std :
            std = HList[i] - 1

        if HList[i] < std :
            return "No"
    return "Yes"


N = int(input())
HList = [int(i) for i in input().split(" ")]
std = HList[0]
print(getResult(HList, std))

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

int main() {
  int64_t X; cin >> X;
  queue<int> div;
  
  for (int i = 1; i <= sqrt(X); i++) {
    if (X % i == 0) {
      div.push(i);
      div.push(X / i);
    }
  }
  
  int64_t a = 10000;
  int64_t b;
  while (!div.empty()) {
    int64_t N = div.front();
    int64_t B = -200;
    int64_t BN = 0;
    while (B < 200) {
      BN = 5 * pow(B, 4) + 10 * pow(B, 3) * N + 10 * B * B * N * N + 5 * B * pow(N, 3) + pow(N, 4);
      if (BN == X / N) {
        a = B + N;
        b = B;
        break;
      }
      B++;
    }
    if (a != 10000) break;
    div.pop();
  }
  cout << a << " " << b << endl;        
}

Measured memory_bytes: 3904
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static FastReader input = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	static int n, w;
	static int[][] wV;
	static long[][] memo;
	static final int  _INF = (int)-1e9;
	
	static long solve (int n, int w) {
		
		if (w<0) 
			return _INF;
		
		if (n<0) return 0;
		
		if (memo[n][w]!=-1) return memo[n][w];
		long x  = wV[n][1]+solve(n-1, w-wV[n][0]); 
		long y  = solve(n-1, w); 
		
		return memo[n][w] = Math.max(x, y);
		
	}

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

		n = input.nextInt();
		w = input.nextInt();

		wV = new int[n][2];

		for (int i = 0; i < n; i++) {
			wV[i][0] = input.nextInt();
			wV[i][1] = input.nextInt();
		}

		memo = new long[n + 5][(int) 1e5 + 100];

		for (int i = 0; i < memo.length; i++)
			Arrays.fill(memo[i], -1);
		
		
		System.out.println(solve (n-1,w));
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

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

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

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

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

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


Measured memory_bytes: 127060
#include<algorithm>
#include<cmath>
#include<cstdint>
#include<cstdio>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); ++i)
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(v) begin(v), end(v)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

int main() {
  std::ios::sync_with_stdio(false);

  map<string, int> a;
  map<string, int> b;
  int n, m;
  string s;
  cin >> n;
  rep(i, n) {
    cin >> s;
    a[s]++;
  }
  cin >> m;
  rep(i, m) {
    cin >> s;
    b[s]++;
  }

  int ans = 0;
  for(auto t : a) {
    s = t.first;
    if (a[s] > b[s]) {
      ans = max(ans, a[s] - b[s]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
ans = [[0]*W for _ in range(H)]

x, y = 0, 0
sign = 1
for idx, a in enumerate(A):
  idx += 1
  for _ in range(a):
    if x < 0 or x >= W:
      y += 1
      sign = sign * -1
      x += 1 * sign
    ans[y][x] = idx
    x += 1 * sign

for a in ans:
  print(*a)

Measured memory_bytes: 3920
#include<vector>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
#define INF (1e9+1)
#define M 1000000
#define F(i,s,e) for(int i=s;i<e;i++)
struct edge{int to,cost;};
typedef pair<int,int> mypair ;
	void solve(vector<int> ans,vector<vector<edge> > g,int r,int v){
		priority_queue<mypair,vector<mypair>,greater<mypair> > q;
		q.push(mypair(0,r));
		while(!q.empty()){
			mypair temp=q.top();
			q.pop();
			int now=temp.second;
			int cost=temp.first;
			if(cost>ans[now])continue;
			for(int i=0;i<g[now].size();i++){
				edge a=g[now][i];
				int to=a.to;
				if(cost+a.cost<ans[to]){
					ans[to]=cost+a.cost;
					q.push(mypair(ans[to],to));
				}
			}
		}
		for(int i=0;i<v;i++){
		if(ans[i]==INF){
			cout<<"INF"<<endl;
		}else{
			cout<<ans[i]<<endl;
		}
	}
		return;
	}
int main(void){
	int v,e,r;
	cin>>v>>e>>r;
	vector<int> s(e),t(e),d(e);
	vector<int> ans(v,INF);
	ans[r]=0;
	vector<vector<edge> > g(v);
	for(int i=0;i<e;i++){
		cin>>s[i]>>t[i]>>d[i];
		g[s[i]].push_back(((edge){t[i],d[i]}));
	}
	solve(ans,g,r,v);
	/*for(int i=0;i<v;i++){
		if(ans[i]==INF){
			cout<<"INF"<<endl;
		}else{
			cout<<ans[i]<<endl;
		}
	}*/
	return 0;
}


Measured memory_bytes: 26424
#include<stdio.h>
int main()
{
    int t,h,m,s;
    scanf("%d",&t);
    h=t/3600;
    m=(t-h*3600)/60;
    s=(t-h*3600)%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2096
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef bitset<4000005> bs;

int r, c;
string g[505];
bool red[505][505];
bool blue[505][505];
void solve() {
  cin >> r >> c;
  for(int i = 0; i < r; i++) {
    cin >> g[i];
    for(int j = 0; j < c; j++) {
      if(i%2 == 0 && j < c-1) red[i][j] = true;
      else if(i%2 == 1 && j == 0) red[i][j] = true;
      else blue[i][j] = true;
    }
    for(int j = 0; j < c; j++) {
      if(g[i][j] == '#') {
        red[i][j] = true;
        blue[i][j] = true;
      }
    }
  }
  for(int i = 0; i < r; i++) {
    for(int j = 0; j < c; j++) {
      cout << (red[i][j] ? '#' : '.');
    }
    cout << "\n";
  }
  cout << "\n";
  for(int i = 0; i < r; i++) {
    for(int j = 0; j < c; j++) {
      cout << (blue[i][j] ? '#' : '.');
    }
    cout << "\n";
  }
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define mp            make_pair
#define PI            3.14159265
#define M             1000000007
#define MM            998244353
#define fr            first
#define sc            second
#define all(v)        (v).begin(),(v).end()
#define rall(v)       (v).rbegin(),v.rend()
#define vc            vector
#define vi            vector<int>
#define pii           pair<int,int>
#define psi           pair<string,int>
#define pis           pair<int,string>
#define mii           map<int,int>
#define msi           map<string,int>

int ans;
int solve() {
    int n; cin>>n;
    msi m;
    for (int i = 0; i < n; ++i)
    {
        string str; cin>>str;
        sort(all(str));
        m[str]++;
    }
    for(auto it:m){
        //cout<<it<<"\n";
        ans+=((it.sc)*(it.sc-1))/2;
    }
    cout<<ans;
}

signed main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 11264
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class PriorityQueue
    {
        int H;
        int[] heap;
        const int MAX = 2000000;

        public PriorityQueue()
        {
            H = 0;
            heap = new int[MAX];
        }
        
        public PriorityQueue(int size)
        {
            H = size;
            heap = new int[H + 1];
        }

        public void MaxHeapfy(int p)
        {
            while(2 * p <= H)
            {
                int son_n = 2 * p;
                int son = heap[2 * p];
                if(2 * p + 1 <= H && son < heap[2 * p + 1])
                {
                    son = heap[2 * p + 1];
                    son_n++;
                }

                if(son > heap[p])
                {
                    int tmp = heap[p];
                    heap[p] = son;
                    heap[son_n] = tmp;
                }
                else
                {
                    break;
                }

                p = son_n;
            }
        }

        public void BuildMaxHeap()
        {
            for(int s = H / 2; s >= 1; s--)
            {
                MaxHeapfy(s);
            }
        }

        public void Insert(int key)
        {
            H++;
            heap[H] = key;

            int son = H;

            while(son != 1)
            {
                int p = son / 2;
                if(heap[son] > heap[p])
                {
                    int tmp = heap[p];
                    heap[p] = heap[son];
                    heap[son] = tmp;
                    son /= 2;
                }
                else
                {
                    break;
                }
            }

        }

        public int ExtractMax()
        {
            int max = heap[1];
            heap[1] = heap[H];
            H--;

            MaxHeapfy(1);

            return max;
        }

    }


    
    class Program
    {
        
        static void Main(string[] args)
        {
            PriorityQueue pq = new PriorityQueue();

            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');

                string order = input[0];
                int key;
                
                if(order == "insert")
                {
                    key = int.Parse(input[1]);
                    pq.Insert(key);
                }
                else if(order == "extract")
                {
                    Console.WriteLine(pq.ExtractMax());
                }
                else if(order == "end")
                {
                    break;
                }
                
            }
            
        }
    }
}


Measured memory_bytes: 24880
/** omgursocute **/
#include <bits/stdc++.h>

using namespace std;

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

	char c;
	map<char, int> mp;
	for(int i = 0; i < 4; i++) {
		c = getchar();
		++mp[c];
	}

	if(mp.size() == 2) {
		for(auto p: mp)
			if(p.second != 2) {
				cout << "No";
				return 0;
			}
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
	return 0;
}




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

int main()
{
	long long N;
	cin >> N;
	vector<string> s( N );
	vector<int> t( N );
	for( int i = 0; i < N; i++ ) {
		cin >> s[i] >> t[i];
	}
	string X;
	cin >> X;

	int ans = 0;
	int flag = 0;
	for( int i = 0; i < N; i++ ) {
		if( flag ) ans += t[i];
		if( s[i] == X ) flag = 1;
		
	}

	cout << ans << endl;
}


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

using namespace std;
int main(){
	int i,a[4];
	for(i=0;i<4;i++){
		cin >> a[i];
	}
	sort(a,a+4);
	if(a[0]==1 && a[1]==4 && a[2]==7 && a[3]==9){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
import math

def get_circle_center_and_radius1(x1, y1, x2, y2, x3, y3):
    """
    3点を通る円の中心と半径を取得
    """
    d = 2 * ((y1 - y3) * (x1 - x2) - (y1 - y2) * (x1 - x3))
    if d == 0:
        return (0, 0), 0
    x = ((y1 - y3) * (y1 ** 2 - y2 ** 2 + x1 ** 2 - x2 ** 2) - (y1 - y2) * (y1 ** 2 - y3 ** 2 + x1 ** 2 - x3 ** 2)) / d
    y = ((x1 - x3) * (x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2) - (x1 - x2) * (x1 ** 2 - x3 ** 2 + y1 ** 2 - y3 ** 2)) / -d
    r = math.sqrt((x - x1) ** 2 + (y - y1) ** 2)
    return (x, y), r


def get_circle_center_and_radius2(x1, y1, x2, y2):
    x = (x2 + x1) / 2
    y = (y2 + y1) / 2
    r = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5 / 2
    return (x, y), r


n = int(input())
xs = []
ys = []
for _ in range(n):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)


ans = 10 ** 9
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            x1 = xs[i]
            y1 = ys[i]
            x2 = xs[j]
            y2 = ys[j]
            x3 = xs[k]
            y3 = ys[k]
            (x, y), r = get_circle_center_and_radius1(x1, y1, x2, y2, x3, y3)
            if r == 0:
                continue
            ok = True
            for l in range(n):
                if l in [i, j, k]:
                    continue
                if (x - xs[l]) ** 2 + (y - ys[l]) ** 2 > r ** 2:
                    ok = False
                    break
            if ok:
                ans = min(ans, r)

for i in range(n - 1):
    for j in range(i + 1, n):
        x1 = xs[i]
        y1 = ys[i]
        x2 = xs[j]
        y2 = ys[j]
        (x, y), r = get_circle_center_and_radius2(x1, y1, x2, y2)
        ok = True
        for l in range(n):
            if l in [i, j]:
                continue
            if (x - xs[l]) ** 2 + (y - ys[l]) ** 2 > r ** 2:
                ok = False
                break
        if ok:
            ans = min(ans, r)

print(ans)


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

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

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

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


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	VI a(n);
	rep(i, n) cin >>a[i];
	
	int ans = (n - 1 + k - 2) /(k-1);
	cout << ans <<"\n";
	return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  int cnt = 1;
  for (int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    if (t == cnt) cnt++;
  }
  cnt--;
  if (!cnt) cout << -1 << '\n';
  else cout << n - cnt << '\n';
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372037ll;

void solve()
  {
   int n;
   int ans = 0;
   cin>>n;
   string s;
   cin>>s;
   loop(i,0,n)
    {
      ans++;
      int pos= i;
      while(pos<n && s[i] == s[pos])
         pos++;
      i = pos-1;
    }
   cout<<ans;
  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 

     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3680
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 27 23:37:06 2020

@author: H_Hoshigi
"""

"""
xとyの絶対値を同じにしてから、符号を合わせる。

abs(x)<abs(y)なら、xをまず正の数にしてボタンAで値を増やす。
このときボタンAを押す回数は(abs(y)-abs(x))回。
この後で、yが負ならボタンBを1回押す。

abs(x)>abs(y)なら、xをまず負の数にしてボタンAで値を減らす。
このときボタンAを押す回数は(abs(x)-abs(y))回。
この後で、yが正ならボタンBを1回押す。
"""

x, y = map(int, input().split())

counter = 0

#絶対値を比較する。
if abs(x) == abs(y):
    if x*y >= 0:
        pass
    else:
        counter += 1
elif abs(x) < abs(y):
    if x >= 0:
        pass
    else:
        #x = -x
        counter += 1
    counter += abs(y)-abs(x)
    if y >= 0:
        pass
    else:
        #y = -y
        counter += 1
else:
    if x <= 0:
        pass
    else:
        #x = -x
        counter += 1
    counter += abs(x)-abs(y)
    if y <= 0:
        pass
    else:
        #y = -y
        counter += 1

print(counter)




Measured memory_bytes: 3064