akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
const int maxn = 2e5 + 10;
int seq[maxn];
map<int,int> mp;
int val[maxn];
int fen[maxn];
int update(int i,int v){
    for (;i < maxn;i+= i&-i)
        fen[i] += v;
}
int query(int i){
    int sum = 0;
    for (;i;i-=i&-i)
        sum += fen[i];
    return sum;
}
int32_t main() {
    int n;
    cin >> n;
    int k;
    cin >> k;
    for (int i = 1;i <= n;i++){
        cin >> seq[i];
        seq[i] -= k;
    }
    int sum = 0;
    vector<int> v;
    for (int i = 0;i<= n;i++){
        sum += seq[i];
        v.pb(sum);
    }
    sort(v.begin(),v.end());
    int l = -1e16;
    int cc = 0;
    for (int i = 0;i < v.size();i++){
        if (v[i] == l) continue;
        cc++;
        val[cc] = v[i];
        mp[v[i]] = cc;

    }
    sum = 0;
    int sum2 = 0;
    int cnt = 0;
    for (int i = 1;i <= n;i++){
        update(mp[sum],1);
        sum2 += seq[i];
        int lo = 1,hi = cc,m,found = -1;
        while(lo <= hi){
            m = (lo + hi) / 2;
            if (val[m] <= sum2){
                found = m;
                lo = m + 1;
            }else hi = m - 1;
        }
        if (found != -1){
            cnt += query(found);
        }
        sum += seq[i];
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 19056
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

class dinic {
private:
	struct edge {
		int to; long long cap; int rev;
		edge(int t_, long long c_, int r_) :to(t_), cap(c_), rev(r_) {}
	};
	vector<vector<edge> >G; vector<int>level, iter;
	//sourceからBFSをする
	void bfs(int s_) {
		fill(level.begin(), level.end(), -1);
		std::queue<int>que;
		level[s_] = 0;
		que.push(s_);
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (int i = 0; i < G[v].size(); ++i) {
				edge &e = G[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}
	//DFSで増加パスを見つけて、流す。
	long long dfs(int v_, int t_, long long f_) {
		if (v_ == t_)return f_;
		for (int &i = iter[v_]; i < G[v_].size(); ++i) {
			edge &e = G[v_][i];
			if (e.cap > 0 && level[v_] < level[e.to]) {
				long long d = dfs(e.to, t_, min(f_, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
public:
	dinic(int vec_) :G(vec_), level(vec_), iter(vec_) {}
	//fromからtoへ容量capの辺を張る
	void add_edge(int from_, int to_, long long cap_) {
		G[from_].push_back(edge(to_, cap_, G[to_].size()));
		G[to_].push_back(edge(from_, 0ll, G[from_].size() - 1));
	}
	//Dinic法で、頂点source→sinkの最大流量を計算する 最悪計算量O(V^2*E)
	long long max_flow(int source_, int sink_) {
		long long flow = 0;
		for (;;) {
			bfs(source_);
			if (level[sink_] < 0)return flow;
			fill(iter.begin(), iter.end(), 0);
			for (;;) {
				long long f = dfs(source_, sink_, LLONG_MAX);
				if (f > 0)flow += f;
				else break;
			}
		}
		return flow;
	}
};

const LL INF = 1145148101919893;

int main(void)
{
	int N;
	vector<LL>a;
	cin >> N;
	LL ans = 0;
	for (int i = 0; i < N; ++i) {
		LL aa; cin >> aa; a.push_back(aa);
		ans += max(0LL, aa);
	}
	dinic D(N + 2);
	for (int i = 0; i < N; ++i) {
		if (a[i] >= 0) {
			D.add_edge(0, i + 1, a[i]);
			D.add_edge(i + 1, N + 1, 0);
		}
		else {
			D.add_edge(0, i + 1, 0);
			D.add_edge(i + 1, N + 1, -a[i]);
		}
	}
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j < i; ++j) {
			if (i % j == 0) {
				D.add_edge(i, j, INF);
			}
		}
	}
	cout << ans - D.max_flow(0, N + 1);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n;
int p[202];
vector<int> ans;
void nuo(int k){
    ans.push_back(k);
    for(int i=k; i<n; i++) swap(p[i], p[i-k]);
}
void move(int k){
    if(k==0){
        nuo(n-1);
        return;
    }
    for(int i=0; i<k-1; i++){
        nuo(n-1);
        nuo(1);
    }
    nuo(n-1);
    for(int i=0; i<n-k; i++){
        nuo(1);
    }
}
int main()
{
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>p[i];
    }
    for(int i=1; i<n-1; i++){
        while(p[n-1]!=i){
            nuo(1);
        }
        for(int j=0; j<n; j++){
            if(p[j]==i-1){
                move((j+1)%n);
            }
        }
    }
    while(p[0]!=0){
        nuo(1);
    }
    cout<<ans.size()<<endl;
    for(auto x:ans) cout<<x<<endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> L(N+1,0);
    REP(i,N){
        int a;
        cin >> a;
        L[a-1] = i;}

    ll ans = 0;
    set<ll> S;
    S.insert(-1);
    S.insert(N);
    REP(i,N){
        auto t = S.lower_bound(L[i]);
        ll r = *t - L[i];
        t--;
        ll l = L[i] - *t;
        ans += (i+1)*l*r;
        S.insert(L[i]);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long int lli;

const int MAXN = 1010;
const lli INF = 1000000000000000000LL;

int n;
int xs, ys;
int xt, yt;

int X[MAXN];
int Y[MAXN];
int R[MAXN];

double dist[MAXN];
double cost[MAXN][MAXN];

set< pair<double,int> > s;

void Dijsktra()
{
	for(int i = 1 ; i <= n ; i++)
		dist[i] = INF;

	for(int i = 0 ; i <= n ; i++)
		s.insert( { dist[i] , i } );

	while( !s.empty() )
	{
		int cur = s.begin()->second;
		s.erase( s.begin() );

		for(int i = 0 ; i <= n ; i++)
		{
			if( dist[i] > dist[cur] + cost[i][cur] )
			{
				s.erase( { dist[i] , i } );
				dist[i] = dist[cur] + cost[i][cur];
				s.insert( { dist[i] , i } );
			}
		}
	}
}

int main()
{
	scanf("%d %d %d %d",&X[0],&Y[0],&X[1],&Y[1]);
	scanf("%d",&n);

	n++;

	for(int i = 2 ; i <= n ; i++)
		scanf("%d %d %d",&X[i],&Y[i],&R[i]);

	for(int i = 0 ; i <= n ; i++)
	{
		for(int j = 0 ; j <= n ; j++)
		{
			lli dx = X[i] - X[j];
			lli dy = Y[i] - Y[j];

			lli dist = dx*dx + dy*dy;

			cost[i][j] = sqrtl( dist );

			cost[i][j] -= R[i];
			cost[i][j] -= R[j];

			cost[i][j] = max( cost[i][j] , 0.0 );
		}
	}

	Dijsktra();

	printf("%.10f\n",dist[1]);
}

Measured memory_bytes: 8192
let n = Int(readLine()!)!
let l = readLine()!.split(separator: " ").map{Int($0)!}
var c = 0
for i in 0..<n {
    if (i+1)%2 == 1 && l[i]%2 == 1 {
        c += 1
    }
}
print(c)


Measured memory_bytes: 8016
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

				int n = sc.nextInt();
				int a[] = new int[200010];
				int ans[] = new int[200010];
		
				for (int i = 2; i <= n; i++) {
					a[i] = sc.nextInt();
					ans[a[i]]++;
				}
				for (int i = 1; i <= n; i++) {
					System.out.println(ans[i]);
				}
    }
}

Measured memory_bytes: 55160
#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()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    for (int i = sx; i < tx; i++)
    {
        cout << "R";
    }
    for (int i = sy; i < ty; i++)
    {
        cout << "U";
    }
    for (int i = 0; i < tx-sx; i++)
    {
        cout << "L";
    }
    for (int i = 0; i < ty-sy; i++)
    {
        cout << "D";
    }
    cout << "D";
    for (int i = 0; i < tx-sx+1; i++)
    {
        cout << "R";
    }
    for (int i = 0; i < ty-sy+1; i++)
    {
        cout << "U";
    }
    cout << "LU";
    for (int i = 0; i < tx - sx+1; i++)
    {
        cout << "L";
    }
    for (int i = 0; i < ty-sy+1; i++)
    {
        cout << "D";
    }
    cout << "R" << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#M-SOLUTIONS プロコンオープン B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
c = s.count('x')
if c >= 8:
    print('NO')
else:
    print('YES')


Measured memory_bytes: 38384
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	HashMap<String,Integer> hash=new HashMap<String, Integer>();
	public void run() {
		hash.put("I",1);
		hash.put("V",5);
		hash.put("X",10);
		hash.put("L",50);
		hash.put("C",100);
		hash.put("D",500);
		hash.put("M",1000);

		while (sc.hasNext()) {
			String str = sc.next();
			int[] data=new int[str.length()];
			for(int i=0;i<str.length();i++){
				data[i]=hash.get(str.charAt(i)+"");
			}
			int prev=data[0];
			int val=0;
			for(int i=1;i<data.length;i++){
				if(data[i]>prev){
					val-=prev;
				}else{
					val+=prev;
				}
				prev=data[i];
			}
			val+=data[data.length-1];

			ln(val);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

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

int felicidade(int n){
    int a[n+1],b[n+1],c[n+1];
    
    for(int i=1;i<=n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    for(int i=2;i<=n;i++){
        a[i]=max(b[i-1],c[i-1])+a[i];
        b[i]=max(a[i-1],c[i-1])+b[i];
        c[i]=max(a[i-1],b[i-1])+c[i];
    }

    if(a[n]>=b[n] and a[n]>=c[n]){
        return a[n];
    } else if(b[n]>=a[n] and b[n]>=c[n]){
        return b[n];
    }else if(c[n]>=a[n] and c[n]>=b[n]){
        return c[n];
    }
    
    return 0;
}

int main() {
    int n;

    cin >> n;

    cout << felicidade(n) << endl;
}

Measured memory_bytes: 1408
package main

import "fmt"

type D int

func (s D) String() string {
	switch s {
	case 25:
		return "Christmas"
	case 24:
		return "Christmas Eve"
	case 23:
		return "Christmas Eve Eve"
	case 22:
		return "Christmas Eve Eve Eve"
	}
	return ""
}

func main() {
	var d D

	fmt.Scan(&d)

	fmt.Println(d.String())
}


Measured memory_bytes: 512
L = int(input())

inf = float('inf')
dp = [[inf] * 5 for _ in range(L+1)]
dp[0][0] = 0
for i in range(1, L+1):
    a = int(input())

    b = a & 1
    c = b ^ 1
    p, n = dp[i-1], dp[i]
    n[0] = p[0] + a
    n[1] = min(p[:2]) + b
    n[2] = min(p[:3]) + c
    n[3] = min(p[:4]) + b
    n[4] = min(p[:5]) + a

    if a == 0:
        n[1] += 2
        n[3] += 2

print(min(dp[L]))

Measured memory_bytes: 59892
N = int(input())

S = {}

for _ in range(N):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

S = reversed(sorted(S.items(), key=lambda x:x[1]))

result = []
num = 0
for s in S:
    if s[1] < num:
        break
    result.append(s[0])
    num = s[1]

for res in sorted(result):
    print(res)



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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int n;
vector<vector<int>> g(100010);

int rec(int cur, int pre)
{
    if(g[cur].size()==1)
    {
        // leaf
        return 0;
    }
    int cnt = 0, sum = 0;
    for(auto v:g[cur])
    {
        if(v==pre) continue;
        int tmp = rec(v, cur);
        if(tmp)
        {
            cnt++;
            sum += tmp;
        }
    }
    if(pre==-1)
    {
        return sum + max(0, (int)g[cur].size()-1-cnt);
    }
    return sum + max(0, (int)g[cur].size()-2-cnt);
}

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

    cin >> n;
    for(int i=0;i<n-1;i++)
    {
        int a,b;cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int index = -1;
    for(int i=0;i<n;i++)
    {
        if(g[i].size()>2)
        {
            index = i;
            break;
        }
    }
    if(index==-1)
    {
        cout << 1 << endl;
        return 0;
    }
    cout << rec(index, -1) << endl;
}


Measured memory_bytes: 9984
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int ret=0;
	for(int i=0;i<a;i++){
		int now=0;
		for(int j=0;j<b;j++){
			int c;
			scanf("%d",&c);
			now+=c;
		}
		ret=max(ret,now);
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 0
my ($d) = split(/\s+/, <>);
my (@c) = (-1, split(/\s+/, <>));

my @s = ();
for my $i (1..$d) {
    $s[$i] = [-1, split(/\s+/, <>)];
}

sub score {
    my (@contest) = @_;
    my $ret = 0;
    my @last = (-1); for (1..26) { push @last, 0; }
    my $j = 1;

    for my $i (@contest) {
	$ret += $s[$j][$i];
	$last[$i] = $j;
	for (1..26) {
	    $ret -= $c[$_] * ($j-$last[$_]);
	}
	$j++;
    }
    return $ret;
}

sub max_index {
    my (@list) = @_;
    #print join(":", @list), "\n";
    my $maxi = 0;
    for (my $i=0; $i<scalar(@list); $i++) {
	$maxi = $i if $list[$maxi] < $list[$i];
    }
    return $maxi;
}

my @cont = ();
for my $j (1..$d) {
    push @cont, max_index(@{$s[$j]});
}

print join("\n", @cont), "\n";


Measured memory_bytes: 5732
s = input()
s1 = int(s[0:2])
s2 = int(s[2:4])

s1m = False
s1y = False
s2m = False
s2y = False
if s1 <= 12 and s1 >= 1:
  s1y = True
  s1m = True
elif s1 > 12 or s1 == 0:
  s1y = True
  
if s2 <= 12 and s2 >= 1:
  s2y = True
  s2m = True
elif s2 > 12  or s2 == 0:
  s2y = True

if s1y and s2y and s1m and s2m:
  print("AMBIGUOUS")
elif s1y and s2m :
  print("YYMM")
elif s2y and s1m :
  print("MMYY")
else :
  print("NA")
  

Measured memory_bytes: 9136
a, b, c = map(int,input().split(' '))
n = 1
mod = []
while(True):
    if (a * n) % b == c:
        print("YES")
        break
    else:
        if (a * n) % b not in mod:
            mod.append((a * n) % b)
        else:
            print("NO")
            break
    n += 1


Measured memory_bytes: 2940
/* Ahmed Maher ( Acro_14 ) */
/*while(WA)try();*/
#include <bits/stdc++.h>
typedef long long ll;
const ll oo = 0x3f3f3f3f;
int const N = 3e5+5;
int const mod = 1e9+7;
using namespace std;
/*string Alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet="abcdefghijklmnopqrstuvwxyz";*/
long long fast_Power(int Base , int Expo){
    if(Expo == 0){
        return 1;
    }
    if(Expo == 1){
        return Base;
    }
    if(Expo % 2 == 0){
        long long ret = fast_Power(Base , Expo / 2);
        return ret * ret;
    } else {
        long long ret = fast_Power(Base , Expo - 1);
        return Base * ret;
    }
}
void solve(){
int n;
cin>>n;
while(n--)cout<<"ACL";
  }
int main()
{
    /*freopen("input.txt" , "r" , stdin);
    freopen("output.txt" , "w" , stdout);*/
  int t;
	t=1;
     while(t--)
    {

		solve();

    }
	return 0;
}

//       int anss[t+1];
//            anss[j]=ans;
//     for(int j=1;j<=t;j++) printf("Case %d: %d\n",j,anss[j]);


Measured memory_bytes: 3616
import sys
input = sys.stdin.readline
n = int(input())
ab = [list(map(int,input().split())) for i in range(n-1)]
graph = [[] for i in range(n+1)]
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
stack = [(1,1)]
color = [0]*(n+1)
while stack:
  x,c = stack.pop()
  color[x] = c
  for y in graph[x]:
    if color[y] == 0:
      stack.append((y,3-c))
ans = [0]*(n+1)
cnt1 = 1
cnt2 = 2
cnt3 = 3
if color.count(1) >= (n*2+2)//3:
  for i in range(1,n+1):
    if color[i] == 1:
      if cnt1 <= n:
        ans[i] = cnt1
        if cnt1%3 == 1:
          cnt1 += 1
        else:
          cnt1 += 2
      else:
        ans[i] = cnt3
        cnt3 += 3
    else:
      ans[i] = cnt3
      cnt3 += 3
elif color.count(2) >= (n*2+2)//3:
  for i in range(1,n+1):
    if color[i] == 2:
      if cnt1 <= n:
        ans[i] = cnt1
        if cnt1%3 == 1:
          cnt1 += 1
        else:
          cnt1 += 2
      else:
        ans[i] = cnt3
        cnt3 += 3
    else:
      ans[i] = cnt3
      cnt3 += 3
else:
  c1 = []
  c2 = []
  for i in range(1,n+1):
    if color[i] == 1:
      c1.append(i)
    else:
      c2.append(i)
  for x in c1:
    if cnt1 <= n:
      ans[x] = cnt1
      cnt1 += 3
    else:
      ans[x] = cnt3
      cnt3 += 3
  for x in c2:
    if cnt2 <= n:
      ans[x] = cnt2
      cnt2 += 3
    else:
      ans[x] = cnt3
      cnt3 += 3
ans = ans[1:]
print(*ans)

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

int main(){
  int n,k,s;
  cin>>n>>k>>s;
  if(k==n){
    for(int i=0;i<n;i++)
       cout<<s<<" ";
  }
  else{
    for(int i=0;i<k;i++)
      cout<<s<<" ";
    if(n-k>=s){
      if(s==1){
        for(int i=k;i<n;i++)
          cout<<s+1<<" ";
      }
      else{
        for(int i=k;i<n;i++)
           cout<<s-1<<" ";
      }
    }
    else{
		for(int i=k;i<n;i++)
			cout<<1<<" ";
    }
  }
}


Measured memory_bytes: 1280
n = int(input())
a = list(map(int,input().split()))
asum = sum(a)
a2sum = 0
for m in a:
  a2sum += m**2
x1 = asum//n
x2 = x1+1
z1 = n*x1**2-2*asum*x1+a2sum
z2 = n*x2**2-2*asum*x2+a2sum
print(min(z1,z2))

Measured memory_bytes: 3060
// インクルード(GCC only)
#include <bits/stdc++.h>

// 長い型名
using namespace std;
typedef long long LL;

// 省略記法
#define INF 1e9
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i##_len=(n), i=(i##_len-1); i>=0; ++i)
#define FOR(i,m,n) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define all(x) (x).cbegin(),(x).cend()
#define sizei(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define printvector(x) rep(i,sizei(x)){cout << x[i] << endl;}
#define summation(x) (accumulate(all(x), 0LL))
#define product(x) (accumulate(all(x), 1LL, [](int acc, int i) { return acc * i;}))

// mod付き四則演算(mod関数のオーバーヘッドが重いかも)
// TODO: 二項係数、離散対数、平方剰余の実装
//#define MOD 1000000007LL
#define MOD 998244353LL
inline LL mod(LL const &a) { return (a % MOD + MOD) % MOD; }
inline LL madd(LL const &a, LL const &b) { return mod(mod(a) + mod(b)); }
inline LL msub(LL const &a, LL const &b) { return mod(mod(a) - mod(b)); }
inline LL mmul(LL const &a, LL const &b) { return mod(mod(a) * mod(b)); }
inline LL mpow(LL a, LL b) {
  LL r = 1;
  for (; b > 0; b >>= 1) {
    if (b & 1) (r *= a) %= MOD;
    (a *= a) %= MOD;
  }
  return r;
}
inline LL minv(LL const &a) { return mpow(a, MOD-2); }
inline LL mdiv(LL const &a, LL const &b) { return mod(mod(a) * minv(b)); }


// デバッグ用
#ifdef LOCAL
    #define TO_STRING(VariableName) # VariableName
    #define eprint(...) {fprintf(stderr, "DEBUG: "); fprintf(stderr, __VA_ARGS__);}
    #define eprintvector(x) rep(i,sizei(x)){fprintf(stderr, "DEBUG: %s[%d] = %lld\n", TO_STRING(x), i, x[i]);}
#else
    #define eprint(...) 42
    #define eprintvector(x) 42
#endif

/**************** 便利な関数 ****************/
vector<string> split_impl(string &&s, regex &&r) { return { sregex_token_iterator{s.begin(), s.end(), r, -1}, sregex_token_iterator{} }; }
auto split(string s, string pattern) { return split_impl(move(s), regex{pattern}); }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


/**************** ラムダ再帰用 ****************/
template<typename F>
class FixPoint : F
{
public:
  explicit constexpr FixPoint(F&& f) noexcept
    : F(std::forward<F>(f))
  {}
 
  template<typename... Args>
  constexpr decltype(auto)
  operator()(Args&&... args) const
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};
 
template<typename F>
static inline constexpr decltype(auto)
makeFixPoint(F&& f) noexcept
{
  return FixPoint<F>{std::forward<F>(f)};
}

/**************** main ****************/
 
int main()
{
  LL N, W;
  cin >> N >> W;

  vector<LL> w(N+1), v(N+1);
  FOR(i, 1, N+1) {
    cin >> w[i] >> v[i];
  }

  vector<vector<LL>> dp(N+1, vector<LL>(W+1, 0));
  FOR(i, 1, N+1) {
    FOR(k, 1, W+1) {
      if (k >= w[i]) {
        dp[i][k] = max(dp[i-1][k - w[i]] + v[i], dp[i-1][k]);
      }
      else {
        dp[i][k] = dp[i-1][k];
      }
    }
  }
  
  eprintvector(dp[1]);

  cout << dp[N][W] << endl;

  return 0;
}


Measured memory_bytes: 80256
# -*- coding: utf-8 -*-
N,M = map(int, input().split())

if N%2==1:
  for i in range(M):
    print(M-i,M+1+i)
else:
  for i in range(M):
    if 4*(i+1)>N:
      print(M-i,M+2+i)
    else:
      print(M-i,M+1+i)

Measured memory_bytes: 9280
N = int(input())
H = list(map(int,input().split()))

ans = 0
tmp = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        tmp += 1
    else:
        ans = max(ans,tmp)
        tmp = 0

ans = max(ans,tmp)

print(ans)

Measured memory_bytes: 85332
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
			int n=sc.nextInt();
			long []fib=new long[87];
			fib[0]=2;fib[1]=1;
			for(int i=2;i<=86;i++)
				fib[i]=fib[i-1]+fib[i-2];
			System.out.println(fib[n]);

	}
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

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

		public int nextInt() throws IOException {return Integer.parseInt(next());}
		
		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}
		
		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}
		
		public boolean ready() throws IOException {return br.ready();}


	}
}


Measured memory_bytes: 23124
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, c;
    int count = 0;
    
    scanf("%d %d %d",  &a, &b, &c);
    while (1) {
        if (c%a==0) {
            count++;
        }
        if (a==b) {
            break;
        }
        a++;
    }
    printf("%d\n", count);
    
    return 0;
}

Measured memory_bytes: 596
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N, M;
ll K;
ll sumA[200005]={}, sumB[200005]={};

signed main(){
    cin >> N >> M >> K;
    rep(i, N){
        cin >> sumA[i+1];
        sumA[i+1] += sumA[i];
    }
    rep(i, M){
        cin >> sumB[i+1];
        sumB[i+1] += sumB[i];
    }

    int ans = 0;
    rep(i, N+1){
        if(sumA[i] > K) break;
        int ok = -1;
        int ng = M+1;
        while(ng-ok > 1){
            int m = (ok+ng) / 2;
            if(sumA[i]+sumB[m] <= K) ok = m;
            else ng = m;
        }
        ans = max(ans, i+ok);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6756
//let input = "6\nAC\nTLE\nAC\nAC\nWA\nTLE";

//Si は AC, WA, TLE, RE のいずれか

function main(input){
  input = input.trim();
  let list = input.split("\n");
  let caseL = ["AC","WA","TLE","RE"];
  let nl = [0,0,0,0];
  for(let i=1; i<list.length; i++){
    if(list[i]===caseL[0]){
      nl[0]++;
    }else if(list[i]===caseL[1]){
      nl[1]++;
    }else if(list[i]===caseL[2]){
      nl[2]++;
    }else if(list[i]===caseL[3]){
      nl[3]++;
    }
  }
  //AC x 3
  for(let i=0; i<caseL.length; i++){
    console.log(caseL[i]+" x "+nl[i]);
  }
}//main(input);

main(require("fs").readFileSync("/dev/stdin","utf8"));


Measured memory_bytes: 37292
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

char str[1000001];
int k, len;
int sa[1000001], Rank[1000001], temp[1000001];

bool compare_sa(int i, int j) {
    if (Rank[i] == Rank[j]) {
        int t1 = -1, t2 = -1;
        if (i + k <= len) {
            t1 = Rank[i + k];
        }
        if (j + k <= len) {
            t2 = Rank[j + k];
        }
        return t1 < t2;
    }
    else {
        return Rank[i] < Rank[j];
    }
}

void construct_sa() {
    for (int i = 0; i <= len; i++) {
        sa[i] = i;
        if (i == len) {
            Rank[i] = -1;
        }
        else {
            Rank[i] = str[i];
        }
    }

    for (k = 1; k <= len; k *= 2) {
        sort(sa, sa + len + 1, compare_sa);
        
        temp[sa[0]] = 0;
        for (int i = 1; i <= len; i++) {
            temp[sa[i]] = temp[sa[i - 1]] + compare_sa(sa[i - 1], sa[i]);
        }
        for (int i = 0; i <= len; i++) {
            Rank[i] = temp[i];
        }
    }
}

int main() {
    cin >> str;
    len = strlen(str);

    construct_sa();

    int n, tlen;
    char t[1001];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> t;
        tlen = strlen(t);
        int left = 0, right = len + 1, pivot;
        while (left + 1 < right) {
            pivot = (left + right) / 2;

            if (strncmp(str + sa[pivot], t, tlen) <= 0) {
                left = pivot;
            }
            else {
                right = pivot;
            }
        }
        cout << (strncmp(str + sa[left], t, tlen) == 0) << endl;
    }

    return 0;
}

Measured memory_bytes: 13888
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = Vec::new();
    for _ in 0..n {
        a.push(iterator.next().unwrap().parse().unwrap());
    }

    let mut l: Vec<usize> = vec![0; n + 2];
    for i in 1..(n + 1) {
        l[i] = gcd(l[i - 1], a[i - 1]);
    }

    let mut r: Vec<usize> = vec![0; n + 2];
    for i in (1..(n + 1)).rev() {
        r[i] = gcd(r[i + 1], a[i - 1]);
    }

    let mut ans: usize = 0;
    for i in 1..(n + 1) {
        ans = max(ans, gcd(l[i - 1], r[i + 1]));
    }
    return ans.to_string();
}

fn gcd(mut x: usize, mut y: usize) -> usize {
    while y > 0 {
        let r = x % y;
        x = y;
        y = r;
    }
    return x;
}


Measured memory_bytes: 10492
N = int(input())
s = str(N)
if s[-1] == "3":
  print("bon")
elif s[-1] == "0":
  print("pon")
elif s[-1] == "1":
  print("pon")
elif s[-1] == "6":
  print("pon")
elif s[-1] == "8":
  print("pon")
else:
  print("hon")

Measured memory_bytes: 9188
class UnionFindTree:
    def __init__(self, n):
        self._tree = [i for i in range(n)]
#        self._rank = [1] * n
        self._size = [1] * n
    def root(self, a):
        if self._tree[a] == a:return a
        self._tree[a] = self.root(self._tree[a])
        return self._tree[a]
    def is_same_set(self, a, b):
        return self.root(a)==self.root(b)
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]:
            self._tree[ra] = rb
            self._size[rb] += self._size[ra]
        else:
            self._tree[rb] = ra
            self._size[ra] += self._size[rb]
    def size(self, a):
        return self._size[self.root(a)]

N,M=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(M)]
 
uft=UnionFindTree(N)
s=[0]
for a,b in AB[::-1]:
    if not(uft.is_same_set(a-1,b-1)):
        sa = uft.size(a-1)
        sb = uft.size(b-1)
        s += [s[-1] +(sa+sb)*(sa+sb-1)//2 -sa*(sa-1)//2 -sb*(sb-1)//2]
        uft.unite(a-1,b-1)
    else:s += [s[-1]]
#print(s)
for r in s[:M][::-1]:print(N*~-N//2-r)

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

using namespace std;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) {
        string s; getline(cin, s);
        if(s == ".") break;

        stack<char> st;
        bool flag = true;
        for(char c : s) {
            if(c == '(' || c == '[') {
                st.push((c=='('? ')':']'));
            } else if(c == ')' || c == ']') {
                if(st.empty() || st.top() != c) {
                    flag = false;
                    break;
                }
                st.pop();
            }
        }
        flag = flag? st.empty():flag;
        cout << (flag? "yes":"no") << endl;
    }
}


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


int main(void){
    // Your code here!
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    
    double kaku = h*30+30*(m/60.0)-m*6;
    if(kaku>180) kaku=abs(kaku-360);
    //cout<<kaku<<endl;
    double ans = pow(a,2.0)+pow(b,2.0)-2*a*b*cos(2.0*(kaku/360.0)*M_PI);
    
    printf("%.12f\n", sqrt(ans));
}


Measured memory_bytes: 4124
#include <stdio.h>
#include <string.h>
#include<algorithm>
using namespace std;
int main()
{
    int p,q,r;
    scanf("%d%d%d",&p,&q,&r);
    int a=q+p;
    int b=q+r;
    int c=p+r;
    if(a>b)
    {
        a=b;
    }
    if(a>c)
    {
        a=c;
    }
    printf("%d\n",a);
    return 0;
}


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

using namespace std;

int main()
{
    int n, a, b;
    int p[10001];
    int q1 = 0, q2 = 0, q3 = 0;

    cin >> n >> a >> b;

    for (int i = 0; i < n; i++) {
        cin >> p[i];
        if (p[i] <= a) {
            q1++;
        }
        else if (p[i] >= a+1 && p[i] <= b) {
            q2++;
        }
        else if (p[i] >= b+1) {
            q3++;
        }
    }

    cout << min(q1, min(q2, q3)) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n, q;
	while (cin >> n >> q, n){
		int date[100] = { 0 };
			REP(i, n){
				int m;
				cin >> m;
				REP(j, m){
					int a;
					cin >> a;
					date[a - 1]++;
				}
		}
			int ans = 0;
			int ma = 0;
			REP(i, 100){
				if (date[i] >= q){
					if (ma < date[i]){
						ma = date[i];
						ans = i + 1;
					}
				}
			}
			cout << ans << endl;
	}
}

Measured memory_bytes: 3068
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx, dy = ty - sy;
    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx + 1, 'L');
    cout << string(dy + 1, 'U') << string(dx + 1, 'R') << "DR";
    cout << string(dy + 1, 'D') << string(dx + 1, 'L') << "U\n";
    return 0;
}


Measured memory_bytes: 256
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " <<a << endl;
bool chckPalin(string s)
{
	ll i = 0, n = s.length(), j = n / 2;

	while (j < n)
	{
		if (s[i] != s[j])
			return false;
		i++, j++;
	}
	return true;
}
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("D:\\input.txt", "r", stdin);
	freopen("D:\\output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		string s;
		cin >> s;
		ll n = s.length(), del = 0;
		bool chk = false;
		s.pop_back(), n--, del++;
		while (n > 1)
		{
			if (n % 2 == 0)
			{
				chk = chckPalin(s);
				if (chk == true)
					break;
			}
			del++, n--, s.pop_back();
		}
		cout << n << endl;
	}
	return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int W, a, b;
	cin >>W >>a >>b;
	cout <<max(0, (abs(a-b)-W)) <<endl;
	return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

class Main {
    public static void main(String[] args){
        try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

            int n=Integer.parseInt(br.readLine());
            String[] ss=br.readLine().split(" ");
            int[] arr=new int[n];
            int[] c=new int[n];
            //System.out.println(n);
            for(int j=0;j<n-1;j++){
                arr[j]=Integer.parseInt(ss[j])-1;
                //System.out.println(arr[j]);
                c[arr[j]]+=1;

            }
            for(int j=0;j<n;j++){
                System.out.println(c[j]);
            }



        }catch(Exception e){
            System.out.println("KKKK "+e.getMessage());
        }
    }
    static boolean check(int[] arr){
        int odd=0;
        for(int i=0;i<arr.length;i++){
            if(arr[i]%2!=0){
                odd++;
            }
        }
        if(odd<=1){
            return true;
        }
        return false;
    }
}

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

int main() {
    int64_t N;
    string S;
    cin >> N >> S;

    int64_t ans=0;

    int64_t R_=0,B_=0,G_=0;
    for(int64_t i=0;i<S.size();i++){
        if(S[i]=='R')R_++;
        else if(S[i]=='B')B_++;
        else if(S[i]=='G')G_++;
    }

    ans = R_*B_*G_;

    for(int64_t i=0;i<N-2;i++){
        for(int64_t j=1;j<=(N-i-1)/2;j++){
            if(S[i]!=S[i+j]&&S[i+j]!=S[i+j+j]&&S[i]!=S[i+j+j]){
                ans--;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0175
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == -1) break;

                Stack<int> st = new Stack<int>();
                do
                {
                    st.Push(n % 4);
                    n /= 4;

                } while (n > 0);

                Console.WriteLine(WAr(st, ""));

            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 18640
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();

    int n = N * (N - 1) / 2;
    int m = M * (M - 1) / 2;
    
    int NM = n + m;
    System.out.println(NM);//nCr = nPr / r!
    						//nPr = n! / (n-r)!
  }
}

Measured memory_bytes: 21844
import copy


class Card:
    def __init__(self, pair):
        self.suit = pair[0]
        self.value = int(pair[1])

    def __str__(self):
        return self.suit + str(self.value)


def bubble_sort(a, n):
    for i in range(0, n):
        for j in range(n-1, i, -1):
            if a[j].value < a[j-1].value:
                a[j], a[j-1] = a[j-1], a[j]


def selection_sort(a, n):
    for i in range(0, n):
        min_j = i
        for j in range(i, n):
            if a[j].value < a[min_j].value:
                min_j = j
        a[i], a[min_j] = a[min_j], a[i]


def equals(cards1, cards2):
    for card1, card2 in zip(cards1, cards2):
        if card1.suit != card2.suit:
            return False
    return True


def main():
    # input
    n = int(input())
    cards1 = list(map(Card, input().split(' ')))
    cards2 = copy.deepcopy(cards1)

    # sort
    bubble_sort(cards1, n)
    selection_sort(cards2, n)

    # output
    print(' '.join(map(str, cards1)))
    print('Stable')
    print(' '.join(map(str, cards2)))
    if equals(cards1, cards2):
        print('Stable')
    else:
        print('Not stable')


if __name__ == "__main__":
    main()



Measured memory_bytes: 6348
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

int main() {
	int n;
	bool flag = false;
	cin >> n;
	for (int i = 0; i <= 20; i++) {
		for (int j = 0; j <= 14; j++) {
			if (n ==( i * 4 + j * 7)) flag = true;
		}
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5,mod=1e9+7;
int n,ans,a[N],b[N],f[2][N];
int C(int n,int m)
{
    if (m<0||m>n) return 0;
    return 1ll*a[n]*b[m]%mod*b[n-m]%mod;
}
int fpow(int a,int b)
{
    int ans=1;
    while (b)
    {
        if (b&1) ans=1ll*ans*a%mod;
        a=1ll*a*a%mod,b>>=1;
    }
    return ans;
}
int main()
{
    scanf("%d",&n),a[0]=a[1]=b[0]=b[1]=f[0][0]=1;
    for (int i=2;i<=n;i++) a[i]=1ll*i*a[i-1]%mod,b[i]=1ll*(mod-mod/i)*b[mod%i]%mod;
    for (int i=2;i<=n;i++) b[i]=1ll*b[i]*b[i-1]%mod;
    for (int i=1;i<=n;i++) f[0][i]=(f[1][i-1]<<1)%mod,f[1][i]=(f[0][i-1]+f[1][i-1])%mod,ans=(ans+1ll*f[1][i]*C(n,i)%mod*b[i]%mod*a[i-1])%mod;
    printf("%d",1ll*ans*fpow(1ll*fpow(3,n)*n%mod,mod-2)%mod);
    return 0;
}

Measured memory_bytes: 15872
a, b, c, d = map(int, input().split())  

while a>0 and b>0:
    c -= b
    if c <= 0:
        flag = 2
        break
    a -= d
    if a <=0:
        flag = 1
        break

if flag == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9180
#include<iostream>
#include<string>
int main(){
	std::string S;
  	int counter=0;
  	std::cin>>S;
  	if(S[0]=='o')++counter;
  	if(S[1]=='o')++counter;
  	if(S[2]=='o')++counter;
  	std::cout<<(700+counter*100);
  
  
}


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

ll memo[15];

const ll MOD = 1e9+7;

ll fib(ll n){
    if(n <= 0) return 1LL;
    
    if(memo[n] > 0) return memo[n];
    else return memo[n] = (fib(n-1) + fib(n-2))%MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h,w,k; cin >> h >> w >> k;
    if(w == 1){
        cout << 1 << endl;
        return 0;
    }
    --k;
    vector<ll> bef(w+1, 0LL), now(w+1, 0LL);

    // fib計算
    bef[0] = 1LL;

    rep(i,h){
        rep(j, w){
            if(j == 0){
                now[0] = bef[1]*fib(w-3)%MOD + bef[0]*fib(w-2)%MOD;
                now[0] %= MOD;
                continue;
            }
            if(j == w-1){
                now[w-1] = bef[w-2]*fib(w-3)%MOD + bef[w-1]*fib(w-2)%MOD;
                now[w-1] %= MOD;
                continue;
            }
            // 1
            now[j] = (( (fib(w-j-2)*fib(j-2))%MOD )*bef[j-1]) % MOD;
            now[j] %= MOD;
            // 2
            now[j] += (( (fib(w-j-3)*fib(j-1))%MOD )*bef[j+1]) % MOD;
            now[j] %= MOD;
            // 3
            now[j] += (( (fib(w-j-2)*fib(j-1))%MOD )*bef[j]) % MOD;
            now[j] %= MOD;
        }

        rep(j,w){
            bef[j] = now[j];
            now[j] = 0LL;
        }
    }
    
    cout << bef[k] << endl;
}

Measured memory_bytes: 3608
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

S = str(input())
n = len(S)
ans = [0]*n
for _ in range(2):
    cnt = 0
    for i in range(n):
        if S[i] == 'R':
            cnt += 1
        else:
            ans[i] += int(cnt/2)
            ans[i-1] += int((cnt+1)/2)
            cnt = 0
    S = S[::-1]
    ans = ans[::-1]
    S = S.replace('L','T')
    S = S.replace('R','L')
    S = S.replace('T','R')

print(*ans)


Measured memory_bytes: 7376