akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;

int main(){
	int m, d, year;
	while(1){
		year = 2004;
		cin >> m >> d;
		if(m == 0 && d == 0){
			break;
		}
		if(m <= 2){
			m += 12;
			year -= 1;
		}
		int c = floor(year / 100);
		int gamma = 5 * c + floor(c / 4);
		int y = year % 100;
		int h = d + floor(26 * (m + 1) / 10) + y + floor(y / 4) + gamma;
		int day = h % 7;
		switch(day){
			case 0:
				cout << "Saturday" << endl;
				break;
			case 1:
				cout << "Sunday" << endl;
				break;
			case 2:
				cout << "Monday" << endl;
				break;
			case 3:
				cout << "Tuesday" << endl;
				break;
			case 4:
				cout << "Wednesday" << endl;
				break;
			case 5: 
				cout << "Thursday" << endl;
				break;
			case 6:
				cout << "Friday" << endl;
				break;
			default:
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    ll n, k;
    cin >> n >> k;
    auto dp = make_v(63, n, 0);
    for (int j = 0; j < n; ++j) {
        scanf("%d", &dp[0][j]);
        dp[0][j]--;
    }
    for (int i = 0; i < 62; ++i) {
        for (int j = 0; j < n; ++j) {
            dp[i+1][j] = dp[i][dp[i][j]];
        }
    }
    int x = 0;
    for (int i = 62; i >= 0; --i) {
        if((1LL << i) <= k){
            k -= (1LL << i);
            x = dp[i][x];
        }
    }
    cout << x+1 << "\n";
    return 0;
}

Measured memory_bytes: 53368
#075_C
n,m=map(int,input().split())
ans=0

edges=[]
graph=[[False for _ in range(n)] for _ in range(n)]

for _ in range(m):
    a,b=map(int,input().split())
    edges.append((a-1,b-1))
    graph[a-1][b-1]=True
    graph[b-1][a-1]=True

def dfs(v):
    visit[v]=True
    for v2 in range(n):
        if visit[v2]==True: continue
        if graph[v][v2]==False: continue
        dfs(v2)

for x in edges:
    a,b=x
    graph[a][b]=False
    graph[b][a]=False
    visit=[False for _ in range(n)]
    
    dfs(0)
    ans+=any([visit[i]==False for i in range(n)])
    
    graph[a][b]=True
    graph[b][a]=True
    
print(ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
Created on Sun Sep  6 01:25:38 2020

@author: liang
"""

from itertools import combinations

H, W, K = map(int, input().split())

C = [input() for _ in range(H)]
            
ans = 0
for comb_H in [list(combinations(range(H),a)) for a in range(H+1)]:
    for comb_W in [list(combinations(range(W),a)) for a in range(W+1)]:
        for tuple_H in comb_H:
            for tuple_W in comb_W:
                tmp = 0
                for i in range(H):
                    for j in range(W):
                        if i not in tuple_H and j not in tuple_W and C[i][j] == "#":
                            tmp += 1
                #print(tuple_H)
                #print(tuple_W)
                #print(tmp)
                if tmp == K:
                    ans += 1
print(ans)

Measured memory_bytes: 9220
#include <stdio.h>
int main(){

  int n,m,costm,cost[1000],get[1000]={0},a,result,i,j;

  scanf("%d %d",&n,&m);

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

  for(i = 0; i < m; i++){

    scanf("%d",&costm);

    for(j = 0; j < n; j++){

      if(cost[j] <= costm){

	get[j]++;
	break;

      }

    }

  }

  /*
  for(i = 0; i < n; i++) printf("%d ",get[i]);
  printf("\n");
  */

  for(i = 0; i < n; i++){

    a=0;

    for(j = 0; j < n; j++){
      
      if(get[i] < get[j]) a++;

    }

    if(a == 0){
      
      printf("%d\n",i+1);
      return 0;

    }
    
  }
  
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n + 1);
    rep (i, n) {
        cin >> a[i];
        a[i]--;
    }
    int pos = 0;
    map<int, int> used;
    vector<int> city;
    while (used[pos] == 0) {
        used[pos]++;
        city.push_back(pos);
        pos = a[pos];
    }
    int index;
    rep (i, city.size()) {
        if (pos == city[i]) {
            index = i;
            break;
        }
    }
    int len = city.size() - index;
    if (k <= city.size() - 1) {
        cout << city[k] + 1 << endl;
    } else {
        ll t = (k - index) % len;
        cout << city[index + t] + 1 << endl;
    }

    return 0;
}



Measured memory_bytes: 13984
using System;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        int D = ScanInt(), N = ScanInt();
        Console.WriteLine(Math.Pow(100, D) * (N == 100 ? 101 : N));
    }
}

public static class Scanner
{
    static readonly Stream stream = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte ConsoleIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stream.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = ConsoleIn();
        while ((by < '!' || '~' < by) && !isEof) by = ConsoleIn();
        return (char) by;
    }
    public static int ScanInt() {
        var temp = 0;
        for (var ch = GetChar(); '0' <= ch && ch <= '9'; ch = (char) ConsoleIn()) {
            temp = temp * 10 + ch - '0';
        }
        return temp;
    }
}

Measured memory_bytes: 26056
n,k=map(int,input().split())
a=list(map(int,input().split()))

d={}

for x in range(n):
  if a[x] not in d:
    d[a[x]]=0
  d[a[x]]+=1
  
ans=0
ans1=[]
for g in d:
  ans1.append(d[g])
  
if len(ans1)<=k:
  print(0)
  
else:
  ans1.sort()
  r=len(ans1)-k
  for t in range(r):
    ans+=ans1[t]
    
  print(ans)
  


Measured memory_bytes: 34756
#include <iostream>
#include <cstring>
using namespace std;
typedef long long LL;
const int maxn = 1000005;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
int n, A, B;
int fac[maxn], inv[maxn];
int c[maxn], w[maxn], minci[maxn];
int Gs[maxn];
inline int pow(int a, int b)
{
    int ans = 1;
    for(; b; b >>= 1, a = (LL) a * a % mod)
        if(b & 1)
            ans = (LL) ans * a % mod;
    return ans;
}
inline int C(int n, int m)
{
    if(!n)
        return 1;
    if(m < n)
        return 0;
    return (LL) fac[m] * (LL) inv[m - n] % mod * (LL) inv[n] % mod;
}
int main()
{
    scanf("%d%d%d", &n, &A, &B);
    memset(minci, 0x3f, sizeof(minci));
    for(int i = 1; i <= n; ++i)
    {
        scanf("%d%d", &c[i], &w[i]);
        minci[c[i]] = min(minci[c[i]], w[i]);
    }
    int minn = 0, minnn = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(minci[i] < minci[minn])
        {
            minnn = minn;
            minn = i;
        }
        else if(minci[i] < minci[minnn])
            minnn = i;
    }
    int gss = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(w[i] + minci[c[i]] <= A)
            w[i] = minci[c[i]];
        if(c[i] == minn && minci[minnn] + w[i] <= B)
        {
            Gs[c[i]]++;
            gss++;
        }
        if(c[i] != minn && minci[minn] + w[i] <= B)
        {
            Gs[c[i]]++;
            gss++;
        }
    }
    int ans = 1;
    fac[0] = 1;
    for(int i = 1; i <= n; ++i)
        fac[i] = (LL) i * fac[i - 1] % mod;
    inv[n] = pow(fac[n], mod - 2);
    for(int i = n - 1; ~i; --i)
        inv[i] = (LL) inv[i + 1] * (i + 1) % mod;
    for(int i = 1; i <= n; ++i)
    {
        if(Gs[i])
        {
            ans = (LL) ans * (LL) C(Gs[i], gss) % mod;
            gss -= Gs[i];
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

vector<int> union_find_parent;
int union_find_init(int n);
int union_find_unite(int a,int b);
int union_find_root(int a);

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

	union_find_init(n);
	for (int i=0;i<q;++i)
	{
		int com, x, y;
		cin >> com >> x >> y;
		if (com==0)
		{
			union_find_unite(x,y);
		}
		else
		{
			if (union_find_root(x)==union_find_root(y))
			{
				cout << 1 << endl;
			}
			else
			{
				cout << 0 << endl;
			}
		}
	}

}


int union_find_init(int n)
{
	for (int i=0;i<n;++i)
	{
		union_find_parent.push_back(i);
	}
	return 0;
}

int union_find_unite(int a,int b)
{
	a=union_find_root(a);
	b=union_find_root(b);
	if (a!=b)
	{
		union_find_parent[a]=b;
	}
	return 0;
}

int union_find_root(int a)
{
	if (union_find_parent[a]==a)
	{
		return a;
	}
	else
	{
		return union_find_parent[a]=union_find_root(union_find_parent[a]);
	}
}





Measured memory_bytes: 3384
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
	int n;
	int min = 1000000, max = -1000000;
	long sum = 0;
	cin >> n;
	for (int i = 0; i<n; i++){
		int in;
		cin >> in;
		if (in<min) min = in;
		if (in>max) max = in;
		sum += in;
	}
	cout << min << " " << max << " " << sum << endl;
}

Measured memory_bytes: 1168
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pir
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < n; i++)
#define REP(i,n) for(int i=1;i<=n;i++)

using namespace std;
typedef long long ll;

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    // Input
    int n, m, q;
    cin >> n >> m >> q;

    int a[q], b[q], c[q], d[q];
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    int A[10];  // nじゃなくて10.10回Loop回すので
    int ans = 0;
    for (int i0 = 1; i0 <= m; i0++) {
        A[0] = i0;
        for (int i1 = i0; i1 <= m; i1++) {
            A[1] = i1;
            for (int i2 = i1; i2 <= m; i2++) {
                A[2] = i2;
                for (int i3= i2; i3 <= m; i3++) {
                    A[3] = i3;
                    for (int i4 = i3; i4 <= m; i4++) {
                        A[4] = i4;
                        for (int i5 = i4; i5 <= m; i5++) {
                            A[5] = i5;
                            for (int i6 = i5; i6 <= m; i6++) {
                                A[6] = i6;
                                for (int i7 = i6; i7 <= m; i7++) {
                                    A[7] = i7;
                                    for (int i8 = i7; i8 <= m; i8++) {
                                        A[8] = i8;
                                        for (int i9 = i8; i9 <= m; i9++) {
                                            A[9] = i9;

                                            int sum = 0;
                                            rep(i, q) {
                                                if (c[i] == A[b[i]-1] - A[a[i]-1]) sum += d[i];
                                                // if (A[b[i] - 1] - A[a[i] - 1] == c[i]) {
                                                //     sum += d[i];
                                                // }
                                            }
                                            ans = max(ans, sum);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3200
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String s = sc.nextLine();
		s = s.replaceAll("apple","AAAAA");
		s = s.replaceAll("peach","apple");
		s = s.replaceAll("AAAAA","peach");
		out.println(s);
	}
}


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

signed main() {
  int N,L; cin >> N >> L;
  int sum = 0;
  for(int i = 0; i<N; i++) sum += i+L;
  int ans = 2e9;
  int mn = 2e9;
  for(int i = 0; i<N; i++) {
    if(mn > abs(i+L)) {
      mn= min(abs(i+L), mn);
      ans = sum - (i+L);
    }
  }
  cout << ans << endl;
}


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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

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

	vector<ll> a(n);
	ll sum = 0;
	rep(i, n){
		cin >> a[i];
		sum += a[i];
	}

	SORT(a);
	reverse(a.begin(), a.end());
	bool f = true;
	rep(i, m){
		if(a[i] * 4 * m < sum) f= false;
	}

	if(f) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
def bs_left(l, target): # l=sortedのリスト, target以上の値をもつ要素のうち一番左のindexを返す
    low, high = 0, len(l)
    while low < high:
        mid = (low+high)//2
        if l[mid] < target:
            low = mid+1
        else:
            high = mid
    if low == len(l):
        return -1
    return low
N = int(input())
A = list(map(int,input().split()))
A.sort()
if A[N-1] <= 0:
    print(2*A[N-1]-sum(A))
    x = A[N-1]
    for i in range(N-1):
        y = A[N-2-i]
        print(x,y)
        x = x-y

else:
    id = bs_left(A,0)
    #print(id)
    s = -A[0]
    for i in range(1,N):
        if i < id:
            s -= A[i]
        else:
            s += A[i]
    print(s)
    if id == 0:
        x = A[0]
        for i in range(1,N-1):
            y = A[i]
            print(x,y)
            x = x-y
        print(A[N-1],x)
    else:
        x = A[0]
        for i in range(id,N-1):
            y = A[i]
            print(x,y)
            x = x-y

        print(A[N-1],x)
        x = A[N-1]-x
        for i in range(1,id):
            y = A[i]
            print(x,y)
            x = x-y







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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

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

const char newl = '\n';
ll const mod = 998244353;

struct LazySegmentTree {
private:
    int n;
    vector<ll> node,lazy_b,lazy_c;
    vector<bool> upd;
public:
    LazySegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1);
        lazy_b.resize(2*n-1,1);
        lazy_c.resize(2*n-1,0);
        upd.resize(2*n-1,false);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = (node[i*2+1]+node[i*2+2])%mod;
    }

    void eval(int k,int l,int r) {
        if (upd[k]) {
            node[k] *= lazy_b[k];
            (node[k] += lazy_c[k]*(r-l)%mod) %= mod;
            if (r-l > 1) {
                (lazy_b[2*k+1] *= lazy_b[k]) %= mod;
                (lazy_b[2*k+2] *= lazy_b[k]) %= mod;
                lazy_c[2*k+1] *= lazy_b[k];
                lazy_c[2*k+2] *= lazy_b[k];
                (lazy_c[2*k+1] += lazy_c[k]) %= mod;
                (lazy_c[2*k+2] += lazy_c[k]) %= mod;
                upd[2*k+1] = upd[2*k+2] = true;
            }
            lazy_b[k] = 1;
            lazy_c[k] = 0;
            upd[k] = false;
        }
    }

    void update(int a,int b,ll x,ll y,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        eval(k,l,r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy_b[k] = x;
            lazy_c[k] = y;
            upd[k] = true;
            eval(k,l,r);
        } else {
            update(a,b,x,y,2*k+1,l,(l+r)/2);
            update(a,b,x,y,2*k+2,(l+r)/2,r);
            node[k] = (node[2*k+1]+node[2*k+2])%mod;
        }
    }

    ll getsum(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (b <= l || r <= a) return 0;
        eval(k,l,r);
        if (a <= l && r <= b) return node[k];
        ll vl = getsum(a,b,k*2+1,l,(l+r)/2);
        ll vr = getsum(a,b,2*k+2,(l+r)/2,r);
        return (vl+vr)%mod;
    }
};

int main() {
    int n,q;
    cin >> n >> q;
    vector<ll> a(n);
    // for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 0;i < n;++i) scanf("%d",&a[i]);
    LazySegmentTree seg(a);
    for (int i = 0;i < q;++i) {
        int t,l,r;
        // cin >> t >> l >> r;
        scanf("%d%d%d",&t,&l,&r);
        if (t) cout << seg.getsum(l,r) << newl;
        else {
            int b,c;
            // cin >> b >> c;
            scanf("%d%d",&b,&c);
            seg.update(l,r,b,c);
        }
    }
}

Measured memory_bytes: 35796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    str s; cin >> s;
    int ans = inf;
    rep(i, s.size()-2){
        str substr = s.substr(i, 3);
        int subint = stoi(substr);
        ans = min(abs(subint - 753), ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long int a,b,c,d;
	cin>>a>>b>>c>>d;
	double ds=min(fabs((c*30+d*0.5)-(d*6)),double(10000.0000009)/*360-fabs((c*30+d*0.5)-(d*6))*/);
	if(ds==180){
		cout<<a+b;
		return 0;
	}
	if(ds==0){
		cout<<fabs(a-b);
		return 0;
	}
	long double s=sqrt(double(a*a)+double(b*b)-double(2.0*a*b*cos(acos(-1)/180*ds)));
	cout<<fixed<<setprecision(50)<<s;
	return 0;
}


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

#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "["<< *it << " = " << a << "]"<< endl;
    err(++it, args...);
}
using ll = long long;

int main() {
    int n;
    scanf("%d", &n);
    printf("%.10lf", (((n+1) / 2) + 0.0) / n);


}


Measured memory_bytes: 256
import sys
import math

def add_ball(idx):
    add_list = []
    for j in range(1, int(math.sqrt(idx))+1):
        if idx%j == 0:
            add_list.append(j)
            if j != idx//j:
                add_list.append(idx//j)
    for k in add_list:
        b_list[k] += 1

if __name__ == "__main__":
    input = sys.stdin.readline

    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0] * (n+1)
    cnt = 0
    ans_list = []
    for a, i in zip(reversed(a_list), range(n, 0, -1)):
        if a != b_list[i]%2:
            cnt += 1
            ans_list.append(i)
            add_ball(i)
    ans_list.sort()
    print(cnt)
    if cnt > 0:
        print(' '.join(map(str, ans_list)))


Measured memory_bytes: 88312
#include<bits/stdc++.h>
using namespace std;
const int N = 1005;
const double eps = 1e-9;

int n, sx, sy, ex, ey, x[N], y[N], r[N];
double c[N][N], dist[N], ans;

priority_queue<pair<double,int> > pq;

double d (int X1, int Y1, int X2, int Y2, int R) {
	return max(0.0, hypot(X1-X2, Y1-Y2)-R);
}

int main()
{
	scanf("%d%d%d%d%d",&sx,&sy,&ex,&ey,&n);
	for(int i=1;i<=n;i++) {
		scanf("%d%d%d",&x[i],&y[i],&r[i]);
		for(int j=1;j<i;j++) {
			c[i][j] = d(x[i], y[i], x[j], y[j], r[i]+r[j]);
			c[j][i] = c[i][j];
		}
		dist[i] = d(x[i], y[i], sx, sy, r[i]);
		pq.push({-dist[i], i});
	}
	while(!pq.empty()) {
		double V; int I; tie(V, I) = pq.top(); V *= -1; pq.pop();
		if(dist[I]+eps < V) continue;
		for(int i=1;i<=n;i++) {
			if(i == I) continue;
			if(dist[i] > V + c[I][i]) {
				dist[i] = V + c[I][i];
				pq.push({-dist[i], i});
			}
		}
	}
	ans = d(sx, sy, ex, ey, 0);
	for(int i=1;i<=n;i++) {
		ans = min(ans, dist[i] + d(x[i], y[i], ex, ey, r[i]));
	}
	printf("%.12f",ans);
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
char da[4] = { 'R', 'L', 'D', 'U' };
char dad[4] = { 'L', 'R', 'U', 'D' };
ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }

ll N;




vector<pint> e[100005];
ll d[100005];

void dfs(int s) {

	rep(i, e[s].size()) {
		if (d[e[s][i].first] == inf) {
			d[e[s][i].first] = d[s] + e[s][i].second;
			dfs(e[s][i].first);
		}
	}

}


int ans[100005];

int main() {
	ll N;

	cin >> N;

	rep(i, N - 1) {
		ll u, v, w;
		cin >> u >> v >> w;
		e[u-1].push_back({ v-1, w });
		e[v-1].push_back({ u-1, w });
	}

	rep(i, N)
		d[i] = inf;

	d[0] = 0;
	dfs(0);


	rep(i, N) {
			cout << d[i] % 2 << endl;
		
		
	}
	
	

	return 0;

}

Measured memory_bytes: 10240
import itertools
import numpy as np
 
N,M,X = map(int,input().split())
ca = ([list(map(int,input().split())) for _ in range(N)])
ca = np.array(ca)
sumX = sum(ca)[1:]
sumcos = sum(ca)[0]
cost = sumcos
if sum(sumX>=X)<M:
    print(-1)
else:
    for j in range(1,N+1):
        for a in itertools.combinations(range(1,N+1),j):       
            x = sum(ca)[1:]
            fx = np.array([0]*M)
            c = sumcos
            for i in range(len(a)):
                x -= ca[a[i]-1][1:]
                c -= ca[a[i]-1][0]
                if sum(x>=X)<M:
                    break
                else:
                    cost = min(c,cost)
    print(cost)


Measured memory_bytes: 27308
#include<stdio.h>
#include<iostream>
using namespace std;

int a[112345];
long long int sum[2];
long long int cnt[2];

int N;
int main (){
    cin >> N;
    for(int i=0; i<N; i++) cin >> a[i];
    for(int j=0; j<2; j++) {
        for(int i=0; i<N; i++) {
            if( i % 2 == j ) {
                sum[j] += a[i];
                if( sum[j] <= 0 ) {
                    cnt[j] += 1 - sum[j];
                    sum[j] = 1;
                }
            } else {
                sum[j] += a[i];
                if( sum[j] >= 0 ) {
                    cnt[j] += sum[j] + 1;
                    sum[j] = -1;
                }
            }
        }
    }
    cout << min(cnt[0],cnt[1]) << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int x = 0;
    int y = 0;
    vector <int> a(n+1);
    vector <int> b(n+1);
    a[0] = 0;
    b[0] = 0;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++) {
        x += a[i];
    }
    for (int i = 2; i <= (n - 1); i += 2) {
        y = y + a[i];
    }
    y *= 2;
    x = x - y;
    b[1] = x;
    for (int i = 2; i <= n; i++) {
        b[i] = (2 * a[i - 1] - b[i - 1]);

    }
    for (int i = 1; i <= n; i++)
        cout << b[i] << " ";


    return 0;
}


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

int main() {
int n,a[200000],m;
cin>>n;
for(int i=0;i<n;i++){
    cin>>a[i];
}
m=n-1;
while(m>=0){
    cout<<a[m]<<" ";
    m-=2;
}
if(m==-1){
    m=0;
}else{
    m=1;
}
while(m<=n-2){
    cout<<a[m]<<" ";
    m+=2;
}
cout<<endl;
	return 0;
}

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

int main()
{
    ll n;
    cin>>n;
    vector<pair<ll,ll> > pos(n);
    for(ll i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        pos[i]={x+y,x-y};
    }
    sort(pos.begin(),pos.end());
    ll last=0,ans=0;
    for(ll i=1;i<n;i++)
    {
        if(pos[last].first>pos[i].second)
        ans++;
        else
        last = i;
    }
    cout<<(n-ans)<<endl;
}

Measured memory_bytes: 1792
s=input()
n=len(s)
ans=0
for i in range(2**(n-1)):
    tmp=""
    for j in range(n):
        tmp+=s[j]
        if (i >> j) & 1:
            tmp+="+"
    ans+=sum([int(x) for x in tmp.split("+") if len(x)])
    # print(tmp)
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  
  val h = sc.nextInt
  val n = sc.nextInt
  val a = List.fill(n)(sc.nextInt)
  
  val res = if( h <= a.sum) "Yes" else "No"
  
  println(res)
}

Measured memory_bytes: 62304
#include <stdio.h>

int main(void)
{
	int h,w,a,b;
	while(1){
	scanf("%d %d",&h,&w);
if(h==0)
if(w==0)
{	break;}
		
	for(a=0;a<h;a++){
	 for(b=0;b<w;b++){
	if(a==0||a==h-1||b==0||b==w-1)
printf("#");
else printf(".");
}
	printf("\n");
	}
	printf("\n");
}
	return 0;
}
    

Measured memory_bytes: 572
#include<stdio.h>
#include<stdlib.h>

int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	int i;
	int count = 0;
	for(i = (a>b)?a:b;;i--){
		if(a%i==0&&b%i==0)count++;
		if(count == c){
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}

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


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

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = [A[i] - i for i in range(n)]
C = [-A[i] - i for i in range(n)]

# Bの要素それぞれに対するCの中ある等しいものの数の総和

C.sort()
from bisect import *

ans = 0

for b in B:
    ans += bisect(C, b) - bisect_left(C, b)

print(ans)


Measured memory_bytes: 110120
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  priority_queue<int> q;
  cin>>n>>m;
  rep(i,n){
    int num;
    cin>>num;
    q.push(num);
  }
  rep(i,m){
    int num=q.top();
    q.pop();
    q.push(num/2);
  }
  int ans=0;
  while(!q.empty() ){
    ans+=q.top();
    q.pop();
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1400
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    int pos = 0;
    while (pos != S.length()) {
        if (S.substr(pos, 5) == "maerd") pos += 5;
        else if (S.substr(pos, 7) == "remaerd") pos += 7;
        else if (S.substr(pos, 5) == "esare") pos += 5;
        else if (S.substr(pos, 6) == "resare") pos += 6;
        else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 512
import heapq

N, M = list(map(int, input().split()))
jobs = [[] for _ in range(M)]

for i in range(N):
    d, r = list(map(int, input().split()))
    if d-1 < M:
        jobs[d-1].append(-r)

rewords = 0
heap = []

for i in range(M):
    for reword in jobs[i]:
        heapq.heappush(heap, reword)
    if len(heap) >0:
        r = heapq.heappop(heap)
        rewords -= r

print(rewords)

Measured memory_bytes: 23752
#include <stdio.h>
//#include <string.h>

int main(void){
  int a1,a2,a3;
  scanf("%d %d %d", &a1, &a2, &a3);
  //scanf("%d", &b);

  if(a1+a2+a3>21)
    printf("bust");
  else
    printf("win");
  
  //printf("%d", 6-a-b);

  return 0;
}

  

Measured memory_bytes: 1708
#include <iostream>
#include <vector>
#include <cmath>

template<typename T>
auto print(std::vector<T> array,bool reverse = false) 
 -> void{
 	if(reverse){
		auto iterator = array.rbegin();
		std::cout<<*iterator;
		iterator++;
		for(;iterator != array.rend();++iterator){
			std::cout<<" "<< *iterator;
		}

	}else{
		auto iterator = array.begin();
		std::cout<<*iterator;
		iterator++;
		for(;iterator != array.end();++iterator){
			std::cout<<" "<< *iterator;
		}
	}
	std::cout<<"\n";
}

template<typename T>
auto println(std::vector<T> array) 
 -> void{
	for(auto v : array){
		std::cout<< v <<"\n";
	}
}


auto main()
 -> int{

	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);

	int n, m;
	std::cin>> n >> m;

	std::vector<int> array(m);
	for(int i=0;i < m;i++)
		std::cin>>array[i];

	std::vector<int> T(n+1);
	for(auto &v : T){
		v = 1 << 24;
	}
	T[0] = 0;

	for(int i = 0;i <= m+1;i++){
		for(int j = array[i];j <= n;j++){
			T[j] = std::min(T[j], T[j - array[i]] + 1);
		}
	}

	std::cout<<T[n]<<"\n";

	return 0;
}

Measured memory_bytes: 1292
import numpy as np

q = int(input())

params = [[int(el) for el in input().split()] for _ in range(q)]


def get_nearst(max):
    primes = [True for i in range(max+1)]

    for i in range(2, max):
        if primes[i]:
            for j in range(i+i, max+1, i):
                primes[j] = False

    primes[0] = False
    primes[1] = False

    neast = [False for i in range(max)]

    for i in range(3, max+1, 2):
        if primes[i] and primes[int((i+1)/2)]:
            neast[i] = True

    return tuple(neast)


primes = get_nearst(max=10**5)

ruise = np.cumsum(primes)

# for index, el in enumerate(ruise[:100]):
#     print(index, el)

for l, r in params:
    if r == l:
        print(int(primes[r]))
    else:
        print(ruise[r]-ruise[l-1])


Measured memory_bytes: 33000
#include<cstdio>
#include<vector>


using namespace std;

using ll=long long;
using vll=vector<ll>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vll a(n+2);

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

		ll ans=0;
		ll p=a[0];
		int tail=0;
		for(int i=0;i<n;i++)
		{
			for(;tail+1<n;)
			{
				if((p^a[tail+1])==(p+a[tail+1]))
				{
					p^=a[tail+1];
					tail++;
				}
				else
				{
					break;
				}
			}
			int add=tail+1-i;
//			printf("i=%d  add=%d  p=%lld tail=%d\n", i, add, p, tail);
			ans+=add;
			p^=a[i];
		}
		printf("%lld\n", ans);
	}


	return 0;
}


Measured memory_bytes: 1792
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
map<array<int,15>,int>memo;
int solve(array<int,15>in,int L,int R){
	//cerr<<"de";for(int i=1;i<=13;i++){cerr<<in[i];}cerr<<endl;
	if(memo.count(in)){return memo[in];}
	//1側が先手
	array<int,15>gya;
	bool make=1;
	for(int i=0;i<15;i++){gya[i]=-in[i];if(in[i]<0){make=0;}}
	if(make){return -1;}
	//相手の札がないと負けている
	if(in[L]<=0&&in[R]<=0){return -solve(gya,L,R);}
	if(in[L]>0&&in[R]<=0){gya[L]=0;return -solve(gya,L-1,R);}
	if(in[L]<=0&&in[R]>0){gya[R]=0;return -solve(gya,L,R+1);}
	if(in[L]>0&&in[R]>0){
		gya[L]=0;
		if(-solve(gya,L-1,R)>0){return 1;}
		else{gya[L]=-1;gya[R]=0;return -solve(gya,L,R+1);}
	}
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int Q;cin>>Q;
	while(Q--){
		array<int,15>in;
		for(int i=0;i<15;i++){in[i]=-1;}
		in[0]=0;in[7]=0;in[14]=0;
		for(int i=0;i<6;i++){int f;cin>>f;in[f]=1;}
		cout<<(solve(in,6,8)==1?"yes":"no")<<endl;
	}
	return 0;
}



Measured memory_bytes: 3184
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, n;
    int ans = Inf;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) {
      cin >> h[i];
    }
    sort(h.begin(), h.end());

    rep(i, n - k + 1) {
      ans = min(ans, h[i + k - 1] - h[i]);
    }

    cout << ans << '\n';

    return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(ll X, ll Y) {
    if (X == Y - 1 || X == Y || X == Y + 1) {
        cout << "Brown" << endl;
    } else {
        cout << "Alice" << endl;
    }

}


void main_(istream &cin) {
    ll Y;
    ll X;
    cin >> X;
    cin >> Y;
    solve(X, Y);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  if(a+b<c+d){
    cout << "Right" << endl;
  }
  else if(a+b==c+d){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Left" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
 
int n;
vector <string> ans;

void rec(int cnt, char c, char mx, string &s) {
  if (cnt > n) {
    return;
  }
  if (cnt == n) { 
    ans.push_back(s);
    return;
  }
  for (char kek = 'a'; kek <= mx + 1; kek++) {
    if (kek == c) continue;
    for (int i = 1; i <= 10; i++) {
      for (int x = 1; x <= i; x++) {
        s.push_back(kek);
      }
      rec(cnt + i, kek, mx + (kek == mx + 1), s);
      for (int x = 1; x <= i; x++) {
        s.pop_back();
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  string s = "";
  rec(0, 'a' - 1, 'a' - 1, s);
  sort(ans.begin(), ans.end());
  for (auto to : ans) {
    cout << to << '\n';
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 11124
#pragma warning(disable:4996)
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>

using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)b - *(int*)a;
}


int main() {
	int n, l[2000];
	int count = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> l[i];
	}

	qsort(l, n, sizeof(l[0]), asc);
	/*
	for (int i = 0; i < n; ++i) {
		cout << l[i] << ' ';
	}
	cout << endl;
	*/
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			for (int k = j +1; k < n; ++k) {
				if (l[i] < l[j] + l[k]) {
					++count;
				}
				else break;
			}
		}
	}
	cout << count << endl;
	return 0;
}

/*


*/

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

using namespace std;

const int N = (int)1e5 + 7;

char s[N];

main() {    
	int n; 
	scanf("%d", &n);
	set < char > asd;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		asd.insert(s[i]);
	}                  
	if ((int)asd.size() == 3) {
		puts("Three");
	} else {
		puts("Four");
	}
}

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

fn solve(X: i64, N: i64,mut p: Vec<i64>) {
    p.sort();
    let mut res = X;
    
    for i in 0..101 {
        let dp = X + i;
        let dm = X - i;
        {
            let mut exist = false;
            for k in 0..N as usize {
                if p[k] == dm {
                    exist = true;
                }
            }
            if !exist {
                println!("{}", dm);
                return;
            }
        }

        {
            let mut exist = false;
            for k in 0..N as usize {
                if p[k] == dp {
                    exist = true;
                }
            }
            if !exist {
                println!("{}", dp);
                return;
            }
        }
    }
    println!("{}", X);
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut X: i64;
    X = scanner.next();
    let mut N: i64;
    N = scanner.next();
    let mut p: Vec<i64> = vec![0i64; (N) as usize];
    for i in 0..(N) as usize {
        p[i] = scanner.next();
    }
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(X, N, p)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 2264
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
int h1, m1, h2, m2, k;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << h2*60 + m2 - h1*60 - m1 - k << endl;
}

Measured memory_bytes: 3652
// J'aime
// Chemise Blanche

#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()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  string s;
  cin >> s;
  int ans = 0;
  for (auto &i : s) {
    if (i == '+') ans++;
    else ans--;
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3564
N,K=map(int,input().split())
p=list(map(int,input().split()))
for i in range(N):
    p[i]=((p[i]+1)/2)
su=[0]
for i in range(N):
    su.append(su[i]+p[i])
ans=0
for i in range(K,N+1):
    ans=max(ans,su[i]-su[i-K])
print(ans)

Measured memory_bytes: 25060
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	static int[][] map = new int[101][101];
	static int[][] dp = new int[101][101];
	public static void main(String[] args) {
		
		FastScanner sc = new FastScanner();
		Scanner stdIn = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		boolean[] list = new boolean[3000];
		for(int i = 1; i < 3000; i++) {
			if(i % 4 == 0 && (!(i%100 == 0) || i % 400 == 0)) {
				list[i] = true;
			}
		}
		boolean F = true;
		while(true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a == 0 && b == 0) break;
			
			if(!F) {
				out.println();
			}
			F = false;
			boolean A = false;
			for(int i = a; i <= b; i++) {
				if(list[i]) {
					A = true;
					out.println(i);
				}
			}
			if(!A) {
				out.println("NA");
			}
		}
		out.flush();
	}
}
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
    	return (int)nextLong();
    }
    

}

Measured memory_bytes: 18152
S = input()
MOD =2019
count = [0]*MOD
r = 0
t = 1
for i in reversed(S):
    r += int(i) * t
    r %= MOD
    t *= 10
    t %= MOD
    count[r] += 1

count[0] += 1
print(int(sum(i*(i-1)/2 for i in count)))

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

int dp[223456][3];
bool used[223445][3];
int main() {
    string s;
    cin >> s;
    used[0][1] = used[0][2] = 1;
    used[1][1] = 1;
    dp[1][1] = 1;
    for(int i = 2; i <= s.size(); i++) {
        if(s[i - 1] != s[i - 2]) {
            int first = 0;
            if(used[i - 1][1]) first = dp[i - 1][1];
            int second = 0;
            if(used[i - 1][2]) second = dp[i - 1][2];
            dp[i][1] = max(first, second) + 1;
            used[i][1] = 1;
        }
        used[i][1] = 1;
        dp[i][1] = max(dp[i][1], dp[i - 1][2] + 1);
        int first = 0;
        if(used[i - 2][1]) first = dp[i - 2][1];
        int second = 0;
        if(used[i - 2][2]) second = dp[i - 2][2];
        dp[i][2] = first + 1;
        if(i < 3 or (s[i - 3] != s[i - 1] && s[i - 2] != s[i - 4]))
            dp[i][2] = max(dp[i][2], dp[i - 2][2] + 1);
        used[i][2] = 1;
    }
    //cout << dp[5][2];
    int n = s.size();
    cout << max(dp[n][1], dp[n][2]);
    return 0;
}

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

class Program
{
	static void Main()
	{
		var rgb = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));

		Console.WriteLine((rgb[0] * 100 + rgb[1] * 10 + rgb[2]) % 4 == 0 ? "YES" : "NO");

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}


Measured memory_bytes: 11092