akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    long double pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211;

    int H, M;
    long double A, B;
    cin >> A >> B >> H >> M;

    long  double ta = (long double)H / 12.0 + (long double)M / 60.0 / 12;
    long double tb = (long double)M / 60.0 ;

    long double ax = A * cos(2.0f * pi * ta);
    long double ay = A * sin(2.0f * pi * ta);
    long double bx = B * cos(2.0f * pi * tb);
    long double by = B * sin(2.0f * pi * tb);

    cout << sqrt((ax-bx) * (ax-bx) + (ay-by) * (ay-by))<< endl;
}


Measured memory_bytes: 4184
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0,d=0,ans=0, x = 0, y = 0, z = 0,n=0,m=0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001],sec[100001],pointx[100001],pointy[100001];
long long int iremono2[100001],check[100001];
std::vector<long long int>kinds{}, kaku{};
char moji, moji2;
bool okada = false, okada2 = false;
std::string output, output2, input,input2;
char rev[100001];
unsigned long long int kakunou2[101][101] = {};
unsigned long long int M, A, R, C, H;

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}
int main()
{
	cin >> input;
	for (int bit = 0; bit < 8; bit++) {

		long long sum = input[0] - '0';
		output.clear();
		for (int i = 2; i >= 0; i--) {

			if (bit&(1 << i)) {
				sum += input[3 - i] - '0';
				output += "+";
			}
			else {
				sum -= input[3 - i] - '0';
				output += "-";

			}

		}
		if (sum == 7) {
			cout << input[0] << output[0] << input[1] << output[1] << input[2] << output[2] << input[3] << "=7";
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
int main(){
    long long n;
    cin >> n;
    if(n == 2) {
        cout << 1 << endl;
        return 0;
    }
    int cnt = 0;
    bool flag = true;
    while(1){
        if(flag == false || n == 3) {
            cnt++;
            break;
        }
        cnt++;
        vector<long long> vec;
        flag = false;
        rep(i,3) vec.push_back((n+i)/3);
        int num = 0;
        rep(i,vec.size()){
            if(vec[i] > num) num = vec[i];
            if(vec[i] > 2) flag = true;
        }
        if(flag == false || num == 3) {
            cnt++;
            break;
        }
        n = num;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3140
n, a, b = map(int,input().split())
wa = 0
ans = 0

for i in range(n+1):
    i_str = str(i)
    wa = 0
    for j in range(len(i_str)):
        wa += int(i_str[j])
    if (wa >= a and wa <= b):
        ans += i
print(ans)

        










Measured memory_bytes: 2940
s = gets.chomp

if s[0] == "A" && s[2..-2].count("C") == 1
  if s.count("A") == 1 && s.count("C") == 1
    s = s.sub("A", "a").sub("C","c")
    s.match(/[a-z]*/)
    if $& == s
      ans = "AC"
    else
      ans = "WA"
    end
  else
    ans = "WA"
  end
else
  ans = "WA"
end

puts ans

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

int main()
{
    string s1, s2, s3;

    cin >> s1 >> s2 >> s3;

    cout << (char)(s1[0]-'a'+'A');
    cout << (char)(s2[0]-'a'+'A');
    cout << (char)(s3[0]-'a'+'A');
    cout << endl;

    return 0;
}

Measured memory_bytes: 3552
N, K = map(int,input().split())
S = input()

arr = [0]
for i in range(N):
    if i == 0:
        if S[i] == "1":
            arr[-1] += 1
        else:
            arr.append(1)
    else:
        if S[i-1] == S[i]:
            arr[-1] += 1
        else:
            arr.append(1)
    if i == N-1:
        if S[i] == "1":
            continue
        else:
            arr.append(0)
sumarr = [0]
for i in arr:
    sumarr.append(sumarr[-1] + i)
ans = 0
if 2*K + 1 >= len(arr):
    ans = sumarr[-1]
else:
    for i in range((len(arr)-(2*K+1))//2 + 1):
        left = 1 + 2*i
        right = 2*K + 1 + 2*i
        ans = max(ans, sumarr[right]-sumarr[left-1])

print(ans)


    




Measured memory_bytes: 46920
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        # 根への距離を管理
        self.weight = [0] * (n + 1)

    # 検索
    def find(self, x):  # xの親を返す
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            # 親の値を更新(アルゴリズムの高速化)
            self.par[x] = y
            return y  # 親

    # 併合
    # (xからyへの重みがw) = (y - x = W)
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # 既に同集合の場合
        if rx == ry:
            if self.diff(x, y) != w:
                print("No")
                exit()
        # 木の高さで処理を変えるのは高速化(木を低くする)のため
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

    def show(self):
        for i in range(1, n + 1):
            print("node:{} par:{} w:{}".format(i, union.par[i], union.weight[i]))


n, m = [int(i) for i in input().split()]
l = [0 for i in range(m)]
r = [0 for i in range(m)]
d = [0 for i in range(m)]

union = WeightedUnionFind(n)
for i in range(m):
    l[i], r[i], d[i] = [int(i) for i in input().split()]
    union.union(l[i], r[i], d[i])
print("Yes")
#union.show()

Measured memory_bytes: 29808
s = input()

keyence = 'keyence'

for index, char in enumerate(s):
    if char!=keyence[0]:
        break
    keyence = keyence[1:]

keyence = keyence[::-1]
for index, char in enumerate(s[::-1]):
    if keyence and char!=keyence[0]:
        break
    keyence = keyence[1:]
    
if not keyence:
    print('YES')
else:
    print('NO')



Measured memory_bytes: 2940
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D: Transit Tree Path
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

vpii nbrs[MAX_N];
ll ds[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 1; i < n; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    a--, b--;
    nbrs[a].push_back(pii(b, c));
    nbrs[b].push_back(pii(a, c));
  }

  int m, k;
  scanf("%d%d", &m, &k);

  k--;
  ds[k] = 0;
  queue<pii> q;
  q.push(pii(k, -1));

  while (! q.empty()) {
    pii u = q.front(); q.pop();
    int &ui = u.first, &up = u.second;

    vpii &nbru = nbrs[ui];
    for (vpii::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &vi = vit->first;
      if (vi != up) {
	ds[vi] = ds[ui] + vit->second;
	q.push(pii(vi, ui));
      }
    }
  }

  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    printf("%lld\n", ds[x] + ds[y]);
  }

  return 0;
}


Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,a[110];
int li[110];

int main(){
	cin >> n;
	REP(i,0,n) cin >> a[i],li[a[i]]++; sort(a,a+n);
	int pos=a[n-1]+1,mi=INF;
	for(int i=0;i<=a[n-1];i++) {
		if(i <= a[n-1] / 2) pos--;
		if(i > (a[n-1] + 1) / 2) pos++;
		--li[pos];

		if(li[pos]<0){cout << "Impossible" << endl; return 0;}
		mi=min(mi,pos);
	}
	REP(i,0,mi+1) if(li[i]){cout << "Impossible" << endl; return 0;}
	cout << "Possible" << endl;
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int N, M, P;
int main(){
	cin >> N >> M >> P;

	vector<int> shop;
	for(int i=0; i<M; i++){
		int tmp;
		cin >> tmp;
		shop.PB((tmp+N-P)%N);
	}
	sort(shop.begin(), shop.end());

	int ans = INT_MAX;;
	//一方通行
	ans = min(shop.back(), N-shop.front());
	//折り返し 時計回り，反時計回り
	for(int i=0; i+1<M; i++){
		ans = min(ans, shop[i]*2+N-shop[i+1]);
	}
	//折り返し 反時計回り，時計回り
	for(int i=1; i<M; i++){
		ans = min(ans, (N-shop[i])*2+shop[i-1]);
	}
	cout << ans * 100 << endl;
}



Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
   int n;
   cin >> n;
   vector<ll> v(n);
   int u=0,d=0;
   ll sum = 0;
   ll mn = 100100100;
   rep(i,n){
      cin >> v[i];
      if (v[i] < 0) d++;
      sum += abs(v[i]);
      if (abs(v[i]) < mn){
         mn = abs(v[i]);
      }
   }
   //cout << sum  << ":" << mn << endl;
   if (d%2 == 0) cout << sum << endl;
   else cout << sum - 2*mn << endl;

}


Measured memory_bytes: 4048
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vector<T>>;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    int K, A, B; cin >> K >> A >> B;
    for (int i = A; i <= B; ++i)
    {
        if (i % K == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

    return 0;
}


Measured memory_bytes: 3688
S = input()

res = "NO"
if S == "keyence":
    res = "YES"
else:
    if "keyence" in S:
        if S[:7] == "keyence" or S[-7:] == "keyence":
            res = "YES"
    else:
        if S[0] == "k" and S[-6:] == "eyence":
            res = "YES"
        elif S[:2] == "ke" and S[-5:] == "yence":
            res = "YES"
        elif S[:3] == "key" and S[-4:] == "ence":
            res = "YES"
        elif S[:4] == "keye" and S[-3:] == "nce":
            res = "YES"
        elif S[:5] == "keyen" and S[-2:] == "ce":
            res = "YES"
        elif S[:6] == "keyenc" and S[-1:] == "e":
            res = "YES"

print(res)

Measured memory_bytes: 3064
# Binary Indexed Tree (Fenwick Tree)
class BIT:
  def __init__(self, n):
    self.n = n
    self.bit = [0]*(n+1)
    self.el = [0]*(n+1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.bit[i]
      i -= i & -i
    return s
  def add(self, i, x):
    # assert i > 0
    self.el[i] += x
    while i <= self.n:
      self.bit[i] += x
      i += i & -i
  def get(self, i, j=None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i-1)

import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
A = list(map(int, input().split()))
bit = BIT(N)
for i in range(N):
  bit.add(i+1,A[i])
ans = []
for i in range(Q):
  t,a,b = map(int, input().split())
  if t:
    ans.append(bit.get(a+1,b))
  else:
    bit.add(a+1,b)
print(*ans, sep='\n')

Measured memory_bytes: 149828
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll h,w;cin>>h>>w;ll count=0;
	
	char a[h][w];ll row[h];ll col[w];
	for(int i=0;i<h;i++)
	{
		ll cr=0,cc=0;
		for(int j=0;j<w;j++)
		 {
		   cin>>a[i][j];
		   if(a[i][j]=='.')
		     cr++;
	 
		 
		 }
		 if(cr==w)
		   row[i]=1;
		 else
		   count++;  
		 cr=0;  
	}
	
	char b[count][w];ll k=0;
	for(int i=0;i<h;i++)
	{
		if(row[i]!=1){
		
		for(int j=0;j<w;j++)
		{
		b[k][j]=a[i][j];	
		}
		k++;
	    }
	   
	}
	
	int p[w];
	for(int j=0;j<w;j++)
	{
		ll cw=0;
		for(int i=0;i<count;i++)
		{
			if(b[i][j]=='.')
			   cw++;
		}
		
		if(cw==count)
		  p[j]=1;
	}
	
	
	for(int i=0;i<count;i++)
	{
		
	for(int j=0;j<w;j++)
		{
		if(p[j]!=1)
		   cout<<b[i][j];	
		}
		cout<<endl;
	    
    
	}
	
	
	
}

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

long long n, t;

long long solve();

int main() {
  cin >> n >> t;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = t, bf;
  cin >> bf;
  for(long long i = 1; i < n; ++i) {
    long long x;
    cin >> x;
    ans += min(t, x - bf);
    bf = x;
  }
  return ans;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {

	var N, D, X int
	fmt.Scan(&N)
	fmt.Scan(&D, &X)
	a := make([]int, N+1)
	for i := 1; i <= N; i++ {
		fmt.Scan(&a[i])
	}
	sum := 0
	for i := 1; i <= N; i++ {
		for d := 1; d <= D; d++ {
			if (d-1)%a[i] == 0 {
				sum++
			}
		}
	}
	fmt.Println(sum + X)
}


Measured memory_bytes: 512
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner input = new Scanner(System.in);
        int[] array = new int[input.nextInt()];
        long total = 0;
        for(int i = 0; i < array.length; i++){
            array[i] = input.nextInt();
            total += array[i];
        }
        Arrays.sort(array);
        System.out.println(array[0]+" "+array[array.length-1]+" "+total);
    }
}

Measured memory_bytes: 42592
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n;
    cin >>n;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    ll q;
    cin >> q;
    vector<ll> b(q), e(q);
    rep(i,0,q) cin >> b[i] >> e[i];

    rep(i,0,q)
    {
        reverse(&a[b[i]], &a[e[i]]);
    }

    rep(i,0,n)
    {
        if (i!=n-1)
            cout << a[i] << ' '; 
        else
            cout << a[i]; 
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3228
#python3

def main():
    n = int(input())
    s = input()
    ans = -1000
    x = 0
    for st in s:
        if st == 'I':
            x+=1
        else:
            x-=1
        ans = max(ans, x)
    if ans>=0:
        print(ans)
    else:
        print(0)
main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
	ll ch[62][2];
int main() {
	ll n;
	cin>>n;
	ll a[300010];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	for(ll i=0;i<n;i++){
		ll now=a[i];
		ll j=0;
		while(j<=61){
			ch[j][now%2]++;
			now/=2;
			j++;
		}
	}
	ll keta=1;
	ll ans=0;
	for(ll i=0;i<=61;i++){
		ll now=ch[i][0]*ch[i][1];
	//	cout << ch[i][0]<<ch[i][1]<<endl;
		now%=inf;
		now*=keta;
		now%=inf;
		ans+=now;
		ans%=inf;
		keta*=2;
		keta%=inf;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) \
    for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, pair<T1, T2> P) {
    return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream& operator<<(ostream& s, vector<T> P) {
    for (int i = 0; i < P.size(); ++i) {
        if (i > 0) {
            s << " ";
        }
        s << P[i];
    }
    return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<vector<T> > P) {
    for (int i = 0; i < P.size(); ++i) {
        s << endl << P[i];
    }
    return s << endl;
}
template <class T>
ostream& operator<<(ostream& s, set<T> P) {
    EACH(it, P) { s << "<" << *it << "> "; }
    return s << endl;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, map<T1, T2> P) {
    EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; }
    return s << endl;
}
template <class T>
void show(vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        cerr << v[i] << " ";
    }
    cerr << "\n";
}
typedef long long ll;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int>a(n);
    int cnt=0;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
        cnt ^=a[i];
    }
    for (int i = 0; i < n; i++)
    {
        int x=cnt^a[i];
        cout<<x<<" ";
    }
    cout<<endl;
   // cout<<(75^73^88)<<endl;
    return 0;
}

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

int main(void) {

    int a, b, h, m;
    cin >> a >> b >> h >> m;

    // 分単位の時間
    int minutes = h * 60 + m;

    // 1が時針、2が分針
    ld x1, y1, x2, y2;
    ld t1, t2;
    t1 = 2 * M_PI * ((ld)(minutes % (12 * 60))) / ((ld)12 * 60);
    t2 = 2 * M_PI * ((ld)(minutes % 60)) / ((ld)60);

    x1 = a * cos(M_PI / 2 - t1);
    y1 = a * sin(M_PI / 2 - t1);
    x2 = b * cos(M_PI / 2 - t2);
    y2 = b * sin(M_PI / 2 - t2);

    ld dx = x1 - x2, dy = y1 - y2;
    ld distance = sqrt(dx * dx + dy * dy);

    std::cout << std::fixed;
    std::cout << std::setprecision(16) << distance;
    cout << endl;

    return 0;

}

Measured memory_bytes: 4160
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    x = S()
    s_cnt = 0
    removed = 0
    for c in x:
        if c == 'S':
            s_cnt += 1
        if c == 'T':
            if s_cnt > 0:
                s_cnt -= 1
                removed += 2
    print(len(x) - removed)
main()



Measured memory_bytes: 7120
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll W, H, N; cin >> W >> H >> N;
	ll x[100] = {}, y[100] = {}, a[100] = {};
	ll z = 1 << 21;
	ll xl = 0, xr = z;
	ll yu = z, yd = 0;

	rep(i, 0, N) {
		ll X, Y, A; cin >> X >> Y >> A;
		x[i] = X;
		y[i] = Y;
		a[i] = A;
		if (a[i] == 1) {
			xl = max(xl, X);
		}
		else if (a[i] == 2) {
			xr = min(xr, X);
		}
		else if (a[i] == 3) {
			yd = max(yd, Y);
		}
		else if (a[i] == 4) {
			yu = min(yu, Y);
		}
	}
	if (xr == z) xr = W;
	if (yu == z) yu = H;

	if (yu > yd && xr > xl) {
		cout << (yu - yd)*(xr - xl) << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define gcd(a,b) __gcd(a,b)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define pb(n) push_back(n)
#define pp pop_back()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define type(a) typeid(a).name();
#define print(arr) cout << "[" ;for(unsigned int i=0;i<(unsigned int) arr.size();i++){ (i==arr.size()-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define Arr(arr,l) cout << "[" ;for(unsigned int i=0;i<(unsigned int) l;i++){ (i==l-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define console(arr) cout << "["<<endl; for(ll i=0;i<(ll)arr.size();++i){cout << " [";for(ll j=0;j<(ll)arr[i].size();++j){(j==(int)arr[i].size()-1)?cout << arr[i][j]:cout << arr[i][j] << ",";}cout << "]"<<endl;} cout << "]"<<endl
#define starting() auto start = high_resolution_clock::now()
#define ending() auto stop = high_resolution_clock::now();auto duration = duration_cast<microseconds>(stop - start);cout << endl << endl << "Execution Time : "<<duration.count()/1000 << " ms" << endl
 
template <typename T1,typename T2>
void mapped(map<T1,T2>m){for(auto ite=m.begin();ite!=m.end();++ite){cout << "'" << ite->first << "'"<<" : "<<ite->second <<endl;}}
 
template <typename T1 , typename T2>
void mappedArr(map<T1,vector<T2>>m){for(auto ity=m.begin();ity!=m.end();++ity){cout << "'"<< ity->first <<"'"<<" : "<<"[";
for(int i=0;i<(int)ity->second.size();++i){(i==(int)ity->second.size()-1)?cout << ity->second[i]:cout << ity->second[i] << ",";}cout << "]"<<endl;}}
 
string int_to_string(int x){ stringstream ss; ss << x; string ni = ss.str(); return ni;}
int char_to_int(char c){ int n = (int)c - 48; return n; }
int string_to_int(string x){ int n; stringstream s(x); s >> n; return n; }
char upperCase(char a){int d = (int)a - 97 + 65;char c = (char)d;return c;} 
char lowerCase(char a){int d = (int)a - 65 + 97;char c = (char)d;return c;}  
bool isInt(char a){int d = (int)a - 48;if(d>=0 && d<=9){return true;}return false;}
//string char_to_string(char a){string d = (1,a);return d;}
 
template <typename T1,typename T2>
void ArrPair(vector<pair<T1,T2>>vp){for(int i=0;i<(int)vp.size();++i){
cout << "(" << vp[i].first << "," << vp[i].second << ")"<<endl ;}}
 
const int MOD = 1e9 + 7;
const ll INF = 1e18L + 5;
 
//unordered_map<int,int> um;
//unordered_set<int> us;
//set<int> s;
// v.front() gives the first element of vector 
// v.back()  gives the last element of vector
// insert erase substr

//bool bySecond(pair<int,int> a,pair<int,int> b){
//  return a.second < b.second;
//} 

//bool f(vector<ll> a,vector<ll> b){
//	return a[1] > b[1];
//}

//swap(a,b);
 
int main(){
 ll n;
 cin >> n;
 ll ans = -1;
 for(int i = n;i>=1;--i){
	 ll w = (i/100.0)*8;
	 ll z = i + w;
	 if(z==n){
		 ans = i;
		 break;
	 }
 }

 if(ans==-1){
	 cout << ":(";
	}else{
		cout << ans;
	}
 
 return 0;
}







Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
//#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

int main(void){

	int D, E;
	while (cin >> D >> E, D, E){

		double result = 10000.0;

		for (int i = 0; i <= D / 2; i++){
			if (i * i + (D - i) * (D - i) == E * E){
				result = 0;
				break;
			}
			else{
				result = min(result, abs(E - sqrt(i * i + (D - i) * (D - i))));
			}
		}

		cout << result << endl;

	}

	return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

int32_t main() {
 
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  string s, t;
  cin >> s >> t;
  int n, m;
  n = SZ(s);
  m = SZ(t);
  vector<int> hast(26, 0), hass(26, 0);
  for (char c : t) {
    hast[c - 'a'] = 1;
  }
  for (char c : s) {
    hass[c - 'a'] = 1;
  }
  for (int i = 0; i < 26; ++i) {
    if (hast[i] && !hass[i]) kek(-1);
  }
  string ss = s + s;
  vector<vector<int>> nxt(2 * n + 1, vector<int>(26, MOD));
  for (int i = 2 * n - 1; i >= 0; --i) {
    nxt[i] = nxt[i + 1];
    nxt[i][ss[i] - 'a'] = i;
  }
  int ptr = 0;
  i64 pos = 0;
  while (ptr < m) {
    pos += nxt[pos % n][t[ptr++] - 'a'] + 1 - pos % n;
  }
  kek(pos);
    
  return 0;
}


Measured memory_bytes: 27216
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    string S; int K; cin >> S >> K;
    
    vector<pair<char, ll>> P;
    auto p = make_pair(S[0], 1);
    REP(i, 1, S.size()) {
        if (p.first == S[i]) {
            p.second++;
        } else {
            P.push_back(p);
            p = make_pair(S[i], 1);
        }
    }
    P.push_back(p);

    ll ans = 0;
    if (P.front().first == P.back().first) {
        if (P.size() > 1) {
            REP(i, 1, P.size() - 1) {
                ans += P[i].second / 2;
            }
            ans *= K;
            ans += (P.front().second + P.back().second) / 2 * (K - 1) + P.front().second / 2 + P.back().second / 2;
        } else {
            ans += P.front().second * K / 2;
        }
    } else {
        REP(i, 0, P.size()) {
            ans += P[i].second / 2;
        }
        ans *= K;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

[n,a,b] = inpl()
print(min(n*a,b))

Measured memory_bytes: 12496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


const int MAX = 510000;
const int mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

int main(){
  int n;cin>>n;
  int d[n];rep(i,n)cin>>d[i];
  sort(d,d+n);
  cout<<d[n/2]-d[n/2-1]<<endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
	
	int b1,b2,b3;
	cin >> b1 >> b2 >> b3;

	if ((b1 == 1 && b2 == 1)||b3 == 1) {
		cout << "Open" << endl;
	} else {
		cout << "Close" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 100000;
typedef pair<int,int> P;
int main()
{
  int n,m,t,i,co=0,pe=0;
  P p[N_MAX];
  string s;
  cin >> n >> m;
  fill(p,p+n,P(0,0));
  for(i=0;i<m;i++){
    cin >> t >> s;
    if(s=="WA"&&p[t].first==0){
      p[t].second++;
    }else if(s=="AC"&&p[t].first==0){
      p[t].first=1;
      co++;
      pe+=p[t].second;
    }
  }
  cout << co << " " << pe << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

int main()
{
    string s; cin >> s;
    int len = s.size();

    if (len == 26) {
        string t = s;
        if (next_permutation(t.begin(), t.end())) {
            for (int i = 0; i < len; i++) {
                if (s[i] != t[i]) {
                    cout << t[i] << endl;
                    break;
                }
                else {
                    cout << t[i];
                }
            }
        }
        else {
            cout << -1 << endl;
        }
    }
    else {
        bool dict[26] = { false };
        for (int i = 0; i < len; i++) {
            dict[s[i] - 'a'] = true;
        }
        for (char c = 'a'; c <= 'z'; c++) {
            if (!dict[c - 'a']) {
                s += c;
                cout << s << endl;
                break;
            }
        }
    }
}

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

#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;


ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll modfact(ll n){
  ll ans =1;
  for(int i=1;i<=n;i++){
    ans =mod(mod(ans, MOD)*mod(i,MOD), MOD);
  }
  return ans;
}

ll modinvfact(ll n){
  ll ans =1;
  for(int i=1;i<=n;i++){
    ans =mod(modinv(ans, MOD)*modinv(i, MOD), MOD);
  }
  return ans;
}


bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll fact[200001];
ll factinv[2000001];

int gen_fact(ll n){
  fact[0]=1;
  factinv[0] = modinv(1, MOD);
  for(int i=1;i<=200001;i++){
    //fact[i] = mod(fact[i-1]*mod(i, MOD), MOD);
    factinv[i]=mod(factinv[i-1]*modinv(i, MOD), MOD);
  }
  return 0;
}

ll perm(ll n, ll k){
  ll ans = 1;
  for(int i = n;i > n-k;i--){
    ans = mod(ans*i, MOD);
    //cout << ans << endl;
  }
  return ans;
}

ll comb(ll n, ll k){
  return mod(perm(n,k)*factinv[k] , MOD);
}



/******************************************
** A main function is start from here  ****
*******************************************/
int main(){
  ll n, a,b;
  cin >> n >> a >> b;
  gen_fact(n);

  //cout << perm(n, a) << " "<<comb(n,a) << endl;
  //cout << perm(n, b) << " "<<comb(n,b) << endl;

  ll ans = modpow(2, n, MOD)-comb(n,a) - comb(n,b) - 1;
  cout << mod(ans, MOD);
  
  return 0;
}


Measured memory_bytes: 3840
n,a,b,c,d=map(int,input().split())
s=input()
flag=0
for i in range(n):
  if a-1<=i<=c-1 or b-1<=i<=d-1:
    if flag==1 and s[i]=="#":
      print("No")
      exit()
    elif flag==0 and s[i]=="#":
      flag=1
    elif s[i]==".":
      flag=0

m=0
con=0
if d<c:
  for i in range(b-2,d+1):
    if s[i]==".":
      con+=1
      m=max(m,con)
    else:
      con=0
  if m>=3:
    print("Yes")
    exit()
  else:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3572
abs2 = lambda a,b: -(abs(int(1.0*a/b)))

def number(begin):
	global i
	
	if begin[i] == "(":
		i += 1
		res = expression(begin)
		i += 1 
		return res
	
	res = 0
	
	while begin[i].isdigit():
		res *= 10
		res += int(begin[i])
		i+=1
	
	return res
	
def term(begin):# your code goes here

	global i
	res = number(begin)
	
	while True:
		if begin[i] == "*":
			i += 1
			res *= number(begin)
		elif begin[i] == "/":
			i += 1
			num = number(begin)
			if res < 0 or num < 0:
				res = abs2(res,num)
			else:
				res /= num
		else:
			break
	return res
	
def expression(begin):
	
	global i
	res = term(begin)
	
	while True:
		if begin[i] == "+":
			i += 1
			res += term(begin)
			
		elif begin[i] == "-":
			i += 1
			res -= term(begin)
		else:
			break
	return res
	

def main():
	global i
	for j in range(input()):
			i = 0
			ex = raw_input() +"="
			ans = expression(ex)
	
			print ans
main()

Measured memory_bytes: 4292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll a, b, x;
    cin >> a >> b >> x;
    if(b > x)
    {
        cout << a * x / b << endl;
    }
    else
    {
        cout << a * (b-1) / b << endl;
    }
}



Measured memory_bytes: 3624
<?php
  $top3 = array();
  $top3 = array_pad($top3, 3, 0); 
  $heights = array();
  $result = array();


  $fp = fopen('php://stdin', 'r');
  while (feof($fp) == false) {
    $line = (int)fgets($fp);
    array_push($heights, $line);    
  }
  fclose($fp);

  for ($i=0; $i<count($heights); $i++) {
    if ($top3[min_index()] < $heights[$i]) {
      $top3[min_index()] = $heights[$i];
    }   
  }

  for ($i=0; $i<3; $i++) {
    $result[2-$i] = $top3[min_index()];
    $top3[min_index()] = 10001;
  }

  for ($i=0; $i<3; $i++) {
    echo $result[$i]."\n";
  }

  function min_index() {
    global $top3;
    $min_value = 10001;
    $min_index = 0;
    for ($i=0; $i<count($top3); $i++) {
      if ($top3[$i] < $min_value) {
        $min_value = $top3[$i];
        $min_index = $i; 
      }   
    }   
    return $min_index;
  }

Measured memory_bytes: 6652
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
B.append(0)
cnt = 0

if A[0] <= B[0]:
    cnt += A[0]
    B[0] -= A[0]
else:
    cnt += B[0]
    B[0] = 0
    
for i in range(1,N+1):
    M = B[i-1]
    L = B[i]
    if A[i] <= M:
        cnt += A[i]
    elif A[i] <= L+M:
        cnt += A[i]
        B[i] -= A[i]-M
    elif A[i] > L+M:
        cnt += L+M
        B[i] = 0

print(cnt)    

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

int main(void)
{
    int n;
    scanf("%d",&n);
    int L[n];
    int i,j,k;
    int M;
    int ans=0;

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

    int e1,e2,e3;
    for (i=0; i<n-2; i++){
        e1=L[i];
        for (j=i+1; j<n-1; j++){
            e2=L[j];
            for (k=j+1; k<n; k++){
                e3=L[k];
                if (e1==e2 || e2==e3 || e3==e1) continue;
                M=e1;
                if (e2>M) M=e2;
                if (e3>M) M=e3;
                if (2*M>=(long long int)e1+e2+e3) continue;
                ans++;
            }
        }
    }
    printf("%d\n",ans);
}   

Measured memory_bytes: 1736
import java.util.Scanner;

public class Main {

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

        if(a.equals("SAT")){
            System.out.println("1");
        }else if(a.equals("FRI")){
            System.out.println("2");
        }else if(a.equals("THU")){
            System.out.println("3");
        }else if(a.equals("WED")){
            System.out.println("4");
        }else if(a.equals("TUE")){
            System.out.println("5");
        }else if(a.equals("MON")){
            System.out.println("6");
        }else if(a.equals("SUN")){
            System.out.println("7");
        }





    }
}

Measured memory_bytes: 22736
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

typedef int Weight;
struct Edge{
  int src;int dst;
  Weight wei;
  Edge(int s=0,int d=0,Weight w=0):
    src(s),dst(d),wei(w){}
};
using Graph = vector<vector<Edge>>;
int prim(const Graph &g,const int r=0){
  struct comp{
    bool operator()(const Edge &e,const Edge &f)const {return e.wei>f.wei;}
  };
  Weight sum=0;
  vector<int> used(g.size());
  priority_queue<Edge,vector<Edge>,comp> q;
  q.emplace(-1,r,0);
  while(q.size()){
    Edge e=q.top();
    q.pop();
    if(used[e.dst])continue;
    used[e.dst]=1;
    sum+=e.wei;
    for(auto &f : g[e.dst]){
      if(!used[f.dst])q.emplace(f);
    }
  }
  return sum;
}

signed main(){
  int n;
  cin>>n;
  Graph g(n);
  REP(i,n)REP(j,n){
    int a;
    cin>>a;
    if(a!=-1){
      g[i].emplace_back(i,j,a);
    }
  }
  cout<<prim(g,0)<<endl;
  return 0;
}

Measured memory_bytes: 3224
<?php

while(fscanf(STDIN, "%d", $n)) {
  if($n == 0) break;
  
  $s = array();
  for($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%d", $s[$i]);
  }
  
  sort($s);
  
  $sum = 0;
  for($i = 1; $i < $n - 1; $i++) {
    $sum += $s[$i];
  }

  $ans = (int)($sum / ($n - 2));
  
  print $ans . "\n";
}

Measured memory_bytes: 6620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int N, K, ans;
  ans = 0;
  cin >> N >> K;
  int p[N];
  rep(i, N) cin >> p[i];
  sort(p, p+N);
  for (int i = 0; i < K; ++i) {
    ans += p[i];
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 3696
#include<stdio.h>
#include<vector>
using namespace std;
#define ran 222222
int n;
vector<int> e[ran];

double res[ran];int ch[ran];
double out[ran];

void dfs2(int x,int f,double to){
	if(x!=1){
		out[x] = res[x] * ch[x] + to + 1;
		ch[x] ++;
	}else{
		out[x] = res[x] * ch[x];
	}
	for(vector<int>::iterator it = e[x].begin(); it!=e[x].end(); it++){
		int y = *it;
		if(y == f)continue;
		dfs2(y,x, ch[x] == 1 ? 0 : (out[x] - (res[y]+1))/(ch[x]-1));
	}
}
void dfs(int x,int f){
	ch[x] = 0;
	res[x] = 0;
	for(vector<int>::iterator it = e[x].begin(); it!=e[x].end(); it++){
		int y = *it;
		if(y == f)continue;
		dfs(y,x);
		res[x] += res[y]+1;
		ch[x] ++;
	}
	if(ch[x]){
		res[x] /= ch[x];
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1; i<n; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	dfs(1,1);
	dfs2(1,1,0);
	for(int i=1; i<=n; i++)
		printf("%.12lf\n",ch[i] == 0 ? 0 : out[i]/ch[i]);
	return 0;
}


Measured memory_bytes: 20736
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-01 15:43:52
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int n, k; cin >> n >> k;
  cout << (n > k ? 0 : 1) << endl;

  return 0;
}


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

using namespace std;

int main(){
    double a;
    double area;
    double cir;
    const double pi = 3.14159265358979;
    cin >> a;
    
    cout << fixed << setprecision(6) << a*a*pi << " " << (double)2*a*pi << endl;
    
    return 0;
}


Measured memory_bytes: 3244
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

int main(){
    string S;
    cin >> S;
    int w;
    cin >> w;
    for(size_t i = 0; i < S.size(); ++i){
        if(i % w == 0){
            cout << S[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && a == c){
    cout << "No\n";
    return 0;
  }
  if(a != b && b != c && a != c){
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
}

Measured memory_bytes: 3604
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
//ld dis(ll a,ll b,ll c,ll d){return sqrt((a-c)*(a-c)+(b-d)*(b-d)) ;}

int main(){
	ll a,b,c,k ;
	cin >> a >> b >> c >> k ;
	ll ans = 0 ;
	if(a>=k) cout << k << endl ;
	else if(a+b>=k) cout << a << endl ;
	else cout << a-(k-a-b) << endl ;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h> 
using namespace std; 
int gi() { 
	int res = 0, w = 1; 
	char ch = getchar(); 
	while (ch != '-' && !isdigit(ch)) ch = getchar(); 
	if (ch == '-') w = -1, ch = getchar(); 
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar(); 
	return res * w; 
} 
typedef long long LL;
const int MAX_N = 2e3 + 5; 
int N, a[MAX_N]; 
vector<int> G[MAX_N];
bool vis[MAX_N]; 
void dfs(int x) { 
	vis[x] = 1; 
	for (int i = 1; i <= N; i++)
		if (!vis[i] && __gcd(a[i], a[x]) != 1) 
			G[x].push_back(i), dfs(i); 
} 
int main () { 
#ifndef ONLINE_JUDGE 
    freopen("cpp.in", "r", stdin); 
#endif 
	N = gi(); 
	for (int i = 1; i <= N; i++) a[i] = gi();
	sort(&a[1], &a[N + 1]); 
	for (int i = 1; i <= N; i++) sort(G[i].begin(), G[i].end());
	priority_queue<int> Q; 
	for (int i = 1; i <= N; i++) 
		if (!vis[i]) dfs(i), Q.push(i); 
	while (!Q.empty()) { 
		int x = Q.top(); Q.pop(); 
		for (int i = 0; i < (int)G[x].size(); i++) Q.push(G[x][i]); 
		printf("%d ", a[x]); 
	} 
	putchar('\n'); 
    return 0; 
} 

Measured memory_bytes: 3912
#include <iostream>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b && b == c){
    cout << "No" << endl;
    return 0;
  }
  if (a != b && b != c){
    if(a != c){
      cout << "No" << endl;
      return 0;
    } else {
      cout << "Yes" << endl;
      return 0;
    }
  } else {
    cout << "Yes" << endl;
  }
}


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

const int INF = 0x3f3f3f3f;
const int maxm = 2e5+10;
const int maxn = 10005;

struct node{
	int to,d,w,next;
};

node edges[maxn*maxn];

int n,m;
int head[maxn],edge;
bool vis[maxn];
long long dis[maxn],cost[maxn];

void add(int u,int v,int d,int c){
	edges[edge].w = c;
	edges[edge].d = d;
	edges[edge].to = v;
	edges[edge].next = head[u];
	head[u] = edge++;
}

void init(){
	memset(head,-1,sizeof(head));
	edge = 0;
}

int spfa(int n){
	int u,sum2 = 0;
	dis[0] = 0;
	cost[0] = 0;
	for(int i=1; i<=n; i++){
		dis[i] = INF;
		cost[i] = INF;
	}

	memset(vis,0,sizeof(vis));
	queue<int> Q;
	Q.push(1);
	vis[1] = 1;
	dis[1] = 0;
	cost[1] = 0;
	while(!Q.empty()){
		u = Q.front(); Q.pop();
		vis[u] = false;

		for(int i=head[u]; i!=-1; i=edges[i].next){
			int v = edges[i].to;
			int w = edges[i].w;
			int d = edges[i].d;
			if(dis[v] > dis[u]+d){
				dis[v] = dis[u] + d;
				cost[v] = w;
				if(!vis[v]){
					vis[v] = true;
					Q.push(v);
				}
			}else if(dis[v] == dis[u]+d){
				if(cost[v] > w) cost[v] = w;
			}
		}
	}

	for(int i=1; i<=n; i++){
		cost[0] += cost[i];
	}
	return cost[0];
}


int main(){
	int u,v,d,c;
	while(scanf("%d%d",&n,&m) && n){
		init();
		int sum = 0;
		for(int i=1; i<=m; i++){
			scanf("%d%d%d%d",&u,&v,&d,&c);
			add(u,v,d,c);
			add(v,u,d,c);
		}

		sum = spfa(n);
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n,d,a;
  cin >> n >> d >> a;
  vector<pp> xh(n);
  rep(i,n) cin >> xh.at(i).first >> xh.at(i).second;
  sort(xh.begin(),xh.end());
  vector<int> xxx(n);
  rep(i,n) xxx.at(i) = xh.at(i).first;
  vector<ll> damage(n,0);
  ll ans = 0;
  rep(i,n){
    if(i != 0){
      damage.at(i) += damage.at(i-1);
      xh.at(i).second -= damage.at(i);
    }
    if(xh.at(i).second <= 0) continue;
    int att = (xh.at(i).second+a-1)/a;
    damage.at(i) += att * a;
    int bound = upper_bound(xxx.begin(),xxx.end(),xh.at(i).first + 2*d) - xxx.begin();
    if(bound < n) damage.at(bound) -= att*a; 
    
    ans += att;
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 4096